c# - 如何使用 aspose.pdf for .net 从头开始​​创建空白 pdf?

标签 c# .net aspose aspose.pdf

我想知道我应该使用哪个类来创建空白 pdf,以便通过 c# 代码将我的内容写入其中,但在 aspose.pdf 的文档中,他们建议使用 Aspose.Pdf.Generator.Pdf 类,但具体命名空间在 Aspose.Pdf api 中已过时。

最佳答案

@Shashank,

Aspose.Pdf.Genertor 已过时,但 Aspose.Pdf 命名空间是新的文档对象模型,它提供创建和操作现有 PDF 文件的功能。因此,根据您的要求,您可以使用此命名空间从头开始创建 PDF 文件。 请注意,旧版 Aspose.Pdf.Generator 的所有功能都出现在新的 DOM 方法中。

[c#]

// create Document instance
Aspose.Pdf.Document mypdf = new Aspose.Pdf.Document();
// add page to pages collection of Document instance
mypdf.Pages.Add();
// create TextFragment instance
Aspose.Pdf.Text.TextFragment fragment = new TextFragment("Hello World....");
// add fragment to first page of document
mypdf.Pages[1].Paragraphs.Add(fragment);
// save PDF document
mypdf.Save("c:/pdftest/PdfFile.pdf");

关于c# - 如何使用 aspose.pdf for .net 从头开始​​创建空白 pdf?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44794820/

相关文章:

c# - 延迟的 NUnit 断言消息评估

c# - 发生异常时 Visual Studio 和 Process 卡住(我认为)C#

c# - EPG 时间线控制

c# - 如何检查 string.IsNullOrEmpty 和 IsDateEmpty 的所有可见行 CELL

c# - 获取 WPF UIElement 的左上角坐标

java - 使用 Apache POI 刷新数据透视表

c# - 从 .NET 调用 Powershell 时设置启动目录?

c# - ZipArchiveEntry Length 是否返回错误的大小?

java - 使用 aspose.PDF java 库将 PDF 转换为 HTML?

docker - Aspose Word v18.8.0 中的“SkiaSharp.SKImageInfo”异常