{"id":35,"date":"2024-02-19T15:14:36","date_gmt":"2024-02-19T15:14:36","guid":{"rendered":"https:\/\/html2pdfrocket.com\/blog\/?p=35"},"modified":"2024-04-13T16:45:04","modified_gmt":"2024-04-13T16:45:04","slug":"convert-php-to-pdf","status":"publish","type":"post","link":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/","title":{"rendered":"Convert HTML to PDF with PHP"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">You can convert HTML files to PDF format using PHP. In the tutorial below, we will show you how you can easily do this.<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<div class=\"wp-block-group alignwide is-vertical is-content-justification-stretch is-layout-flex wp-container-core-group-is-layout-c6f38d1e wp-block-group-is-layout-flex\" style=\"padding-top:var(--wp--preset--spacing--20)\">\n<h4 class=\"wp-block-heading has-text-align-center\">Advantages of HTML2PDF Rocket in Converting HTML to PDF with PHP<\/h4>\n\n\n\n<div style=\"height:0px\" aria-hidden=\"true\" class=\"wp-block-spacer wp-container-content-32e3a40d\"><\/div>\n\n\n\n<div class=\"wp-block-columns alignwide is-layout-flex wp-container-core-columns-is-layout-5a989b3a wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"border-top-color:var(--wp--preset--color--contrast-3);border-top-width:1px;padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--30)\">\n<h4 class=\"wp-block-heading has-text-align-center has-text-color has-link-color has-large-font-size wp-elements-52c27bc0bccf5ac57b993b7adc761f20\" style=\"color:#c62222;padding-top:1px\">Excellent Quality<\/h4>\n\n\n\n<p class=\"has-text-align-center has-contrast-2-color has-text-color has-link-color wp-elements-3d6fabb6cf5e70c99841a92c58e86205 wp-block-paragraph\"><strong>OUR WEB SERVICES ARE COMMERCIALLY USED BY OVER 10,500 COMPANIES AND COUNTING.<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-center has-contrast-2-color has-text-color has-link-color wp-elements-4a904bed9e266a7a971a9bca0ae673ca wp-block-paragraph\"><strong>YOU CAN EXPECT HIGH QUALITY OUTPUT AS WE MAINTAIN AND KEEP IMPROVING OUR SERVICES<\/strong><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"border-top-color:var(--wp--preset--color--contrast-3);border-top-width:1px;padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--30)\">\n<h4 class=\"wp-block-heading has-text-align-center has-text-color has-link-color has-large-font-size wp-elements-22d8d3f27261b8521aa0b46eb37aca06\" style=\"color:#c62222;padding-top:1px\">Easy to Use<\/h4>\n\n\n\n<p class=\"has-text-align-center has-contrast-2-color has-text-color has-link-color wp-elements-116023bd1464cf8f580d9011ffbd64bb wp-block-paragraph\"><strong>COPY AND PASTE THE SAMPLE CODES WE CREATED FOR YOU AND CONVERT HTML TO PDF IN SECONDS!<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-center has-contrast-2-color has-text-color has-link-color wp-elements-2b17f9c0da049f3170f62d67006fd351 wp-block-paragraph\"><strong>OUR HTML TO PDF CONVERTER WORKS IN ANY OPERATING SYSTEM, WINDOWS, LINUX OR MACOS.<\/strong><\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\" style=\"border-top-color:var(--wp--preset--color--contrast-3);border-top-width:1px;padding-top:var(--wp--preset--spacing--30);padding-right:var(--wp--preset--spacing--30);padding-bottom:var(--wp--preset--spacing--10);padding-left:var(--wp--preset--spacing--30)\">\n<h4 class=\"wp-block-heading has-text-align-center has-text-color has-link-color has-large-font-size wp-elements-cfe5aa6574f6fbea9af843f112f06678\" style=\"color:#c62222;padding-top:1px\">Best Value<\/h4>\n\n\n\n<p class=\"has-text-align-center has-contrast-2-color has-text-color has-link-color wp-elements-e77266a9c2b58647278f1115cba09f72 wp-block-paragraph\"><strong>OUR HTML TO PDF CONVERTER SERVICE IS ALWAYS FREE TO USE FOR LOW VOLUME CONVERSIONS.<\/strong><\/p>\n\n\n\n<p class=\"has-text-align-center has-contrast-2-color has-text-color has-link-color wp-elements-178b538434522e87dd71408696ae843b wp-block-paragraph\"><strong>FOR HIGH VOLUME CONVERSIONS, WE OFFER THE MOST AFFORDABLE AND BEST VALUE PLANS IN THE MARKET.<\/strong><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-content-justification-center is-layout-constrained wp-block-group-is-layout-constrained\" style=\"border-top-color:var(--wp--preset--color--contrast-2);border-top-style:dashed;border-top-width:1px;border-bottom-color:var(--wp--preset--color--contrast-2);border-bottom-style:dotted;border-bottom-width:1px;margin-bottom:var(--wp--preset--spacing--10);padding-top:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10)\">\n<h4 class=\"wp-block-heading has-text-align-center\">Try HTML2PDF Rocket for FREE<\/h4>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-190e7bf0 wp-block-buttons-is-layout-flex\" style=\"margin-top:0.5rem;margin-bottom:0.5rem\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"\/account\/register\">GET YOUR FREE API KEY<\/a><\/div>\n<\/div>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\">and start converting HTML to PDF instantly!<\/p>\n<\/div>\n\n\n\n<h3 class=\"wp-block-heading is-style-default\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Code Examples to Convert HTML to PDF with PHP<\/h3>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\">Example #1 &#8211; How to use PHP to convert an HTML string to a PDF and save to disk<\/h4>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/9552c04c58af1c0eddd2f23a919ee18c.js\"><\/script>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\">Example #2 &#8211; How to convert a PHP webpage to a PDF and stream it to a user as an attachment with PHP<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Example also shows how you can download the file as an attachment, or show it inline in the web browser.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/afc65bfb3052f685b8416ac0b937cfad.js\"><\/script>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\">Example #3 &#8211; How convert an webpage to an image thumbnail using PHP<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">You can also convert an HTML string to a PDF by supplying the HTML directly. It can be as complex as you like and may include image references and stylesheeet information &#8212; just make sure it is valid HTML.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/dc2ba657cdc2e3026797f5739c665a8f.js\"><\/script>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\">Example #4 &#8211; How to add a standard header or footer when converting HTML to PDF using PHP<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Be sure to urlencode any extra parameters you send to the API, especially if they have funny HTML characters in them.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/4f1e5c546dc1e3068e77d3cea1a0dcba.js\"><\/script>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\">Example #5 &#8211; Using POST rather than GET when calling the API to convert HTML to PDF&#8217;s<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">For long strings PHP may have a limitation with GET but you can POST the parameters instead using this syntax.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/9dc075e7b9cc1dd0adf2968ea7a40d16.js\"><\/script>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\">Example #6 &#8211; PDF Custom HTML Headers and Footers<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Instead of using the Footer and Header Left\/Right parameters which allow basic text, you can have a full HTML based header or footer by including a URL or a string to an HTML snippet in the HeaderUrl\/HeaderHtml or FooterUrl\/FooterHtml parameters. You can use page numbering, fonts, colours and images to lay out the header as you see fit here is an example of a standard HTML header. As by default page margins are set to 0 to allow full access to the page, make sure you specify are margin parameter large enough to allow the header or footer to fit. Make sure your header\/footer code starts with &lt;!DOCTYPE html&gt; and include the &lt;html&gt; and &lt;body&gt; tags.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/f273be4dcd0ae9abc766479658a7dd90.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Here is an example custom HTML header file with page numbers. Do not forget the doctype.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/737a42e709d33ed88a01d453edc8a88e.js\"><\/script>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">This is an example which hides the header on page 1 and 3.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/a9d7db0837cf9937befa24e21dabeb17.js\"><\/script>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\">\n<h4 class=\"wp-block-heading\">Example #7 &#8211; Batch\/Asynchronous Process<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">For PDF conversion taking more than 30 seconds or input\/output files more than 6 Mb, you need to use the batch\/asynchronous parameters.<\/p>\n\n\n\n<script src=\"https:\/\/gist.github.com\/html2pdf-rocket\/3ee6fde6a49197bc0df41ecbfc0daf77.js\"><\/script>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Need another PHP example? Would you mind dropping us a&nbsp;<a href=\"https:\/\/html2pdfrocket.com\/contact\">quick one line note<\/a>&nbsp;to say which example you would have liked and we&#8217;ll put the most commonly used ones here.<\/p>\n\n\n\n<div class=\"wp-block-group has-global-padding is-layout-constrained wp-block-group-is-layout-constrained\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">\n<h4 class=\"wp-block-heading\">About HTML2PDF Rocket<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\"><a href=\"https:\/\/html2pdfrocket.com\/\">Html2PDF Rocket<\/a>&nbsp;is based on an open source technology. It is a free and easy to use web service to convert html webpages into PDF files or images. HTML2PDF Rocket is trusted by over 10,500 companies worldwide.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">What is an HTML to PDF API?<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">An HTML to PDF API is a web service that will read your webpage and dynamically generate a PDF or an image. It will convert the contents of a webpage to a PDF file. It handles fairly complex documents and layouts, including images.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Why Convert HTML to PDF?<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\" style=\"margin-top:var(--wp--preset--spacing--10);margin-bottom:var(--wp--preset--spacing--10)\">Converting HTML to PDF is great for reporting, creating brochures, and printing invoices. Just create one HTML or PHP webpage, and use it as a source to generate downloadable PDF or viewable PDF pages. PDF is a fixed-layout document created by&nbsp;<a href=\"https:\/\/www.adobe.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Adobe Systems<\/a>. It is a perfect document for downloading text or HTML content in a file, with consistent layout that does not depend on the device for viewing and does not require internet connection.<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-group has-global-padding is-content-justification-center is-layout-constrained wp-block-group-is-layout-constrained\" style=\"border-top-color:var(--wp--preset--color--contrast-2);border-top-style:dashed;border-top-width:1px;border-bottom-color:var(--wp--preset--color--contrast-2);border-bottom-style:dotted;border-bottom-width:1px;margin-bottom:var(--wp--preset--spacing--10);padding-top:var(--wp--preset--spacing--10);padding-bottom:var(--wp--preset--spacing--10)\">\n<h4 class=\"wp-block-heading has-text-align-center\">Try HTML2PDF Rocket for FREE<\/h4>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-center is-layout-flex wp-container-core-buttons-is-layout-190e7bf0 wp-block-buttons-is-layout-flex\" style=\"margin-top:0.5rem;margin-bottom:0.5rem\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"\/account\/register\">GET YOUR FREE API KEY<\/a><\/div>\n<\/div>\n\n\n\n<p class=\"has-text-align-center wp-block-paragraph\">and start converting HTML to PDF instantly!<\/p>\n<\/div>\n\n\n\n<div class=\"wp-block-group alignwide has-background is-layout-flow wp-block-group-is-layout-flow\" style=\"background-color:#f7f7f7\">\n<div style=\"height:55px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading has-text-align-center\">Conversion Tip<\/h4>\n\n\n\n<div style=\"height:19px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"has-text-align-center has-heading-font-family has-medium-font-size wp-block-paragraph\" style=\"font-style:normal;font-weight:400;line-height:1.2\">The number #1 reason a conversion fails to come out how you expect is because it contains references to external links or images that don&#8217;t exist &#8211; or you are trying to link to localhost! If there is a conversion error, please check the page using your web browsers &#8216;developer&#8217; network tab to ensure there are no 404 errors.<\/p>\n\n\n\n<div style=\"height:55px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>You can convert HTML files to PDF format using PHP. In the tutorial below, we will show you how you can easily do this. Code Examples to Convert HTML to PDF with PHP Example #1 &#8211; How to use PHP to convert an HTML string to a PDF and save to disk Example #2 &#8211; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":258,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-35","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code-examples"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Convert HTML to PDF with PHP - HTML2PDFRocket<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Convert HTML to PDF with PHP - HTML2PDFRocket\" \/>\n<meta property=\"og:description\" content=\"You can convert HTML files to PDF format using PHP. In the tutorial below, we will show you how you can easily do this. Code Examples to Convert HTML to PDF with PHP Example #1 &#8211; How to use PHP to convert an HTML string to a PDF and save to disk Example #2 &#8211; [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/\" \/>\n<meta property=\"og:site_name\" content=\"HTML2PDFRocket\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-19T15:14:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-13T16:45:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/02\/code-1076536_1280.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"719\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"willie\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"willie\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-php-to-pdf\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-php-to-pdf\\\/\"},\"author\":{\"name\":\"willie\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#\\\/schema\\\/person\\\/7fdf75521bc4c44d3e39cde19dddc776\"},\"headline\":\"Convert HTML to PDF with PHP\",\"datePublished\":\"2024-02-19T15:14:36+00:00\",\"dateModified\":\"2024-04-13T16:45:04+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-php-to-pdf\\\/\"},\"wordCount\":446,\"publisher\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-php-to-pdf\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/02\\\/code-1076536_1280.jpg\",\"articleSection\":[\"Code Examples\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-php-to-pdf\\\/\",\"url\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-php-to-pdf\\\/\",\"name\":\"Convert HTML to PDF with PHP - HTML2PDFRocket\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-php-to-pdf\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-php-to-pdf\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/02\\\/code-1076536_1280.jpg\",\"datePublished\":\"2024-02-19T15:14:36+00:00\",\"dateModified\":\"2024-04-13T16:45:04+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-php-to-pdf\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-php-to-pdf\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-php-to-pdf\\\/#primaryimage\",\"url\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/02\\\/code-1076536_1280.jpg\",\"contentUrl\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/02\\\/code-1076536_1280.jpg\",\"width\":1280,\"height\":719},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/convert-php-to-pdf\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Convert HTML to PDF with PHP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/\",\"name\":\"HTML 2 PDF ROCKET\",\"description\":\"An easy to use web service to convert HTML webpage to PDF\",\"publisher\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#organization\",\"name\":\"HTML 2 PDF ROCKET\",\"url\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/02\\\/logo.png\",\"contentUrl\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/wp-content\\\/uploads\\\/2024\\\/02\\\/logo.png\",\"width\":270,\"height\":48,\"caption\":\"HTML 2 PDF ROCKET\"},\"image\":{\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/#\\\/schema\\\/person\\\/7fdf75521bc4c44d3e39cde19dddc776\",\"name\":\"willie\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ac2d372b04aaa8746f077a7de8e21085bc881ab36abd61bc96fc67c861fc46b2?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ac2d372b04aaa8746f077a7de8e21085bc881ab36abd61bc96fc67c861fc46b2?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/ac2d372b04aaa8746f077a7de8e21085bc881ab36abd61bc96fc67c861fc46b2?s=96&d=mm&r=g\",\"caption\":\"willie\"},\"sameAs\":[\"https:\\\/\\\/html2pdfrocket.com\\\/blog\"],\"url\":\"https:\\\/\\\/html2pdfrocket.com\\\/blog\\\/author\\\/willie\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Convert HTML to PDF with PHP - HTML2PDFRocket","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/","og_locale":"en_US","og_type":"article","og_title":"Convert HTML to PDF with PHP - HTML2PDFRocket","og_description":"You can convert HTML files to PDF format using PHP. In the tutorial below, we will show you how you can easily do this. Code Examples to Convert HTML to PDF with PHP Example #1 &#8211; How to use PHP to convert an HTML string to a PDF and save to disk Example #2 &#8211; [&hellip;]","og_url":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/","og_site_name":"HTML2PDFRocket","article_published_time":"2024-02-19T15:14:36+00:00","article_modified_time":"2024-04-13T16:45:04+00:00","og_image":[{"width":1280,"height":719,"url":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/02\/code-1076536_1280.jpg","type":"image\/jpeg"}],"author":"willie","twitter_card":"summary_large_image","twitter_misc":{"Written by":"willie","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/#article","isPartOf":{"@id":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/"},"author":{"name":"willie","@id":"https:\/\/html2pdfrocket.com\/blog\/#\/schema\/person\/7fdf75521bc4c44d3e39cde19dddc776"},"headline":"Convert HTML to PDF with PHP","datePublished":"2024-02-19T15:14:36+00:00","dateModified":"2024-04-13T16:45:04+00:00","mainEntityOfPage":{"@id":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/"},"wordCount":446,"publisher":{"@id":"https:\/\/html2pdfrocket.com\/blog\/#organization"},"image":{"@id":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/#primaryimage"},"thumbnailUrl":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/02\/code-1076536_1280.jpg","articleSection":["Code Examples"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/","url":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/","name":"Convert HTML to PDF with PHP - HTML2PDFRocket","isPartOf":{"@id":"https:\/\/html2pdfrocket.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/#primaryimage"},"image":{"@id":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/#primaryimage"},"thumbnailUrl":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/02\/code-1076536_1280.jpg","datePublished":"2024-02-19T15:14:36+00:00","dateModified":"2024-04-13T16:45:04+00:00","breadcrumb":{"@id":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/#primaryimage","url":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/02\/code-1076536_1280.jpg","contentUrl":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/02\/code-1076536_1280.jpg","width":1280,"height":719},{"@type":"BreadcrumbList","@id":"https:\/\/html2pdfrocket.com\/blog\/convert-php-to-pdf\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/html2pdfrocket.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Convert HTML to PDF with PHP"}]},{"@type":"WebSite","@id":"https:\/\/html2pdfrocket.com\/blog\/#website","url":"https:\/\/html2pdfrocket.com\/blog\/","name":"HTML 2 PDF ROCKET","description":"An easy to use web service to convert HTML webpage to PDF","publisher":{"@id":"https:\/\/html2pdfrocket.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/html2pdfrocket.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/html2pdfrocket.com\/blog\/#organization","name":"HTML 2 PDF ROCKET","url":"https:\/\/html2pdfrocket.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/html2pdfrocket.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/02\/logo.png","contentUrl":"https:\/\/html2pdfrocket.com\/blog\/wp-content\/uploads\/2024\/02\/logo.png","width":270,"height":48,"caption":"HTML 2 PDF ROCKET"},"image":{"@id":"https:\/\/html2pdfrocket.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/html2pdfrocket.com\/blog\/#\/schema\/person\/7fdf75521bc4c44d3e39cde19dddc776","name":"willie","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ac2d372b04aaa8746f077a7de8e21085bc881ab36abd61bc96fc67c861fc46b2?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ac2d372b04aaa8746f077a7de8e21085bc881ab36abd61bc96fc67c861fc46b2?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ac2d372b04aaa8746f077a7de8e21085bc881ab36abd61bc96fc67c861fc46b2?s=96&d=mm&r=g","caption":"willie"},"sameAs":["https:\/\/html2pdfrocket.com\/blog"],"url":"https:\/\/html2pdfrocket.com\/blog\/author\/willie\/"}]}},"_links":{"self":[{"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/posts\/35","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/comments?post=35"}],"version-history":[{"count":55,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/posts\/35\/revisions"}],"predecessor-version":[{"id":378,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/posts\/35\/revisions\/378"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/media\/258"}],"wp:attachment":[{"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/media?parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/categories?post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/html2pdfrocket.com\/blog\/wp-json\/wp\/v2\/tags?post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}