WEB: PDF display example by Javier Menendez unfortunately does not work as expected

Hello Javier,

I hope you read this. Unfortunately, your example at How To Download and Preview PDFs in Xojo Web Apps – Xojo Programming Blog does not work for me.

My experiment conditions:
Xojo 3.2 Windows
Web App Development
Firefox 102.5.0esr
Acrobat is set up in Firefox as a program for displaying PDF’s.

hapr_PDFWebFile = New Webfile

If( hapr_PDFWebFile <> Nil ) Then

//
// that’s the magic…
// Erlaeutert unter How To Download and Preview PDFs in Xojo Web Apps – Xojo Programming Blog
//
hapr_PDFWebFile.ForceDownload = False

hapr_PDFWebFile.Data = hapr_PDF.ToData

hapr_PDFWebFile.MIMEType = “application/pdf”

//hapr_PDFWebFile.Filename = hapr_TempDatei.Name

//hapr_PDFWebFile.ForceDownload = True

//Call hapr_PDFWebFile.Download

//hapr_PDFWebFile.ForceDownload = False

//
// Der letzte Schritt beim Aufruf ist nun nur noch …
// z.B. HTMLViewer.LoadURL( hapr_PDFWebFile.URL )/
//
End If

Already in the line ‘hapr_PDFWebFile.MIMEType = “application/pdf”’ the download is done by the browser and the display in Acrobat. If I activate the rest of the code a second download takes place. So that afterwards two equal PDF’S are displayed in Acrobat. In the HTML Viewer, however, it is not displayed at all.

But actually I want to prevent that anything is displayed in Acrobat at all. I only want it to be displayed in my Web App in the HTML Viewer. Do you see a chance there?

Best regards
Ralf

Hello all,

I tried again and found a way to display the generated PDF in the HTML Viewer.

The most crucial was to change Firefox so that it displays PDF downloads and not the external program Acrobat.

And it remains only the following lines are sufficient for this:

hapr_PDFWebFile.ForceDownload = False

hapr_PDFWebFile.Data = hapr_PDF.ToData

hapr_PDFWebFile.MIMEType = “application/pdf”

hapr_PDFWebFile.Filename = hapr_TempDatei.Name

//In the Show Event des HTMLViewers:
me.LoadURL( hapr_PDFWebFile.URL )

Now I will install the whole thing on a Linux server and then test it again.

Best Regards

Ralf

2 Likes

Yeah, the way a PDF file is handled by the navigator varies… specially on Windows / Linux, where they “tend” to use the external app helper instead of displaying it in the frame. :slight_smile:

Hi Ralf,

for me PDF Viewer from @Anthony_G_Cyphers is a great option.

https://demo2.graffitisuite.com/

Andreas

1 Like