PDF

Create a Word(.docx) template file when outputting PDF files.

 

Formatting of Merge fields

For formatting Date, Date/Time, Currency, and Numeric fields, refer to below.

Formatting of Date and Date/Time Fields

Formatting of Currency and Number Fields

 

 

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

In the Word template file, check off "Snap to grid when document grid is defined". When checked on, the template and PDF will output significantly different line spacing. Normally, the PDF output will be slightly narrower than the line spacing in the Word template.

 

 

Tables

Borders

  • If extra borders are output, 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.
  • If table borders are not output, set the borders again from the Table Properties. On the Word template, the borders of adjacent cells are displayed and the borders of the target cell may not be set.

 

Row Height

If the row height of the table is not output correctly, specify the row height from the Table Properties.

 

Position of text in cell

When setting the vertical position of text in a cell, set the Table Properties and Paragraph.

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

 

Cell Size

From Table Properties>Options in the Table tab, check off "Automatically resize to fit contents".

 

Layout

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.

 

 

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.

 

 

Font

Only the following four PDF fonts can be used for PDF output. If other fonts are used in the Word template file, it will be output in the font set in the "PDF default font" in the OFC_Template record. When using double-byte characters such as Japanese, only Arial Unicode MS fonts can be output.

 

Word Font PDF Font
Arial Arial Unicode MS
Microsoft Sans Serif

Tahoma

Helvetica

Helvetica(sans-serif)
Times New Roman

Times

Century

Times(serif)
Courier New

Courier

Monospace

Courier(Monospace)

 

 

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.

  1. Save the Word template file as a PDF manually.
  2. Open the PDF, enlarge the target text and image to 200-400%, and save the screen capture as an image.
  3. 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.

 

 

Template Sample

 

 

Download Sample Template Files

 

 

Limitations

  • When outputting PDF, the borders of the table may be cut off from the bottom line of the previous page or the first line of the next page at page break.
  • Word field codes are not supported.
  • Blank spaces with tabs in Word are not supported.
  • 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.
  • 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.
  • Arial Unicode MS doesn’t support bold or italic font-weight.
  • External characters are not supported.
  • Watermarks in Word are not supported.
  • 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.

 

 

Reference

Generate a PDF file in Salesforce using Office File Creator

 

 

Troubleshooting

When outputting PDF files, extra borders are displayed.

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.

 

When outputting PDF files, the borders are not displayed.

Set the borders again from the Table Properties. On the Word template, the borders of adjacent cells are displayed and the borders of the target cell may not be set.

 

When outputting PDF files, the borders of the table are cut off at the page break of the child record.

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 OFC side.

In Office File Creator Pro, borders are output without being cut by setting.

PDF Page Break Settings

 

When outputting PDF files, a one-page template is output as two pages.

Reduce the top and bottom margins in the Page Layout.

 

When outputting PDF files, the row height is low.

Specify the row height from the Table Properties.

 

The text position of the cells in the table is set to center alignment, but the PDF is output with bottom alignment.

When setting the vertical position of text in a cell, set the table properties and paragraphs.

  • From Table Properties > Cells tab, set vertical alignment to "Center"
  • From Paragraph > Indents and Spacing tab, set the Line spacing to "Single"

 

The text position of the cells in the table is set to bottom alignment, but the PDF is output with center alignment.

When setting the vertical position of text in a cell, set the table properties and paragraphs.

  • 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

 

When setting merge fields in a table in a Word template, the text in the cell does not wrap and the table stretches horizontally.

From Table Properties>Options in the Table tab, check off "Automatically resize to fit contents".

 

When outputting PDF files, the beginning of characters is aligned by tab spacing in Word, but it is not output at the correct position.

The Word tab spacing is not supported. Create a table with uncolored borders to align the top position.

 

When outputting PDF files, the text is shifted to the left, right, top, and bottom.

Create a table and place the text within the table. Set the layout by dividing cells and showing/hiding table borders.

 

When outputting PDF files, the Watermarks are not output.

Watermarks in Word are not supported.

 

When outputting a PDF file, an image is superimposed over the company name, but the image is out of alignment.

It is not possible to output images 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.

*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 output.

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.

 

When outputting PDF files, shapes are not output.

Objects such as shapes and text boxes are not supported.

 

When outputting PDF files, Text Boxes are not output.

Objects such as shapes and text boxes are not supported.

 

When outputting PDF files, the layout is corrupted.

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.

 

When outputting PDF files, it does not output double-byte characters.

Please make sure that "PDF Includes MultiByte Character" in the template record is set to "Include" and "PDF default font" is set to "Arial Unicode MS". Or, the output characters may be External characters. External characters are not supported.

 

When outputting PDF files, the error message "An internal server error has occurred" is shown.

Plese 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.

 

When outputting PDF files, the error message "common.apex.runtime.impl.ExecutionException: id: xxxxx Invalid integer: 0.99999.." is shown.

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 are not supported.

 

When outputting PDF files, the error message "common.apex.runtime.impl.ExecutionException: id:xxxx Attempt to de-reference a null object: execute=write:curElem=r row=4" is shown.

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