Rendering

8 articles

How to create a PDF from my HTML and CSS Code?

In this article, we describe how to create a PDF from your HTML and CSS code. To create a PDF from your HTML, you need to pass both HTML and CSS code in a JSON structure as the body of the POST request to our API. The JSON structure you need to send should look like the following: { "html": "", "...

How do I change the rendering tool for my request?

The PrintCSS Cloud API offers the three rendering tools WeasyPrint (default), PagedJS, and Vivliostyle. If you want to change the rendering tool for your REST request, all you need to do is provide the renderer's name within the options section of the requests JSON. { "html": "<h1>Hello PrintCSS Cl...

Can I use JavaScript within my Code?

PagedJS and Vivliostyle both handle JavaScript just like your browser would do. Why? Because they also use a headless Chromium in the background but have a layer on top to support the modern CSS Paged Media features.To send JavaScript, either you directly put it in a SCRIPT tag within your HTML or a...

Can I influence the version of the rendering tool?

No. You will always get the latest stable version of the rendering tool you choose in your API request.

How do I include Images and other Assets in my PDF?

There are two ways to include your images in the PDF either you have the images available via a public URL or provide a base64 encoded ZIP file within the requests body. The ZIP file is the preferred way as you do not need to provide your assets elsewhere. We support the following filetypes for imag...

Is there the possibility to add dynamic content?

Yes! We support the templating engine Twig for your HTML content. So you can add some dynamic content like the date and time of the PDF rendering or reformat some content, for example, to uppercase. For the full details of Twig's possibilities, please check their documentation.See a small example of...

I want to render the same HTML and CSS with different data. Can I do that?

Yes! We support that via the templating engine Twig and an additional data key within the requests body JSON. That data key needs to contain an array of your data objects. If you have only one data object, it still needs to be in an array. Widespread examples for such data-driven PDF exports are bil...

Can I make an asynchronous request?

Yes, asynchronous requests are straightforward! All you need to do is set sync to false in the requests body JSON. Here is an example of how you can do this: { "css": "body{ color:red; }", "html": "Hello PrintCSS Cloud", "options": { "sync": "false" } } To send the request to our API now, ...