Good news! We’ve just brought the merging functionality, which we recently introduced to the SDK, also to the API. This now allows you to take different sources of HTML and put them together into one big PDF, without having to do any HTML juggling.
The merging functionality is quite useful for a lot of different use cases. Here are some examples of what you could do with it:
- You can take different (generated) pages of your own (or any other) website and put them together into one big PDF for your customer. This can be useful if you want to send a cover letter as well as a specific part of a brochure in one PDF for example
- You can merge different page layouts into one PDF. Normally you can only select one page format & orientation when you create a PDF, but by merging different PDFs you can mix the pages in the final PDF up!
- You now don’t have to worry about fitting your pages anymore. You can just fit any page into one long PDF and then merge the separate PDFs together into one PDF. This prevents content overrunning the page without having to think about CSS page breaking or other tricks you’d normally do.
And of course there are many other use cases where this may be useful.
The merging command is very easy to execute. All you need to do is pass the ‘merge’ parameter that states how many of the last PDFs you want to merge.
So if you’d like to merge the last two PDFs you just created, you’d use the following command:
We can merge PDFs that you have created with the API and/or SDK, but there are a few major limitations:
- The API only merge the PDFs in the order that they were created (unlike the SDK)
- Because of point 1, you can not change any of the options on the resulting merged PDF, except for setting the encryption parameters. So for example, if you’d like a watermark in the merged PDF, you’d have to set it in the original PDFs that you are merging.
- We can only merge the PDFs you created in the last two hours. This is the amount of time we currently cache your PDFs. If you need us to store your PDFs longer, then please contact us.
With this new update to the API we have also introduced some additional parameters. These are footer, header and page offset. They allow you to overwrite the header/footer and page numbering for each PDF that you want to generate, without having to do it in the members area.
Please have a look at the extensive documentation for our HTML to PDF API to learn all about it.