{"id":19060536,"url":"https://github.com/uiii/processwire-fieldtypepdf","last_synced_at":"2025-10-08T05:13:59.450Z","repository":{"id":17202992,"uuid":"19971339","full_name":"uiii/ProcessWire-FieldtypePDF","owner":"uiii","description":"Fieldtype/Inputfield module for ProcessWire allowing easy generation of thumbnails of the PDF files","archived":false,"fork":false,"pushed_at":"2025-02-26T16:09:38.000Z","size":612,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-24T06:53:04.961Z","etag":null,"topics":["fieldtype","inputfield","pdf","processwire"],"latest_commit_sha":null,"homepage":"http://modules.processwire.com/modules/fieldtype-pdf","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/uiii.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-05-20T07:18:56.000Z","updated_at":"2025-02-26T16:08:55.000Z","dependencies_parsed_at":"2025-04-24T06:53:06.101Z","dependency_job_id":"6382358d-6aad-41bc-9e1d-9aa68c63e57f","html_url":"https://github.com/uiii/ProcessWire-FieldtypePDF","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/uiii/ProcessWire-FieldtypePDF","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uiii%2FProcessWire-FieldtypePDF","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uiii%2FProcessWire-FieldtypePDF/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uiii%2FProcessWire-FieldtypePDF/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uiii%2FProcessWire-FieldtypePDF/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uiii","download_url":"https://codeload.github.com/uiii/ProcessWire-FieldtypePDF/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uiii%2FProcessWire-FieldtypePDF/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278891753,"owners_count":26063858,"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","status":"online","status_checked_at":"2025-10-08T02:00:06.501Z","response_time":56,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["fieldtype","inputfield","pdf","processwire"],"created_at":"2024-11-09T00:15:52.061Z","updated_at":"2025-10-08T05:13:59.420Z","avatar_url":"https://github.com/uiii.png","language":"PHP","readme":"# PDF Fieldtype/Inputfield\n\n[![Packagist](https://img.shields.io/packagist/v/uiii/processwire-fieldtypepdf.svg)](https://packagist.org/packages/uiii/processwire-fieldtypepdf)\n\nModule for [ProcessWire CMS](https://processwire.com) allowing you to easily generate images from the PDF files embedded to the site.\n\n1. [Requirements](#requirements)\n2. [Installation](#installation)\n3. [How to use](#how-to-use)\n\t- [In site's administration](#in-sites-administration)\n\t- [In templates](#in-templates)\n4. [API documentation](#api-documentation)\n5. [Tests](#tests)\n6. [Upgrading from 1.0.1 and lower](#upgrading-from-101-and-lower)\n7. [Troubleshooting](#troubleshooting)\n8. [Changelog](CHANGELOG.md)\n\n## Requirements\n\n- Processwire 3+\n- ImageMagick PHP extension\n- Ghostscript\n\n\u003e For ProcessWire 2.x support use version 1.x, maintained in [pw-2](https://github.com/uiii/ProcessWire-FieldtypePDF/tree/pw-2) branch.\n\n## Installation\n\n[How to install or uninstall modules](http://modules.processwire.com/install-uninstall/).\n\n### Via Composer\nIn your ProcessWire installation root run:\n```\ncomposer require uiii/processwire-fieldtypepdf\n```\nLogin to your ProcessWire admin and go to *Modules* \u003e *Refresh* and install the module.\n\nIf you want to read more about ProcessWire and Composer visit [https://processwire.com/blog/posts/composer-google-calendars-and-processwire/](https://processwire.com/blog/posts/composer-google-calendars-and-processwire/)\n\n## How to use\n\n### In site's administration\n\nAdd a field and set its type to `PDF`.\nUse the field the same way as the file field (obviously, this accepts only \\*.pdf files).\nAfter the file is uploaded you will see a small thumbnail of it, just like for image field.\n\nImage generation is highly configurable (image format, extension, background, ...). See the *PDF to image converter* section on field's *Details* tab.\n\n![Field settings](http://i.imgbox.com/xP1dt37q)\n\n### In templates\n\n\u003e There are some backward-compatible API changes against the version 1.0.1 and lower, see [Upgrading from 1.0.1 and lower](#upgrading-from-101-and-lower).\n\nThe PDF field extends file field and adds new hookable [`___toImage($page = 0, $options = array())`](http://uiii.github.io/ProcessWire-FieldtypePDF/dev/class-FieldtypePDF.PagePDF.html#____toImage) method to generate the image from PDF.\n\n```php\n$image = $page-\u003epdfFile-\u003etoImage();\n$image-\u003esize(100, 100);\n```\nMethod accepts two optional parameters. First is the `$page`, which specifies the PDF's page number the image is generated from, default is 0. The exception is thrown if the page is out of range.\n\nThe second is `$options` parameter, which is an array of options to override the options set in administration.\n```php\n$options = array(\n\t'suffix' =\u003e array('suffix1', 'suffix2'), // suffixes used in filename\n\t'forceNew' =\u003e false, // if TRUE the image is regenerated if already exists\n\t'format' =\u003e 'JPEG', // image format\n\t'extension' =\u003e 'jpg', // image file extension\n\t'background' =\u003e '#FFFFFF', // background color used when the PDF has transparent background\n\t'resolution' =\u003e '300x300', // resolution used when reading the PDF\n\t'colorspace' =\u003e Imagick::COLORSPACE_RGB, // colorspace used when reading the PDF\n\t'imagickOptions' =\u003e array( // ImageMagick options\n\t\t'pdf:use-cropbox=true'\n\t)\n)\n```\n\nFor each combinations of *page* and *suffixes* there will be one image. The generated images are saved in page's assets and will be **created only once** until *forceNew* options is TRUE. The image is the instance of `Pageimage`, so you can do with it whatever you can do with the image field. When you delete the PDF file the generated images are deleted too.\n\n## API documentation\n\nGenerate into *doc* directory:\n```\napigen generate -d doc\n```\n\n## Tests\n\n\u003e **DO NOT** run the tests against the production site. They modify the fields, templates and pages as they need, so can potentially damage your site!\n\nPrepare the PW testing installation and export the `PW_PATH` environment variable containing the path to the root of that installation. Copy the module sources in the `$PW_PATH/site/modules/FieldtypePDF` directory.\n\nInstall required packages:\n```\ncomposer install\n```\n\nRun the tests\n```\n./vendor/bin/phpunit\n```\n\n### Test multiple ProcessWire versions (automatically)\n\nYou can also automatically test against multiple ProcessWire versions.\nIt uses [Tense](https://github.com/uiii/tense) tool for it.\n\n1. Install reuquired packages:\n\n\t```\n\tcomposer install\n\t```\n\n2. Run the tests:\n\n\t```\n\tvendor/bin/tense run\n\t```\n\n\u003e **WARNING**: The tool will ask you for database connection parameters.\n\u003e Configure the `db` connection parameters carefully because it\n\u003e creates and drops a database for each ProcessWire installation.\n\n## Upgrading from 1.0.1 and lower\n\nIn 1.1.0 some methods of class PagePDF are deprecated. See the list [here](http://uiii.github.io/ProcessWire-FieldtypePDF/dev/deprecated.html). You doesn't have to make any changes but it is recommended to use the new API, for compatibility with later versions.\n\nInstructions for replacing the deprecated methods:\n\n- `$page-\u003epdf-\u003ethumbnail($width, $height)` replace with the code\n\n```php\n$image = $page-\u003epdf-\u003etoImage();\n$image-\u003esize($width, $height);\n```\n\n- `isThumbnail($basename)` replace with `isImageOfThis($basename)`\n\n\u003e NOTE: There is certain incompatibility between these two methods. While `isThumbnail` returns TRUE for all the images generated from the PDF and also theirs derivatives (e.g. *pdf.jpg*, *pdf.100x100.jpg*), the `isImageOfThis` return TRUE only for the images generated directly from PDF (e.g. *pdf.jpg*). That doesn't change much, because you can use it in combination with `Pageimage::isVariation`.\n\n- `removeThumbnails` replace with `removeImages`\n\n## Troubleshooting\n\n### Thumbnail's colors do not match the colors in PDF\n\nTo fix that, you need to made some changes in ImageMagick delegate files. Detailed instructions can be found here: http://www.lassosoft.com/CMYK-Colour-Matching-with-ImageMagick\n\n### GhostScript exceptions occured\n\nIf you got some *GhostScript* exceptions when generating image, update *GhostScript* and *ImageMagick* to the latest versions.\n\nIf you can't, you can use the **fallback mode**. Turn it on in the module's settings.\n\u003e Be aware of that this will produce low quality images and most of the field type options won't be abvailable.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuiii%2Fprocesswire-fieldtypepdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuiii%2Fprocesswire-fieldtypepdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuiii%2Fprocesswire-fieldtypepdf/lists"}