Web/HTML To PDF REST API for Java Samples

javaSelectPdf API is the best when it comes to converting web pages to pdf. Just send your url or html string to our API and get back the perfect PDF document. Externalize the load from your servers. Outsource the html to pdf conversion to SelectPdf REST API and get the best results no matter the platform you are using: Java, PHP, .NET, Ruby, Perl or anything else.

SelectPdf HTML To PDF Online REST API is a professional solution that lets you create PDF from web pages and raw HTML code in your applications. The API is easy to use and the integration takes only a few lines of code. The following Java code samples use v2 of SelectPdf Online HTML to PDF REST API.

It’s very easy to convert any URL or raw HTML string to PDF in Java using SelectPdf HTML To PDF API.

Exemple #1 – How to use Java to convert a webpage to PDF and save it on the disk

This code converts an url to pdf in Java using SelectPdf REST API through a GET request. The content is saved into a file on the disk.

Exemple #2 – How to use Java to convert a webpage to PDF with a POST API request and save it on the disk

This code converts an url to pdf in Java using SelectPdf HTML To PDF REST API through a POST request. The parameters are url encoded. The content is saved into a file on the disk.

The above samples use only the 2 mandatory parameters (key and url or html) for the html to pdf conversion. For the full list of optional parameters, take a look at SelectPdf HTML To PDF API page. Using the API optional parameters, you can control the page size, orientation and margins in the pdf document, the document information and security, the headers and footers and a lot more.

Hopefully these examples will help you to be on your way using the API for URL to PDF conversion in Java.

The above Java samples can also be found in the following GitHub repository:
https://github.com/selectpdf/selectpdf-api-java-samples