Solved

Printing more than one PDF

Posted on 2009-05-07
3
698 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

803 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