Goal
Product's DAM Update Asset Workflow (executed on file upload) does not generate renditions of HTML files (whether HTML files uploaded to Assets can serve as web pages from AEM is not discussed here...)
In the following steps we use CommandLineProcess workflow step in DAM Update Asset workflow to generate PNG (or PDF) renditions of HTML files on upload
To generate PDFs of Sites pages on activation check this post
Demo | Package Install | Github
Solution
1) Install library
wkhtmltopdf
from https://wkhtmltopdf.org/ (command line tool to render HTML into PDF and various image formats)2) Modify the DAM Update asset workflow - /conf/global/settings/workflow/models/dam/update_asset to add a Command Line step for converting the uploaded HTML file to PNG
1. Drag and drop Command Line step
2. Specify the allowed mime types - text/html
3. A workaround step to rename the temp file generated by command line process to include .html extension
cmd /c ren ${file} ${filename}.html
4. Execute command to generate the image rendition (you may have to adjust based on output quality, screensize etc.)
C:/dev/install/wkhtmltopdf/bin/wkhtmltoimage.exe --height 1200 ${file}.html thumbnail.png
3) Upload a html file e.g. eaem.html
4) Rendition thumbnail.png generated and added as eaem.html/jcr:content/renditions/thumbnail.png
No comments:
Post a Comment