{"id":26415575,"url":"https://github.com/spiritix/html-to-pdf","last_synced_at":"2025-10-04T16:05:10.412Z","repository":{"id":31154785,"uuid":"34714751","full_name":"spiritix/html-to-pdf","owner":"spiritix","description":"Convert HTML markup into beautiful PDF files using the famous wkhtmltopdf library.","archived":false,"fork":false,"pushed_at":"2018-07-25T05:56:27.000Z","size":50,"stargazers_count":19,"open_issues_count":0,"forks_count":9,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-02-19T01:35:06.937Z","etag":null,"topics":["html","html-to-pdf","htmltopdf","pdf","pdf-conversion","pdf-converter","php","wkhtmltopdf"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spiritix.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-04-28T07:10:07.000Z","updated_at":"2024-09-04T03:25:20.000Z","dependencies_parsed_at":"2022-08-24T14:21:28.842Z","dependency_job_id":null,"html_url":"https://github.com/spiritix/html-to-pdf","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spiritix%2Fhtml-to-pdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spiritix%2Fhtml-to-pdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spiritix%2Fhtml-to-pdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spiritix%2Fhtml-to-pdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spiritix","download_url":"https://codeload.github.com/spiritix/html-to-pdf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244130285,"owners_count":20402756,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html","html-to-pdf","htmltopdf","pdf","pdf-conversion","pdf-converter","php","wkhtmltopdf"],"created_at":"2025-03-18T00:19:05.900Z","updated_at":"2025-10-04T16:05:05.374Z","avatar_url":"https://github.com/spiritix.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HtmlToPdf\n\nConvert HTML markup into beautiful PDF files using the famous wkhtmltopdf library.\n\n[![Build Status](https://travis-ci.org/spiritix/html-to-pdf.svg?branch=master)](https://travis-ci.org/spiritix/html-to-pdf)\n[![Code Climate](https://codeclimate.com/github/spiritix/html-to-pdf/badges/gpa.svg)](https://codeclimate.com/github/spiritix/html-to-pdf)\n[![Total Downloads](https://poser.pugx.org/spiritix/html-to-pdf/d/total.svg)](https://packagist.org/packages/spiritix/html-to-pdf)\n[![Latest Stable Version](https://poser.pugx.org/spiritix/html-to-pdf/v/stable.svg)](https://packagist.org/packages/spiritix/html-to-pdf)\n[![Latest Unstable Version](https://poser.pugx.org/spiritix/html-to-pdf/v/unstable.svg)](https://packagist.org/packages/spiritix/html-to-pdf)\n[![License](https://poser.pugx.org/spiritix/html-to-pdf/license.svg)](https://packagist.org/packages/spiritix/html-to-pdf)\n\n**Unfortunately, wkhtmltopdf is based on a very outdated version of WebKit and [not really maintained anymore](https://github.com/wkhtmltopdf/wkhtmltopdf/issues). I've therefore recently launched a [new version](https://github.com/spiritix/php-chrome-html2pdf) of this library which is based on Google Chrome. Give it a try!**\n\n## Features\n\n- Does not require any complex installation or configuration, works out of the box\n- Offers all [features](http://wkhtmltopdf.org/usage/wkhtmltopdf.txt) of wkhtmltopdf\n- Possibility to get the HTML from an external URL\n- Possibility to download, embed or save the generated PDF files (or even get their contents as a string)\n- Supports PHP7\n\n## Requirements\n\n- PHP 5.5+\n- Enabled program execution functions (proc_open)\n- Enabled 'fopen' wrappers (in order to use the URL to PDF functionality)\n- Unix based operating system (Windows support ~~will~~ may be added in the future)\n\n## Installation\n\nHtmlToPdf can be installed via [Composer](http://getcomposer.org) by requiring the\n`spiritix/html-to-pdf` package in your project's `composer.json`.\n\n```sh\nphp composer.phar require spiritix/html-to-pdf\n```\n\n## Usage\n\nThe usage of this library is pretty simple. \nYou just need a converter instance, pass an input and an output handler to it and set some options if you like.\nAfter running the conversion, the converter will provide you with the output handler instance.\nNow you may use it's specific functionality to get your PDF file.\n\n```php\nuse Spiritix\\HtmlToPdf\\Converter;\nuse Spiritix\\HtmlToPdf\\Input\\UrlInput;\nuse Spiritix\\HtmlToPdf\\Output\\DownloadOutput;\n\n$input = new UrlInput();\n$input-\u003esetUrl('https://www.google.com');\n\n$converter = new Converter($input, new DownloadOutput());\n\n$converter-\u003esetOption('n');\n$converter-\u003esetOption('d', '300');\n\n$converter-\u003esetOptions([\n    'no-background',\n    'margin-bottom' =\u003e '100',\n    'margin-top' =\u003e '100',\n]);\n\n$output = $converter-\u003econvert();\n$output-\u003edownload();\n```\n\n### Input handlers\n\nThe following input handlers are available:\n\n- StringInput - Accepts the HTML contents as a string\n- UrlInput - Fetch the HTML contents from an URL\n\n### Output handlers\n\nThe following output handlers are available:\n\n- StringOutput - Get the PDF contents as a string\n- FileOutput - Store the PDF to your file system\n- DownloadOutput - Force the browser to download the PDF file\n- EmbedOutput - Force the browser to embed the PDF file\n\n## Options\n\n    General Options\n        allow                   \u003cpath\u003e      Allow the file or files from the specified folder to be loaded (repeatable)\n    b,  book*                               Set the options one would usually set when printing a book\n        collate                             Collate when printing multiple copies\n        cookie                  \u003cname\u003e \u003cvalue\u003e     Set an additional cookie (repeatable)\n        cookie-jar              \u003cpath\u003e      Read and write cookies from and to the supplied cookie jar file\n        copies                  \u003cnumber\u003e    Number of copies to print into the pdf file (default 1)\n        cover*                  \u003curl\u003e       Use html document as cover. It will be inserted before the toc with no headers and footers\n        custom-header           \u003cname\u003e \u003cvalue\u003e     Set an additional HTTP header (repeatable)\n        debug-javascript                    Show javascript debugging output\n    H,  default-header*                     Add a default header, with the name of the page to the left, and the page number to the right, this is short for: header-left='[webpage]' header-right='[page]/[toPage]' top 2cm header-line\n        disable-external-links*             Do no make links to remote web pages\n        disable-internal-links*             Do no make local links\n    n,  disable-javascript                  Do not allow web pages to run javascript\n        disable-pdf-compression*            Do not use lossless compression on pdf objects\n        disable-smart-shrinking*            Disable the intelligent shrinking strategy used by WebKit that makes the pixel/dpi ratio none constant\n        disallow-local-file-access          Do not allowed conversion of a local file to read in other local files, unless explecitily allowed with allow\n    d,  dpi                     \u003cdpi\u003e       Change the dpi explicitly (this has no effect on X11 based systems)\n        enable-plugins                      Enable installed plugins (such as flash\n        encoding                \u003cencoding\u003e  Set the default text encoding, for input\n        forms*                              Turn HTML form fields into pdf form fields\n    g,  grayscale                           PDF will be generated in grayscale\n        ignore-load-errors                  Ignore pages that claimes to have encountered an error during loading\n    l,  lowquality                          Generates lower quality pdf/ps. Useful to shrink the result document space\n    B,  margin-bottom           \u003cunitreal\u003e  Set the page bottom margin (default 10mm)\n    L,  margin-left             \u003cunitreal\u003e  Set the page left margin (default 10mm)\n    R,  margin-right            \u003cunitreal\u003e  Set the page right margin (default 10mm)\n    T,  margin-top              \u003cunitreal\u003e  Set the page top margin (default 10mm)\n        minimum-font-size       \u003cint\u003e       Minimum font size (default 5)\n        no-background                       Do not print background\n    O,  orientation             \u003corientation\u003e     Set orientation to Landscape or Portrait\n        page-height             \u003cunitreal\u003e  Page height (default unit millimeter)\n        page-offset*            \u003coffset\u003e    Set the starting page number (default 1)\n    s,  page-size               \u003csize\u003e      Set paper size to: A4, Letter, etc.\n        page-width              \u003cunitreal\u003e  Page width (default unit millimeter)\n        password                \u003cpassword\u003e  HTTP Authentication password\n        post                    \u003cname\u003e \u003cvalue\u003e    Add an additional post field (repeatable)\n        post-file               \u003cname\u003e \u003cpath\u003e     Post an aditional file (repeatable)\n        print-media-type*                   Use print media-type instead of screen\n    p,  proxy                   \u003cproxy\u003e     Use a proxy\n    q,  quiet                               Be less verbose\n        redirect-delay          \u003cmsec\u003e      Wait some milliseconds for js-redirects (default 200)\n        replace*                \u003cname\u003e \u003cvalue\u003e     Replace [name] with value in header and footer (repeatable)\n        stop-slow-scripts                   Stop slow running javascripts\n        title                   \u003ctext\u003e      The title of the generated pdf file (The title of the first document is used if not specified)\n    t,  toc*                                Insert a table of content in the beginning of the document\n        use-xserver*                        Use the X server (some plugins and other stuff might not work without X11)\n        user-style-sheet        \u003curl\u003e       Specify a user style sheet, to load with every page\n        username                \u003cusername\u003e  HTTP Authentication username\n        zoom                    \u003cfloat\u003e     Use this zoom factor (default 1)\n    \n    Headers And Footer Options\n        footer-center*           \u003ctext\u003e     Centered footer text\n        footer-font-name*        \u003cname\u003e     Set footer font name (default Arial)\n        footer-font-size*        \u003csize\u003e     Set footer font size (default 11)\n        footer-html*             \u003curl\u003e      Adds a html footer\n        footer-left*             \u003ctext\u003e     Left aligned footer text\n        footer-line*                        Display line above the footer\n        footer-right*            \u003ctext\u003e     Right aligned footer text\n        footer-spacing*          \u003creal\u003e     Spacing between footer and content in mm (default 0)\n        header-center*           \u003ctext\u003e     Centered header text\n        header-font-name*        \u003cname\u003e     Set header font name (default Arial)\n        header-font-size*        \u003csize\u003e     Set header font size (default 11)\n        header-html*             \u003curl\u003e      Adds a html header\n        header-left*             \u003ctext\u003e     Left aligned header text\n        header-line*                        Display line below the header\n        header-right*            \u003ctext\u003e     Right aligned header text\n        header-spacing*          \u003creal\u003e     Spacing between header and content in mm (default 0)\n    \n    Table Of Content Options\n        toc-depth*               \u003clevel\u003e    Set the depth of the toc (default 3)\n        toc-disable-back-links*             Do not link from section header to toc\n        toc-disable-links*                  Do not link from toc to sections\n        toc-font-name*           \u003cname\u003e     Set the font used for the toc (default Arial)\n        toc-header-font-name*    \u003cname\u003e     The font of the toc header (if unset use toc-font-name)\n        toc-header-font-size*    \u003csize\u003e     The font size of the toc header (default 15)\n        toc-header-text*         \u003ctext\u003e     The header text of the toc (default Table Of Contents)\n        toc-l1-font-size*        \u003csize\u003e     Set the font size on level 1 of the toc (default 12)\n        toc-l1-indentation*      \u003cnum\u003e      Set indentation on level 1 of the toc (default 0)\n        toc-l2-font-size*        \u003csize\u003e     Set the font size on level 2 of the toc (default 10)\n        toc-l2-indentation*      \u003cnum\u003e      Set indentation on level 2 of the toc (default 20)\n        toc-l3-font-size*        \u003csize\u003e     Set the font size on level 3 of the toc (default 8)\n        toc-l3-indentation*      \u003cnum\u003e      Set indentation on level 3 of the toc (default 40)\n        toc-l4-font-size*        \u003csize\u003e     Set the font size on level 4 of the toc (default 6)\n        toc-l4-indentation*      \u003cnum\u003e      Set indentation on level 4 of the toc (default 60)\n        toc-l5-font-size*        \u003csize\u003e     Set the font size on level 5 of the toc (default 4)\n        toc-l5-indentation*      \u003cnum\u003e      Set indentation on level 5 of the toc (default 80)\n        toc-l6-font-size*        \u003csize\u003e     Set the font size on level 6 of the toc (default 2)\n        toc-l6-indentation*      \u003cnum\u003e      Set indentation on level 6 of the toc (default 100)\n        toc-l7-font-size*        \u003csize\u003e     Set the font size on level 7 of the toc (default 0)\n        toc-l7-indentation*      \u003cnum\u003e      Set indentation on level 7 of the toc (default 120)\n        toc-no-dots*                        Do not use dots, in the toc\n    \n    Outline Options\n        dump-outline*            \u003cfile\u003e     Dump the outline to a file\n        outline*                            Put an outline into the pdf\n        outline-depth*           \u003clevel\u003e    Set the depth of the outline (default 4)\n    \n    Options marked * may not work on some servers.\n\n## Known issues and limitations\n\n- Does not work on Windows based systems\n\n## Contributing\n\nContributions in any form are welcome.\nPlease consider the following guidelines before submitting pull requests:\n\n- **Coding standard** - It's mostly [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) with some differences. \n- **Add tests!** - Your PR won't be accepted if it doesn't have tests.\n- **Create feature branches** - I won't pull from your master branch.\n\n## License\n\nHtmlToPdf is free software distributed under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspiritix%2Fhtml-to-pdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspiritix%2Fhtml-to-pdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspiritix%2Fhtml-to-pdf/lists"}