What are the options to print a PDF file using PDFNet?

319 views
Skip to first unread message

Support

unread,
Oct 15, 2010, 3:36:57 PM10/15/10
to PDFTron PDFNet SDK
Q: I have multiple pdf files in a directory that I want to print in
one job. Would merging all of the files together into one file be the
best method to do this? Can I not feed each document one by one into
an open/active print job?

-----------
A: There are at least three ways to print a PDF document using PDFNet.
Each approach has some benefits and drawbacks.

If you are using pdftron.PDF.Print.StartPrintJob() the only way to
print multiple PDFs in a single job is to merge them together. The
main disadvantage is that because this is a platform independent and a
very simple function there is not much flexibility. The advantage is
that this function is very simple to use and is also very efficient
(especially on Vista/Windows 7 and higher).

If you are using PDFDraw for printing (PDFDraw.DrawInRect(...)), you
are controlling the entire print process and you should be able to
print multiple documents in a single job. The main disadvantage is
that PDFDraw is generating bitmaps or GDI+ commands (depending on your
settings in PDFDraw class). As a result, the spool file may become
very large and pages may be slow to print.

A third option, which is optimal in terms of flexibility and
performance, is to use pdftron.PDF.Convert.ToXps (which is part of
PDFNet Convert-Add on) and then use StartXpsPrintJob to print the
resulting XPS file. This way you can control all print ticket (or
DEVMODE) properties yourself, you can print multiple documents in a
single job etc. The main disadvantage is that StartXpsPrintJob is not
available on Windows versions prior to Vista (e.g. XP), there is a bit
more programming, and it requires a license for PDFNet Convert Add-on.

For more information, please see:

Print ticket:
http://msdn.microsoft.com/en-us/library/dd374437(VS.85).aspx
http://msdn.microsoft.com/en-us/library/ff728890(VS.85).aspx
Print ticket:
http://msdn.microsoft.com/en-us/library/ff686808(v=VS.85).aspx


Support

unread,
Oct 15, 2010, 8:04:52 PM10/15/10
to PDFTron PDFNet SDK
Q: So there is no way to select the paper tray with
PDFNet.PDF.StartPrintJob or ::StartXpsPrintJob???

----------

A: If you use ::StartXpsPrintJob you can set a paper try using a print
ticket (http://msdn.microsoft.com/en-us/library/ff686808(v=VS.
85).aspx) which is passed as the last parameter. For more info please
see: http://social.msdn.microsoft.com/forums/en-US/windowsxps/thread/f5859148-26f1-4e89-949c-180413bcc898/

In case you already have a DEVMODE (http://stackoverflow.com/questions/
165567/how-do-you-control-printer-tray-selection-for-printer-in-
windows) you can also convert it to a print ticket which is passed
into StartXpsPrintJob using ConvertDevModeToPrintTicketThunk2

Support

unread,
Oct 15, 2010, 8:27:10 PM10/15/10
to PDFTron PDFNet SDK
Q: PDFDraw.DrawInRect(...) method is way too slow for printing. The
documents we have are being enlarged on the spool greatly using this
method.

So... Can I purchase Convert Add-on (pdftron.PDF.Convert.ToXps())
ONLY, convert the pdfs to xps, then use the windows print commands to
print the xps documents only? With this method will I be able to
select the printer tray AND combine all documents into a single print
job?

---------------------
A: It that case you should use ::StartXPSPrintJob() - as described
above. You could either purchase PDF2XPS command line utility or
PDFNet SDK with Convert Add-on. PDF2XPS is a command-line utility and
you could use it if you don't need a programmatic access.

You can set a paper try using a print ticket (http://
msdn.microsoft.com/en-us/library/ff686808(v=VS.85).aspx) which is
passed as the last parameter in ::StartXPSPrintJob(). For more info
please see: http://social.msdn.microsoft.com/forums/en-US/windowsxps/thread/f5859148-26f1-4e89-949c-180413bcc898/

In case you already have a DEVMODE (http://stackoverflow.com/questions/
165567/how-do-you-control-printer-tray-selection-for-printer-in-
windows) you can also convert it to a print ticket which is passed
into StartXpsPrintJob using ConvertDevModeToPrintTicketThunk2



On Oct 15, 5:04 pm, Support <supp...@pdftron.com> wrote:
> Q: So there is no way to select the paper tray with
> PDFNet.PDF.StartPrintJob or ::StartXpsPrintJob???
>
> ----------
>
> A: If you use ::StartXpsPrintJob you can set a paper try using a print
> ticket (http://msdn.microsoft.com/en-us/library/ff686808(v=VS.
> 85).aspx) which is passed as the last parameter. For more info please
> see:http://social.msdn.microsoft.com/forums/en-US/windowsxps/thread/f5859...
> >        http://msdn.microsoft.com/en-us/library/ff686808(v=VS.85).aspx- Hide quoted text -
>
> - Show quoted text -

Support

unread,
Oct 21, 2010, 8:58:23 PM10/21/10
to PDFTron PDFNet SDK
Q: I used your command line convert to xps and that works fine! I
wrote a sample app to print the produced xps files. That also works
great and the printer spool size is small. And the printed document is
crystal clear.

Now, I started to look into your suggestion of StartXpsPrintJob to
print multiple documents to one print job and realized that it was
part of an API for native applications (which is barely documented). I
am coding in C# not C++. I cannot find much reference for the XPS Api
(none for .net or similar).

Do you have any other ideas for me getting all of these xps documents
to a single print job? OR does any of your products allow me to merge
multiple xps documents into one?

--------------------------
A: pdftron.PDF.Print.StartPrintJob() hides the complexity of using the
native API but it is not giving you all the flexibility of using the
native ::StartXpsPrintJob. As a workaround you could wrap the COM
calls in C#.

Also, after a bit of research, I found that .NET Framework API can
also print XPS (http://msdn.microsoft.com/en-us/library/
aa969772.aspx), but this is not recommended for service use. Also I am
not sure whether this API is sending the job through a 'real' XPS
print path or is emulating it with EMF.

You can also use PDFNet to merge multiple PDFs (that can produce a
single XPS) into one. For an example please see
http://groups.google.com/group/pdfnet-sdk/browse_thread/thread/2a0deb1451e2325e
Reply all
Reply to author
Forward
0 new messages