PdfSaveOptions class

PdfSaveOptions class

Can be used to specify additional options when saving a document into the SaveFormat.PDF format. To learn more, visit the Specify Save Options documentation article.

Inheritance: PdfSaveOptionsFixedPageSaveOptionsSaveOptions

Constructors

NameDescription
PdfSaveOptions()Initializes a new instance of this class that can be used to save a document in the SaveFormat.PDF format.

Properties

NameDescription
additional_text_positioningA flag specifying whether to write additional text positioning operators or not.
allow_embedding_post_script_fontsGets or sets a boolean value indicating whether to allow embedding fonts with PostScript outlines when embedding TrueType fonts in a document upon it is saved. The default value is False.
(Inherited from SaveOptions)
cache_background_graphicsGets or sets a value determining whether or not to cache graphics placed in document’s background.
color_modeGets or sets a value determining how colors are rendered.
(Inherited from FixedPageSaveOptions)
complianceSpecifies the PDF standards compliance level for output documents.
create_note_hyperlinksSpecifies 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.
custom_properties_exportGets or sets a value determining the way Document.custom_document_properties are exported to PDF file.
default_templateGets or sets path to default template (including filename). Default value for this property is empty string ().
(Inherited from SaveOptions)
digital_signature_detailsGets or sets the details for signing the output PDF document.
display_doc_titleA flag specifying whether the window’s title bar should display the document title taken from the Title entry of the document information dictionary.
dml_3d_effects_rendering_modeGets or sets a value determining how 3D effects are rendered.
(Inherited from SaveOptions)
dml_effects_rendering_modeGets or sets a value determining how DrawingML effects are rendered.
dml_rendering_modeGets or sets a value determining how DrawingML shapes are rendered.
(Inherited from SaveOptions)
downsample_optionsAllows to specify downsample options.
embed_attachmentsGets or sets a value determining whether or not to embed attachments to the PDF document.
embed_full_fontsControls how fonts are embedded into the resulting PDF documents.
encryption_detailsGets or sets the details for encrypting the output PDF document.
export_document_structureGets or sets a value determining whether or not to export document structure.
export_generator_nameWhen True, causes the name and version of Aspose.Words to be embedded into produced files. Default value is True.
(Inherited from SaveOptions)
export_language_to_span_tagGets or sets a value determining whether or not to create a “Span” tag in the document structure to export the text language.
export_paragraph_graphics_to_artifactGets or sets a value determining whether a paragraph graphic should be marked as an artifact.
font_embedding_modeSpecifies the font embedding mode.
header_footer_bookmarks_export_modeDetermines how bookmarks in headers/footers are exported.
image_color_space_export_modeSpecifies how the color space will be selected for the images in PDF document.
image_compressionSpecifies compression type to be used for all images in the document.
iml_rendering_modeGets or sets a value determining how ink (InkML) objects are rendered.
(Inherited from SaveOptions)
interpolate_imagesA 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.
jpeg_qualityGets or sets a value determining the quality of the JPEG images inside PDF document.
memory_optimizationGets or sets value determining if memory optimization should be performed before saving the document. Default value for this property is False.
(Inherited from SaveOptions)
metafile_rendering_optionsAllows to specify metafile rendering options.
(Inherited from FixedPageSaveOptions)
numeral_formatGets or sets NumeralFormat used for rendering of numerals. European numerals are used by default.
(Inherited from FixedPageSaveOptions)
open_hyperlinks_in_new_windowGets 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.
optimize_outputFlag indicates whether it is required to optimize output. If this flag is set redundant nested canvases and empty canvases are removed, also neighbor glyphs with the same formatting are concatenated. Note: The accuracy of the content display may be affected if this property is set to True.
(Inherited from FixedPageSaveOptions)
outline_optionsAllows to specify outline options.
page_layoutSpecifies the page layout to be used when the document is opened in a PDF reader.
page_modeSpecifies how the PDF document should be displayed when opened in a PDF reader.
page_saving_callbackAllows to control how separate pages are saved when a document is exported to fixed page format.
(Inherited from FixedPageSaveOptions)
page_setGets or sets the pages to render. Default is all the pages in the document.
(Inherited from FixedPageSaveOptions)
preblend_imagesGets or sets a value determining whether or not to preblend transparent images with black background color.
preserve_form_fieldsSpecifies whether to preserve Microsoft Word form fields as form fields in PDF or convert them to text. Default is False.
pretty_formatWhen True, pretty formats output where applicable. Default value is False.
(Inherited from SaveOptions)
progress_callbackCalled during saving a document and accepts data about saving progress.
(Inherited from SaveOptions)
render_choice_form_field_borderSpecifies whether to render PDF choice form field border.
save_formatSpecifies the format in which the document will be saved if this save options object is used. Can only be SaveFormat.PDF.
temp_folderSpecifies the folder for temporary files used when saving to a DOC or DOCX file. By default this property is None and no temporary files are used.
(Inherited from SaveOptions)
text_compressionSpecifies compression type to be used for all textual content in the document.
update_created_time_propertyGets or sets a value determining whether the BuiltInDocumentProperties.created_time property is updated before saving. Default value is False;
(Inherited from SaveOptions)
update_fieldsGets or sets a value determining if fields of certain types should be updated before saving the document to a fixed page format. Default value for this property is True.
(Inherited from SaveOptions)
update_last_printed_propertyGets or sets a value determining whether the BuiltInDocumentProperties.last_printed property is updated before saving.
(Inherited from SaveOptions)
update_last_saved_time_propertyGets or sets a value determining whether the BuiltInDocumentProperties.last_saved_time property is updated before saving.
(Inherited from SaveOptions)
use_anti_aliasingGets or sets a value determining whether or not to use anti-aliasing for rendering.
(Inherited from SaveOptions)
use_book_fold_printing_settingsGets or sets a boolean value indicating whether the document should be saved using a booklet printing layout, if it is specified via PageSetup.multiple_pages.
use_core_fontsGets 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.
use_high_quality_renderingGets or sets a value determining whether or not to use high quality (i.e. slow) rendering algorithms.
(Inherited from SaveOptions)
use_sdt_tag_as_form_field_nameSpecifies whether to use SDT control Tag or Id property as a name of form field in PDF.
zoom_behaviorGets or sets a value determining what type of zoom should be applied when a document is opened with a PDF viewer.
zoom_factorGets or sets a value determining zoom factor (in percentages) for a document.

Methods

NameDescription
clone()Creates a deep clone of this object.
create_save_options(save_format)Creates a save options object of a class suitable for the specified save format.
(Inherited from SaveOptions)
create_save_options(file_name)Creates a save options object of a class suitable for the file extension specified in the given file name.
(Inherited from SaveOptions)

Examples

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

doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
# Insert headings of levels 1 to 5.
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING1
self.assertTrue(builder.paragraph_format.is_heading)
builder.writeln('Heading 1')
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING2
builder.writeln('Heading 1.1')
builder.writeln('Heading 1.2')
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING3
builder.writeln('Heading 1.2.1')
builder.writeln('Heading 1.2.2')
builder.paragraph_format.style_identifier = aw.StyleIdentifier.HEADING4
builder.writeln('Heading 1.2.2.1')
builder.writeln('Heading 1.2.2.2')
builder.paragraph_format.style_identifier = aw.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.
options = aw.saving.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.outline_options.headings_outline_levels = 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.outline_options.expanded_outline_levels = 2
doc.save(file_name=ARTIFACTS_DIR + 'PdfSaveOptions.ExpandedOutlineLevels.pdf', save_options=options)

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

doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
i = 0
while i < 100:
    builder.writeln('Lorem ipsum dolor sit amet, consectetur adipiscing elit, ' + 'sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.')
    i += 1
# Create a "PdfSaveOptions" object that we can pass to the document's "Save" method
# to modify how that method converts the document to .PDF.
options = aw.saving.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.text_compression = pdf_text_compression
doc.save(file_name=ARTIFACTS_DIR + 'PdfSaveOptions.TextCompression.pdf', save_options=options)

Shows how to change image color with saving options property.

doc = aw.Document(file_name=MY_DIR + '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.
pdf_save_options = aw.saving.PdfSaveOptions()
pdf_save_options.color_mode = color_mode
doc.save(file_name=ARTIFACTS_DIR + 'PdfSaveOptions.ColorRendering.pdf', save_options=pdf_save_options)

See Also