PDF to HTML HTTP API Examples
These examples demonstrate common PDF to HTML API workflows via HTTP API.
You can run the examples below with the displayed API credentials. Update the input URLs and filenames as needed.
Basic examples
PDF file to HTML file
curl -f -s -S \ -u 'demo:demo' \ -o logo.html \ -F file=@logo.pdf \ -F input_format=pdf \ -F output_format=html \ https://api.pdfcrowd.com/convert/24.04/
PDF url to HTML file
curl -f -s -S \ -u 'demo:demo' \ -o invoice.html \ -F url=https://your-server.com/invoice.pdf \ -F input_format=pdf \ -F output_format=html \ https://api.pdfcrowd.com/convert/24.04/
Customize the HTML output
These examples upload report.pdf, a document with text, images, and vector graphics.
Convert selected pages
Convert pages 1 and 3 of report.pdf into excerpt.html.
curl -f -s -S \ -u 'demo:demo' \ -o excerpt.html \ -F file=@report.pdf \ -F input_format=pdf \ -F output_format=html \ -F print_page_range=1,3 \ https://api.pdfcrowd.com/convert/24.04/
Export HTML with separate assets
Save the HTML, stylesheets, fonts, and images in report.zip. Extract the archive and serve its HTML with the accompanying files, preserving their relative paths.
curl -f -s -S \ -u 'demo:demo' \ -o report.zip \ -F file=@report.pdf \ -F input_format=pdf \ -F output_format=html \ -F css_mode=separate \ -F font_mode=separate \ -F force_zip=true \ -F image_mode=separate \ https://api.pdfcrowd.com/convert/24.04/
Customize the document preview
Scale pages to 75% and change the background, page spacing, and corners in preview.html. Use !important to override the generated background and margin rules.
curl -f -s -S \ -u 'demo:demo' \ -o preview.html \ -F file=@report.pdf \ -F input_format=pdf \ -F output_format=html \ --form-string 'custom_css=#page-container { background: #eaf0f6 !important; } .page { margin: 24px auto !important; border-radius: 8px; }' \ -F scale_factor=75 \ https://api.pdfcrowd.com/convert/24.04/
Avoid naming conflicts
Prefix generated IDs, CSS classes, and font names with report_ in namespaced.html. This helps avoid naming conflicts when integrating the converted content into another page; adjust the surrounding layout separately.
curl -f -s -S \ -u 'demo:demo' \ -o namespaced.html \ -F file=@report.pdf \ -F input_format=pdf \ -F output_format=html \ -F html_namespace=report_ \ https://api.pdfcrowd.com/convert/24.04/
Reduce image resolution
Render page graphics at 72 DPI instead of the default 144 DPI and save smaller.html. Lower resolution can reduce file size at the cost of image detail; text remains HTML text.
curl -f -s -S \ -u 'demo:demo' \ -o smaller.html \ -F file=@report.pdf \ -F input_format=pdf \ -F output_format=html \ -F dpi=72 \ https://api.pdfcrowd.com/convert/24.04/
Preserve vector graphics with SVG
Use SVG for page graphics in vector.html, preserving vector shapes when zooming. Raster images in the PDF remain raster images within the SVG.
curl -f -s -S \ -u 'demo:demo' \ -o vector.html \ -F file=@report.pdf \ -F input_format=pdf \ -F output_format=html \ -F image_format=svg \ https://api.pdfcrowd.com/convert/24.04/