|
-
Oct 12th, 2011, 08:40 AM
#1
Thread Starter
Frenzied Member
[RESOLVED] Printing PDF Files
Hi everyone,
I am using the adobe pdf control in my app to load a pdf file and I call the PrintAll method to print it. I then tried to loop through pdf files by loading and printing each. But it only prints one. It seems not to runi n synchronous mode. It done one and then is done because it did nto have time to load and print the others? Not sure.
Does anyone know how to print multiple pdf files? I've already tried many codes I saw for calling the pdf with shellexecute and other ways but it does not work. Many of the pdf controls out there are a lot of money! Any suggestions?
Thanks
Warren
-
Oct 12th, 2011, 10:45 AM
#2
Re: Printing PDF Files
Untested but should work...
vb.net Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strPDFFile As String = Dir("c:\*.pdf")
Dim PrintPDFFile As New ProcessStartInfo
Do Until strPDFFile Is Nothing
PrintPDFFile.UseShellExecute = True
PrintPDFFile.Verb = "print"
PrintPDFFile.WindowStyle = ProcessWindowStyle.Hidden
PrintPDFFile.FileName = strPDFFile
Process.Start(PrintPDFFile)
strPDFFile = Dir()
Loop
End Sub
-
Oct 12th, 2011, 11:00 AM
#3
Thread Starter
Frenzied Member
Re: Printing PDF Files
Hack, thanks for the reply! I just tried the code and on the ProcessStart line it gives an error that the system cannot find the specified file.
So I added the path in front of the filename and it works!!! Thank you!!!!
Warren
-
Oct 12th, 2011, 11:37 AM
#4
Thread Starter
Frenzied Member
Re: [RESOLVED] Printing PDF Files
It did work but now have an issue with it. I get the Adobe Reader X screen popup at times and when I close it, the print continues.
I did modify the code to use the files from a listbox. The files are listed without the extensions so you can see where I added the .pdf.
Code:
For X = 0 To ListBox2.Items.Count - 1
Dim V1 As String = ListBox2.Items(X).ToString & ".pdf"
lblFile.Text = V1
Dim strPDFFile As String = Dir("c:\pdffiles\*" & V1)
Dim PrintPDFFile As New ProcessStartInfo
Do Until strPDFFile Is Nothing
PrintPDFFile.UseShellExecute = True
PrintPDFFile.Verb = "print"
PrintPDFFile.WindowStyle = ProcessWindowStyle.Hidden
PrintPDFFile.FileName = "c:\pdffiles\" & strPDFFile
Process.Start(PrintPDFFile)
If btnYes.Checked = True Then
Dim A1 As String = ListBox2.Items(X).ToString
If File.Exists(WLPath) = True Then
Process.Start(WLPath, A1)
End If
End If
strPDFFile = Dir()
Loop
Next
-
Oct 14th, 2011, 09:34 AM
#5
Thread Starter
Frenzied Member
Re: [RESOLVED] Printing PDF Files
Does anyone know how to use this code and not have the Adobe Reader X screen show at times?
Thanks
-
Oct 14th, 2011, 11:45 AM
#6
Frenzied Member
Re: [RESOLVED] Printing PDF Files
I ditched Adobe Reader years ago to print PDF's & now use PDF-Xchange. Much simpler & more reliable in my experience.
-
Oct 14th, 2011, 12:15 PM
#7
Thread Starter
Frenzied Member
Re: [RESOLVED] Printing PDF Files
Thanks for the reply on that product. I just went to their webpage and it looks like a stand alone program. I want to print from within my .net app. I would even use this if I can call it passing the pdf but not see the program at all.
Can this do anything like that?
Thanks,
Warren
-
Oct 14th, 2011, 12:27 PM
#8
Frenzied Member
Re: [RESOLVED] Printing PDF Files
You can print from PDF-XChange viewer by passing command line arguments.
From the manual:
1.8. Command Line option
The PDF-XChange Viewer may be started with a PDF file or URL name as the first item on the command line. This facilitates starting the
Viewer in File Associations or using Windows ShellExecute.
The form of the command line for using this option is:
PDFXCview.exe [command] [filename1] [[filename2] [… [filenameN]]]
Where command can be one of the following commands:
/A "param=value [¶m2=value [&...]"
/close[:save|discard|ask]
/print[:[default=yes|no][&showui=yes|no][&printer=<printername>][&pages=<pagesrange>]]
/printto[:[default=yes|no][&showui=yes|no][&pages=<pagesrange>]] <printername>
/exportp <setting_file_name>
/importp <setting_file_name>
/RegServer
/UnregServer
/usep <setting_file_name>
-
Oct 26th, 2011, 10:08 AM
#9
Thread Starter
Frenzied Member
Re: [RESOLVED] Printing PDF Files
Hi,
I finally downloaded and installed the viewer. Now I am trying to call the viewer with the command line like you show. When i type the following, it says windows cannot find c:\Program. How would I type this to be called? And do I add the /close parameter to now show the program window? Thanks for any help you can give!
C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe /print c:\bottle1.pdf
-
Oct 26th, 2011, 10:14 AM
#10
Thread Starter
Frenzied Member
Re: [RESOLVED] Printing PDF Files
I did this in DOS while in the folder and it worked. I added the showui=no so that worked great too.
I was typing in the C:\Program Files\Tracker Software\PDF Viewer\PDFXCview.exe /print c:\bottle1.pdf in the windows Run window. I'll try this in VB.NET now.
Thanks
-
Oct 26th, 2011, 10:19 AM
#11
Frenzied Member
Re: [RESOLVED] Printing PDF Files
This is taken directly from one of my programs:
Code:
Process.Start("C:\Program Files\Tracker Software\PDF Viewer\pdfxcview.exe", " /print:printer=""" & printerName & """ """ & pdfFile & """")
You just need to provide the printer name & pdf filename. If you dont provide a printer name I think it will just print to the default printer.
-
Oct 26th, 2011, 11:33 AM
#12
Thread Starter
Frenzied Member
Re: [RESOLVED] Printing PDF Files
Thanks for the example. That was exactly what I needed!
Warren
-
Mar 2nd, 2016, 03:08 PM
#13
New Member
Printing PDF Files with PDF X-Change
Hi,
Everything works fine, except... My PDF file is in landscape format and print out of the printer in Portrait format... Any way I can provide the page orientation in the command line? I can't find any info on the available parameters...
[QUOTE=nbrege;4084109]This is taken directly from one of my programs:
Code:
Process.Start("C:\Program Files\Tracker Software\PDF Viewer\pdfxcview.exe", " /print:printer=""" & printerName & """ """ & pdfFile & """")
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|