Displaying a PDF

On the Mac, getting a picture object from a PDF file like…

[code]dim f As FolderItem = SpecialFolder.Desktop.Child(“My Folder”)
if f <> NIl and f.Exists Then
f = f.Child(“easy.pdf”)

if f <> Nil and f.Exists Then
  curPic = Picture.Open(f)
  picCnv.Invalidate
else
  MsgBox "Error getting pic"
end if

end if[/code]
and then displaying it in a canvas with g.drawpicture curPic, etc…
works just fine.
I can’t get this to work on Win. I seem to get the picture object OK, but nothing displays. Is it not possible to display a PDF as a picture in Win, or might I still be doing something wrong?

Apple’s graphics libraries are able to treat PDFs as a picture but Windows libraries do not. Since Xojo uses a platform’s native libraries you are limited to what the underlying platform supports.

On a recent system I wrote in another language on Linux I used ImageMagik’s convert command which worked quite well. Should work about the same on Windows. If you are planning on distributing the software you will want to look into the license as well.

The HTMLviewer should work for displaying PDFs.

  • Karen

Thanks for that info, Bob. I suspected as much.
Interesting idea I hadn’t considered, Karen. I’ll take a look. Thanks

I was never able to obtain the Windows HTMLViewer to display PDF, native renderer or WebKit :frowning:

HtMLViewer is depending on Windows. So far, I’ve been lucky by displaying PDF’s on only one machine. All the others (4) complained about missing DLL’s or simply no display. That’s why I shifted to .XPS. That’s PDF, but without the overhead. Fast to render and guaranteed to display on Windows.

You can use our DynaPDF Plugin to raster a picture from a PDF page on Windows. No problem.

For HTMLViewer (Native with IE) you need to install a PDF plugin there.

christian, how do i raster a picture from PDF page on Windows.?? which sample in your sample folder?

Did you see the Raster folder in the DynaPDF examples?
There are a couple of them.

I have, but not recently.

  • karen

Seems that it works only when Acrobat Reader and its plugin reader is installed. Otherwise in native mode it offers to open the file in an external program, and with Webkit nothing happens at all.

On Windows 8.1 without Acrobat Reader installed, the system does not know what PDF is at all.

DynaPDF or some other renderer seems to be the only way to reliably display PDF on unknown Windows systems.

[quote=97514:@Michel Bujardet]Seems that it works only when Acrobat Reader and its plugin reader is installed. Otherwise in native mode it offers to open the file in an external program, and with Webkit nothing happens at all.

[/quote]

Last time I did it on a PC was before we had the webkit option ,so it was in native mode. while I did not think about it, of course Acrobat reader was already installed… it is pretty ubiquitous.

I would think requiring Acrobat reader to be installed would not be a big issue for an app, as it is pretty universal as most people want to be able to read PDFs in their browser.

Hi. Just wondering. Is this still the best way to go around displaying PDFs inline in a window? (in windows)

I’m being asked to replace an old, sourceless VB program that’s been used in the system for over a decade to display and tag multipage TIFFs. One of the changes that the business wants to do is to migrate everything to PDF.

I have seen using webkit as the only viable option for multi-page PDFs in Windows. I don’t see why this wouldn’t work but I assume whatever the plug-in displays, the app itself is “blind” to it, right? For example, if the users wanted to select an area to “tag” it they just wouldn’t be able to.

I find it frustrating that I might end up having to build this in html5 with pdfjs (from Mozilla, works very nicely) because there’s no native handling of multi-page PDFs.

I don’t have permission of using external closed-source plug-ins, either. So not an option either :frowning:

I could maintain TIFF as a format, but then I’d lose the enormous space savings and the inherent advantages of storing vectorial images instead of bitmaps.

I know a few people (including me) wrote a PDF Viewer in Xojo based on MBS DynaPDF Pro Plugin.
check the “PDFPreview Window.rbp” project.

[quote=175912:@Eduardo Gutierrez de Oliveira]Hi. Just wondering. Is this still the best way to go around displaying PDFs inline in a window? (in windows)

I’m being asked to replace an old, sourceless VB program that’s been used in the system for over a decade to display and tag multipage TIFFs. One of the changes that the business wants to do is to migrate everything to PDF.

I have seen using webkit as the only viable option for multi-page PDFs in Windows. I don’t see why this wouldn’t work but I assume whatever the plug-in displays, the app itself is “blind” to it, right? For example, if the users wanted to select an area to “tag” it they just wouldn’t be able to.

I find it frustrating that I might end up having to build this in html5 with pdfjs (from Mozilla, works very nicely) because there’s no native handling of multi-page PDFs.

I don’t have permission of using external closed-source plug-ins, either. So not an option either :frowning:

I could maintain TIFF as a format, but then I’d lose the enormous space savings and the inherent advantages of storing vectorial images instead of bitmaps.[/quote]

XPS is fine under Windows. All you need to do is to print the PDF to the XPS printer to convert.

Not an option. I need PDF.

[quote=175918:@Christian Schmitz]I know a few people (including me) wrote a PDF Viewer in Xojo based on MBS DynaPDF Pro Plugin.
check the “PDFPreview Window.rbp” project.[/quote]

Yes. This is my last resort if I can’t find a way around it. At the moment using plugins is out of the question for me, though. Especially since this is a migration from an old platform that we have to leave precisely because we lost support and the product doesn’t work any more in newer Windows versions.

FYI: sudden death, when hitting the print button

sudden death?

Ah, I see you need to open it from file in this example, but it tries to open from data which fails.
I’ll email a new example.

[quote]Yes. This is my last resort if I can’t find a way around it. At the moment using plugins is out of the question for me, though.
[/quote]

Create a project that opens the TIFF files one by one, and prints them on page 1, 2, 3 etc of a normal print graphics object.

When you have that working, install CutePDF or PDF995 or other ‘PDF printer driver’… they are usually free.
(No affiliation)

http://www.cutepdf.com/Products/CutePDF/writer.asp

Set the chosen printer to be the PDF printer driver and you will get multi page PDF created.