?
Solved

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

Posted on 1999-01-05
8
Medium Priority
?
282 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: 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!

 
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
 
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 400 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

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

800 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