Class PdfSaveOptions

Class PdfSaveOptions

Namespace: Aspose.Words.Saving
Assembly: Aspose.Words.dll (26.2.0)

Can be used to specify additional options when saving a document into the Aspose.Words.SaveFormat.Pdf format.

To learn more, visit the Specify Save Options documentation article.

public class PdfSaveOptions : FixedPageSaveOptions

Inheritance

object SaveOptions FixedPageSaveOptions PdfSaveOptions

Inherited Members

FixedPageSaveOptions.Equals(object) , FixedPageSaveOptions.AssertValidIdPrefix(string) , FixedPageSaveOptions.IsValidIdPrefix(string) , FixedPageSaveOptions.PageSet , FixedPageSaveOptions.PageSavingCallback , FixedPageSaveOptions.NumeralFormat , FixedPageSaveOptions.MetafileRenderingOptions , FixedPageSaveOptions.JpegQuality , FixedPageSaveOptions.ColorMode , FixedPageSaveOptions.OptimizeOutput , SaveOptions.CreateSaveOptions(SaveFormat) , SaveOptions.CreateSaveOptions(string) , SaveOptions.SaveFormat , SaveOptions.ExportGeneratorName , SaveOptions.TempFolder , SaveOptions.UpdateOleControlImages , SaveOptions.PrettyFormat , SaveOptions.UseAntiAliasing , SaveOptions.UseHighQualityRendering , SaveOptions.DmlRenderingMode , SaveOptions.DmlEffectsRenderingMode , SaveOptions.ImlRenderingMode , SaveOptions.DefaultTemplate , SaveOptions.UpdateFields , SaveOptions.UpdateLastSavedTimeProperty , SaveOptions.UpdateLastPrintedProperty , SaveOptions.UpdateCreatedTimeProperty , SaveOptions.MemoryOptimization , SaveOptions.UpdateAmbiguousTextFont , SaveOptions.Dml3DEffectsRenderingMode , SaveOptions.ProgressCallback , SaveOptions.AllowEmbeddingPostScriptFonts , SaveOptions.CustomTimeZoneInfo , object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()

Examples

Shows how to change image color with saving options property.

Document doc = new Document(MyDir + "Images.docx");

                                                                        // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                        // to modify how that method converts the document to .PDF.
                                                                        // Set the "ColorMode" property to "Grayscale" to render all images from the document in black and white.
                                                                        // The size of the output document may be larger with this setting.
                                                                        // Set the "ColorMode" property to "Normal" to render all images in color.
                                                                        PdfSaveOptions pdfSaveOptions = new PdfSaveOptions { ColorMode = colorMode };

                                                                        doc.Save(ArtifactsDir + "PdfSaveOptions.ColorRendering.pdf", pdfSaveOptions);

Shows how to apply text compression when saving a document to PDF.

Document doc = new Document();
                                                                             DocumentBuilder builder = new DocumentBuilder(doc);

                                                                             for (int i = 0; i < 100; i++)
                                                                                 builder.Writeln("Lorem ipsum dolor sit amet, consectetur adipiscing elit, " +
                                                                                                 "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");

                                                                             // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                             // to modify how that method converts the document to .PDF.
                                                                             PdfSaveOptions options = new PdfSaveOptions();

                                                                             // Set the "TextCompression" property to "PdfTextCompression.None" to not apply any
                                                                             // compression to text when we save the document to PDF.
                                                                             // Set the "TextCompression" property to "PdfTextCompression.Flate" to apply ZIP compression
                                                                             // to text when we save the document to PDF. The larger the document, the bigger the impact that this will have.
                                                                             options.TextCompression = pdfTextCompression;

                                                                             doc.Save(ArtifactsDir + "PdfSaveOptions.TextCompression.pdf", options);

Shows how to convert a whole document to PDF with three levels in the document outline.

Document doc = new Document();
                                                                                                  DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                  // Insert headings of levels 1 to 5.
                                                                                                  builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

                                                                                                  Assert.That(builder.ParagraphFormat.IsHeading, Is.True);

                                                                                                  builder.Writeln("Heading 1");

                                                                                                  builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

                                                                                                  builder.Writeln("Heading 1.1");
                                                                                                  builder.Writeln("Heading 1.2");

                                                                                                  builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;

                                                                                                  builder.Writeln("Heading 1.2.1");
                                                                                                  builder.Writeln("Heading 1.2.2");

                                                                                                  builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading4;

                                                                                                  builder.Writeln("Heading 1.2.2.1");
                                                                                                  builder.Writeln("Heading 1.2.2.2");

                                                                                                  builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading5;

                                                                                                  builder.Writeln("Heading 1.2.2.2.1");
                                                                                                  builder.Writeln("Heading 1.2.2.2.2");

                                                                                                  // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                  // to modify how that method converts the document to .PDF.
                                                                                                  PdfSaveOptions options = new PdfSaveOptions();

                                                                                                  // The output PDF document will contain an outline, which is a table of contents that lists headings in the document body.
                                                                                                  // Clicking on an entry in this outline will take us to the location of its respective heading.
                                                                                                  // Set the "HeadingsOutlineLevels" property to "4" to exclude all headings whose levels are above 4 from the outline.
                                                                                                  options.OutlineOptions.HeadingsOutlineLevels = 4;

                                                                                                  // If an outline entry has subsequent entries of a higher level inbetween itself and the next entry of the same or lower level,
                                                                                                  // an arrow will appear to the left of the entry. This entry is the "owner" of several such "sub-entries".
                                                                                                  // In our document, the outline entries from the 5th heading level are sub-entries of the second 4th level outline entry,
                                                                                                  // the 4th and 5th heading level entries are sub-entries of the second 3rd level entry, and so on.
                                                                                                  // In the outline, we can click on the arrow of the "owner" entry to collapse/expand all its sub-entries.
                                                                                                  // Set the "ExpandedOutlineLevels" property to "2" to automatically expand all heading level 2 and lower outline entries
                                                                                                  // and collapse all level and 3 and higher entries when we open the document.
                                                                                                  options.OutlineOptions.ExpandedOutlineLevels = 2;

                                                                                                  doc.Save(ArtifactsDir + "PdfSaveOptions.ExpandedOutlineLevels.pdf", options);

Constructors

PdfSaveOptions()

Initializes a new instance of this class that can be used to save a document in the Aspose.Words.SaveFormat.Pdf format.

public PdfSaveOptions()

Examples

Shows how to enable or disable subsetting when embedding fonts while rendering a document to PDF.

Document doc = new Document();
                                                                                                            DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                            builder.Font.Name = "Arial";
                                                                                                            builder.Writeln("Hello world!");
                                                                                                            builder.Font.Name = "Arvo";
                                                                                                            builder.Writeln("The quick brown fox jumps over the lazy dog.");

                                                                                                            // Configure our font sources to ensure that we have access to both the fonts in this document.
                                                                                                            FontSourceBase[] originalFontsSources = FontSettings.DefaultInstance.GetFontsSources();
                                                                                                            Aspose.Words.Fonts.FolderFontSource folderFontSource =
                                                                                                                new Aspose.Words.Fonts.FolderFontSource(FontsDir, true);
                                                                                                            FontSettings.DefaultInstance.SetFontsSources(new[] { originalFontsSources[0], folderFontSource });

                                                                                                            FontSourceBase[] fontSources = FontSettings.DefaultInstance.GetFontsSources();
                                                                                                            Assert.That(fontSources[0].GetAvailableFonts().Any(f => f.FullFontName == "Arial"), Is.True);
                                                                                                            Assert.That(fontSources[1].GetAvailableFonts().Any(f => f.FullFontName == "Arvo"), Is.True);

                                                                                                            // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                            // to modify how that method converts the document to .PDF.
                                                                                                            PdfSaveOptions options = new PdfSaveOptions();

                                                                                                            // Since our document contains a custom font, embedding in the output document may be desirable.
                                                                                                            // Set the "EmbedFullFonts" property to "true" to embed every glyph of every embedded font in the output PDF.
                                                                                                            // The document's size may become very large, but we will have full use of all fonts if we edit the PDF.
                                                                                                            // Set the "EmbedFullFonts" property to "false" to apply subsetting to fonts, saving only the glyphs
                                                                                                            // that the document is using. The file will be considerably smaller,
                                                                                                            // but we may need access to any custom fonts if we edit the document.
                                                                                                            options.EmbedFullFonts = embedFullFonts;

                                                                                                            doc.Save(ArtifactsDir + "PdfSaveOptions.EmbedFullFonts.pdf", options);

                                                                                                            // Restore the original font sources.
                                                                                                            FontSettings.DefaultInstance.SetFontsSources(originalFontsSources);

Properties

AdditionalTextPositioning

A flag specifying whether to write additional text positioning operators or not.

public bool AdditionalTextPositioning { get; set; }

Property Value

bool

Examples

Show how to write additional text positioning operators.

Document doc = new Document(MyDir + "Text positioning operators.docx");

                                                                   // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                   // to modify how that method converts the document to .PDF.
                                                                   PdfSaveOptions saveOptions = new PdfSaveOptions
                                                                   {
                                                                       TextCompression = PdfTextCompression.None,

                                                                       // Set the "AdditionalTextPositioning" property to "true" to attempt to fix incorrect
                                                                       // element positioning in the output PDF, should there be any, at the cost of increased file size.
                                                                       // Set the "AdditionalTextPositioning" property to "false" to render the document as usual.
                                                                       AdditionalTextPositioning = applyAdditionalTextPositioning
                                                                   };

                                                                   doc.Save(ArtifactsDir + "PdfSaveOptions.AdditionalTextPositioning.pdf", saveOptions);

Remarks

If true, additional text positioning operators are written to the output PDF. This may help to overcome issues with inaccurate text positioning with some printers. The downside is the increased PDF document size.

The default value is false.

AttachmentsEmbeddingMode

Gets or sets a value determining how attachments are embedded to the PDF document.

public PdfAttachmentsEmbeddingMode AttachmentsEmbeddingMode { get; set; }

Property Value

PdfAttachmentsEmbeddingMode

Examples

Shows how to add embed attachments to the PDF document.

Document doc = new Document();
                                                                  DocumentBuilder builder = new DocumentBuilder(doc);

                                                                  builder.InsertOleObject(MyDir + "Spreadsheet.xlsx", "Excel.Sheet", false, true, null);

                                                                  PdfSaveOptions saveOptions = new PdfSaveOptions();
                                                                  saveOptions.AttachmentsEmbeddingMode = PdfAttachmentsEmbeddingMode.Annotations;

                                                                  doc.Save(ArtifactsDir + "PdfSaveOptions.AttachmentsEmbeddingMode.pdf", saveOptions);

Remarks

Default value is Aspose.Words.Saving.PdfAttachmentsEmbeddingMode.None and attachments are not embedded.

PDF/A-1, PDF/A-2 and regular PDF/A-4 (not PDF/A-4f) standards do not allow embedded files. Aspose.Words.Saving.PdfAttachmentsEmbeddingMode.None value will be used automatically.

CacheBackgroundGraphics

Gets or sets a value determining whether or not to cache graphics placed in document’s background.

public bool CacheBackgroundGraphics { get; set; }

Property Value

bool

Examples

Shows how to cache graphics placed in document’s background.

Document doc = new Document(MyDir + "Background images.docx");

                                                                       PdfSaveOptions saveOptions = new PdfSaveOptions();
                                                                       saveOptions.CacheBackgroundGraphics = true;

                                                                       doc.Save(ArtifactsDir + "PdfSaveOptions.CacheBackgroundGraphics.pdf", saveOptions);

                                                                       long asposeToPdfSize = new FileInfo(ArtifactsDir + "PdfSaveOptions.CacheBackgroundGraphics.pdf").Length;
                                                                       long wordToPdfSize = new FileInfo(MyDir + "Background images (word to pdf).pdf").Length;

                                                                       Assert.That(asposeToPdfSize, Is.LessThan(wordToPdfSize));

Remarks

Default value is true and background graphics are written to the PDF document as an xObject.

When the value is false background graphics are not cached.

Some shapes are not supported for caching(shapes with fields, bookmarks, HRefs).

Document background graphic is various shapes, charts, images placed in the footer or header, well as background and border of a page.

Compliance

Specifies the PDF standards compliance level for output documents.

public PdfCompliance Compliance { get; set; }

Property Value

PdfCompliance

Examples

Shows how to set the PDF standards compliance level of saved PDF documents.

Document doc = new Document(MyDir + "Images.docx");

                                                                                      // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                      // to modify how that method converts the document to .PDF.
                                                                                      // Note that some PdfSaveOptions are prohibited when saving to one of the standards and automatically fixed.
                                                                                      // Use IWarningCallback to know which options are automatically fixed.
                                                                                      PdfSaveOptions saveOptions = new PdfSaveOptions();

                                                                                      // Set the "Compliance" property to "PdfCompliance.PdfA1b" to comply with the "PDF/A-1b" standard,
                                                                                      // which aims to preserve the visual appearance of the document as Aspose.Words convert it to PDF.
                                                                                      // Set the "Compliance" property to "PdfCompliance.Pdf17" to comply with the "1.7" standard.
                                                                                      // Set the "Compliance" property to "PdfCompliance.PdfA1a" to comply with the "PDF/A-1a" standard,
                                                                                      // which complies with "PDF/A-1b" as well as preserving the document structure of the original document.
                                                                                      // Set the "Compliance" property to "PdfCompliance.PdfUa1" to comply with the "PDF/UA-1" (ISO 14289-1) standard,
                                                                                      // which aims to define represent electronic documents in PDF that allow the file to be accessible.
                                                                                      // Set the "Compliance" property to "PdfCompliance.Pdf20" to comply with the "PDF 2.0" (ISO 32000-2) standard.
                                                                                      // Set the "Compliance" property to "PdfCompliance.PdfA4" to comply with the "PDF/A-4" (ISO 19004:2020) standard,
                                                                                      // which preserving document static visual appearance over time.
                                                                                      // Set the "Compliance" property to "PdfCompliance.PdfA4Ua2" to comply with both PDF/A-4 (ISO 19005-4:2020)
                                                                                      // and PDF/UA-2 (ISO 14289-2:2024) standards.
                                                                                      // Set the "Compliance" property to "PdfCompliance.PdfUa2" to comply with the PDF/UA-2 (ISO 14289-2:2024) standard.
                                                                                      // This helps with making documents searchable but may significantly increase the size of already large documents.
                                                                                      saveOptions.Compliance = pdfCompliance;

                                                                                      doc.Save(ArtifactsDir + "PdfSaveOptions.Compliance.pdf", saveOptions);

Remarks

Default is Aspose.Words.Saving.PdfCompliance.Pdf17.

CreateNoteHyperlinks

Specifies whether to convert footnote/endnote references in main text story into active hyperlinks. When clicked the hyperlink will lead to the corresponding footnote/endnote. Default is false.

public bool CreateNoteHyperlinks { get; set; }

Property Value

bool

Examples

Shows how to make footnotes and endnotes function as hyperlinks.

Document doc = new Document(MyDir + "Footnotes and endnotes.docx");

                                                                           // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                           // to modify how that method converts the document to .PDF.
                                                                           PdfSaveOptions options = new PdfSaveOptions();

                                                                           // Set the "CreateNoteHyperlinks" property to "true" to turn all footnote/endnote symbols
                                                                           // in the text act as links that, upon clicking, take us to their respective footnotes/endnotes.
                                                                           // Set the "CreateNoteHyperlinks" property to "false" not to have footnote/endnote symbols link to anything.
                                                                           options.CreateNoteHyperlinks = createNoteHyperlinks;

                                                                           doc.Save(ArtifactsDir + "PdfSaveOptions.NoteHyperlinks.pdf", options);

CustomPropertiesExport

Gets or sets a value determining the way Aspose.Words.Document.CustomDocumentProperties are exported to PDF file.

public PdfCustomPropertiesExport CustomPropertiesExport { get; set; }

Property Value

PdfCustomPropertiesExport

Examples

Shows how to export custom properties while converting a document to PDF.

Document doc = new Document();

                                                                                    doc.CustomDocumentProperties.Add("Company", "My value");

                                                                                    // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                    // to modify how that method converts the document to .PDF.
                                                                                    PdfSaveOptions options = new PdfSaveOptions();

                                                                                    // Set the "CustomPropertiesExport" property to "PdfCustomPropertiesExport.None" to discard
                                                                                    // custom document properties as we save the document to .PDF.
                                                                                    // Set the "CustomPropertiesExport" property to "PdfCustomPropertiesExport.Standard"
                                                                                    // to preserve custom properties within the output PDF document.
                                                                                    // Set the "CustomPropertiesExport" property to "PdfCustomPropertiesExport.Metadata"
                                                                                    // to preserve custom properties in an XMP packet.
                                                                                    options.CustomPropertiesExport = pdfCustomPropertiesExportMode;

                                                                                    doc.Save(ArtifactsDir + "PdfSaveOptions.CustomPropertiesExport.pdf", options);

Remarks

Default value is Aspose.Words.Saving.PdfCustomPropertiesExport.None.

Aspose.Words.Saving.PdfCustomPropertiesExport.Metadata value is not supported when saving to PDF/A. Aspose.Words.Saving.PdfCustomPropertiesExport.Standard will be used instead for PDF/A-1 and PDF/A-2 and Aspose.Words.Saving.PdfCustomPropertiesExport.None for PDF/A-4.

Aspose.Words.Saving.PdfCustomPropertiesExport.Standard value is not supported when saving to PDF 2.0. Aspose.Words.Saving.PdfCustomPropertiesExport.Metadata will be used instead.

DigitalSignatureDetails

Gets or sets the details for signing the output PDF document.

public PdfDigitalSignatureDetails DigitalSignatureDetails { get; set; }

Property Value

PdfDigitalSignatureDetails

Examples

Shows how to sign a generated PDF document.

Document doc = new Document();
                                                      DocumentBuilder builder = new DocumentBuilder(doc);
                                                      builder.Writeln("Contents of signed PDF.");

                                                      CertificateHolder certificateHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw");

                                                      // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                      // to modify how that method converts the document to .PDF.
                                                      PdfSaveOptions options = new PdfSaveOptions();

                                                      // Configure the "DigitalSignatureDetails" object of the "SaveOptions" object to
                                                      // digitally sign the document as we render it with the "Save" method.
                                                      DateTime signingTime = new DateTime(2015, 7, 20);
                                                      options.DigitalSignatureDetails =
                                                          new PdfDigitalSignatureDetails(certificateHolder, "Test Signing", "My Office", signingTime);
                                                      options.DigitalSignatureDetails.HashAlgorithm = PdfDigitalSignatureHashAlgorithm.RipeMD160;

                                                      Assert.That(options.DigitalSignatureDetails.Reason, Is.EqualTo("Test Signing"));
                                                      Assert.That(options.DigitalSignatureDetails.Location, Is.EqualTo("My Office"));
                                                      Assert.That(options.DigitalSignatureDetails.SignatureDate.ToLocalTime(), Is.EqualTo(signingTime));
                                                      Assert.That(options.DigitalSignatureDetails.CertificateHolder, Is.EqualTo(certificateHolder));

                                                      doc.Save(ArtifactsDir + "PdfSaveOptions.PdfDigitalSignature.pdf", options);

Remarks

The default value is null and the output document will not be signed. When this property is set to a valid Aspose.Words.Saving.PdfDigitalSignatureDetails object, then the output PDF document will be digitally signed.

DisplayDocTitle

A flag specifying whether the window’s title bar should display the document title taken from the Title entry of the document information dictionary.

public bool DisplayDocTitle { get; set; }

Property Value

bool

Examples

Shows how to display the title of the document as the title bar.

Document doc = new Document();
                                                                           DocumentBuilder builder = new DocumentBuilder(doc);
                                                                           builder.Writeln("Hello world!");

                                                                           doc.BuiltInDocumentProperties.Title = "Windows bar pdf title";

                                                                           // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                           // to modify how that method converts the document to .PDF.
                                                                           // Set the "DisplayDocTitle" to "true" to get some PDF readers, such as Adobe Acrobat Pro,
                                                                           // to display the value of the document's "Title" built-in property in the tab that belongs to this document.
                                                                           // Set the "DisplayDocTitle" to "false" to get such readers to display the document's filename.
                                                                           PdfSaveOptions pdfSaveOptions = new PdfSaveOptions { DisplayDocTitle = displayDocTitle };

                                                                           doc.Save(ArtifactsDir + "PdfSaveOptions.DocTitle.pdf", pdfSaveOptions);

Remarks

If false, the title bar should instead display the name of the PDF file containing the document.

This flag is required by PDF/UA compliance. true value will be used automatically when saving to PDF/UA.

The default value is false.

DmlEffectsRenderingMode

Gets or sets a value determining how DrawingML effects are rendered.

public override DmlEffectsRenderingMode DmlEffectsRenderingMode { get; set; }

Property Value

DmlEffectsRenderingMode

Examples

Shows how to configure the rendering quality of DrawingML effects in a document as we save it to PDF.

Document doc = new Document(MyDir + "DrawingML shape effects.docx");

                                                                                                                // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                                // to modify how that method converts the document to .PDF.
                                                                                                                PdfSaveOptions options = new PdfSaveOptions();

                                                                                                                // Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.None" to discard all DrawingML effects.
                                                                                                                // Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.Simplified"
                                                                                                                // to render a simplified version of DrawingML effects.
                                                                                                                // Set the "DmlEffectsRenderingMode" property to "DmlEffectsRenderingMode.Fine" to
                                                                                                                // render DrawingML effects with more accuracy and also with more processing cost.
                                                                                                                options.DmlEffectsRenderingMode = effectsRenderingMode;

                                                                                                                Assert.That(options.DmlRenderingMode, Is.EqualTo(DmlRenderingMode.DrawingML));

                                                                                                                doc.Save(ArtifactsDir + "PdfSaveOptions.DrawingMLEffects.pdf", options);

Remarks

The default value is Aspose.Words.Saving.DmlEffectsRenderingMode.Simplified.

This property is used when the document is exported to fixed page formats.

If Aspose.Words.Saving.PdfSaveOptions.Compliance is set to Aspose.Words.Saving.PdfCompliance.PdfA1a or Aspose.Words.Saving.PdfCompliance.PdfA1b, property always returns Aspose.Words.Saving.DmlEffectsRenderingMode.None.

DownsampleOptions

Allows to specify downsample options.

public DownsampleOptions DownsampleOptions { get; set; }

Property Value

DownsampleOptions

Examples

Shows how to change the resolution of images in the PDF document.

Document doc = new Document(MyDir + "Images.docx");

                                                                            // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                            // to modify how that method converts the document to .PDF.
                                                                            PdfSaveOptions options = new PdfSaveOptions();

                                                                            // By default, Aspose.Words downsample all images in a document that we save to PDF to 220 ppi.
                                                                            Assert.That(options.DownsampleOptions.DownsampleImages, Is.True);
                                                                            Assert.That(options.DownsampleOptions.Resolution, Is.EqualTo(220));
                                                                            Assert.That(options.DownsampleOptions.ResolutionThreshold, Is.EqualTo(0));

                                                                            doc.Save(ArtifactsDir + "PdfSaveOptions.DownsampleOptions.Default.pdf", options);

                                                                            // Set the "Resolution" property to "36" to downsample all images to 36 ppi.
                                                                            options.DownsampleOptions.Resolution = 36;

                                                                            // Set the "ResolutionThreshold" property to only apply the downsampling to
                                                                            // images with a resolution that is above 128 ppi.
                                                                            options.DownsampleOptions.ResolutionThreshold = 128;

                                                                            // Only the first two images from the document will be downsampled at this stage.
                                                                            doc.Save(ArtifactsDir + "PdfSaveOptions.DownsampleOptions.LowerResolution.pdf", options);

EmbedFullFonts

Controls how fonts are embedded into the resulting PDF documents.

public bool EmbedFullFonts { get; set; }

Property Value

bool

Examples

Shows how to enable or disable subsetting when embedding fonts while rendering a document to PDF.

Document doc = new Document();
                                                                                                            DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                            builder.Font.Name = "Arial";
                                                                                                            builder.Writeln("Hello world!");
                                                                                                            builder.Font.Name = "Arvo";
                                                                                                            builder.Writeln("The quick brown fox jumps over the lazy dog.");

                                                                                                            // Configure our font sources to ensure that we have access to both the fonts in this document.
                                                                                                            FontSourceBase[] originalFontsSources = FontSettings.DefaultInstance.GetFontsSources();
                                                                                                            Aspose.Words.Fonts.FolderFontSource folderFontSource =
                                                                                                                new Aspose.Words.Fonts.FolderFontSource(FontsDir, true);
                                                                                                            FontSettings.DefaultInstance.SetFontsSources(new[] { originalFontsSources[0], folderFontSource });

                                                                                                            FontSourceBase[] fontSources = FontSettings.DefaultInstance.GetFontsSources();
                                                                                                            Assert.That(fontSources[0].GetAvailableFonts().Any(f => f.FullFontName == "Arial"), Is.True);
                                                                                                            Assert.That(fontSources[1].GetAvailableFonts().Any(f => f.FullFontName == "Arvo"), Is.True);

                                                                                                            // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                            // to modify how that method converts the document to .PDF.
                                                                                                            PdfSaveOptions options = new PdfSaveOptions();

                                                                                                            // Since our document contains a custom font, embedding in the output document may be desirable.
                                                                                                            // Set the "EmbedFullFonts" property to "true" to embed every glyph of every embedded font in the output PDF.
                                                                                                            // The document's size may become very large, but we will have full use of all fonts if we edit the PDF.
                                                                                                            // Set the "EmbedFullFonts" property to "false" to apply subsetting to fonts, saving only the glyphs
                                                                                                            // that the document is using. The file will be considerably smaller,
                                                                                                            // but we may need access to any custom fonts if we edit the document.
                                                                                                            options.EmbedFullFonts = embedFullFonts;

                                                                                                            doc.Save(ArtifactsDir + "PdfSaveOptions.EmbedFullFonts.pdf", options);

                                                                                                            // Restore the original font sources.
                                                                                                            FontSettings.DefaultInstance.SetFontsSources(originalFontsSources);

Remarks

The default value is false, which means the fonts are subsetted before embedding. Subsetting is useful if you want to keep the output file size smaller. Subsetting removes all unused glyphs from a font.

When this value is set to true, a complete font file is embedded into PDF without subsetting. This will result in larger output files, but can be a useful option when you want to edit the resulting PDF later (e.g. add more text).

Some fonts are large (several megabytes) and embedding them without subsetting will result in large output documents.

EncryptionDetails

Gets or sets the details for encrypting the output PDF document.

public PdfEncryptionDetails EncryptionDetails { get; set; }

Property Value

PdfEncryptionDetails

Examples

Shows how to set permissions on a saved PDF document.

Document doc = new Document();
                                                                DocumentBuilder builder = new DocumentBuilder(doc);

                                                                builder.Writeln("Hello world!");

                                                                // Extend permissions to allow the editing of annotations.
                                                                PdfEncryptionDetails encryptionDetails =
                                                                    new PdfEncryptionDetails("password", string.Empty, PdfPermissions.ModifyAnnotations | PdfPermissions.DocumentAssembly);

                                                                // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                // to modify how that method converts the document to .PDF.
                                                                PdfSaveOptions saveOptions = new PdfSaveOptions();
                                                                // Enable encryption via the "EncryptionDetails" property.
                                                                saveOptions.EncryptionDetails = encryptionDetails;

                                                                // When we open this document, we will need to provide the password before accessing its contents.
                                                                doc.Save(ArtifactsDir + "PdfSaveOptions.EncryptionPermissions.pdf", saveOptions);

Remarks

The default value is null and the output document will not be encrypted. When this property is set to a valid Aspose.Words.Saving.PdfEncryptionDetails object, then the output PDF document will be encrypted.

AES-128 encryption algorithm is used when saving to PDF 1.7 based compliance (including PDF/UA-1). AES-256 encryption algorithm is used when saving to PDF 2.0 based compliance.

Encryption is prohibited by PDF/A compliance. This option will be ignored when saving to PDF/A.

Aspose.Words.Saving.PdfPermissions.ContentCopyForAccessibility permission is required by PDF/UA compliance if the output document is encrypted. This permission will automatically used when saving to PDF/UA.

Aspose.Words.Saving.PdfPermissions.ContentCopyForAccessibility permission is deprecated in PDF 2.0 format. This permission will be ignored when saving to PDF 2.0.

ExportDocumentStructure

Gets or sets a value determining whether or not to export document structure.

public bool ExportDocumentStructure { get; set; }

Property Value

bool

Examples

Shows how to preserve document structure elements, which can assist in programmatically interpreting our document.

Document doc = new Document();
                                                                                                                             DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                                             builder.ParagraphFormat.Style = doc.Styles["Heading 1"];
                                                                                                                             builder.Writeln("Hello world!");
                                                                                                                             builder.ParagraphFormat.Style = doc.Styles["Normal"];
                                                                                                                             builder.Write(
                                                                                                                                 "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");

                                                                                                                             // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                                             // to modify how that method converts the document to .PDF.
                                                                                                                             PdfSaveOptions options = new PdfSaveOptions();
                                                                                                                             // Set the "ExportDocumentStructure" property to "true" to make the document structure, such tags, available via the
                                                                                                                             // "Content" navigation pane of Adobe Acrobat at the cost of increased file size.
                                                                                                                             // Set the "ExportDocumentStructure" property to "false" to not export the document structure.
                                                                                                                             options.ExportDocumentStructure = exportDocumentStructure;

                                                                                                                             // Suppose we export document structure while saving this document. In that case,
                                                                                                                             // we can open it using Adobe Acrobat and find tags for elements such as the heading
                                                                                                                             // and the next paragraph via "View" -> "Show/Hide" -> "Navigation panes" -> "Tags".
                                                                                                                             doc.Save(ArtifactsDir + "PdfSaveOptions.ExportDocumentStructure.pdf", options);

Remarks

This value is ignored when saving to PDF/A-1a, PDF/A-2a and PDF/UA-1 because document structure is required for this compliance.

Note that exporting the document structure significantly increases the memory consumption, especially for the large documents.

ExportFloatingShapesAsInlineTag

Gets or sets a value determining whether floating shapes are exported as inline tags in the document structure.

public bool ExportFloatingShapesAsInlineTag { get; set; }

Property Value

bool

Examples

Shows how to export floating shapes as inline tags.

Document doc = new Document(MyDir + "Floating object.docx");

                                                              PdfSaveOptions saveOptions = new PdfSaveOptions();
                                                              saveOptions.ExportFloatingShapesAsInlineTag = true;

                                                              doc.Save(ArtifactsDir + "PdfSaveOptions.ExportFloatingShapesAsInlineTag.pdf", saveOptions);

Remarks

Default value is false and floating shapes will be exported as block-level tags, placed after the paragraph in which they are anchored.

When the value is true floating shapes will be exported as inline tags, placed within the paragraph where they are anchored.

This value is ignored when Aspose.Words.Saving.PdfSaveOptions.ExportDocumentStructure is false.

ExportLanguageToSpanTag

Gets or sets a value determining whether or not to create a “Span” tag in the document structure to export the text language.

public bool ExportLanguageToSpanTag { get; set; }

Property Value

bool

Examples

Shows how to create a “Span” tag in the document structure to export the text language.

Document doc = new Document();
                                                                                                  DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                  builder.Writeln("Hello world!");
                                                                                                  builder.Writeln("Hola mundo!");

                                                                                                  PdfSaveOptions saveOptions = new PdfSaveOptions
                                                                                                  {
                                                                                                      // Note, when "ExportDocumentStructure" is false, "ExportLanguageToSpanTag" is ignored.
                                                                                                      ExportDocumentStructure = true, ExportLanguageToSpanTag = true
                                                                                                  };

                                                                                                  doc.Save(ArtifactsDir + "PdfSaveOptions.ExportLanguageToSpanTag.pdf", saveOptions);

Remarks

Default value is false and "Lang" attribute is attached to a marked-content sequence in a page content stream.

When the value is true "Span" tag is created for the text with non-default language and "Lang" attribute is attached to this tag.

This value is ignored when Aspose.Words.Saving.PdfSaveOptions.ExportDocumentStructure is false.

ExportParagraphGraphicsToArtifact

Gets or sets a value determining whether a paragraph graphic should be marked as an artifact.

public bool ExportParagraphGraphicsToArtifact { get; set; }

Property Value

bool

Examples

Shows how to export paragraph graphics as artifact (underlines, text emphasis, etc.).

Document doc = new Document(MyDir + "PDF artifacts.docx");

                                                                                                PdfSaveOptions saveOptions = new PdfSaveOptions();
                                                                                                saveOptions.ExportDocumentStructure = true;
                                                                                                saveOptions.ExportParagraphGraphicsToArtifact = true;
                                                                                                saveOptions.TextCompression = PdfTextCompression.None;

                                                                                                doc.Save(ArtifactsDir + "PdfSaveOptions.ExportParagraphGraphicsToArtifact.pdf", saveOptions);

Remarks

Default value is false and paragraph graphics (underlines, text emphasis, etc.) will be marked as "Span" in the logical structure of the document.

When the value is true the paragraph graphics will be marked as "Artifact".

This value is ignored when Aspose.Words.Saving.PdfSaveOptions.ExportDocumentStructure is false.

FontEmbeddingMode

Specifies the font embedding mode.

public PdfFontEmbeddingMode FontEmbeddingMode { get; set; }

Property Value

PdfFontEmbeddingMode

Examples

Shows how to set Aspose.Words to skip embedding Arial and Times New Roman fonts into a PDF document.

Document doc = new Document();
                                                                                                               DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                               // "Arial" is a standard font, and "Courier New" is a nonstandard font.
                                                                                                               builder.Font.Name = "Arial";
                                                                                                               builder.Writeln("Hello world!");
                                                                                                               builder.Font.Name = "Courier New";
                                                                                                               builder.Writeln("The quick brown fox jumps over the lazy dog.");

                                                                                                               // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                               // to modify how that method converts the document to .PDF.
                                                                                                               PdfSaveOptions options = new PdfSaveOptions();
                                                                                                               // Set the "EmbedFullFonts" property to "true" to embed every glyph of every embedded font in the output PDF.
                                                                                                               options.EmbedFullFonts = true;
                                                                                                               // Set the "FontEmbeddingMode" property to "EmbedAll" to embed all fonts in the output PDF.
                                                                                                               // Set the "FontEmbeddingMode" property to "EmbedNonstandard" to only allow nonstandard fonts' embedding in the output PDF.
                                                                                                               // Set the "FontEmbeddingMode" property to "EmbedNone" to not embed any fonts in the output PDF.
                                                                                                               options.FontEmbeddingMode = pdfFontEmbeddingMode;

                                                                                                               doc.Save(ArtifactsDir + "PdfSaveOptions.EmbedWindowsFonts.pdf", options);

Remarks

The default value is Aspose.Words.Saving.PdfFontEmbeddingMode.EmbedAll.

This setting works only for the text in ANSI (Windows-1252) encoding. If the document contains non-ANSI text then corresponding fonts will be embedded regardless of this setting.

PDF/A and PDF/UA compliance requires all fonts to be embedded. Aspose.Words.Saving.PdfFontEmbeddingMode.EmbedAll value will be used automatically when saving to PDF/A and PDF/UA.

HeaderFooterBookmarksExportMode

Determines how bookmarks in headers/footers are exported.

public HeaderFooterBookmarksExportMode HeaderFooterBookmarksExportMode { get; set; }

Property Value

HeaderFooterBookmarksExportMode

Examples

Shows to process bookmarks in headers/footers in a document that we are rendering to PDF.

Document doc = new Document(MyDir + "Bookmarks in headers and footers.docx");

                                                                                                    // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                    // to modify how that method converts the document to .PDF.
                                                                                                    PdfSaveOptions saveOptions = new PdfSaveOptions();

                                                                                                    // Set the "PageMode" property to "PdfPageMode.UseOutlines" to display the outline navigation pane in the output PDF.
                                                                                                    saveOptions.PageMode = PdfPageMode.UseOutlines;

                                                                                                    // Set the "DefaultBookmarksOutlineLevel" property to "1" to display all
                                                                                                    // bookmarks at the first level of the outline in the output PDF.
                                                                                                    saveOptions.OutlineOptions.DefaultBookmarksOutlineLevel = 1;

                                                                                                    // Set the "HeaderFooterBookmarksExportMode" property to "HeaderFooterBookmarksExportMode.None" to
                                                                                                    // not export any bookmarks that are inside headers/footers.
                                                                                                    // Set the "HeaderFooterBookmarksExportMode" property to "HeaderFooterBookmarksExportMode.First" to
                                                                                                    // only export bookmarks in the first section's header/footers.
                                                                                                    // Set the "HeaderFooterBookmarksExportMode" property to "HeaderFooterBookmarksExportMode.All" to
                                                                                                    // export bookmarks that are in all headers/footers.
                                                                                                    saveOptions.HeaderFooterBookmarksExportMode = headerFooterBookmarksExportMode;

                                                                                                    doc.Save(ArtifactsDir + "PdfSaveOptions.HeaderFooterBookmarksExportMode.pdf", saveOptions);

Remarks

The default value is Aspose.Words.Saving.HeaderFooterBookmarksExportMode.All.

This property is used in conjunction with the Aspose.Words.Saving.PdfSaveOptions.OutlineOptions option.

ImageColorSpaceExportMode

Specifies how the color space will be selected for the images in PDF document.

public PdfImageColorSpaceExportMode ImageColorSpaceExportMode { get; set; }

Property Value

PdfImageColorSpaceExportMode

Examples

Shows how to set a different color space for images in a document as we export it to PDF.

Document doc = new Document();
                                                                                                    DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                    builder.Writeln("Jpeg image:");
                                                                                                    builder.InsertImage(ImageDir + "Logo.jpg");
                                                                                                    builder.InsertParagraph();
                                                                                                    builder.Writeln("Png image:");
                                                                                                    builder.InsertImage(ImageDir + "Transparent background logo.png");

                                                                                                    // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                    // to modify how that method converts the document to .PDF.
                                                                                                    PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();

                                                                                                    // Set the "ImageColorSpaceExportMode" property to "PdfImageColorSpaceExportMode.Auto" to get Aspose.Words to
                                                                                                    // automatically select the color space for images in the document that it converts to PDF.
                                                                                                    // In most cases, the color space will be RGB.
                                                                                                    // Set the "ImageColorSpaceExportMode" property to "PdfImageColorSpaceExportMode.SimpleCmyk"
                                                                                                    // to use the CMYK color space for all images in the saved PDF.
                                                                                                    // Aspose.Words will also apply Flate compression to all images and ignore the "ImageCompression" property's value.
                                                                                                    pdfSaveOptions.ImageColorSpaceExportMode = pdfImageColorSpaceExportMode;

                                                                                                    doc.Save(ArtifactsDir + "PdfSaveOptions.ImageColorSpaceExportMode.pdf", pdfSaveOptions);

Remarks

The default value is Aspose.Words.Saving.PdfImageColorSpaceExportMode.Auto.

If Aspose.Words.Saving.PdfImageColorSpaceExportMode.SimpleCmyk value is specified, Aspose.Words.Saving.PdfSaveOptions.ImageCompression option is ignored and Flate compression is used for all images in the document.

Aspose.Words.Saving.PdfImageColorSpaceExportMode.SimpleCmyk value is not supported when saving to PDF/A. Aspose.Words.Saving.PdfImageColorSpaceExportMode.Auto value will be used instead.

ImageCompression

Specifies compression type to be used for all images in the document.

public PdfImageCompression ImageCompression { get; set; }

Property Value

PdfImageCompression

Examples

Shows how to specify a compression type for all images in a document that we are converting to PDF.

Document doc = new Document();
                                                                                                              DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                              builder.Writeln("Jpeg image:");
                                                                                                              builder.InsertImage(ImageDir + "Logo.jpg");
                                                                                                              builder.InsertParagraph();
                                                                                                              builder.Writeln("Png image:");
                                                                                                              builder.InsertImage(ImageDir + "Transparent background logo.png");

                                                                                                              // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                              // to modify how that method converts the document to .PDF.
                                                                                                              PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
                                                                                                              // Set the "ImageCompression" property to "PdfImageCompression.Auto" to use the
                                                                                                              // "ImageCompression" property to control the quality of the Jpeg images that end up in the output PDF.
                                                                                                              // Set the "ImageCompression" property to "PdfImageCompression.Jpeg" to use the
                                                                                                              // "ImageCompression" property to control the quality of all images that end up in the output PDF.
                                                                                                              pdfSaveOptions.ImageCompression = pdfImageCompression;
                                                                                                              // Set the "JpegQuality" property to "10" to strengthen compression at the cost of image quality.
                                                                                                              pdfSaveOptions.JpegQuality = 10;

                                                                                                              doc.Save(ArtifactsDir + "PdfSaveOptions.ImageCompression.pdf", pdfSaveOptions);

Remarks

Default is Aspose.Words.Saving.PdfImageCompression.Auto.

Using Aspose.Words.Saving.PdfImageCompression.Jpeg lets you control the quality of images in the output document through the Aspose.Words.Saving.PdfSaveOptions.JpegQuality property.

Using Aspose.Words.Saving.PdfImageCompression.Jpeg provides the fastest conversion speed when compared to the performance of other compression types, but in this case, there is lossy JPEG compression.

Using Aspose.Words.Saving.PdfImageCompression.Auto lets to control the quality of Jpeg in the output document through the Aspose.Words.Saving.PdfSaveOptions.JpegQuality property, but for other formats, raw pixel data is extracted and saved with Flate compression. This case is slower than Jpeg conversion but lossless.

InterpolateImages

A flag indicating whether image interpolation shall be performed by a conforming reader. When false is specified, the flag is not written to the output document and the default behaviour of reader is used instead.

public bool InterpolateImages { get; set; }

Property Value

bool

Examples

Shows how to perform interpolation on images while saving a document to PDF.

Document doc = new Document();
                                                                                       DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                       builder.InsertImage(ImageDir + "Transparent background logo.png");

                                                                                       // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                       // to modify how that method converts the document to .PDF.
                                                                                       PdfSaveOptions saveOptions = new PdfSaveOptions();
                                                                                       // Set the "InterpolateImages" property to "true" to get the reader that opens this document to interpolate images.
                                                                                       // Their resolution should be lower than that of the device that is displaying the document.
                                                                                       // Set the "InterpolateImages" property to "false" to make it so that the reader does not apply any interpolation.
                                                                                       saveOptions.InterpolateImages = interpolateImages;

                                                                                       // When we open this document with a reader such as Adobe Acrobat, we will need to zoom in on the image
                                                                                       // to see the interpolation effect if we saved the document with it enabled.
                                                                                       doc.Save(ArtifactsDir + "PdfSaveOptions.InterpolateImages.pdf", saveOptions);

Remarks

When the resolution of a source image is significantly lower than that of the output device, each source sample covers many device pixels. As a result, images can appear jaggy or blocky. These visual artifacts can be reduced by applying an image interpolation algorithm during rendering. Instead of painting all pixels covered by a source sample with the same color, image interpolation attempts to produce a smooth transition between adjacent sample values.

A conforming Reader may choose to not implement this feature of PDF, or may use any specific implementation of interpolation that it wishes.

The default value is false.

Interpolation flag is prohibited by PDF/A compliance. false value will be used automatically when saving to PDF/A.

JpegQuality

Gets or sets a value determining the quality of the JPEG images inside PDF document.

public int JpegQuality { get; set; }

Property Value

int

Examples

Shows how to specify a compression type for all images in a document that we are converting to PDF.

Document doc = new Document();
                                                                                                              DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                              builder.Writeln("Jpeg image:");
                                                                                                              builder.InsertImage(ImageDir + "Logo.jpg");
                                                                                                              builder.InsertParagraph();
                                                                                                              builder.Writeln("Png image:");
                                                                                                              builder.InsertImage(ImageDir + "Transparent background logo.png");

                                                                                                              // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                              // to modify how that method converts the document to .PDF.
                                                                                                              PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
                                                                                                              // Set the "ImageCompression" property to "PdfImageCompression.Auto" to use the
                                                                                                              // "ImageCompression" property to control the quality of the Jpeg images that end up in the output PDF.
                                                                                                              // Set the "ImageCompression" property to "PdfImageCompression.Jpeg" to use the
                                                                                                              // "ImageCompression" property to control the quality of all images that end up in the output PDF.
                                                                                                              pdfSaveOptions.ImageCompression = pdfImageCompression;
                                                                                                              // Set the "JpegQuality" property to "10" to strengthen compression at the cost of image quality.
                                                                                                              pdfSaveOptions.JpegQuality = 10;

                                                                                                              doc.Save(ArtifactsDir + "PdfSaveOptions.ImageCompression.pdf", pdfSaveOptions);

Remarks

The default value is 100.

This property is used in conjunction with the Aspose.Words.Saving.PdfSaveOptions.ImageCompression option.

Has effect only when a document contains JPEG images.

Use this property to get or set the quality of the images inside a document when saving in PDF format. The value may vary from 0 to 100 where 0 means worst quality but maximum compression and 100 means best quality but minimum compression. If quality is 100 and source image is JPEG, it means no compression - original bytes will be saved.

OpenHyperlinksInNewWindow

Gets or sets a value determining whether hyperlinks in the output Pdf document are forced to be opened in a new window (or tab) of a browser.

public bool OpenHyperlinksInNewWindow { get; set; }

Property Value

bool

Examples

Shows how to save hyperlinks in a document we convert to PDF so that they open new pages when we click on them.

Document doc = new Document();
                                                                                                                          DocumentBuilder builder = new DocumentBuilder(doc);
                                                                                                                          builder.InsertHyperlink("Testlink", @"https://www.google.com/search?q=%20aspose", false);

                                                                                                                          // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                                          // to modify how that method converts the document to .PDF.
                                                                                                                          PdfSaveOptions options = new PdfSaveOptions();

                                                                                                                          // Set the "OpenHyperlinksInNewWindow" property to "true" to save all hyperlinks using Javascript code
                                                                                                                          // that forces readers to open these links in new windows/browser tabs.
                                                                                                                          // Set the "OpenHyperlinksInNewWindow" property to "false" to save all hyperlinks normally.
                                                                                                                          options.OpenHyperlinksInNewWindow = openHyperlinksInNewWindow;

                                                                                                                          doc.Save(ArtifactsDir + "PdfSaveOptions.OpenHyperlinksInNewWindow.pdf", options);

Remarks

The default value is false. When this value is set to true hyperlinks are saved using JavaScript code. JavaScript code is app.launchURL("URL", true);, where URL is a hyperlink.

Note that if this option is set to true hyperlinks can't work in some PDF readers e.g. Chrome, Firefox.

JavaScript actions are prohibited by PDF/A-1 and PDF/A-2 compliance. false will be used automatically when saving to PDF/A-1 and PDF/A-2.

OutlineOptions

Allows to specify outline options.

public OutlineOptions OutlineOptions { get; }

Property Value

OutlineOptions

Examples

Shows how to limit the headings’ level that will appear in the outline of a saved PDF document.

Document doc = new Document();
                                                                                                          DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                          // Insert headings that can serve as TOC entries of levels 1, 2, and then 3.
                                                                                                          builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

                                                                                                          Assert.That(builder.ParagraphFormat.IsHeading, Is.True);

                                                                                                          builder.Writeln("Heading 1");

                                                                                                          builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

                                                                                                          builder.Writeln("Heading 1.1");
                                                                                                          builder.Writeln("Heading 1.2");

                                                                                                          builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;

                                                                                                          builder.Writeln("Heading 1.2.1");
                                                                                                          builder.Writeln("Heading 1.2.2");

                                                                                                          // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                          // to modify how that method converts the document to .PDF.
                                                                                                          PdfSaveOptions saveOptions = new PdfSaveOptions();
                                                                                                          saveOptions.SaveFormat = SaveFormat.Pdf;

                                                                                                          // The output PDF document will contain an outline, which is a table of contents that lists headings in the document body.
                                                                                                          // Clicking on an entry in this outline will take us to the location of its respective heading.
                                                                                                          // Set the "HeadingsOutlineLevels" property to "2" to exclude all headings whose levels are above 2 from the outline.
                                                                                                          // The last two headings we have inserted above will not appear.
                                                                                                          saveOptions.OutlineOptions.HeadingsOutlineLevels = 2;

                                                                                                          doc.Save(ArtifactsDir + "PdfSaveOptions.HeadingsOutlineLevels.pdf", saveOptions);

Shows how to work with outline levels that do not contain any corresponding headings when saving a PDF document.

Document doc = new Document();
                                                                                                                           DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                                           // Insert headings that can serve as TOC entries of levels 1 and 5.
                                                                                                                           builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

                                                                                                                           Assert.That(builder.ParagraphFormat.IsHeading, Is.True);

                                                                                                                           builder.Writeln("Heading 1");

                                                                                                                           builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading5;

                                                                                                                           builder.Writeln("Heading 1.1.1.1.1");
                                                                                                                           builder.Writeln("Heading 1.1.1.1.2");

                                                                                                                           // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                                           // to modify how that method converts the document to .PDF.
                                                                                                                           PdfSaveOptions saveOptions = new PdfSaveOptions();

                                                                                                                           // The output PDF document will contain an outline, which is a table of contents that lists headings in the document body.
                                                                                                                           // Clicking on an entry in this outline will take us to the location of its respective heading.
                                                                                                                           // Set the "HeadingsOutlineLevels" property to "5" to include all headings of levels 5 and below in the outline.
                                                                                                                           saveOptions.OutlineOptions.HeadingsOutlineLevels = 5;

                                                                                                                           // This document contains headings of levels 1 and 5, and no headings with levels of 2, 3, and 4.
                                                                                                                           // The output PDF document will treat outline levels 2, 3, and 4 as "missing".
                                                                                                                           // Set the "CreateMissingOutlineLevels" property to "true" to include all missing levels in the outline,
                                                                                                                           // leaving blank outline entries since there are no usable headings.
                                                                                                                           // Set the "CreateMissingOutlineLevels" property to "false" to ignore missing outline levels,
                                                                                                                           // and treat the outline level 5 headings as level 2.
                                                                                                                           saveOptions.OutlineOptions.CreateMissingOutlineLevels = createMissingOutlineLevels;

                                                                                                                           doc.Save(ArtifactsDir + "PdfSaveOptions.CreateMissingOutlineLevels.pdf", saveOptions);

Remarks

Outlines can be created from headings and bookmarks.

For headings outline level is determined by the heading level.

It is possible to set the max heading level to be included into outlines or disable heading outlines at all.

For bookmarks outline level may be set in options as a default value for all bookmarks or as individual values for particular bookmarks.

Also, outlines can be exported to XPS format by using the same Aspose.Words.Saving.PdfSaveOptions.OutlineOptions class.

PageLayout

Specifies the page layout to be used when the document is opened in a PDF reader.

public PdfPageLayout PageLayout { get; set; }

Property Value

PdfPageLayout

Examples

Shows how to display pages when opened in a PDF reader.

Document doc = new Document(MyDir + "Big document.docx");

                                                                  // Display the pages two at a time, with odd-numbered pages on the left.
                                                                  PdfSaveOptions saveOptions = new PdfSaveOptions();
                                                                  saveOptions.PageLayout = PdfPageLayout.TwoPageLeft;

                                                                  doc.Save(ArtifactsDir + "PdfSaveOptions.PageLayout.pdf", saveOptions);

Remarks

The default value is Aspose.Words.Saving.PdfPageLayout.SinglePage.

PageMode

Specifies how the PDF document should be displayed when opened in a PDF reader.

public PdfPageMode PageMode { get; set; }

Property Value

PdfPageMode

Examples

Shows how to set instructions for some PDF readers to follow when opening an output document.

Document doc = new Document();
                                                                                                        DocumentBuilder builder = new DocumentBuilder(doc);
                                                                                                        builder.Writeln("Hello world!");

                                                                                                        // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                        // to modify how that method converts the document to .PDF.
                                                                                                        PdfSaveOptions options = new PdfSaveOptions();

                                                                                                        // Set the "PageMode" property to "PdfPageMode.FullScreen" to get the PDF reader to open the saved
                                                                                                        // document in full-screen mode, which takes over the monitor's display and has no controls visible.
                                                                                                        // Set the "PageMode" property to "PdfPageMode.UseThumbs" to get the PDF reader to display a separate panel
                                                                                                        // with a thumbnail for each page in the document.
                                                                                                        // Set the "PageMode" property to "PdfPageMode.UseOC" to get the PDF reader to display a separate panel
                                                                                                        // that allows us to work with any layers present in the document.
                                                                                                        // Set the "PageMode" property to "PdfPageMode.UseOutlines" to get the PDF reader
                                                                                                        // also to display the outline, if possible.
                                                                                                        // Set the "PageMode" property to "PdfPageMode.UseNone" to get the PDF reader to display just the document itself.
                                                                                                        // Set the "PageMode" property to "PdfPageMode.UseAttachments" to make visible attachments panel.
                                                                                                        options.PageMode = pageMode;

                                                                                                        doc.Save(ArtifactsDir + "PdfSaveOptions.PageMode.pdf", options);

Shows to process bookmarks in headers/footers in a document that we are rendering to PDF.

Document doc = new Document(MyDir + "Bookmarks in headers and footers.docx");

                                                                                                    // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                    // to modify how that method converts the document to .PDF.
                                                                                                    PdfSaveOptions saveOptions = new PdfSaveOptions();

                                                                                                    // Set the "PageMode" property to "PdfPageMode.UseOutlines" to display the outline navigation pane in the output PDF.
                                                                                                    saveOptions.PageMode = PdfPageMode.UseOutlines;

                                                                                                    // Set the "DefaultBookmarksOutlineLevel" property to "1" to display all
                                                                                                    // bookmarks at the first level of the outline in the output PDF.
                                                                                                    saveOptions.OutlineOptions.DefaultBookmarksOutlineLevel = 1;

                                                                                                    // Set the "HeaderFooterBookmarksExportMode" property to "HeaderFooterBookmarksExportMode.None" to
                                                                                                    // not export any bookmarks that are inside headers/footers.
                                                                                                    // Set the "HeaderFooterBookmarksExportMode" property to "HeaderFooterBookmarksExportMode.First" to
                                                                                                    // only export bookmarks in the first section's header/footers.
                                                                                                    // Set the "HeaderFooterBookmarksExportMode" property to "HeaderFooterBookmarksExportMode.All" to
                                                                                                    // export bookmarks that are in all headers/footers.
                                                                                                    saveOptions.HeaderFooterBookmarksExportMode = headerFooterBookmarksExportMode;

                                                                                                    doc.Save(ArtifactsDir + "PdfSaveOptions.HeaderFooterBookmarksExportMode.pdf", saveOptions);

Remarks

The default value is Aspose.Words.Saving.PdfPageMode.UseOutlines.

PreblendImages

Gets or sets a value determining whether or not to preblend transparent images with black background color.

public bool PreblendImages { get; set; }

Property Value

bool

Examples

Shows how to preblend images with transparent backgrounds while saving a document to PDF.

Document doc = new Document();
                                                                                                    DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                    builder.InsertImage(ImageDir + "Transparent background logo.png");

                                                                                                    // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                    // to modify how that method converts the document to .PDF.
                                                                                                    PdfSaveOptions options = new PdfSaveOptions();
                                                                                                    // Set the "PreblendImages" property to "true" to preblend transparent images
                                                                                                    // with a background, which may reduce artifacts.
                                                                                                    // Set the "PreblendImages" property to "false" to render transparent images normally.
                                                                                                    options.PreblendImages = preblendImages;

                                                                                                    doc.Save(ArtifactsDir + "PdfSaveOptions.PreblendImages.pdf", options);

Remarks

Preblending images may improve PDF document visual appearance in Adobe Reader and remove anti-aliasing artifacts.

In order to properly display preblended images, PDF viewer application must support /Matte entry in soft-mask image dictionary. Also preblending images may decrease PDF rendering performance.

The default value is false.

PreserveFormFields

Specifies whether to preserve Microsoft Word form fields as form fields in PDF or convert them to text. Default is false.

public bool PreserveFormFields { get; set; }

Property Value

bool

Examples

Shows how to save a document to the PDF format using the Save method and the PdfSaveOptions class.

Document doc = new Document();
                                                                                                             DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                             builder.Write("Please select a fruit: ");

                                                                                                             // Insert a combo box which will allow a user to choose an option from a collection of strings.
                                                                                                             builder.InsertComboBox("MyComboBox", new[] { "Apple", "Banana", "Cherry" }, 0);

                                                                                                             // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                             // to modify how that method converts the document to .PDF.
                                                                                                             PdfSaveOptions pdfOptions = new PdfSaveOptions();

                                                                                                             // Set the "PreserveFormFields" property to "true" to save form fields as interactive objects in the output PDF.
                                                                                                             // Set the "PreserveFormFields" property to "false" to freeze all form fields in the document at
                                                                                                             // their current values and display them as plain text in the output PDF.
                                                                                                             pdfOptions.PreserveFormFields = preserveFormFields;

                                                                                                             doc.Save(ArtifactsDir + "PdfSaveOptions.PreserveFormFields.pdf", pdfOptions);

Remarks

Microsoft Word form fields include text input, drop down and check box controls.

When set to false, these fields will be exported as text to PDF. When set to true, these fields will be exported as PDF form fields.

When exporting form fields to PDF as form fields, some formatting loss might occur because PDF form fields do not support all features of Microsoft Word form fields.

Also, the output size depends on the content size because editable forms in Microsoft Word are inline objects.

RenderChoiceFormFieldBorder

Specifies whether to render PDF choice form field border.

public bool RenderChoiceFormFieldBorder { get; set; }

Property Value

bool

Examples

Shows how to render PDF choice form field border.

Document doc = new Document(MyDir + "Legacy drop-down.docx");

                                                            PdfSaveOptions saveOptions = new PdfSaveOptions();
                                                            saveOptions.PreserveFormFields = true;
                                                            saveOptions.RenderChoiceFormFieldBorder = true;

                                                            doc.Save(ArtifactsDir + "PdfSaveOptions.RenderChoiceFormFieldBorder.pdf", saveOptions);

Remarks

PDF choice form fields are used for export of SDT Combo Box Content Control, SDT Drop-Down List Content Control and legacy Drop-Down Form Field when Aspose.Words.Saving.PdfSaveOptions.PreserveFormFields option is enabled.

The default value is true.

SaveFormat

Specifies the format in which the document will be saved if this save options object is used. Can only be Aspose.Words.SaveFormat.Pdf.

public override SaveFormat SaveFormat { get; set; }

Property Value

SaveFormat

Examples

Shows how to limit the headings’ level that will appear in the outline of a saved PDF document.

Document doc = new Document();
                                                                                                          DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                          // Insert headings that can serve as TOC entries of levels 1, 2, and then 3.
                                                                                                          builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading1;

                                                                                                          Assert.That(builder.ParagraphFormat.IsHeading, Is.True);

                                                                                                          builder.Writeln("Heading 1");

                                                                                                          builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading2;

                                                                                                          builder.Writeln("Heading 1.1");
                                                                                                          builder.Writeln("Heading 1.2");

                                                                                                          builder.ParagraphFormat.StyleIdentifier = StyleIdentifier.Heading3;

                                                                                                          builder.Writeln("Heading 1.2.1");
                                                                                                          builder.Writeln("Heading 1.2.2");

                                                                                                          // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                          // to modify how that method converts the document to .PDF.
                                                                                                          PdfSaveOptions saveOptions = new PdfSaveOptions();
                                                                                                          saveOptions.SaveFormat = SaveFormat.Pdf;

                                                                                                          // The output PDF document will contain an outline, which is a table of contents that lists headings in the document body.
                                                                                                          // Clicking on an entry in this outline will take us to the location of its respective heading.
                                                                                                          // Set the "HeadingsOutlineLevels" property to "2" to exclude all headings whose levels are above 2 from the outline.
                                                                                                          // The last two headings we have inserted above will not appear.
                                                                                                          saveOptions.OutlineOptions.HeadingsOutlineLevels = 2;

                                                                                                          doc.Save(ArtifactsDir + "PdfSaveOptions.HeadingsOutlineLevels.pdf", saveOptions);

TextCompression

Specifies compression type to be used for all textual content in the document.

public PdfTextCompression TextCompression { get; set; }

Property Value

PdfTextCompression

Examples

Shows how to apply text compression when saving a document to PDF.

Document doc = new Document();
                                                                             DocumentBuilder builder = new DocumentBuilder(doc);

                                                                             for (int i = 0; i < 100; i++)
                                                                                 builder.Writeln("Lorem ipsum dolor sit amet, consectetur adipiscing elit, " +
                                                                                                 "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.");

                                                                             // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                             // to modify how that method converts the document to .PDF.
                                                                             PdfSaveOptions options = new PdfSaveOptions();

                                                                             // Set the "TextCompression" property to "PdfTextCompression.None" to not apply any
                                                                             // compression to text when we save the document to PDF.
                                                                             // Set the "TextCompression" property to "PdfTextCompression.Flate" to apply ZIP compression
                                                                             // to text when we save the document to PDF. The larger the document, the bigger the impact that this will have.
                                                                             options.TextCompression = pdfTextCompression;

                                                                             doc.Save(ArtifactsDir + "PdfSaveOptions.TextCompression.pdf", options);

Remarks

Default is Aspose.Words.Saving.PdfTextCompression.Flate.

Significantly increases output size when saving a document without compression.

UseBookFoldPrintingSettings

Gets or sets a boolean value indicating whether the document should be saved using a booklet printing layout, if it is specified via Aspose.Words.PageSetup.MultiplePages.

public bool UseBookFoldPrintingSettings { get; set; }

Property Value

bool

Examples

Shows how to save a document to the PDF format in the form of a book fold.

Document doc = new Document(MyDir + "Paragraphs.docx");

                                                                                     // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                     // to modify how that method converts the document to .PDF.
                                                                                     PdfSaveOptions options = new PdfSaveOptions();

                                                                                     // Set the "UseBookFoldPrintingSettings" property to "true" to arrange the contents
                                                                                     // in the output PDF in a way that helps us use it to make a booklet.
                                                                                     // Set the "UseBookFoldPrintingSettings" property to "false" to render the PDF normally.
                                                                                     options.UseBookFoldPrintingSettings = renderTextAsBookfold;

                                                                                     // If we are rendering the document as a booklet, we must set the "MultiplePages"
                                                                                     // properties of the page setup objects of all sections to "MultiplePagesType.BookFoldPrinting".
                                                                                     if (renderTextAsBookfold)
                                                                                         foreach (Section s in doc.Sections)
                                                                                         {
                                                                                             s.PageSetup.MultiplePages = MultiplePagesType.BookFoldPrinting;
                                                                                         }

                                                                                     // Once we print this document on both sides of the pages, we can fold all the pages down the middle at once,
                                                                                     // and the contents will line up in a way that creates a booklet.
                                                                                     doc.Save(ArtifactsDir + "PdfSaveOptions.SaveAsPdfBookFold.pdf", options);

Remarks

<p>

If this option is specified, Aspose.Words.Saving.FixedPageSaveOptions.PageSet is ignored when saving. This behavior matches MS Word. If book fold printing settings are not specified in page setup, this option will have no effect.

UseCoreFonts

Gets or sets a value determining whether or not to substitute TrueType fonts Arial, Times New Roman, Courier New and Symbol with core PDF Type 1 fonts.

public bool UseCoreFonts { get; set; }

Property Value

bool

Examples

Shows how enable/disable PDF Type 1 font substitution.

Document doc = new Document();
                                                                 DocumentBuilder builder = new DocumentBuilder(doc);

                                                                 builder.Font.Name = "Arial";
                                                                 builder.Writeln("Hello world!");
                                                                 builder.Font.Name = "Courier New";
                                                                 builder.Writeln("The quick brown fox jumps over the lazy dog.");

                                                                 // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                 // to modify how that method converts the document to .PDF.
                                                                 PdfSaveOptions options = new PdfSaveOptions();
                                                                 // Set the "UseCoreFonts" property to "true" to replace some fonts,
                                                                 // including the two fonts in our document, with their PDF Type 1 equivalents.
                                                                 // Set the "UseCoreFonts" property to "false" to not apply PDF Type 1 fonts.
                                                                 options.UseCoreFonts = useCoreFonts;

                                                                 doc.Save(ArtifactsDir + "PdfSaveOptions.EmbedCoreFonts.pdf", options);

Remarks

The default value is false. When this value is set to true Arial, Times New Roman, Courier New and Symbol fonts are replaced in PDF document with corresponding core Type 1 font.

Core PDF fonts, or their font metrics and suitable substitution fonts, are required to be available to any PDF viewer application.

This setting works only for the text in ANSI (Windows-1252) encoding. Non-ANSI text will be written with embedded TrueType font regardless of this setting.

PDF/A and PDF/UA compliance requires all fonts to be embedded. false value will be used automatically when saving to PDF/A and PDF/UA.

Core fonts are not supported when saving to PDF 2.0 format. false value will be used automatically when saving to PDF 2.0.

This option has a higher priority then Aspose.Words.Saving.PdfSaveOptions.FontEmbeddingMode option.

UseSdtTagAsFormFieldName

Specifies whether to use SDT control Tag or Id property as a name of form field in PDF.

public bool UseSdtTagAsFormFieldName { get; set; }

Property Value

bool

Examples

Shows how to use SDT control Tag or Id property as a name of form field in PDF.

Document doc = new Document(MyDir + "Form fields.docx");

                                                                                          PdfSaveOptions saveOptions = new PdfSaveOptions();
                                                                                          saveOptions.PreserveFormFields = true;
                                                                                          // When set to 'false', SDT control Id property is used as a name of form field in PDF.
                                                                                          // When set to 'true', SDT control Tag property is used as a name of form field in PDF.
                                                                                          saveOptions.UseSdtTagAsFormFieldName = true;

                                                                                          doc.Save(ArtifactsDir + "PdfSaveOptions.SdtTagAsFormFieldName.pdf", saveOptions);

Remarks

The default value is false.

When set to false, SDT control Id property is used as a name of form field in PDF.

When set to true, SDT control Tag property is used as a name of form field in PDF.

If set to true and Tag is empty, Id property will be used as a form field name.

If set to true and Tag values are not unique, duplicate Tag values will be altered to build unique PDF form field names.

ZoomBehavior

Gets or sets a value determining what type of zoom should be applied when a document is opened with a PDF viewer.

public PdfZoomBehavior ZoomBehavior { get; set; }

Property Value

PdfZoomBehavior

Examples

Shows how to set the default zooming that a reader applies when opening a rendered PDF document.

Document doc = new Document();
                                                                                                           DocumentBuilder builder = new DocumentBuilder(doc);
                                                                                                           builder.Writeln("Hello world!");

                                                                                                           // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                           // to modify how that method converts the document to .PDF.
                                                                                                           // Set the "ZoomBehavior" property to "PdfZoomBehavior.ZoomFactor" to get a PDF reader to
                                                                                                           // apply a percentage-based zoom factor when we open the document with it.
                                                                                                           // Set the "ZoomFactor" property to "25" to give the zoom factor a value of 25%.
                                                                                                           PdfSaveOptions options = new PdfSaveOptions
                                                                                                           {
                                                                                                               ZoomBehavior = PdfZoomBehavior.ZoomFactor,
                                                                                                               ZoomFactor = 25
                                                                                                           };

                                                                                                           // When we open this document using a reader such as Adobe Acrobat, we will see the document scaled at 1/4 of its actual size.
                                                                                                           doc.Save(ArtifactsDir + "PdfSaveOptions.ZoomBehaviour.pdf", options);

Remarks

The default value is Aspose.Words.Saving.PdfZoomBehavior.None, i.e. no fit is applied.

ZoomFactor

Gets or sets a value determining zoom factor (in percentages) for a document.

public int ZoomFactor { get; set; }

Property Value

int

Examples

Shows how to set the default zooming that a reader applies when opening a rendered PDF document.

Document doc = new Document();
                                                                                                           DocumentBuilder builder = new DocumentBuilder(doc);
                                                                                                           builder.Writeln("Hello world!");

                                                                                                           // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                           // to modify how that method converts the document to .PDF.
                                                                                                           // Set the "ZoomBehavior" property to "PdfZoomBehavior.ZoomFactor" to get a PDF reader to
                                                                                                           // apply a percentage-based zoom factor when we open the document with it.
                                                                                                           // Set the "ZoomFactor" property to "25" to give the zoom factor a value of 25%.
                                                                                                           PdfSaveOptions options = new PdfSaveOptions
                                                                                                           {
                                                                                                               ZoomBehavior = PdfZoomBehavior.ZoomFactor,
                                                                                                               ZoomFactor = 25
                                                                                                           };

                                                                                                           // When we open this document using a reader such as Adobe Acrobat, we will see the document scaled at 1/4 of its actual size.
                                                                                                           doc.Save(ArtifactsDir + "PdfSaveOptions.ZoomBehaviour.pdf", options);

Remarks

This value is used only if Aspose.Words.Saving.PdfSaveOptions.ZoomBehavior is set to Aspose.Words.Saving.PdfZoomBehavior.ZoomFactor.

Methods

Clone()

Creates a deep clone of this object.

public PdfSaveOptions Clone()

Returns

PdfSaveOptions

Examples

Shows how to update all the fields in a document immediately before saving it to PDF.

Document doc = new Document();
                                                                                                DocumentBuilder builder = new DocumentBuilder(doc);

                                                                                                // Insert text with PAGE and NUMPAGES fields. These fields do not display the correct value in real time.
                                                                                                // We will need to manually update them using updating methods such as "Field.Update()", and "Document.UpdateFields()"
                                                                                                // each time we need them to display accurate values.
                                                                                                builder.Write("Page ");
                                                                                                builder.InsertField("PAGE", "");
                                                                                                builder.Write(" of ");
                                                                                                builder.InsertField("NUMPAGES", "");
                                                                                                builder.InsertBreak(BreakType.PageBreak);
                                                                                                builder.Writeln("Hello World!");

                                                                                                // Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
                                                                                                // to modify how that method converts the document to .PDF.
                                                                                                PdfSaveOptions options = new PdfSaveOptions();

                                                                                                // Set the "UpdateFields" property to "false" to not update all the fields in a document right before a save operation.
                                                                                                // This is the preferable option if we know that all our fields will be up to date before saving.
                                                                                                // Set the "UpdateFields" property to "true" to iterate through all the document
                                                                                                // fields and update them before we save it as a PDF. This will make sure that all the fields will display
                                                                                                // the most accurate values in the PDF.
                                                                                                options.UpdateFields = updateFields;

                                                                                                // We can clone PdfSaveOptions objects.
                                                                                                Assert.That(options.Clone(), Is.Not.SameAs(options));

                                                                                                doc.Save(ArtifactsDir + "PdfSaveOptions.UpdateFields.pdf", options);
 English