Solved

Printing more than one PDF

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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 (3.5 Framework) Remove all items from List 3 32
SqlServer no dupes 25 38
VB.net and sql server 4 45
Help with opening combobox using VB.NET. 3 26
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…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

820 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