Help with proper location for a pdf displayed in a WebHTMLViewer

In my setup I have a database server listining on port 80 and redirects the request for my Xojo web app to port 8882 where Xojo is listenting and manages the remainder of the session. Both are on the same computer.

The database server manages the creation of the PDFs and passes a path back to Xojo when requested, which in turn supplies the returned path to a WebHTMLViewer.URL. Looks something like this…

Xojo: http://host.com/reqForm?formID=1234 → returnedPath (Database server creates PDF and retrurns path to file in database server’s web folder.)
Xojo: HTMLViewer1.URL = http://host.com/returnedPath

This works fine. The only problem is that HTMLViewer1.Print does not work. As I understand the documentaion, this is because Xojo is listening on port 8882 and the URL is addressed to the default port 80…

I am confused now how I should be doing this. In my first attempt at this I loaded the HTMLViewer using a WebFile to the PDF file. This displayed the file in the HTMLViewer and HTMLViewer.Print worked as well. But I soon found that this only worked while running in debug on the server machine. Using a remote client did not work, I think because the WebFile is pointing to a file on the client machine, which in debug is the same machine as the web app…?

I think the solution is to instead of having the database server serve the PDF, have the Xojo WebApp serve the PDF, but I cannot figure out to do this with the pdf file residing on the WebApp machine. I did try…

HTMLViewer1.URL = http://host.com:8882/returnedFullPath
returnedFullPath is the full path to the pdf, i.e. Volume/myWebFolder/formsFolder/myFile.pdf.

In this case nothing loads.

Thanks,

John

You can turn the pdf into a webfile and serve that up. There should be an example of how to create a webfile in the docs or in the included example projects. I’m too lazy to check, but I think that will help you solve the problem as long as the PDFs aren’t super big.

Isn’t a webfile a path to a file or folder on the user’s machine? I know how to create a we display and print a pdf on the user machine in an HTMLViewer.
If the database server returns the following path on the server machine, however…

How do you create a webfile referencing a PDF on the server and display and print it in an HTMLViewer in a remote client browser. Something like this?

[code] 
  Dim pdfWebFile As New WebFile
  pdfWebFile.Filename = returnedFullPath
  HTMLViewer1.URL = "http://"+host.com+": 8882/"+pdfWebFile.URL[/code]

I don’t get any errors but do not get anything in the HTMLViewer in debug mode.

To keep the WebFile from going out of scope, it should be a property of the webpage, session or app.

See this other thread recently about pdfs in HTMLViewer.

You would open returnedFullPath as a FolderItem, then use the open method of WebFile and serve the URL address of your WebFile.

dim f as FolderItem = GetFolderItem( returnedFullPath ) If f <> Nil and f.Exists Then WebPage1.pdfWebFile = WebFile.Open( f ) WebPage1.pdfWebFile.ForceDownload = False WebPage1.pdfWebFile.UseCompression = False WebPage1.pdfWebFile.MIMEType = "application/pdf" HTMLViewer1.URL = "" HTMLViewer1.URL = WebPage1.pdfWebFile.URL End If

My apologies to everyone who responded.

I had it working with a webfile in debug mode for several weeks and then it broke when I first deployed it this week. I then made a few bad assumptions as to why it no longer worked when deployed and so changed things which then broke HTMLViewer.Print.

Turns out that the problem was a single charecter in the file path that only existed on the production server. On the production server the path contained a folder name containing the character ƒ (option f) which was not being properly encoded when the database server sent back the file path.

I am back to using the WebFile and all is working well.

John