One-page PDF generation

How to generate one-page PDF on the fly with a template

Updated over a week ago

Catalog Machine provides API to generate one-page PDF on the fly based on prepared templates. You can call PDF generation as a link, using HTML form or call API from other program code.

You can use this API to generate flyers, invoices, product sheets, etc without need to build them manually in a designer. You can switch to advanced API to generate multi-page PDF with JSON.

To use API follow the steps below

  1. Create a new template or use existing with field placeholders (blue border). Copy template id to use it as a key for PDF generation (red border).

 

In addition, Full page templates enable special attributes for designer elements to control PDF page rendering of the large text blocks.

  • Fixed attribute marks header or footer elements that will be repeated on every page if the page content expands to the new page.

  • Expandable attribute marks text elements that can flow to the next page. This text will fill space between fixed elements on the new page.

 

2. Build a link for pdf generation:

Format:


http://www.catalogmachine.com/public/api/1/pdf?templateid={Template ID}&{Field1}={Field1 Value}&{Field2}={Field2 Value}&{Image Field1}=image:{Local Image Path}

Example:


http://www.catalogmachine.com/public/api/1/pdf?templateid=5a65a225-0659-48cf-a2bf-e8f4f110196c&Name=Test&Price=$100&Description=My%20Description&Image=image:Sample/4FRNTEHPSki.jpg

Images should refer to local path that you can copy from image preview and prefix image:should be added before.

3. HTML Forms and direct program access using HTTP request to API

Format

 http://www.catalogmachine.com/public/api/1/pdf?templateid={Template ID}

Advanced users can build an HTML form on their site that make a GET or POST request to the link above to download PDF.

Another approach is to use any programming library on any platform to submit request and receive PDF as a binary stream.

Note: Daily quote of API calls depends on plan limits.

Did this answer your question?