Show PDF in HTMLViewer Without File From a String on Windows

We’re using the einhugur pdf plugin to create a pdf. We are showing it in an HTML viewer using HTMLViewer.LoadPage(fPDF). This is working very well. We are currently creating a temporary file with the einhugur plugin and then passing that to HTMLViewer.LoadPage. Since the einhugur plugin can create the PDF as a string and the HTML viewer can display HTML from a string, it would seem logical to skip the temp file and display the PDF without a file. However, when we try this, the viewer just shows the data of the PDF file. Is there a way to set the file type in the HTML Viewer?

Sounds like the content type header isn’t getting set right for PDF. Unfortunately I don’t see anyway to set that in the docs.

Thanks @Kevin Windham

This works but creates new issues:

 sData = "<embed src=""data:application/pdf;base64," + EncodeBase64(sPDFData,0) + """ width=""" + iWidth.ToText +"pts"" height=""" + iHeight.ToText + "pts"" />"

HTMLViewer1.LoadPage(sPDFData, nil)   

I’m now having issues with the HTMLViewer itself. When the window is resized, it goes blank. Attempting to invalidate it or refresh it does not work. And I had to add the width and height of the viewer and that does not work exactly right. There are no problems when a file is created and passed to the viewer, so I will probably just resort to that.

If you have MBS Plugins, you can use HTMLViewer.IELoadHTMLMBS to load html without temporary file and without data URL.
Not sure if it helps for PDF, but maybe the PDF could be in the HTML?.

Could you reload the page on the resized event?

Good idea. Tried that, but it will not reload unless the file content changes.

Thanks for the suggestions. I’m just going to move on with using temp files.