Link to home
Start Free TrialLog in
Avatar of Pirie
Pirie

asked on

How can I create a PDF from VB6 without using a 'pseudo printer' app?

I am looking for a control with which my VB6 app can create a PDF document such that:

1. No pseudo-printer application like PDFCreator needs to be installed (not allowed by our customer)

2. The PDF control is plug-compatible with  the printer object of VB6 without the need for extra coding (saves work!)


In fact, what we are looking for is an extension of VB6's possibility of printing to a Picture box and the PRINTER object using 99% compatible code.

In our current program, we first print information to a picturebox object on a form:

                Call PrintReport(frmPrint.picPrint)

and then 'show' the screen.

The coding of the subroutine is similar to the following:

                Sub PrintReport(lvObj)

            lvObj.CurrentX = 10

            lvObj.CurrentY = 5

            lvObj.Print "Hello World"

                end sub

 

If the user is satisfied with the result and wants to print this text to a printer then the subroutine is called again, but now with the Printer object as argument:

                Call PrintReport(Printer)

and the result will be printed on the default printer.

Up until now, we have been using PDFCreator as the default printer to create a PDF but the customer now wants to avoid having to install extra programs like this.

So we are looking to be able to create a PDF document using subroutine PrintReport but using a 'PDF Control' as the argument for the subroutine. Something like

                Call PrintReport('some PDF Control')

, resulting in a PDF Document with a standard name and location.


Does somebody have any idea how I could achieve this?
Avatar of aikimark
aikimark
Flag of United States of America image

What software is on the target PCs? (OS, apps, utilities)

Are the PCs connected to a network?  If so, install just one PDF creator application and have everyone print to that pseudo-device on the network.

Does your application produce single-page documents or multi-page documents?
If the customer owns licenses for Adobe Acrobat (not just the reader) on all the computers, then you might be able to do it with Adobe's API.

There is nothing built into VB that allows manipulation of PDFs so you will need to install something at some point. Since PDFCreator is working, you should probably just stick with it. There is no simple, easy, cheap fix to what you want to do.
@Tommy

That is why I asked my questions.  There are applications and utilities that can create a PDF.  Many people don't know they exist or were installed on their corporate PC.
Avatar of Pirie
Pirie

ASKER

The last suggestion, using the mjwPDF class, comes close to achieving to what I'm looking for since it doesn't seem to require other applications to be installed.

However, it doesn't seem to support the same methods that the VB Print statement does. Therefore I would have to write 2 sets of code - one for the screen and 'real' printer and one for the PDF. I'm trying to avoid this if possible (by the way, the coding I showed in my question was just to demonstrate the technique - the real coding stretches to many more statements).

Thanks any way.


Are there any more  suggestions before I award the points?
SOLUTION
Avatar of TommySzalapski
TommySzalapski
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Pirie

ASKER

TommySzalapski:

By two sets of coding I meant
1. Using the VB6 Print methods to output the contents of the proposed PDF to an Image control so that the user can approve it (as now).
2. If approved by the user, using the (different) methods of the mjwPDF class to do the same and produce a PDF.

Alkimark:

If I understand correctly, you are suggesting a slightly different approach:
1. Using the VB6 Print methods to output the contents of the proposed PDF to an Image control so that the user can approve it (as now).
2. If approved by the user, using the (different) methods of the mjwPDF class to output the contents of the Image control to a PDF.
Yes, that would seem to minimise the amount of extra coding.

It seems to me that the solution lies in the mjwPDF class. I'll need a few days to try a few things out and I'll then get back to you.

Thanks everybody for your help so far.

Pirie
I assume when you say "image control" that you mean a picturebox control.  The VB image control is mostly a collection container for images.  It doesn't have the graphics methods that the picturebox control has.
Avatar of Pirie

ASKER

Thanks for the correction. You're right of course.
You could potentially use a pdf viewer control instead of a picturebox control. The benefit there would be that you may have more of a guarantee that what the user sees is what he gets. Also, it could avoid the "two sets of codes" thing.
Avatar of Pirie

ASKER

Do you know of a pdf viewer control that can be loaded with content using the Print method of VB6?
No. As far as I can tell, such a tool does not exist.

Which print method are you referring to anyway?
Avatar of Pirie

ASKER

I referred to the Printer control in VB6
Avatar of Pirie

ASKER

Alkimark:
Thank you for your advice. I tested your idea, but came to the conclusion that by making the PDF using the picturebox the quality of the print is not as good as when I print it directly via the Printer control. For example the letters on the print are not as sharp. Unfortunately for this reason your advice does not solve my problem.

Are there any more  suggestions?
Is the picturebox the same size as a sheet of paper when you are doing your Print operations?  You said you were doing print preview and enlarging any graphic will cause the fuzziness, dithering, and jagged edges you might be seeing.
Avatar of Pirie

ASKER

Yes it is the same size. But if I send the screen preview as a picturebox to a PDF, it is less sharp the a PDF that is created using the PDF printer driver.
How are you creating the PDF from the picturebox?  Please paste your code and pertinent details.
Avatar of Pirie

ASKER

Thank you all for your help. I will look for a solution by adding a class module to my coding