Google App Conversion API API not working with BackendError

I am trying to convert html to pdf .
The conversion works fine if I do not include any images, but if I include images, it is not with error code 3 and Description BackendError .
I mean the image resource included as static / thumb.jpg in my html resource.

 def prepare_bar_attachment(bars): asset = conversion.Asset('text/html', render_template('bar/print.html', bars=bars), 'print.html') thumbnail = None if bar.thumbnailurl: img_response = urlfetch.fetch(bar.thumbnailurl) if img_response.status_code == 200: thumbnail = conversion.Asset('image/jpeg', img_response.content, 'thumb.jpg') conv = conversion.Conversion(asset, 'application/pdf') if thumbnail: conv.add_asset(thumbnail) result = conversion.convert(conv) if result.assets: attachment = [('Bars.pdf', result.assets[0].data)] else: attachment = [] app.logger.error('Error Code: %s\nDescription\%s'%\ (result.error_code, result.error_text)) return attachment 
+4
source share
2 answers

This is probably due to the fact that the elements you specified as static in your application. yaml may not be accessible by your application code. Try either to include the image somewhere inside your code, or not matching the images as static in app.yaml.

It sounds like this because the img src path in the html resource must match the resource path.

+2
source

In my case, a BackendError was thrown when I referred to an image that was not represented as an asset.

Curiously, when the image referred to CSS, but the CSS rule was not applied, it worked fine.

An error occurred while starting the HTML, and the previously unused CSS rule - a reference to a missing image object - was applied to a new / changed HTML element.

So, it’s normal to refer to missing image objects in CSS if these CSS rules are not used by themselves.

0
source

Source: https://habr.com/ru/post/1392072/


All Articles