Embed PDF inline with HTML source in HTMLViewer

I’d like to be able to display a PDF in a webpage, but not just the PDF - I’ll have other stuff I want to load on the page as well in regular HTML.

So the page will look something like this:

HTML Content
More HTML Content
PDF file displayed
More HTML Content
End of Page

It appears that the googles recommend using either an or tag, which does indeed work when I create a page like the above and load it in my desktop browser. However, when I try the same in an HTMLViewer instance in my app, I get a pop-up that appears that says “AdobePDFViewer cannot find a compatible Adobe Acrobat or Adobe Reader to view this PDF. Please select one.”

It appears to me that this pop-up is generated by the Xojo app, but I certainly did not program it that way.

Has anyone done this? Am I missing something simple?

(by the way, I’m trying this on OS X 10.11, but ultimately I’ll need this on all recent versions of OS X and Windows)

When I point the WebHTMLViewer to the URL of a pdf file, it displays it, scaled.

Try with

me.url = "http://fontmenu.com/xojo/xmetro.pdf"

Then instead of doing it in HTML, use the regular controls like Labels.

@Michel Bujardet - unfortunately, I need to display more than just the pdf in the browser at the same time. See my explanation above about having a PDF file embedded within an HTML page.

For example, I may want to pass something like this to the HTMLViewer:

dim html as String = pageHeaderAndIntro
html = html + "<embed src='http://fontmenu.com/xojo/xmetro.pdf' width='500' height='375' type='application/pdf'>"
html = html + pageClosing
html = html + footerAndCopyright

When I try loading this html into an HTMLViewer on OS X, I get the above error message about it needing the AdobePDFViewer.

Wait. Are we talking about the WebHTMLViewer, or the desktop HTMLViewer ?

Desktop.

OK. On Desktop, it displays just fine on Mac here using LoadPage.

[code]

untitled
[/code]

On PC, you do need a plugin in Internet Explorer to display a PDF that way.

Well. On Windows 10, the Edge browser does support PDF. I was able to open this page with the following shell command :

start Microsoft-Edge:http://fontmenu.com/xojo/untitled.html

Unfortunately, Edge does not take local files.

You may want to consider converting your PDF to picture.

You could load the pdf in an IFRAME html tag.

[quote=242759:@Michel Bujardet]OK. On Desktop, it displays just fine on Mac here using LoadPage.

[code]

untitled
[/code]

On PC, you do need a plugin in Internet Explorer to display a PDF that way.

Well. On Windows 10, the Edge browser does support PDF. I was able to open this page with the following shell command :

start Microsoft-Edge:http://fontmenu.com/xojo/untitled.html

Unfortunately, Edge does not take local files.

You may want to consider converting your PDF to picture.[/quote]

@Michel Bujardet - what version of OS X are you using?

10.11.4

But I have used that method at least since 2013R1.

Interesting - I’m using 10.11.3, as I’m not willing to put beta releases of the OS on my main production machine. In 10.11.3 I’m seeing this issue with loading PDFs into browsers not only in my Xojo-built apps but also in Xojo itself.

<https://xojo.com/issue/42577>

What you were seeing was not a bug in Xojo. We meant to have the PDFs external anyway. Have you tried the iframe solution mentioned? Also keep in mind that you may be seeing an Apple embedded web bug that is resolved in 10.11.4- I don’t have both in front of me to compare.

Yes, I have tried it. Here’s yet another screencast demonstrating what I can only call a bug:

No one else is seeing that Adobe message as far as I’m aware- I’m not. I’d suggest you try removing that from your test machine or test in a fresh VM.

I have tried it on my OSX machine using two different methods

<html>
<body>
    <object data="test.pdf" type="application/pdf">
        <embed src="test.pdf" type="application/pdf" />
    </object>
    
    <iframe id="fred" style="border:1px solid #666CCC" title="PDF in an i-Frame" src="test.pdf" frameborder="1" scrolling="auto" height="1100" width="850" ></iframe>
    
</body>
</html>

BOTH show a white screen… with the IFrame having a border due to the style element.
AND when you mouse over the object area, you get the popup controls indicating it THINKS there is a PDF there,

in SAFARI you see the PDF, AND the popuup controls

BUT I DO NOT GET ADOBE warning

Yes- it seems like there are two issues at play- but neither seem to be Xojo specific.

An Adobe plugin causing messages to pop up in embedded web views, and a possible issue in Apple’s 10.11.3 embedded web view with PDFs that they may have resolved in 10.11.4.

FYI… when I right click on the blank area… it asks if I want to view in PREVIEW… and THAT works.
SO… my opinion is that it IS loading the PDF, but can’t render it, but all events still seem to work.

and that is using just this HTML

<html>
<body>
    <object style="border:1px solid black" data="test.pdf" type="application/pdf" height="100%" width="77%"> 
</body>
</html>

I’d love it if more people using OS X would take a moment to download and test this for me. Just open the enclosed project and hit run. What do you see in the app window that appears?

Make a note of exactly which version of OS X you are trying on. Some will likely work properly, while others may not- as Michel has mentioned earlier.