PHP Adapter

Configuration and installation

  1. Download the php_adapter here
  2. Edit the pdfnow.php, insert your API Key and copy the file into your php modules directory
    	define('APIKEY', '123');
  3. Include the pdfnow-library into your php Modules:
    	require_once('pdfnow.php');
  4. Add the generator call into your code
    	generatePdf('uploadedTemplate', array('doc' => array(
    'type' => 'letter',
    'subject' => 'An Order from July 2014',
    'recipient' => array(
    'field1' => 'A. Customer',
    'field2' => 'Destinationstreet 999',
    'field3' => '1000 Destinationcity',
    'field4' => 'SomeCountry'
    ),
    'text' => 'Dear customer,
    thank\'s for your order.


    Greetings from here!


    A. Company'
    );

Usage

The signature of the pdfnow php API:

	generatePdf(  String templateName, Array data ) : String

The templateName references the required template, uploaded by you.

The data XML contains the required data to be inserted into your template. The structure of the data will be defined within the template. The array will be transformed to its corresponding XML String.

The result will be either:

  • the URL of the generated PDF
  • an error message, in this case, the result string starts with „NOK“

Please note: the URL of the generated PDF is valid for a few minutes. If you want make it longer available, you have to copy it on your server.

 

Webservice

In order to use our webservice, you have to be a registered user.

After that press in the navigation the button “User area” and you will see your API-Key. This key is necessary for the php_adapter. There are three other areas:

  • show-templates
  • upload-templates
  • generate-Pdf

First step is to upload a template. It is necessary to give your template a name. This name is used for generating a pdf. The second field is used for uploading your template. Please use either a simple-template (XML-File in the right FO-Format). Alternatively it is possible to upload a zip-archive, which contains a file, that must be named “template.xml”. The zip-archive may include other resource-files, like images as well.

Generating a pdf can be done via php-adapter or in the web-frontend. Here you define your template-name and the xml data for your template. Be sure your xml-data is in the right format and fits to your template. After the generation process it is possible to download the ready produced PDF.

For managing, renaming or deleting a template, the show-templates page is the correct one. All actions are transacted immediatelly.