I am using from google.appengine.api import conversion
To allow me to convert an HTML email into a PDF file. The code is below and it works.
However the width of the PDF document slices off the right hand side of my document.
Amy clues how to fix this
asset = conversion.Asset("text/html", message.html, "test.html")
conversion_obj = conversion.Conversion(asset, "application/pdf")
result = conversion.convert(conversion_obj)
if result.assets:
for asset in result.assets:
message.attachments=message.attachments+[(BnPresets.email_filename[0:BnPresets.email_filename.find('.')]+".pdf",asset.data)]
Unfortunately it looks like you cannot control the width (or dimensions) of converted PDF documents. Seems like you can only do this with
.pngimages. Some extra conversion options:*.pngonly)*.pngonly)*.txt,*.html, and*.pdfonly)Note that one way around this could be to convert your html page to a png image (with the correct width), and then re-convert this png image to a pdf document. I wouldn’t advise you to use this method because you would end up using two API calls per conversion, which gets expensive really quickly.
A better way would be to structure the dimensions of your input html page properly such that one-off conversions to PDF documents end up being pretty much identical.