Results 1 to 13 of 13

Thread: [RESOLVED] Printing PDF Files

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Resolved [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

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Printing PDF Files

    Untested but should work...
    vb.net Code:
    1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    2.  
    3. Dim strPDFFile As String = Dir("c:\*.pdf")
    4. Dim PrintPDFFile As New ProcessStartInfo
    5.  
    6. Do Until strPDFFile Is Nothing        
    7.     PrintPDFFile.UseShellExecute = True
    8.     PrintPDFFile.Verb = "print"
    9.     PrintPDFFile.WindowStyle = ProcessWindowStyle.Hidden
    10.     PrintPDFFile.FileName = strPDFFile
    11.     Process.Start(PrintPDFFile)
    12.     strPDFFile = Dir()
    13. Loop
    14.  
    15. End Sub

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    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

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    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

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    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

  6. #6
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    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.

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    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

  8. #8
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    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 [&param2=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>

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    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

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    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

  11. #11
    Frenzied Member
    Join Date
    Jul 2006
    Location
    MI
    Posts
    2,012

    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.

  12. #12

    Thread Starter
    Frenzied Member
    Join Date
    Oct 2000
    Posts
    1,463

    Re: [RESOLVED] Printing PDF Files

    Thanks for the example. That was exactly what I needed!

    Warren

  13. #13
    New Member
    Join Date
    Mar 2016
    Posts
    1

    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
  •  



Click Here to Expand Forum to Full Width