Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Printing more than one PDF

Posted on 2009-05-07
3
Medium Priority
?
729 Views
Last Modified: 2012-05-06
Issue:
Printing PDFs (more than one) from VB Desktop App.

Background:
I have a Windows App in VB .NET 2005, with the imported Adobe SDK, the dlls are:
AxInterop.AcroPDFLib.dll and Interop.AcroPDFLib.dll, this allows me to add a component to my form, an AxAcroPDFLib.AxAcroPDF which I have named AxAcroPDF1
I have the following code (Code 1 below)  to print a PDF file which WORKS perfectly, but as you can see is just one PDF.

The problem:
The code 2 and Code 3, I though they will work to print more than one PDF, but actually they don't, Code 2 prints only one of them, the last in the list, and Code 3 doesn't print any.
Adobe Reader remains open after the printing is done, which is not really important but I will appreciate if somebody knows how to shut it down automatically.

Additional Notes:
I tried to use another way to print, like the System.Drawing namespace, and the trick creating a new process and do a Process.Start, but this won't work on my case because they are changing my page size not sure why.

'Code 1
AxAcroPDF1.LoadFile("C:\PDF\MyPDF.pdf")
AxAcroPDF1.printAll()
 
'Code 2
For Each file As String In FileList
    AxAcroPDF1.LoadFile(file)
    AxAcroPDF1.printAll()
Next
            
'Code 3
For Each file As String In FileList
    AxAcroPDF1.LoadFile(file)
Next
AxAcroPDF1.printAll()

Open in new window

0
Comment
Question by:EVilla1979
  • 2
3 Comments
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 24330996
Is that FileList an array of strings? Debug it and check for each iteration the file path
0
 

Author Comment

by:EVilla1979
ID: 24331010
Yes it is.
Debugging step by step, the first load doesn't do anything, just the last one.
0
 

Accepted Solution

by:
EVilla1979 earned 0 total points
ID: 24335328
I found a turn around.
I changed the default printer to be another one and the page size in the printer properties, so maybe the problem of the size changing was part of that.
However I am still open to give away the 200 points if somebody tells me how to close the Acrobat once it has finished the printing.
Thanks.
For Each file As String In FileList
   Dim p As New Process
   p.StartInfo.FileName = s
   p.StartInfo.Verb = "Print"
   p.Start()
   p.Close()
   p = Nothing
Next

Open in new window

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

971 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