Documentation/Device setup

For administrators

PDF forms

Configure pdf_forms.xml and HTML templates with a ready-to-use order example.

A PDF form is an HTML template into which the application inserts document data. The PDF is generated on the Android device and can be opened for preview or shared through another application.

Data is inserted using Chunk Templates. Its separate guide covers fields, filters, conditions, loops and calculations.

Ready-to-use example

For an order, use the PDF form example archive. It contains:

FilePurpose
pdf_forms.xmlPDF form list with an Order form.
order_summary_en.htmlHTML order template with products, discounts and totals.
exchange-profile.xmlProfile to add to your exchange.xml.
README.txtBrief installation steps.

The downloaded HTML file is a template: tags are replaced with values when the application generates the PDF.

Form list — pdf_forms.xml

<?xml version="1.0" encoding="utf-8"?>
<pdf-forms>
  <document name="order">
    <forms>
      <form lang="en">
        <presentation>Order</presentation>
        <file>order_summary_en.html</file>
      </form>
    </forms>
  </document>
</pdf-forms>
Element or attributePurpose
<document name="…">Document for which the form is available: order for an order, invoice for a payment, storecheck for a store-check.
<forms>Form list for this document.
<form>One form.
langApplication interface language code: en for English, uk for Ukrainian. Optional.
<presentation>Form name shown to the user when choosing a form.
<file>Exact HTML file name, including its extension.

For multiple forms, add separate <form> entries inside <forms>. The pdf_forms.xml file defines the complete PDF form list: the example above leaves only one order form. To retain other forms, add their entries to the same file and transfer their templates.

The application first selects forms whose lang matches the current interface language. If there are none, it selects forms without lang. If neither is available, it shows all forms for the document. A single available form is used immediately; otherwise the application offers a choice.

HTML template

Save the HTML template in UTF-8. Keep styles inside the file, and place the template alongside pdf_forms.xml on the device. In <file>, use a file name without a directory path.

Use tags to insert values:

<h1>Order No. {$doc.number|html}</h1>
<p>Date: {$doc.date_localized|html}</p>
<p>Customer: {$doc.customer_name|html}</p>

For an order, the following data groups are available:

GroupExamples
doc{$doc.number}, {$doc.date_localized}, {$doc.customer_name}, {$doc.sum}, {$doc.discount}.
doc.customerCustomer reference fields, such as {$doc.customer.code} or a custom address field.
weBusiness details: {$we.company}, {$we.address}, {$we.registration}, {$we.billing}, {$we.comment}.
tableDocument lines, accessed in a loop.
row.productProduct reference fields for the current line, such as {$row.product.measure_unit}.

Field names must match the document schema and reference data. For example, a custom customer address is available only if that field exists in the downloaded customer reference.

Document lines

<table>
  <thead>
    <tr>
      <th>Product</th>
      <th>Quantity</th>
      <th>Conversion factor</th>
      <th>Price</th>
      <th>Amount</th>
    </tr>
  </thead>
  <tbody>
    {% loop in $table as $row %}
    <tr>
      <td>{$row.name|html}</td>
      <td>{$row.count|number}</td>
      <td>{$row.koef|number}</td>
      <td>{$row.price|decimal}</td>
      <td>{$row.sum|decimal}</td>
    </tr>
    {% onEmpty %}
    <tr>
      <td colspan="5">There are no products in this order</td>
    </tr>
    {% endloop %}
  </tbody>
</table>

count is the entered quantity, koef is the number of base units in the entered unit, and price is the price per base unit. For example, two packs of six units are represented as count=2 and koef=6.

Here, html prepares text for HTML, number formats quantities without unnecessary trailing zeros, and decimal formats amounts with two decimal places. See Template language — Chunk for these filters, checks for empty business details and line numbering.

Transferring and checking

  1. Extract the example archive.

  2. Place pdf_forms.xml and order_summary_en.html directly in the device's outbox. If you use other forms, first combine their entries in pdf_forms.xml.

  3. Add the contents of exchange-profile.xml inside <palm-client> in your exchange.xml:

    <exchange name="pdf_forms" view="Download PDF forms">
      <get>
        <files>
          <file name="pdf_forms" files="pdf_forms.xml"/>
          <file name="order_summary_pdf" files="order_summary_en.html"/>
        </files>
      </get>
    </exchange>
    
  4. On the device, run Download exchange file, then Download PDF forms. Check the exchange log.

  5. Fill in business details, open an order with products and choose Preview in the document menu.

  6. Check fields, quantities, prices, discounts and totals. Also check a document with long names and many lines to assess pagination.

  7. Choose Share and check sending the PDF through the required application.

The PDF contains the open document's values at the time it is generated. Generate the file again after editing the document.

If PDF generation fails

SymptomWhat to check
Preview and Share are unavailableReceipt of pdf_forms.xml, valid XML and forms for this document.
The required form is missing from the listThe document's name, <form> entries and selection rules for lang.
Form preparation error or empty contentWhether the HTML file was downloaded, its name matches <file> and it has the .html extension.
Fields are empty or {$…} tags remainTag names, open document data, business details and downloaded reference fields; defaults or conditions for optional fields.
PDF was created but does not openA PDF viewer application on the device.
Incorrect quantity precisionThe number filter or the appropriate column settings if an _display tag is used.