Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active March 26, 2023 11:24
Show Gist options
  • Save aspose-com-gists/7291ec6e6426497c7788117d1199990c to your computer and use it in GitHub Desktop.
Save aspose-com-gists/7291ec6e6426497c7788117d1199990c to your computer and use it in GitHub Desktop.
Word to PDF Conversions in C# | Aspose.Words for .NET
Document doc = new Document("word.docx");
// Set PDFSaveOption compliance to PDF17
PdfSaveOptions options = new PdfSaveOptions();
options.Compliance = PdfCompliance.Pdf17;
// Convert Word to PDF
doc.Save("output.pdf", options);
// Load the document from disk.
Document doc = new Document("word.doc");
// Save as PDF
doc.Save("output.pdf");
Document doc = new Document("word.docx");
PdfSaveOptions options = new PdfSaveOptions();
// Digital signatures details
CertificateHolder certHolder = CertificateHolder.Create("signature.pfx", "12345");
options.DigitalSignatureDetails = new PdfDigitalSignatureDetails(certHolder, "reason", "location", DateTime.Now);
// Save Word as PDF
doc.Save("output.pdf", options);
Document doc = new Document("word.docx");
// Set Jpeg quality
PdfSaveOptions options = new PdfSaveOptions();
options.JpegQuality = 100;
// Convert Word to PDF
doc.Save("output.pdf", options);
Document doc = new Document("word.docx");
PdfSaveOptions options = new PdfSaveOptions();
// Convert 3 pages starting from index 1 where 0 is the first page's index
options.PageIndex = 1;
options.PageCount = 3;
// Save Word as PDF
doc.Save("output.pdf", options);
Document doc = new Document("word.docx");
PdfSaveOptions options = new PdfSaveOptions();
// Text and image compression
options.TextCompression = PdfTextCompression.Flate;
options.ImageCompression = PdfImageCompression.Auto;
// Save Word as PDF
doc.Save("output.pdf", options);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment