Solved

How do I Print a picture on a form to a PDF file?

Posted on 1999-01-05
8
270 Views
Last Modified: 2010-05-03
I have several graphs on a form.  This form needs to be saved as a PDF (Adobe Acrobat) file.  There are several such forms.  I can print using the printform command but it prompts to save each form under a different name.  Therefore, this is not a viable option.

Any help greatly appreciated!!
0
Comment
Question by:Chess
8 Comments
 
LVL 4

Expert Comment

by:chabaud
ID: 1454054
Using PrintForm, when printing is complete, PrintForm calls the EndDoc method to clear the printer.
So you have a print job for each form.

So you have to use the Printer Object.

You can use the Printer.PaintPicture function which only print bmp, wmf, or ico FILES.

Or you can use Printer.hDC and API functions.

Just a question: what do you call graphs on forms ? Do you use MsGraph, PictureBox, form background or any other OCX ?
0
 

Expert Comment

by:DPickering
ID: 1454055
I'm pretty sure you can't just create PDF files without having the proper Acrobat application to do this. I've heard that this Acrobat app will convert Office files (ie Powerpoint, Word, etc) plus numerous other DTP/Graphic files to PDF files, but I don't know whether you can just print a VB Form to a PDF. I'd suggest going to
http://www.adobe.com/prodindex/acrobat/prodinfo.html
for more info. This option is going to cost you however :)

Cheers
Dave
0
 
LVL 4

Expert Comment

by:chabaud
ID: 1454056
I suppose that you are using the PDFwriter printer driver...
0
 
LVL 1

Expert Comment

by:fujicast
ID: 1454057
I've an experience on it.

1. Create a postscript printer driver. Make the target destination port into file.
2. Make sure you've install Adobe Acrobat with Adobe Acrobat Distriller and it's active.
3. Use whatever code you want to print into that POSTSCRIPT Printer.
4. The step no. 3 will generate a postscript file. Use name statement to rename it to whatever.ps
5. Once you've got the postscript file, use Windows API WinOpenFile to open it. (Execute whatever.ps)
6. The step no. 5 will activate the Adobe Distiller and generate PDF file.

I think this is just an automatization of the steps that what we're doing if we want to print something to PDF.

If I've a time, I'll create a sample for you.

Regards,
Fuji
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 1

Author Comment

by:Chess
ID: 1454058
The graphs have been created using First Impression, a third party product. And yes, I am using the PDFWriter Printer Driver.

I take a snapshot of the form and put the contents into a Picture Box Control (which is invisible).  Exporting its contents to a PDF file (given that I have over 100 such forms and need to export them to one file) is challenging.
0
 
LVL 4

Accepted Solution

by:
chabaud earned 100 total points
ID: 1454059
If you already have your pictures in a PictureBox, you can use the function Printer.PaintPicture to print them all in one PDF.
Try this sample. I have put in a form one commandbutton and two picturebox.

Option Explicit

Private Sub Command1_Click()

    'Select the PdfWriter...
    Dim p As Printer
    For Each p In Printers
        If Left(p.DeviceName, 17) = "Acrobat PDFWriter" Then
            Set Printer = p
            Exit For
        End If
    Next

    'Load pictures
    Picture1.Picture = LoadPicture("myphoto.jpg")
    Picture2.Picture = LoadPicture("mysister.jpg")

    'Start to print the picture box content

    Printer.PaintPicture Picture1.Picture, 0, 0
    Printer.NewPage
    Printer.PaintPicture Picture2.Picture, 0, 0
    Printer.EndDoc
   
End Sub

0
 
LVL 1

Author Comment

by:Chess
ID: 1454060
You are good!  I got it to work on the first shot.  Many, many thanks.

Chess
0
 
LVL 14

Expert Comment

by:waty
ID: 2331804

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now