This article will show you tips for creating Word templates for PDF output in Office File Creator.
Output Page Number/Page Count
Use the following merge fields in the footer or header for page numbers and total number of pages. Word field codes are not supported.
Page Number・・・{!pagenumber()}
Page Count・・・{!pagecount()}
Line Spacing
Uncheck "Snap to grid when document grid is defined" in the Word template file. When checked, the line spacing is quite wide in the output. When unchecked, the PDF output will be slightly narrower than the line spacing in the Word template.
- Select all existing contents in the template with "Ctrl+A" and uncheck from the paragraph.
- Uncheck from the paragraph of the used style, such as standard style.
Text position in table (centered/justified)
When setting the vertical position of text in a cell, set the Table Properties and Paragraph. If only table properties are set, the output may not be output at the intended position.
Align text in cells to the center (vertical)
- From Table Properties > Cells tab, set vertical alignment to "Center"
- From Paragraph > Indents and Spacing tab, set the Line spacing to "Single"
Align text in cells to the bottom
- From Table Properties > Cells tab, set the Vertical alignment to "Bottom"
- From Paragraph > Indents and Spacing tab, set the Line spacing to "Exactly" and adjust the "At" values
Setting Merge Fields in Tables
From Table Properties>Options in the Table tab, check off "Automatically resize to fit contents".
"Automatically resize to fit contents" is checked
The merge fields extend horizontally and the correct column widths are not displayed.
"Automatically resize to fit contents" is unchecked
The correct column widths are displayed.
Different layouts on the left and right sides
For different layouts on the left and right sides, create a single table and set it up by dividing cells and displaying/hiding table borders. Tables cannot be aligned left to right, nor can text be displayed next to a table.
Layout example (cell division, borders display/non-display)
Output
Striped Layout
To stripe a table of child objects, enter two child object rows. For example, if the first line has a blue background and the second line has a white background, odd-numbered lines are output with a blue background and even-numbered lines with a white background. Alternatively, set the format from the table design.
Images (company logo, seal, etc.)
Template files can include images such as company logos. Considerations for images are below.
Objects not supported
Objects such as shapes and text boxes are not supported. Objects may not be output, the background color may not be output correctly, or output may take a long time. Right-click on the object and select "Save as Picture" to save it as an image and replace the object with an image.
Image over text not supported
It is not possible to output an image over text. Follow the steps below to set the text + image capture image to the template.
- Save the Word template file as a PDF manually.
- Open the PDF, enlarge the target text and image to 200-400%, and save the screen capture as an image.
- Insert the image into the template.
*When taking a screen capture, enlarge the text and image because they are blurred at full size. However, if the image size is too large, an output error will occur. Adjust the magnification ratio accordingly.
Troubleshooting
Too much space between lines in PDF.
Uncheck "Snap to grid when document grid is defined" in the Word template file. When checked, the line spacing is quite wide in the output. When unchecked, the PDF output will be slightly narrower than the line spacing in the Word template.
A one-page template is output as a two-page PDF.
Uncheck "Snap to grid when document grid is defined" in the Word template file. When checked, the line spacing is quite wide in the output. When unchecked, the PDF output will be slightly narrower than the line spacing in the Word template.
The layout is corrupted in PDF.
The pattern may not be supported for PDF output. Check the following.
- Blank spaces with tabs in Word are not supported.
- Tables cannot be aligned left to right, nor can text be displayed next to a table. For different layouts on the left and right sides, create a single table and set it up by dividing cells and displaying/hiding table borders.
- Tables copied and pasted from other applications may have a corrupted layout when output. If the copied layout is corrupted, create a new table in the template file.
- Objects such as shapes and text boxes are not supported.
- Images cannot be output over text. Save the Word template file as a PDF manually, then enlarge the target text and image to 200-400% and save a screen capture. Set the image to the template.
Extra borders of the table are displayed in PDF.
Set the color of the corresponding borders to white. In the application, HTML is converted to PDF using the PDF generation function of Visualforce in Salesforce, and although it is displayed correctly on HTML, it may not be as expected when converted to PDF in Visualforce. This is due to the specification of Visualforce, so it cannot be supported.
The borders of the table are broken at page breaks in PDF.
This is a specification. PDF is output by the PDF generation function of Visualforce of Salesforce, and the page break position is automatically judged by the function of Visualforce.
When automatic judgment is made, the borders output of the table between page breaks cannot be adjusted on the application side.
In Office File Creator Pro, borders are output without being cut by setting.
The row height of the table is low in PDF.
Set the table properties in the template.
- Specify the row height from the Table Properties in the Word template. If the line height is not specified, the output may be at a significantly different height.
- Increase the row height values from the table properties. Since the template and actual output will not be exactly the same, check the output results and adjust the values.
- If a cell is a blank row and is not changed by the row height of the table property, enter a line break.
The text in the table is not centered (vertically) and is bottom-aligned in PDF.
Set the table properties and paragraphs in the template.
- From Table Properties > Cells tab, set vertical alignment to "Center"
- From Paragraph > Indents and Spacing tab, set the Line spacing to "Single"
The text in the table is not bottom-aligned and is centered (vertically) in PDF.
Set the table properties and paragraphs in the template.
- From Table Properties > Cells tab, set the Vertical alignment to "Bottom"
- From Paragraph > Indents and Spacing tab, set the Line spacing to "Exactly" and adjust the "At" values
Merge fields in the table are not wrapped and the columns extend horizontally.
From Table Properties>Options in the Table tab, check off "Automatically resize to fit contents".
The text overlaps the borders in the table below in PDF.
From Paragraph > Indents and Spacing tab, set the Line spacing to "Single".
The text is misaligned in PDF
The pattern may not be supported for PDF output. Check the following.
- Blank spaces with tabs in Word are not supported. To set the starting position of the text, place the text in a table and hide the table borders.
- Tables cannot be aligned left to right, nor can text be displayed next to a table. For different layouts on the left and right sides, create a single table and set it up by dividing cells and displaying/hiding table borders.
- Tables copied and pasted from other applications may have a corrupted layout when output. If the copied layout is corrupted, create a new table in the template file.
- Objects such as shapes and text boxes are not supported.
- Images cannot be output over text. Save the Word template file as a PDF manually, then enlarge the target text and image to 200-400% and save a screen capture. Set the image to the template.
The image seal overlaid on the text is outputted out of alignment in PDF.
It is not possible to output an image over text. Follow the steps below to set the text + image capture image to the template.
- Save the Word template file as a PDF manually.
- Open the PDF, enlarge the target text and image to 200-400%, and save the screen capture as an image.
- Insert the image into the template.
*When taking a screen capture, enlarge the text and image because they are blurred at full size. However, if the image size is too large, an output error will occur. Adjust the magnification ratio accordingly.
The company logo image is not output in PDF.
It may be an object instead of an image. Objects such as shapes and text boxes are not supported. Right-click on the object and select "Save as Picture" to save it as an image and replace the object with an image.
Text Boxes and Shapes are not output in PDF.
Objects such as shapes and text boxes are not supported in PDF.
Watermarks are not output in PDF.
Watermarks in the Word template are not supported in PDF.
Double-byte characters are not output in PDF.
Check "PDF Includes MultiByte Character" and "PDF default font" fields in the OFC_Template record. To output Double-byte characters, "PDF Includes MultiByte Character" field should be set "Include" and "PDF default font" should be set "Arial Unicode MS". Or, the output characters may be External characters. External characters are not supported.
"An internal server error has occurred" is displayed.
Check the error message on the preview screen by clicking the "Preview PDF" button on the OFC_Template record page. More detailed error messages will be displayed in the preview.
In Ver.2, when a PDF error occurs, the error message "An internal server error has occurred" is not displayed. The details of the error will be displayed without the preview, so please consider using Ver.2.
"common.apex.runtime.impl.ExecutionException: id:xxxx Attempt to de-reference a null object: execute=write:curElem=r row=4" is displayed.
There may be a template file pattern that is not supported by Office File Creator. The following are possible ways to deal with this issue.
Change text font to "standard"
Change complex parts of the layout to simple ones
Delete shapes
"common.apex.runtime.impl.ExecutionException: id: xxxxx Invalid integer: 0.99999.." is displayed.
The template file may have been created outside of the Microsoft Office desktop version. Create a template file in Microsoft Office Desktop Edition. Template files created by other applications, such as Google Docs, are not supported.
Reference