PDF Writer Custom Tags

From SmartWiki
Revision as of 12:35, 23 January 2018 by Mark Bridger (talk | contribs) (Examples)

Jump to: navigation, search

The following custom tags can be included in Web Page Views to manipulate the output when converting to PDF:

List of Custom Tags (pd4ml)

  • style="pd4ml-display:none" or style="pd4ml-display:block": Controls whether a HTML element will be included or not included in the PDF.
  • style="PAGE-BREAK-inside: avoid": Prevents an HTML element from being broken by a page break. Note: If the element is more than a page in length this setting cannot be applied and will be ignored.
  • <pd4ml:page.break>: inserts a page break at this location. We recommend using the SmartFields PDF formatting setting for inserting page breaks between custom fields.
Options:
  • ifSpaceBelowLessThan= pixels: allows to suppress the page break if the available space on the current page is more than the specified value.
  • htmlWidth=pixels: forces PD4ML to change current htmlWidth (screenWidth) value and to affect HTML-to-PDF scaling factor. “reset” returns htmlWidth to the initial state.
  • htmlWidth="reset"
  • pageFormat="rotate"
  • pageFormat="WxH"
  • pageFormat="reset"
  • next="even - odd"
  • pageCounter=pagenum


  • <pd4ml:page.header> </pd4ml:page.header>: Content between tags will be used as the page header.
Options:
  • scope="scope": explicitly defines pages where the header should appear. Example: scope="odd,5,15-25,45+,skiplast"
  • height="height"
  • width="width"
  • style="associated style info"
  • $[page], $[total] and $[title]: inserts current page number, total number of pages, and document title (respectively)


  • <pd4ml:page.footer> first page footer. page $[page] of $[total]</pd4ml:page.footer>: Content between tags will be used as the page footer (see Example below). Affects all subsequent pages (unless Scope option is defined)
Options: same as pd4ml:page.header tag.


  • <pd4ml:toc>: table of contents.
Options:
  • pncorr="number": a correction value to add to page numbers


  • <pd4ml:page.break/>: insert this for a PDF page break.

Page Format

To generate PDFs in a specific format within the body of the Web Page View, add the appropriate tag below:

  • <!--Use Landscape--> - will set the HTML width based on the paper type.
  • <!--Use Letter--> - will set the page width to 971.
  • <!--Use Legal--> - will set the page width to 1235.

Table Size

Recommended table sizes are as follows:

  • Letter 700 pixels wide
  • Letter (landscape) 950 pixels wide

Special Characters

Most western Latin Unicode characters will be displayed normally. If your PDF will contain non-Latin characters such as Japanese, Korean or Greek, then the PDF writer must be told to use TTF (True Type Font) and the font should be specified.

  • <!--Use TTF-->

See here for more information

Specify PDF File Name

If the syntax <!--filename='WPF - filename'--> is included in the HTML Template, when saved as a PDF, the PDF filename will default to 'WPF - filename.pdf'.
Variables such as @name@ can be used (ex. <!--filename='WPF - @name@'-->) to dynamically set the resultant PDF filename.

Sample HTML Template

<html>
<head>
<style type="text/css">
<!--
body {font-family: Arial, Times New Roman;}
.overflow {width: 700px; word-wrap: break-word;}
.white {color: #ffffff;}
.spacer {font-family: Arial, Helvetica, sans-serif;	font-size: 10px; color: #FFF;}
-->
</style>
</head>
<body bgcolor="#FFFFFF" topmargin="25" bottommargin="25" leftmargin="30" rightmargin="30">
<!--Use Letter--><!--Use TTF--><!--filename='WPF - filename'-->
<!--START: Header and Footer when converted to PDF-->
<pd4ml:page.header>
<table width="700px" border="0" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><div class="overflow"><strong>@type@ - @year(fullstartdate)@</strong></div></td>
</tr>
</table>
</pd4ml:page.header>
<pd4ml:page.footer>
<div style="pd4ml-display:block;display:none;margin-top: 30px;margin-left:30px;margin-right:30px;margin-bottom:30px">
<table width="700px" align="center">
<tr>
<td style="text-align:right">page $[page] of $[total]</td>
</tr>
</table>
</div>
</pd4ml:page.footer>
<!--END Header and Footer for PDF-->
<pd4ml>
<table width="700" border="0" cellspacing="0" cellpadding="0" align="center" style="PAGE-BREAK-inside: avoid;">
<tr>
<td valign="top"><div class="overflow">Page 1 text goes here</div></td>
</tr>
</table>
<div class="spacer">.</div>
<pd4ml:page.break/>
<table width="700" border="0" cellspacing="0" cellpadding="0" align="center" style="PAGE-BREAK-inside: avoid;">
<tr>
<td valign="top"><div class="overflow">Page 2 text goes here</div></td>
</tr>
</table>
</pd4ml>
</body>
</html>

See Also