Last active
July 10, 2024 08:07
-
-
Save aspose-words-gists/6debb84fc15c7e5b8e35384d9c116215 to your computer and use it in GitHub Desktop.
Aspose.Words for .NET. Options when converting to PDF using C#.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git. | |
Document doc = new Document(MyDir + "Rendering.docx"); | |
// The output PDF will not be embedded with core fonts such as Arial, Times New Roman etc. | |
PdfSaveOptions saveOptions = new PdfSaveOptions { UseCoreFonts = true }; | |
doc.Save(ArtifactsDir + "WorkingWithPdfSaveOptions.AvoidEmbeddingCoreFonts.pdf", saveOptions); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git. | |
Document doc = new Document(); | |
doc.CustomDocumentProperties.Add("Company", "Aspose"); | |
PdfSaveOptions saveOptions = new PdfSaveOptions { CustomPropertiesExport = PdfCustomPropertiesExport.Standard }; | |
doc.Save(ArtifactsDir + "WorkingWithPdfSaveOptions.CustomPropertiesExport.pdf", saveOptions); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git. | |
Document doc = new Document(MyDir + "Rendering.docx"); | |
// The output PDF will be saved without embedding standard windows fonts. | |
PdfSaveOptions saveOptions = new PdfSaveOptions { FontEmbeddingMode = PdfFontEmbeddingMode.EmbedNone }; | |
doc.Save(ArtifactsDir + "WorkingWithPdfSaveOptions.DisableEmbedWindowsFonts.pdf", saveOptions); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git. | |
Document doc = new Document(MyDir + "Rendering.docx"); | |
// We can set a minimum threshold for downsampling. | |
// This value will prevent the second image in the input document from being downsampled. | |
PdfSaveOptions saveOptions = new PdfSaveOptions | |
{ | |
DownsampleOptions = { Resolution = 36, ResolutionThreshold = 128 } | |
}; | |
doc.Save(ArtifactsDir + "WorkingWithPdfSaveOptions.DownsamplingImages.pdf", saveOptions); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git. | |
Document doc = new Document(MyDir + "Rendering.docx"); | |
// The output PDF will be embedded with all fonts found in the document. | |
PdfSaveOptions saveOptions = new PdfSaveOptions { EmbedFullFonts = true }; | |
doc.Save(ArtifactsDir + "WorkingWithPdfSaveOptions.EmbeddedAllFonts.pdf", saveOptions); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git. | |
Document doc = new Document(MyDir + "Rendering.docx"); | |
// The output PDF will contain subsets of the fonts in the document. | |
// Only the glyphs used in the document are included in the PDF fonts. | |
PdfSaveOptions saveOptions = new PdfSaveOptions { EmbedFullFonts = false }; | |
doc.Save(ArtifactsDir + "WorkingWithPdfSaveOptions.EmbeddedSubsetFonts.pdf", saveOptions); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git. | |
Document doc = new Document(MyDir + "Paragraphs.docx"); | |
// The file size will be increased and the structure will be visible in the "Content" navigation pane | |
// of Adobe Acrobat Pro, while editing the .pdf. | |
PdfSaveOptions saveOptions = new PdfSaveOptions { ExportDocumentStructure = true }; | |
doc.Save(ArtifactsDir + "WorkingWithPdfSaveOptions.ExportDocumentStructure.pdf", saveOptions); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git. | |
Document doc = new Document(MyDir + "Rendering.docx"); | |
PdfSaveOptions saveOptions = new PdfSaveOptions | |
{ | |
ImageCompression = PdfImageCompression.Jpeg, PreserveFormFields = true | |
}; | |
doc.Save(ArtifactsDir + "WorkingWithPdfSaveOptions.ImageCompression.pdf", saveOptions); | |
PdfSaveOptions saveOptionsA2U = new PdfSaveOptions | |
{ | |
Compliance = PdfCompliance.PdfA2u, | |
ImageCompression = PdfImageCompression.Jpeg, | |
JpegQuality = 100, // Use JPEG compression at 50% quality to reduce file size. | |
}; | |
doc.Save(ArtifactsDir + "WorkingWithPdfSaveOptions.ImageCompression_A2u.pdf", saveOptionsA2U); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-.NET.git. | |
Document doc = new Document(MyDir + "Rendering.docx"); | |
PdfSaveOptions saveOptions = new PdfSaveOptions(); | |
saveOptions.OutlineOptions.HeadingsOutlineLevels = 3; | |
saveOptions.OutlineOptions.ExpandedOutlineLevels = 1; | |
doc.Save(ArtifactsDir + "WorkingWithPdfSaveOptions.OutlineOptions.pdf", saveOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment