Resize & Compress PDF – PDF Editing Via API

API
Image by http://bit.ly/2ejxaXS

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 basis, 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": "http://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": "http://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 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, Leter 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": "http://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

Sort, Delete & Rotate PDF Pages Via API

API
Image by http://bit.ly/2ejxaXS

Not only for developers: edit PDF files using the Online-Convert.com API.

Our API is versatile and reliable when it comes to file conversion, but there is so much more. Using the API, you can split & merge PDF documents as well as add password protection to a PDF. And yes, there is still more. In this article we’ll have a look at how you can edit a PDF document even further:

  • Delete single PDF pages
  • Rotate PDF pages
  • Sort a PDF’s pages

 

Edit PDF Pages Via API

Before you can start editing your PDF using the Online-Convert.com API, however, you need to be familiar with the basics. We have provided a tutorial on how to use the Online-Convert.com API using postman you can check out. There you will find an introduction to postman as well as a collection file you will need.

A video tutorial on how to use the online-convert.com API is also available.

 

If you have understood the basics, you can start editing your PDF with our API. Following, we will provide you with all necessary commands for postman in order to edit your PDF.

The basic command for a simple PDF to PDF conversion we’ll use is the following:

{
    "input": [{
         "type": "remote",
         "source": "http://cdn.online-convert.com/example-file/document/pdf/example.pdf"
     }],
     "conversion": [{
     "target": "pdf",
     "category": "document"
     }]
 }

This POST command will convert the remote example file into another PDF. With the addition of the following command, we can add the options for deleting, rotating or sorting the pages of a PDF:

"options": {
}

 

Rotate Pages Of A PDF

To rotate one or more pages of a PDF document, a command following this scheme has to be used:

"rotate": {
    "type": "array",
    "additionalProperties": false,
    "pages": {
        "type": "string",
        "pattern": "^(((\\d+|first)-?(\\d*|last))|(first)|(last)|(even)|(odd))(, ?(((\\d+|first)-?(\\d*|last))|(first)|(last)|(even)|(odd)))*$",
        "description": "The page numbers to be rotated. E.g. 5-8 or 5- or 5. It also accepts \"first\" and \"last\" aliases.",
        "default": "1-last"
    },
    "angle": {
        "type": "integer",
        "description": "The angle by which to rotate the pages",
        "enum": [
            0,
            90,
            180,
            270
        ],
        "required": true
    }
}

The rotate function needs, as an input, an array of values for “pages” and “angle”. The value for “angle” should be an integer of the list given below. The numbers given their define the degree of rotation (clockwise).

While the latter is quite easily explained, the values for pages require some additional explanation. The value is given in the form of numbers that indicate which pages should be rotated.

  • Single pages can be listed with a comma in between (e.g. 3,5,6)
  • A span of pages can be indicated by giving the first and last page separated by a hyphen (e.g. 3-6)
  • The last pages of a document can be rotated by giving the first page that should be rotated and a hyphen. (e.g. 3-)
  • One can also specify to rotate the first or last page (input first or last), or all even or odd numbered pages (input even or odd)

 

A complete command should look like the following example:

{
    "input": [{
        "type": "remote",
        "source": "http://cdn.online-convert.com/example-file/document/pdf/example_multipage.pdf"
    }],
    "conversion": [{
        "target": "pdf",
        "category": "document",
        "options": {
            "rotate": [{
                "pages": "3,5-",
                "angle": 180
            }]
        }
    }]
}

This API call creates a PDF file where the 3rd page as well as the 5th and all following pages are rotated by 180°.

 

Of course you could use several arrays for “rotate” in one call to rotate different pages by different degrees. A call for this could look like this:

{
    "input": [{
        "type": "remote",
        "source": "http://cdn.online-convert.com/example-file/document/pdf/example_multipage.pdf"
    }],
    "conversion": [{
        "target": "pdf",
        "category": "document",
        "options": {
            "rotate": [{
                "pages": "odd",
                "angle": 180
            }],
            "rotate": [{
                "pages": "even",
                "angle": 90
            }]
        }
    }]
}

With this call, all odd numbered pages of the PDF will be rotated by 180°, while all even numbered pages are rotated by 90°.

 

Sort The Pages Of A PDF

The pages of a PDF can easily be rearranged or sorted using the following scheme:

"rearrange": {
    "type": "string",
    "pattern": "^(((\\d+|first)-?(\\d*|last))|(first)|(last)|(even)|(odd))(, ?(((\\d+|first)-?(\\d*|last))|(first)|(last)|(even)|(odd)))*$",
    "description": "The page numbers that should be present in the converted file, in the desired order. This is also used to delete pages or extract a set of pages."
}

The “rearrange” option takes a string as an input which should consist of the page number in the order in which they should be sorted in the output PDF. This string can contain the following values:

  • The page numbers in the order in which the pages should appear, separated by comma (e.g. 2,3,4,1,5,6,7)

The other values mentioned in the scheme above will be ignored for now.

 

The following shows a complete POST command for rearranging PDF pages:

{
    "input": [{
        "type": "remote",
        "source": "http://cdn.online-convert.com/example-file/document/pdf/example_multipage.pdf"
    }],
    "conversion": [{
        "target": "pdf",
        "category": "document",
        "options": {
            "rearrange": "2,3,4,1,5,6,7"
        }
    }]
}

Basically, this call moves the first page of our document in between pages 4 and 5.

 

Delete Single Pages Of A PDF

Deleting certain pages in a PDF is easy and uses the exact same command as the rearrange function.

"rearrange": {
    "type": "string",
    "pattern": "^(((\\d+|first)-?(\\d*|last))|(first)|(last)|(even)|(odd))(, ?(((\\d+|first)-?(\\d*|last))|(first)|(last)|(even)|(odd)))*$",
    "description": "The page numbers that should be present in the converted file, in the desired order. This is also used to delete pages or extract a set of pages."
}

 

Again, you can specify a string of numbers, however they will serve an additional purpose other than rearranging the pages: all page numbers left out will be deleted from the resulting document.

Furthermore, you can use the following strings:

  • First: deletes all pages but the first page of the document
  • Last: deletes all pages but the last page of the document
  • Odd: will preserve all odd numbered pages
  • Even: will preserve all even numbered pages

 

With this in mind, a complete API call for the deletion of certain pages in a PDF could look like this:

{
    "input": [{
        "type": "remote",
        "source": "http://cdn.online-convert.com/example-file/document/pdf/example_multipage.pdf"
    }],
    "conversion": [{
        "target": "pdf",
        "category": "document",
        "options": {
            "rearrange": "1,2,3,5,7"
        }
    }]
}

The PDF created using this call will only contain the odd pages and page number 2 of the original document.

 

Sort & Delete PDF Pages In One Step

Due to the nature of the rearrange function, incorporating the delete function, it’s easy to sort and delete pages in a PDF with just one command. Take the following example:

{
    "input": [{
        "type": "remote",
        "source": "http://cdn.online-convert.com/example-file/document/pdf/example_multipage.pdf"
    }],
    "conversion": [{
        "target": "pdf",
        "category": "document",
        "options": {
            "rearrange": "7,6,5,4,1"
        }
    }]
}

The API call above will sort the pages of the PDF according to the array of numbers, as well as delete the missing pages (3 and 2).

 

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

Password Protect A PDF Via API

API
Image by http://bit.ly/2ejxaXS

More PDF editing with the Online-Convert.com API!

We have already explored the topic of PDF editing with our API when we showed you how to split & merge PDF documents. In this article, we will have a look at how to protect your PDF files from copying, editing and being printed and distributed. How? By adding password protection to your PDF.

 

How To Use Our API To Edit PDFs

Before we dive into the process of adding password protection to a PDF, you’ll need to learn the basics of using the Online-Convert.com with the help of an API execution app. This API tutorial contains a basic introduction to postman and a link to the necessary collection file.

Of course you can also check out our video tutorial on how to use the online-convert.com API.

 

Now that we have covered the basics, lets have a look at how to protect your PDF to prevent people from viewing it without the password. You can furthermore specify what “users” of the PDF will be allowed to do once they entered the password.

The following command will be the basic command we’ll use.

{
    "input": [{
         "type": "remote",
         "source": "http://cdn.online-convert.com/example-file/document/pdf/example.pdf"
     }],
     "conversion": [{
     "target": "pdf",
     "category": "document"
     }]
 }

This POST command will convert an example PDF into another PDF file. The following command will be added to enable the usage of different options, in our case the PDF protection:

"options": {
}

 

Add Password Protection To A PDF

In order to add password protection to a PDF file, you have to add the following options to your POST command:

"new_owner_password": {
    "type": "string",
    "pattern": "^[\\w\\W]{0,64}$",
    "description": "Adds or change the owner's password (up to 64 characters)"
},
"new_user_password": {
    "type": "string",
    "pattern": "^[\\w\\W]{0,64}$",
    "description": "Adds or change the user's password (up to 64 characters)"
},
"allow_printing": {
    "type": "boolean",
    "description": "Allows the printing of the document"
},
"allow_copying": {
    "type": "boolean",
    "description": "Allows the copying of the document"
},
"allow_modification": {
    "type": "boolean",
    "description": "Allows the modification of the document"
}

The new owner and user passwords can contain strings of characters made up from letters, numbers and special characters. The individual strings can be up to 64 characters long.

The permissions include permission to print, copy or modify the resulting PDF document. The value for these settings can either be true or false.

 

Following this scheme, a full POST command to add password protection to your PDF should look like this:

{
    "input": [{
        "type": "remote",
        "source": "http://cdn.online-convert.com/example-file/document/pdf/example.pdf"
    }],
    "conversion": [{
    "target": "pdf",
    "category": "document",
    "options": {
        "new_owner_password": "owner",
        "new_user_password": "user",
        "allow_printing": false,
        "allow_copying": false,
        "allow_modification": false
    }
    }]
}

With this call, you are disabling a user of your PDF from printing, copying and modifying. The password for this user is user. When you enter the owner password owner, however, you can do everything you did not allow for a user.

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

Split & Merge PDF – How To Edit PDF Files Via API

API
Image by http://bit.ly/2ejxaXS

Converting from and to PDF is nice, but you want more?

With the API of Online-Convert.com you can now edit PDF documents! Using Postman and our API you can now merge or split PDF files. You don’t have to be a developer for this either. Check out our tutorial on how to use Postman to test our API and start editing!

In this blog article, we will show you how to perform these three easy operations on a PDF document:

  • Merge two or more PDFs into one
  • Split a PDF to create several PDFs

 

How To Edit PDFs Via API

In order to perform these editing functions, you should be familiar with postman and have access to the Online-Convert.com API. This article will show you how to do this, including a link to the necessary collection file.

Of course you can also check out our video tutorial on how to use the Online-Convert.com API.

 

Once you got the basics down, we can have a look at how to edit PDFs using the API. Following, we will talk about both functions mentioned above in detail.

In order to do so, we always need a “default” command we will send to the API:

{
    "input": [{
         "type": "remote",
         "source": "http://cdn.online-convert.com/example-file/document/pdf/example.pdf"
     }],
     "conversion": [{
     "target": "pdf",
     "category": "document"
     }]
 }

This simple POST command will convert our example PDF file into another PDF. Now we can add options using the following command:

"options": {
}

 

Merge PDF Files

In order to merge PDF files you, obviously, need several files as input. In order to do so, you need a POST command like the following:

{
    "input": [{
        "type": "remote",
        "source": "http://cdn.online-convert.com/example-file/document/pdf/example.pdf"
    },
    {
        "type": "remote",
        "source": "http://cdn.online-convert.com/example-file/document/pdf/example_multipage.pdf"
    }],
    "conversion": [{
        "target": "pdf"
        "category": "document"
    }]
}

In this example, we try to merge two PDF files. Of course you can specify more than two files in your call.

 

The general command for merging files is:

"merge": {
    "type": "boolean",
    "description": "Merges the input files in one output file using the order as they appears in the input section of the message."
}

The value that can be added here is, once more, true or false. Furthermore, please note that the files will be merged in the order specified in the input.

 

This is a full POST command that would merge our two PDF files:

{
    "input": [{
        "type": "remote",
        "source": "http://cdn.online-convert.com/example-file/document/pdf/example.pdf"
    },
    {
        "type": "remote",
        "source": "http://cdn.online-convert.com/example-file/document/pdf/example_multipage.pdf"
    }],
    "conversion": [{
        "target": "pdf",
        "category": "document",
        "options": {
            "merge": true
        }
    }]
}

The output of this conversion after your GET is a single PDF file that contains both files you have merged.

 

Split PDF Files

If you want to split a PDF into several output files, your file has to contain more than one page of content. If this is the case, you can use the following command to split this file into several PDFs:

"split": {
    "type": "string",
    "pattern": "^(\\d+-?\\d*)(, ?(\\d+-?\\d*))*$",
    "description": "The pages where to split the original file. E.g. in a 30 pages document, an entry of 10,20 will results in three output files with pages 1-10, 11-20, 21-30"
}

The string to enter for the split function should contain the numbers of the pages after which you would like to split the document.

E.g. specifying 5 would result into a cut after page no 3 of your document. The resulting PDFs will contain pages 1 to 3 (output no 1) and 4 to end (output no 2).

 

The following command is what your complete POST to split a PDF should look like:

{
    "input": [{
        "type": "remote",
        "source": "http://cdn.online-convert.com/example-file/document/pdf/example_multipage.pdf"
    }],
    "conversion": [{
        "target": "pdf",
        "category": "document",
        "options": {
            "split": "3"
        }
    }]
}

With this command, we successfully split our 7-pages document after the third page, resulting in two PDFs (one containing page 1 to 3 and the other containing page 4 to 7). Both PDFs will be packed into a ZIP archive for your convenience.

If you want to split your document into more than two output files, simply add all the pages you want the cut to appear after divided by a comma:

[...]
"options": {
            "split": "3,5"
        }
[...]

This command fill split your PDF after pages 3 and 5, resulting in the following output:

  • PDF 1: pages 1 to 3
  • PDF 2: pages 4 to 5
  • PDF 3: 5 to 7

 

Got any questions?

If you have any questions regarding the API of Online-Convert.com or how to split and merge PDF files using it, feel free to contact us! Our friendly support team will lend you a hand with whatever you may need.

 

Further Information

Test Our API On Your Computer

API Tutorial
Image by http://bit.ly/1Ng7qnB

There are many different reasons, ways and methods how file conversion can make your life easier—online and offline. In this blog, we have talked about many different conversions and for what purpose you may need a free online conversion tool.

However, we at Online-Convert.com don’t stop there! For developers of web and mobile applications, we provide a versatile and powerful API that allows you to integrate file conversion into your projects! For this purpose, we have created two easy tools that allow you to integrate a file conversion link into your homepage. You can find them here.

The more adaptable way, however, is using our API. You can find all important information in our API documentation. To ensure that you will be able to work with our API, we provide you with a free version of it that is accessible for everyone who registered for a free account with Online-Convert.com

 

How To Test The Online-Convert.com API

There are a lot of possibilities to test our API from your computer. However, the one we recommend is a Chrome Plugin called POSTMAN. Our developers use it on a daily basis and it works like a charm.

Here’s a step-by-step tutorial on how to test our API using POSTMAN.

 

EDIT:
You can now use Postman even when you are not using Google Chrome. Head over to GetPostman.com and grab the software app for your operating system. It is available for Mac OS, Windows (x32, x64) and Linux (x32, x64).

 

1. Install POSTMAN from the Google Chrome app store, you can find the Plugin here

2. Launch POSTMAN

  1. Type chrome://apps in the address bar in Chrome.
  2. Click on the POSTMAN icon to open it.

3. You should see a window something like this:

postman1_start

4. Download the online_convert.postman_collection file from here. (save link as…)

5. Now, at the top of the window in POSTMAN, click the Import button

6. A new window should open, asking for a file. Select the online_convert.postman_collection file

7. If you now close the window you should see something like this:

postman2_collection

 

7.1 Click where the number 1 is and you should see two API calls that have been configured there for you to test

7.2 Click on Convert JPG to PNG (2)

7.3 Now you should see more information in the main area of the program window

7.4 If you click in the Headers tab (3) you will see that you have to insert your API key (4) for it to work

7.5 After you did so, you can click the green Save button located at the top right area of the window to save your changes

7.6 Now click send and our API will show a response like this:

postman3_first_response

7.6.1 Copy the contents of the ID variable.

 

8. After doing all of this we are ready to get the information of our just launched job. Click on Get Job Info

9. Open the Headers tab and replace the content with your API Key, like we did in step 7.

10. In the URL, remove the PUT_JOB_ID_HERE and paste the copied data from step 7.6.1

11. Now if you click send you should see something like this:

postman4_response2

11.1 This window provides all the information available after completing your job

11.2 When scrolling down to the bottom of the information, you should see an output section. Here you will find the link to download your converted file.

 

This is the easy way to test our API using nothing more but a collection file and a Google Chrome Plugin. It couldn’t be easier to test whether our API is able to do what you need. Users and supporters of Mozilla Firefox should have a look at the RESTClient extension.

If you still have questions about the usage of the Online-Convert.com API, feel free to send an e-mail to our service team at time2help@online-convert.com