Sunday, 4 July 2021

converting Gmail to PDF: embedded images in HTML

I am using the Gmail API to download e-mails. When these e-mails are HTML, I try to convert them to PDF using Python's pdfkit.

This works in many cases but in some cases the html payload contains image tags like src=“cid:169abdc4ae2c4da871d2”.

It seems that this "cid" tag refers to an image sent as part of the multipart e-mail, but this cannot be processed by PDFkit. Error is:

wkhtmltopdf reported an error:
Loading pages (1/6)
Error: Failed to load cid:169abf0d0cdfffb7aff2, with network status code 301 and http status code 0 - Protocol "cid" is unknown

How can I solve this? Is there a way to convert this HTML I get from the gmail payload to standard HTML with proper picture sources?



from converting Gmail to PDF: embedded images in HTML

No comments:

Post a Comment