This is the legacy 4D documentation web site. Documentations are progressively being moved to developer.4d.com

Home

 
4D v20 R7
Importing and Exporting in .docx format

Importing and Exporting in .docx format    


 

 

4D Write Pro can both import and export documents in the .docx format. This format is supported by word processing applications such as Microsoft Word.

Compatibility note: Support for 4D Write Pro documents imported or exported in .docx format is only certified for Microsoft Word 2010 and newer. Older versions, particularly Microsoft Word 2007, may not be able to open the documents.

Documents in .docx format can be imported into 4D Write Pro with the WP Import document command. For more information, please refer to the description of this command.

While the majority of .docx settings are preserved, some settings are known to be either unsupported or behave differently in 4D Write Pro. These are:

SettingDescription
Anchored text areasAnchored text areas are imported as text boxes by default (they can also be ignored or imported as inline text, see WP Import document command option). Only simple text areas can be imported. Inline text areas are imported as anchored in the front layer. Text areas anchored with text around are imported with their text wrapping properties (exception: the .docx wrapping option "tight" is imported as wrap square).
Paragraph layoutOnly Western text layouts are supported. Distributed, Thai and Asian paragraph styles are not supported.
Page SizeDifferent page sizes per section are not supported. Only the page size from the first section is imported.

SettingDescription
WatermarkNot supported

SettingDescription
MS Word equationsNot supported. Data is not imported.
MS Word chartsNot supported. Data is not imported.
Lists  

SettingDescription
Hierarchical listsMulti-level lists are not supported. Multi-level lists are converted to a single level lists so list appearance and/or numbering may be different 

SettingDescription
DrawingML shapes Only simple DrawingML images (inline or anchored) are imported. Complex DrawingML shapes are not supported.
VML shapes or imagesNot supported. VML is obsolete in MS Word and should not be used in documents created with MS Word 2010 or older.
3D modelsNot supported, however the last rendered 2D image of the 3D model may be imported if present in the .docx.
SmartArtNot supported. 

SettingDescription
CommentsNot supported. Content is not imported.
FootnotesNot supported. Content is not imported.
Spacing  

SettingDescription
"At least" line spacingNot supported. "At least" line spacing is converted to fixed (single) line spacing.
Fit textNot supported. The normal 4D Write Pro style is used.
Tables  

SettingDescription
TablesContiguous tables do not merge automatically.
Text  

SettingDescription
ThemesText themes are not imported. If a color or font definition references a color or font in a theme, the last computed color or font will be used. Otherwise, the
color or font defined in the theme is used.

When importing .docx format into 4D Write Pro, a log object is created and included within the imported document object. This object can be retrieved through the "importLog" custom attribute (or wk import log constant):

 $myDoc:=WP Import document("test.docx")
 if($myDoc#Null)
    var $log : Object
    $log:=$myDoc[wk import log]
 End if

 

The import log object contains the following properties:

 

Constant Comment
wk import log

Log object containing information about the .docx import operation. Properties are read-only and cannot be set:

 

Property   Type Description
status   Text Import status:
  • successful - the document is imported into 4D Write Pro 
  • failed - an empty 4D Write Pro document is returned
developer   Collection Collection of message object(s) for 4D Write Pro developers.
  [ ].type Text The kind of message logged:
  • info
  • warning
  • error
  [ ].message Text Message about the import operation.
user   Collection Collection of message object(s) for 4D Write Pro users.
  [ ].type Text The kind of message logged:
  • info
  • warning
  [ ].messageShort Text Brief message about the import operation.
  [ ].messageLong Text Extended message about the import operation.

 

Warning: importLog is a custom attribute, thus the wk import log constant cannot be used by WP SET ATTRIBUTES, WP GET ATTRIBUTES or WP RESET ATTRIBUTES command (for more information, see Using custom attributes).

  

4D Write Pro objects offer two ways to export 4D Write Pro documents in .docx format:

For more information, please refer to the description of these commands.

While the majority of 4D Write Pro settings are preserved, some settings are known to be either unsupported or behave differently in Microsoft Word. These are:

SettingParagraphsSectionsImages
AnchoringIn Microsoft Word, anchored images are positioned relatively to the top left origin of the page and first paragraph. This could result in images being displayed in different locations than desired due to text layout differences between 4D Write Pro and Microsoft Word.
Text boxes anchored to embedded area are not exported. Rendering can be different in Microsoft Word.  
Vertical alignNot supported by Microsoft Word (all items will be top-aligned)Not supported for inline images (all items will be baseline)

SettingParagraphsSectionsImages
Background clippingNot supported by Microsoft Word (background color fills entire paragraph, not including borders and margins)Not supported by Microsoft Word (background clipping will be equal to the padding box)
Background imageNot supported by Microsoft WordDifferent background pictures/colors not supported by Microsoft Word (converted to anchored images or shapes)Microsoft Word allows either a background color or a background image. If a background image is defined, the background color will be "transparent".
Background image repeatHorizontal or vertical tiles are converted to full tiles in Microsoft WordHorizontal or vertical tiles are converted to full tiles in Microsoft
Background originOrigin box is converted to the same value as background clipping box.Not supported by Microsoft.

Borders  

SettingParagraphsSectionsImages
Border colorDifferent border colors for each border line is not supported by Microsoft Word. The first defined 4D Write Pro image border line (in this order: top, right, bottom, left) will be used for all of an image's borders.
Border radius (rounded borders)Not supported by Microsoft Word
Border widthMicrosoft Word maximum is 12pt, borders exceeding this size will be reduced.Microsoft Word maximum is 12pt, borders exceeding this size will be reduced. 

SettingParagraphsSectionsImages
ExpressionsOnly simple 4D expressions such as "Current date" or "Current time", or 4D Write Pro reserved local variables ($wp_title, $wp_pageNumber, etc.) are converted to Microsoft Word fields. Other 4D expressions are computed and converted to text or images during the export process.

 

Lists  

SettingParagraphsSectionsImages
IndentConverted to 0 for list items (list item indent is converted to hanging indent in Microsoft Word)
Ordered list typeGreek, Armenian, and Georgian are converted to decimal and Hiragana is converted to Katakana in Microsoft Word.

SettingParagraphsSectionsImages
SVGNot supported by Microsoft Word (images in SVG format will be converted to PNG format)

Size  

SettingParagraphsSectionsImages
Minimum heightNot supported by Microsoft Word (height is handled automatically)
Width / Minimum widthNot supported by Microsoft Word (paragraph width is handled automatically)

Spacing  

SettingParagraphsSectionsImages
PaddingMicrosoft Word maximum is 31pt, padding exceeding this size will be reduced.Microsoft Word maximum is 31pt, padding exceeding this size will be reduced.

Tables  

FeatureDescription
Bottom carry-over rowNot exported.
Tabs  

SettingParagraphsSectionsImages
Default tab stopNot supported by Microsoft Word (will be converted to absolute tab stops)
Tab leading charactersMicrosoft Word supports "dot" (....), "dash" (----), and "underscore" (____) leading characters, all others will be converted to "none".

Text  

SettingParagraphsSectionsImages
LinethroughLine color different from text color is not supported by Microsoft Word; only solid and double styles are supported
Style SheetsParagraph style sheets are converted to paragraph styles.
Text alignMicrosoft Word compresses spaces, so justified text layout may be reconfigured.Microsoft Word compresses spaces, so justified text layout may be reconfigured.
Text shadow4D Write Pro shadow will be converted to blur and offset, using the default color in Microsoft Word.
UnderlineSemi-transparent underlines will be converted to solid.

 
 



See also 

WP EXPORT DOCUMENT
WP EXPORT VARIABLE

 
PROPERTIES 

Product: 4D
Theme: Importing and Exporting in .docx format

 
PAGE CONTENTS 
 
HISTORY 

Created: 4D v17 R4
Modified: 4D v18 R6
Modified: 4D v19

 
ARTICLE USAGE

4D Write Pro Reference ( 4D v20 R7)