PDF editing with the Online-Convert.com API –it can do more than “just” convert!
With our API you can easily edit PDFs with regard to various sizes. File size can be changed just as well as the paper size of a PDF document. In this article, we will show you how you can do so using an API execution app named postman. The functions we will look at are the following:
- Compress PDF: Change the file size of a PDF
- Resize PDF: Change the paper size of a PDF
If you are interested in other PDF editing tutorials with our API, check out the list at the end of this article.
Resize & Compress PDFs With Our API
The basis to this tutorial is a general knowledge of postman and access to our Online-Convert.com API. If you are not familiar with the app or can’t access our API, check out this tutorial on how to use the Online-Convert.com API with postman. The tutorial provides a step-by-step guide on how to set up postman using our collection file, which is of course linked.
If you prefer video tutorials, check out how to use the online-convert.com API on YouTube.
After you are familiar with the basics, we can dive into the topic of changing file and paper sizes of PDF documents. The following command is essential for the editing. This simple POST command converts a remote file, here a PDF document, into another PDF file.
{ "input": [{ "type": "remote", "source": "https://cdn.online-convert.com/example-file/document/pdf/example.pdf" }], "conversion": [{ "target": "pdf", "category": "document" }] }
To add the editing function to the command above, the following addition will be needed:
"options": { }
Compress PDF Documents
PDF compression and thus reduction or changing of the file size is done by adjusting the quality settings of a PDF document. Thus, the following schema that is used by postman to apply the changes to an uploaded document is named “quality” instead of “compression”:
"quality": { "type": "string", "description": "Optimizes the output for a specific target which will produce different output file sizes. It may override other quality options.", "enum": [ "screen", "ebook", "default", "printer", "prepress" ] }
For changes in a PDF’s quality – and thus it’s file size – there are several presets available. The value of the “quality” option has therefore to be a string containing one of the presets. Lets have a look at what these presets do (ignoring the “default” string for now):
- Screen: screen quality, 72 dpi images
- eBook: low quality, 150 dpi images
- Printer: high quality, 300 dpi images
- Prepress: high quality, color preserving, 300 dpi images
A full command to compress a PDF file should look like this:
{ "input": [{ "type": "remote", "source": "https://cdn.online-convert.com/example-file/document/pdf/example_multipage.pdf" }], "conversion": [{ "target": "pdf", "category": "document", "options": { "quality": "ebook" } }] }
With this API call, the quality of the converted file will adapt the preset of ebook. In our example, this reduced the file size of the PDF from 1.04 MB to 247 KB.
Change a PDFs Paper Size
In order to change the paper size of a PDF, the following scheme is used:
"page_size": { "type": "string", "description": "The size of the pages", "enum": [ "a0", "a1", "a2", "a3", "a4", "a4small", "a5", "a6", "a7", "a8", "a9", "a10", "isob0", "isob1", "isob2", "isob3", "isob4", "isob5", "isob6", "c0", "c1", "c2", "c3", "c4", "c5", "c6", "11x17", "ledger", "legal", "letter", "lettersmall", "archA", "archB", "archC", "archD", "archE", "jisb0", "jisb1", "jisb2", "jisb3", "jisb4", "jisb5", "jisb6", "b0", "b1", "b2", "b3", "b4", "b5", "flsa", "flse", "halfletter", "hagaki" ] }
The page size option takes a string of characters as a value. The possible strings are listed above and represent common paper sizes. Since some of the labels may be confusing, here’s a full list ordered by the standard:
- ISO A: A0, A1, A2, A3, A4, A4 small, A5, A6, A7, A8, A9, A10
- ISO B: B0, B1, B2, B3, B4, B5, B6
- ISO C: C0, C1, C2, C3, C4, C5, C6
- JIS B: B0, B1, B2, B3, B4, B5, B6
- ARCH: ArchA, ArchB, ArchC, ArchD, ArchE
- Other: Ledger, Legal, Letter, Half Letter, Letter Small, Hagaki, FLSA, FLSE, 11×17
A complete POST command to change the paper size of a PDF should thus look like this:
{ "input": [{ "type": "remote", "source": "https://cdn.online-convert.com/example-file/document/pdf/example_multipage.pdf" }], "conversion": [{ "target": "pdf", "category": "document", "options": { "page_size": "a2" } }] }
This call increases the paper size from our regular, A4 PDF to a page size of A2.
Got any questions?
If you still have questions about how to use Online-Convert.com’s API to edit your PDFs, drop us a message. A friendly and competent support team will make sure that you will be able to do your conversions just like you wanted to.
Further Information
Follow us