ImportFormatOptions class
ImportFormatOptions class
Allows to specify various import options to format output. To learn more, visit the Specify Load Options documentation article.
Constructors
Name | Description |
---|---|
ImportFormatOptions() | The default constructor. |
Properties
Name | Description |
---|---|
adjust_sentence_and_word_spacing | Gets or sets a boolean value that specifies whether to adjust sentence and word spacing automatically. The default value is False . |
force_copy_styles | Gets or sets a boolean value indicating either to copy conflicting styles in ImportFormatMode.KEEP_SOURCE_FORMATTING mode. The default value is False . |
ignore_header_footer | Gets or sets a boolean value that specifies that source formatting of headers/footers content ignored if ImportFormatMode.KEEP_SOURCE_FORMATTING mode is used. The default value is True . |
ignore_text_boxes | Gets or sets a boolean value that specifies that source formatting of textboxes content ignored if ImportFormatMode.KEEP_SOURCE_FORMATTING mode is used. The default value is True . |
keep_source_numbering | Gets or sets a boolean value that specifies how the numbering will be imported when it clashes in source and destination documents. The default value is False . |
merge_pasted_lists | Gets or sets a boolean value that specifies whether pasted lists will be merged with surrounding lists. The default value is False . |
smart_style_behavior | Gets or sets a boolean value that specifies how styles will be imported when they have equal names in source and destination documents. The default value is False . |
Examples
Shows how to resolve duplicate styles while inserting documents.
dst_doc = aw.Document()
builder = aw.DocumentBuilder(doc=dst_doc)
my_style = builder.document.styles.add(aw.StyleType.PARAGRAPH, 'MyStyle')
my_style.font.size = 14
my_style.font.name = 'Courier New'
my_style.font.color = aspose.pydrawing.Color.blue
builder.paragraph_format.style_name = my_style.name
builder.writeln('Hello world!')
# Clone the document and edit the clone's "MyStyle" style, so it is a different color than that of the original.
# If we insert the clone into the original document, the two styles with the same name will cause a clash.
src_doc = dst_doc.clone()
src_doc.styles.get_by_name('MyStyle').font.color = aspose.pydrawing.Color.red
# When we enable SmartStyleBehavior and use the KeepSourceFormatting import format mode,
# Aspose.Words will resolve style clashes by converting source document styles.
# with the same names as destination styles into direct paragraph attributes.
options = aw.ImportFormatOptions()
options.smart_style_behavior = True
builder.insert_document(src_doc=src_doc, import_format_mode=aw.ImportFormatMode.KEEP_SOURCE_FORMATTING, import_format_options=options)
dst_doc.save(file_name=ARTIFACTS_DIR + 'DocumentBuilder.SmartStyleBehavior.docx')
See Also
- module aspose.words