Read ALL the docs, quickstarts, and forum posts. A lot of examples and explanations of how to create and download a .pdf, but nothing I can get to work to simply display a .pdf. You’ll see in my code that I’ve tried to implement what I find to be the nearest example, but no dice. I do suspect I’m close.
well, if anyone has any suggestions, great. Otherwise, we just use SmartSheets. Sigh. I’ve read the PyPDF2 documentation, tried everything. Funny, TONS of examples of how to create .pdfs… not much on displaying them. I can print the number of pages!. not exactly what our uses need to do.
Hmm, my guess is that, if you want your browser to display the PDF instead of downloading it, you could probably toggle the appropriate setting in your browser. A Google turned this up which may help.
Otherwise I would imagine that the PDF media object could be put into an Image component. Maybe search docs for media object and Image component. I’m away from the computer at the moment.
Hi,
I’ve had a go at PDF’s recently as well.
This demo App demonstrates how to open and print PDF files stored in Data Tables:
https://anvil.works/build#clone:UFZZPJUQZ4ZPOHN6=GQJGUQVSEZIFXI4VCNJX23NT
I must add that I’m a beginner so I can’t say whether or not this solution is secure/best practice.
Anyway, if it helps you and you have question as to how it works just ask.
Best,
Mark
interesting, I didnt know that you could get a permanent URL with …[‘file’].get_url(False)
using [‘file’].url gives a one-time use link which I think is for some type of security reason.
I’m not sure if there are any downsides to making the path to your app media visible with the permanent URL, but when I need to generate a permanent url to a media object, I use @anvil.server.http_endpoint(’/doc’) to decorate a function that returns the file from the datatable.
This way, the URL that the user sees is domain.com/_/api/doc.
This looks like it wants to work, I’m getting an error indicating that the server module cannot find global JS function ‘show_pdf’ - is there an import or something I’m missing?
Got, thanks… learning as I go… but I do enjoy Anvil
This worked, cannot thank all of you enough. I had to change to custom HTML for my parent form, but I can work the content display to be correct.
Cheers!