HTM to PDF using Java

The Java SDK for converting HTML files to PDF files using Google Chrome browser.

Features of Our HTM to PDF for Java

The Java library for converting HTML files to PDF files.

Lightning Fast Conversions

Process and convert files in seconds with our high-performance cloud infrastructure.

Accuracy Guaranteed

Our advanced algorithms ensure pixel-perfect and content-accurate file conversions.

Enterprise-Grade Security

ISO 27001, HIPAA, SOC 2, and GDPR compliant with encrypted file processing.

Global Infrastructure

Strategically located servers ensure low latency and high availability worldwide.

Developer Friendly

Comprehensive SDKs and clear documentation for quick and simple integration.

Time-Saving Automation

Automate repetitive document workflows and focus on what matters most.

Integrate using Java

Easy HTM to PDF integration programmatically using our simple Java SDK

Install ConvertAPI library using Maven

Add the ConvertAPI Java client dependency com.convertapi.client to your pom.xml.

Authenticate

Sign up for a free account and authenticate the library using your Secret key or API token.

Customize Parameters

Set up the conversion parameters, and copy the auto-generated code snippet in your account dashboard.

Try the HTM to PDF conversion online

Try it Free

Customizable Parameters

Fine-tune your automation with these powerful conversion options

Authentication username String

HTTP authentication username. Could be used if conversion web page is protected with HTTP authentication.

Authentication password String

HTTP authentication password. Could be used if conversion web page is protected with HTTP authentication.

Cookies for the page request String

Set additional cookies for the page request. Example: cookiename1=cookievalue1; cookiename2=cookievalue2; cookiename3=cookievalue3

Page Range String

Set page range. Example 1-10 or 1,2,5.

Conversion delay Integer

Delay in seconds before page load and PDF creation. Sometimes useful to let web page fully load.

Chromium Version Collection

Specify a particular version of the Chromium engine to render the web page.

Available values:   Latest (130) 126 117

Ad block Bool

Block ads in converting page.

Remove cookie warnings Bool

Tries to remove EU regulation required cookie warnings from web pages.

Enable JavaScript Bool

Allow web pages to run JavaScript.

Wait for DOM element String

Element selector string of the DOM element. Converter will wait for this element to appear in DOM before conversion begins.

Execute JavaScript String

Execute provided JavaScript before conversion begins.

Apply additional CSS String

Apply additional CSS before conversion begins.

Hide DOM elements String

Element selector string of the DOM elements that needs to be hidden during conversion.

CSS media type String

Use CSS media type in conversion process. The default screen and print media types are supported but not limited to these. The custom media type, like convertapi can be used too.

Custom Headers String

Set custom HTTP headers to include in the request. Format: Header1:Value1|Header2:Value2|Header3:Value3

  • Each header is separated by |.
  • Each name/value pair is separated by :.
Load lazy content Bool

Load page images that loads only when they are visible.

Viewport width Integer

Sets browser viewport width.

Viewport height Integer

Sets browser viewport height.

Background Bool

Convert web page background.

Fixed elements Collection

Change fixed elements CSS 'position' property to adapt page for conversion.

Available values:   Leave unchanged Absolute Relative Hide

Show DOM elements String

Element selector string of the DOM elements that should be visible during conversion. Other elements will be hidden.

Avoid page break inside DOM elements String

CSS selector for the elements that pages should not break.

Page break before DOM elements String

CSS selector for the elements that should apply page break before it.

Page break after DOM elements String

CSS selector for the elements that should apply page break after it.

Respect viewport Bool

If true, the converter will generate PDF as the content looks like in the browser. If is set to false, the converter acts like Chrome print to PDF function.

Scale Content Integer

Set web page scale value in percentage.

Page orientation Collection

PDF page orientation.

Available values:   Portrait Landscape

Page size Collection

PDF page size.

Available values:   A0 A1 A2 A3 A4 A5 A6 A7 A8 A9 B0 B1 B2 B3 B4 B5 Letter Legal Ledger

Margin top Integer

Set the page top margin in millimeters (mm).

Margin right Integer

Set the page right margin in millimeters (mm).

Margin bottom Integer

Set the page bottom margin in millimeters (mm).

Margin left Integer

Set the page left margin in millimeters (mm).

Header HTML String

This property will insert an HTML header into each page. HTML tags containing the classes pageNumber, totalPages, title, and date will be filled in with the metadata relevant to each individual page. Inline CSS could be utilized to style the HTML provided.

<style>
    .right {
        float: right;
    }

    .left {
        float: left;
    }
</style>
<span class='left'>
    page number 
    <span class='pageNumber'></span>
</span>
<span class='right'>
    date 
    <span class='date'></span>
</span>
Footer HTML String

This property will insert an HTML footer into each page. HTML tags containing the classes pageNumber, totalPages, title, and date will be filled in with the metadata relevant to each individual page. Inline CSS could be utilized to style the HTML provided.

<style>
    .right {
        float: right;
    }

    .left {
        float: left;
    }
</style>
<span class='left'>
    page number 
    <span class='pageNumber'></span>
</span>
<span class='right'>
    date 
    <span class='date'></span>
</span>
Page width Integer

Custom page width in millimeters (mm). This option override PageSize option.

Page height Integer

Custom page height in millimeters (mm). This option override PageSize option.

Compress PDF Bool

It tries to produce smaller output files but requires Adobe Reader 6, released in 2003 or newer, to view created PDF files.

Integrate within minutes

Our user-friendly interactive demo enables you to easily set up and test the conversion from your account dashboard with just a few simple clicks.

Set up HTM to PDF parameters

Upload your HTM document that you wish to convert, and set up any additional conversion parameters using our intuitive and user-friendly interface. You can fine-tune and adjust the conversion parameters to suit your needs with no technical knowledge required.

Get Started for Free

Download the Conversion Result

When you have your conversion parameters set up, you can run the conversion and download the converted document to evaluate the HTM to PDF conversion quality. You can further adjust the parameters if needed, until you are satisfied with the result.

Get Started for Free

Copy Auto-Generated Code Snippet

Once you are happy with the conversion result, you can copy the auto-generated code snippet to your project and use it to perform the conversion programmatically. This will save you time and effort, and you will be able to focus on your project development.

Get Started for Free

Businesses trust us

Highest rated File Conversion API on major B2B software listing platforms: Capterra, G2, and Trustpilot.

"ConvertAPI has been a game-changer for our document automation workflows. Their conversion accuracy and API reliability are unmatched in the industry for over 7 years."

"ConvertAPI is a reliable, cost-effective solution with a proven track record of stability. It has grown significantly in maturity, adopting enterprise-grade practices over the years."

"We've integrated ConvertAPI across our entire document processing platform. The performance is exceptional and the support team is always responsive. Highly recommended!"

Data security is our top priority

We ensure that all document processing is handled securely in the cloud, adhering to industry-leading standards like ISO 27001, GDPR, and HIPAA. To enhance security even further, we can ensure that no files or data are stored on our servers and never leave your country.

Learn more about security

Ready to Streamline Your File Conversions?