Error downloading PDF report

Hi there,

When generating a PDF report…

Client Side

pdf = anvil.server.call('create_pdf_dk', demo, bio, calc)
anvil.media.download(pdf)

Server Side

from anvil.pdf import PDFRenderer

@anvil.server.callable
def create_pdf_dk(demo, bio, calc):
  
  pdf = PDFRenderer(page_size="A4",quality="original",filename=fileout).render_form("ToolsUI.DoubleK_PDF", demo, bio, calc)
  return pdf

Using an iOS device I get the following error:

Safari cannot open the page. The error was: “The operation couldn’t be completed. (WebKitBlobResource error 1.)”.

Any insight on this?
Thanks!

Does it work on all other devices? If so this might be a bug.

All I have to test is a Windows PC (works fine in Gecko engine and Chromium engine browsers) and two iOS devices which give the above mentioned error.

Any suggestions?

Hi @mglraimundo,

Do you have a clone link you could share so that we can take a look for you?

Thanks!

2 Likes

Sure. You just need an iOS device to replicate the issue.

https://anvil.works/build#clone:NY7ZUA7GXQFJT3UA=2LPGIWFHM62NDNH26UOPCK3S

Bump

(I’ve done some research and this might be a mobile Safari bug)

Hi @mglraimundo

Yes, looks like it’s a bug in Safari 12

1 Like

Hi,

I am facing a similar issue, but regarding csv file downloads in mobile safari ( my iOS is updated to 13.6.1 )
Is this also a bug ?? the downloads work fine on computer, but on mobile it seems to open on another page and display the error message “The operation couldn’t be completed. (WebKitBlobResource error 1.)”

Do let me know if there is a workaround this problem or one has to wait for the bug to be fixed.

It’s the same bug.

As a workaround, save the csv to a datatable media column, trigger the download from the client side and then delete that datatable row. It’s what I’m doing and works well enough.

1 Like

Hi ,

Thanks so much for the suggestion. You see, I am a beginner so it would take a while for me to figure it out myself.

Thus could you perhaps share a clone of the app or code which makes use of this method. It would make things alot easier for me.

Thank you again.

Yeah, it’s in the demo above, just check the workaround button and follow the code.

1 Like