Search code examples
pdfvb6adobeacrobat

Unusual behavior with AcroPDF viewer


I'm working on an old VB6 application and I'm trying to include a .pdf viewer in my application. Previously we were using .snp extensions, however, we decided to make a switch to PDF's since Win10 does not like .snp.

Anyway, I'm trying to have two controls in my form, 1 for snaps and 1 for pdf, so I'm using snap viewer, and AcroPDF viewer. The Component name I'm using for the AcroPDF is

Adobe Acrobat 7.0 Browser Control Type Library 1.0

on Form_LOad i check for extension, and depending on what it is, that's the control i display.

Here's the interesting part - when I create an .exe and run it, it works like a charm, no issues whatsover. The weird behavior I get is when I run it out of IDE, regardless of whether I try to view the .pdf or .snp file, I get an empty message box. Also, if it happens to be a .pdf document, it doesn't display anything in the viewer, however, snaps work.

Here's the image of the message box... enter image description here

I am not doing anything unusual with this... on form load, i simply check the extension and either make set it to Visible or not...For the directory, i do something like this..

pdfViewer.src = C://...directory

Like I said, this works fine when run out of .exe but gives me the message box when running out of IDE> Any help will be appreciated.


Solution

  • The PDF problem maybe because Adobe has migrate the library to 64bit, this break the compatibility with applications (written on any programming language that use this components). A simply solution is to avoid to add the reference of Adobe library in your project (early-binding), and use instead on late-binding as explained on the below article (with sample project for VB6.0 and VB.NET) where you can load a PDF in Form or PictureBox:

    PDF in VBForm with no OCX/DLL (late binding)

    http://nuke.vbcorner.net/Articles/VB60/PDFinVBFormwithnoOCXDLLlatebinding/tabid/120/language/en-US/Default.aspx