Web to PDF API

Convert web pages to PDF with Chrome: layout, margins, headers/footers, page ranges, waits, JS/CSS, and auth support.

Web & HTML Tools

Web to PDF API Overview

Turn any website (URL input) into a pixel‑perfect PDF using a modern headless browser renderer. Control viewport and page layout with size, orientation, custom width/height, margins, and page ranges. Add headers and footers, keep backgrounds, pin fixed elements, and fine‑tune pagination by avoiding or inserting page breaks around specific selectors. For dynamic sites, run JavaScript, wait for an element, and inject your own JS/CSS. Access gated content with custom headers, cookies, and basic auth; block ads and cookie‑consent banners; hide elements; and adjust timeouts/delays for reliable rendering.

Full CSS & JS Rendering

Control loading time, JavaScript execution, and CSS styling.

Block Ads and Cookie Consent

Enable AdBlocker to remove unwanted ads, and hide cookie consent dialogs.

Control Image Quality

Adjust image compression and DPI for lighter or sharper PDFs.

Wait for Elements

Delay rendering until specific elements are loaded or ready.

Set Authentication & Cookies

Pass custom cookies, headers, and auth tokens easily.

Header & Footer Templates

Add dynamic headers, footers, page numbers, and titles.

Customizable Parameters

Fine-tune your automation with these powerful conversion options

Url

Uri

URI of a web page to convert. If URI has special characters like ? or & they must be encoded.

ConversionDelay

Integer Default: 0

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

Range:   0 .. 30

Version

Collection Default: 148

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

Values:   latest 146 147 148

AdBlock

Bool Default: False

Block ads in converting page.

CookieConsentBlock

Bool Default: False

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

JavaScript

Bool Default: True

Allow web pages to run JavaScript.

WaitElement

String

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

UserJs

String

Execute provided JavaScript before conversion begins.

UserCss

String

Apply additional CSS before conversion begins.

HideElements

String

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

CssMediaType

String Default: screen

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.

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 :.

LoadLazyContent

Bool Default: False

Load page images that loads only when they are visible.

ViewportWidth

Integer Default: 1366

Sets browser viewport width.

Range:   200 .. 4000

ViewportHeight

Integer Default: 1024

Sets browser viewport height.

Range:   200 .. 4000

Background

Bool Default: True

Convert web page background.

FixedElements

Collection Default: fixed

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

Values:   fixed absolute relative hide

ShowElements

String

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

AvoidBreakElements

String

CSS selector for the elements that pages should not break.

BreakBeforeElements

String

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

BreakAfterElements

String

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

AuthUsername

String

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

AuthPassword

String

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

Cookies

String

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

RespectViewport

Bool Default: True

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

Integer Default: 100

Set web page scale value in percentage.

Range:   10 .. 200

PageOrientation

Collection Default: portrait

PDF page orientation.

Values:   portrait landscape

PageSize

Collection Default: letter

PDF page size.

Values:   a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 b0 b1 b2 b3 b4 b5 letter legal ledger

MarginTop

Integer Default: 10

Set the page top margin in millimeters (mm).

Range:   0 .. 500

MarginRight

Integer Default: 10

Set the page right margin in millimeters (mm).

Range:   0 .. 500

MarginBottom

Integer Default: 10

Set the page bottom margin in millimeters (mm).

Range:   0 .. 500

MarginLeft

Integer Default: 10

Set the page left margin in millimeters (mm).

Range:   0 .. 500

Header

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

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>

PageWidth

Integer

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

Range:   10 .. 30000

PageHeight

Integer

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

Range:   10 .. 30000

PageRange

String Default: 1-100

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

StoreFile

Bool Default: False

When the StoreFile parameter is set to True, your converted file is written to ConvertAPI’s encrypted, temporary storage and made available via a time-limited secure download URL, valid for up to 3 hours. After this period, the file is permanently deleted.

When StoreFile is set to False, conversion happens entirely in-memory. The raw file bytes are streamed back in the API response without touching disk or external storage, ensuring maximum security and zero persistence so that only you can access the content.

Integrate within minutes

Easy Web to PDF automation using our simple REST-API

Try the Web to PDF conversion online

Try it 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!"

Enterprise-Grade Security

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?