This page contains various examples of using the HTML to PDF API in Command Line. The examples are complete and fully functional. Read more about how to convert HTML to PDF in Command Line.
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ "http://www.example.com" > "example.pdf"
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ "/path/to/MyLayout.html" > "MyLayout.pdf"
echo -n "<html><body><h1>Hello World!</h1></body></html>" | \ html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" - > "HelloWorld.pdf"
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -page-size "Letter" \ -orientation "landscape" \ -no-margins \ "http://www.example.com" > "letter_landscape.pdf"
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -header-height "15mm" \ -footer-height "10mm" \ -header-html "<a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a>" \ -footer-html "<center><span class='pdfcrowd-page-number'></span></center>" \ -margin-top "0" \ -margin-bottom "0" \ "http://www.example.com" > "header_footer.pdf"
echo -n "<html><body>Enter name:<input type=text></body></html>" | \ html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -enable-pdf-forms - > "form.pdf"
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -scale-factor 300 \ "http://www.example.com" > "zoom_300.pdf"
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -author "Pdfcrowd" \ -title "Hello World" \ -subject "Demo" \ -keywords "Pdfcrowd,demo" \ "http://www.example.com" > "with_metadata.pdf"
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -page-layout "single-page" \ -page-mode "full-screen" \ -initial-zoom-type "fit-page" \ -orientation "landscape" \ -no-margins \ "https://pdfcrowd.com/api/" > "slide_show.pdf"
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -element-to-convert "#main" \ "https://pdfcrowd.com/api/" > "html_part.pdf"
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -custom-javascript "el=document.createElement('h2'); el.textContent='Hello from Pdfcrowd API'; el.style.color='red'; el_before=document.getElementsByTagName('h1')[0]; el_before.parentNode.insertBefore(el, el_before.nextSibling)" \ "http://www.example.com" > "html_inject.pdf"
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -content-viewport-width "large" \ -no-margins \ "https://getbootstrap.com/" > "bootstrap.pdf"
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -custom-javascript "libPdfcrowd.highlightHtmlElements({backgroundColor: 'rgba(255, 191, 0, 0.1)', borderColor:null})" \ "http://www.example.com" > "highlight_background.pdf"
html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -custom-javascript "libPdfcrowd.highlightHtmlElements({borderColor: 'orange', backgroundColor: null, padding: '4px', margin: '4px'})" \ "http://www.example.com" > "highlight_borders.pdf"
echo -n "Hello {{ name }} from {{ product }}" | \ html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -data-string "$(echo -e "{ \"name\": \"World\", \"product\": \"Pdfcrowd API\" }")" - > "output.pdf"
echo -n "Hello {{ data.name }} from {{ data.product }}" | \ html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -data-string "$(echo -e "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <data> <name>World</name> <product>Pdfcrowd API</product> </data>")" - > "output.pdf"
echo -n "Hello {{ name }} from {{ product }}" | \ html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -data-string "$(echo -e "name: World product: Pdfcrowd API")" - > "output.pdf"
echo -n "Hello {{ name }} from {{ product }}" | \ html2pdf -user-name "demo" -api-key "ce544b6ea52a5621fb9d55f8b542d14d" \ -data-string "$(echo -e "name,product World,Pdfcrowd API")" - > "output.pdf"