Solved

Printing more than one PDF

Posted on 2009-05-07
3
682 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
Comment Utility
Is that FileList an array of strings? Debug it and check for each iteration the file path
0
 

Author Comment

by:EVilla1979
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now