Solved

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

Posted on 1999-01-05
8
277 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Excel VBA combine two working workbooks 8 60
VBA error replacing data 6 40
I need help formating a date variable in my VB.Net application 2 61
Child Form in front 4 49
There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

830 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