• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 285
  • Last Modified:

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

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
Chess
Asked:
Chess
1 Solution
 
chabaudCommented:
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
 
DPickeringCommented:
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
 
chabaudCommented:
I suppose that you are using the PDFwriter printer driver...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
fujicastCommented:
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
 
ChessAuthor Commented:
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
 
chabaudCommented:
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
 
ChessAuthor Commented:
You are good!  I got it to work on the first shot.  Many, many thanks.

Chess
0
 
watyCommented:

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now