PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.de/

Printing without preview
http://forum.pdfsharp.de/viewtopic.php?f=2&t=3063
Page 1 of 1

Author:  mgbig [ Mon Feb 23, 2015 4:55 pm ]
Post subject:  Printing without preview

Hello

I am pretty sure, that I have seen it somewhere in the samples, but I can not find it anymore.
I want to create a pdf which should be printed on the main printer (or any other?) without any preview.

Thanks for Help
mgbig

Author:  Thomas Hoevel [ Mon Feb 23, 2015 4:59 pm ]
Post subject:  Re: Printing without preview

Hi!

PDFsharp cannot print PDF files.

You can create a PDF file and then invoke Adobe Reader to print (via command line options).

Or run your code twice: first to create a PDF, then to print it.

Author:  mgbig [ Mon Feb 23, 2015 6:40 pm ]
Post subject:  Re: Printing without preview

Ok! What you tell is what I want.

And this is what I actually do:
all VB.NET

Code:
pdfRenderer.PdfDocument.Save(filename)
Process.Start(filename)


And I tried this and this works, but after printing the Adobe Icon stays in the task bar, which is not very nice. Is there a better way?
Code:
...
pdfRenderer.PdfDocument.Save(filename)
Print_Document(filename)
...

Private Sub Print_Document(ByVal strDocpath As String)
        Dim p As New Process
        p.StartInfo.FileName = strDocpath
        p.StartInfo.Verb = "print"
        p.StartInfo.CreateNoWindow = True
        p.Start()
End Sub

Author:  mgbig [ Fri Feb 27, 2015 7:52 am ]
Post subject:  Re: Printing without preview

Finally it works well like this:

I found this pdf viewer "SumatraPDF" which is very smart and fast. and it works nice with this VB Net Code:
Code:
Process.Start("C:\projekte\SumatraPDF\SumatraPDF.exe", "-silent -exit-on-print -print-to-default " & filename)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/