Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active April 14, 2021 07:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/b6bba1756af368eb578b8aa9a94d0ce2 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/b6bba1756af368eb578b8aa9a94d0ce2 to your computer and use it in GitHub Desktop.
C#中Word到PDF的转换| NET的Aspose.Words
Document doc = new Document("word.docx");
PdfSaveOptions options = new PdfSaveOptions();
// 数字签名详细信息
CertificateHolder certHolder = CertificateHolder.Create("signature.pfx", "12345");
options.DigitalSignatureDetails = new PdfDigitalSignatureDetails(certHolder, "reason", "location", DateTime.Now);
// 将Word另存为PDF
doc.Save("output.pdf", options);
Document doc = new Document("word.docx");
// 将PDFSaveOption符合性设置为PDF17
PdfSaveOptions options = new PdfSaveOptions();
options.Compliance = PdfCompliance.Pdf17;
// 将Word转换为PDF
doc.Save("output.pdf", options);
Document doc = new Document("word.docx");
PdfSaveOptions options = new PdfSaveOptions();
// 从索引1开始转换3页,其中0是第一页的索引
options.PageIndex = 1;
options.PageCount = 3;
// 将Word另存为PDF
doc.Save("output.pdf", options);
// 从磁盘加载文档。
Document doc = new Document("word.doc");
// 另存为PDF
doc.Save("output.pdf");
Document doc = new Document("word.docx");
// 设定Jpeg品质
PdfSaveOptions options = new PdfSaveOptions();
options.JpegQuality = 100;
// 将Word转换为PDF
doc.Save("output.pdf", options);
Document doc = new Document("word.docx");
PdfSaveOptions options = new PdfSaveOptions();
// 文字和图像压缩
options.TextCompression = PdfTextCompression.Flate;
options.ImageCompression = PdfImageCompression.Auto;
// 将Word另存为PDF
doc.Save("output.pdf", options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment