Retool Mobile β€” How to generate a PDF from HTML offline?

Hi Retool Community!

i need some assistance with my mobile app.
My goal: In a cloud hosted Retool Mobile app, I need to generate a PDF from HTML that the user can print/share while completely offline. The HTML is a multi-section service report (tables, signatures, etc.) which shall be filled with values from several components.

What I’ve tried:

  1. html2pdf.js / html2canvas inside a Mobile JS query β†’ crashes with

    Failed to read a named property 'document' from 'Window': Blocked a frame with origin "null" from accessing a cross-origin frame.
    
    
  2. dom-to-image-more + jsPDF in a JS query β†’ same error as above.

  3. PDF Exporter resource works online, but appears server-side, so not viable offline. I also hit:

    Markdown document exceeded maximum length
    

Is there a supported on-device way to convert HTML β†’ PDF in Retool Mobile (avoiding the sandbox β€œorigin null” issue in JS queries)? Maybe i am even on the wrong track and just didnt configure it correctly. I am also open to any other ways to generate a PDF from Component values.

Any help would be greatly appreciated!

1 Like

Hi @Shurtugal,

I just tested PDF Exporter offline and it worked for me. How many components are in the app you are trying to generate a PDF with? The error message makes me think there may just be a limit for how much markdown can be converted to a PDF at a time.

Hi @Jack_T,
i need to display at least 40 components. I thought so too but i couldn’t find anything about the documentation. I tried it offline again on my mobile machine but still no luck.

@Joseph1 Well, hit me up with some details

Ah that makes sense, we can definitely add details on the max size to the documentation to better help users understand where that function library is going to run into limits.

I want to guess that closer to 20 components would work but would need to do some additional testing. Let us know if you find the sweet spot number that it will work without hitting the max length.