You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PDF assets are common (downloads, job applications, document libraries), but they can't use Craft's transform system today. setTransform() / getUrl() only work for image types — PDFs are excluded from canManipulateAsImage().
It would be useful if PDFs could be treated like other assets for transforms: pick a page, resize, and output as webp / jpg / png via the same API used everywhere else.
Proposed behaviour
{% do asset.setTransform({ width: 800, format: 'webp' }) %} works on PDF assets
asset.url, getSrcset(), etc. return rasterized previews (first page by default)
GraphQL transforms work the same way (@transform on PDF assets)
Opt-in globally via config (e.g. transformPdfAssets: true), since it depends on Imagick/Ghostscript
Use case
Show a WebP preview/thumbnail of a PDF on the front end without a separate plugin or custom Twig filter.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
PDF assets are common (downloads, job applications, document libraries), but they can't use Craft's transform system today.
setTransform()/getUrl()only work for image types — PDFs are excluded fromcanManipulateAsImage().It would be useful if PDFs could be treated like other assets for transforms: pick a page, resize, and output as
webp/jpg/pngvia the same API used everywhere else.Proposed behaviour
{% do asset.setTransform({ width: 800, format: 'webp' }) %}works on PDF assetsasset.url,getSrcset(), etc. return rasterized previews (first page by default)@transformon PDF assets)transformPdfAssets: true), since it depends on Imagick/GhostscriptUse case
Show a WebP preview/thumbnail of a PDF on the front end without a separate plugin or custom Twig filter.
Beta Was this translation helpful? Give feedback.
All reactions