Open PDF and Show

How i can open a PDF file and show it on Desktop App

I’m sure there are many ways of doing it, but here are a couple.

//Get the PDF file as a folderitem
dim f as FolderItem = SpecialFolder.Desktop.Child("guide.pdf")

//You could launch it to open it in the default PDF viewer
f.launch

//Or you could load it in an HTMLViewer on a window
HTMLViewer1.LoadPage f

Thanks

Or display it in a Canvas; same code as to display an image.

ok thanks

Which option will make the text selectable ? as inside the app I’m making ? I’m using DrawCGPDFDocument inside a paint/canvas now. I’m retrieving the PDF from inside a database as a memoryblock/BLOB.

How to I use HTMLViewer with a CGDataProviderMBS and CGOpenPDFDocument ??

If you need a PDF rasterized cross platform, you can look in our DynaPDF Pro plugin.

Hi Christian,

I don’t need a rasterized version, I just need to have the pdf there and to select text inside it. So that the user can copy and paste from it.

/Helge

My guess is that your best bet is to get the PDF as a folderitem and then launch it. Not all PDFs have selectable text, though.

An HTMLViewer will let you select and copy text in a PDF.

Cool. I needed to do the same thing, launch a PDF and its viewer. It works. Thanks.

I’d like to add that there is no guarantee that HTMLViewer will display your PDF. I tried with 3 different Windows machines and only 1 was capable of showing the PDF… the other two complained about DLL errors. I found a solution in using .XPS files. Like PDF, only lightweight and can be produced on any Windows platform with a guarantee to load in the HTMLViewer (and very fast).

You can always write your own little viewer with our MBS DynaPDF plugin.
(we have examples)

how do you create .XPS file from HTML??

When I try to load a PDF into the HTMLViewer the program crashes using Bill’s code. It launches the PDF fine. Launching or sending an HTML file to the HTMLViewer also worked. But loading a PDF into the HTMLViewer always bombs for me.

On what OS ?
macOS HTMLViewer basically has a PDF viewer (preview) built in as part of the OS control
Not so on Windows or Linux

I’m running MacOS 10.15.1 Catalina
and XOJO Version 2019 Release 2.1