需要 .net API 来生成带有文本旋转选项的 PDF

发布于 2024-09-11 23:18:57 字数 62 浏览 2 评论 0原文

我正在从 xml 创建 PDF,我正在寻找一个也允许我旋转文本的 API,是否有适用于 .net 的 API?

I am creating PDFs from xml I am looking for an API which also allows me to rotate text, Is there any API available for .net?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

千纸鹤 2024-09-18 23:18:57

iText。它是开源的,您甚至可以购买作者写的一本非常好的书。 (是的,它当然支持旋转文本。)

iText. It's Open Source and you can even buy a quite good book on it written by the author. (And yes, of course it supports rotated text.)

·深蓝 2024-09-18 23:18:57

假设您要使用库 iTextSharp,如建议的另一个答案(iText 是一个 Java 库;iTextSharp 是它的 .NET 端口),这里有一些示例。这些本质上是 Bruno Lowagie 的书 iText in Action 来自曼宁出版社。

(请注意,这些示例是用 Java 编写的,因为我直接从书中获取它们,但您应该能够轻松地将它们改编为 iTextSharp 库和 C#。)

图像旋转:

这可以在本书第 155 页中找到。

Image img = Image.getInstance("foo.jpg");
img.setRotationDegrees(45);

文本旋转:

这可以在书中第 351-352 页找到。

PdfContentByte cb = ...;
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "Some text", e, f, angle);

其中ef是平移值(本质上是坐标),angle是旋转角度。

Assuming that you are going to use the library iTextSharp, as suggested in another answer (iText is a Java library; iTextSharp is a .NET port of it), here's some examples. These are essentially stripped-down versions from Bruno Lowagie's book iText in Action from Manning Publications.

(Note that the examples are written in Java, since I took them straight from the book, but you should be able to easily adapt them to the iTextSharp library and C#.)

Image rotation:

This is found in the book on page 155.

Image img = Image.getInstance("foo.jpg");
img.setRotationDegrees(45);

Text rotation:

This is found in the book on page 351-352.

PdfContentByte cb = ...;
cb.showTextAligned(PdfContentByte.ALIGN_LEFT, "Some text", e, f, angle);

where e and f are translation values (the coordinates, essentially), and angle is the rotation angle.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文