开发者

.NET library to print PDF files

I am after a library which can accept an already created PDF file and send it directly to the printer. I don't want the user to need Adobe Reader or anything else installed, the applicati开发者_运维百科on will generate a PDF and I want to print it.


Sorry, my first answer (since deleted -- FGITW answer saying just use iTextSharp) assumed it was PDF FAQ #1 when in fact it was PDF FAQ #~5, mea culpa...

There's no system-provided native PDF processing, so outside of using an app such as FoxIt or Acrobat -- which you shouldn't discount too quickly - people who use PDF will have one or the other and will be choosy about which one they prefer as they're not all equal, esp if you get into more advanced features and their associated licensing and monetisation schemes.

Not aware of any specific libraries that address this requirement, though the other question I've linked to above should have a good answer. ... researches; time passes... An answer on the other question says PDFSharp should suit, the sample looks straightforward.

On reflection based on looking at Pdfsharp's FAQ wiki, iTextSharp has similar stuff for generating TIFFs/images as PDFSharp has.

An alternative which may or may not be in scope is to generate and/or convert to e.g., an XPS file, which does have built in printing support (pretty sure .NET 3.5, and possibly earlier have it as a standard component in the Client Profile).

One point that shouldn't be missed in this all is that the Lowagie book (iText In Action) is excellent and if you're going to be doing anything in reading, writing or providing PDF forms, you should have it on your shelf. Similarly, if you do go the FLOSS library route, iText has to be seriously considered.


I'm not aware of any free/open source libraries available to do this, but after evaluating a handful, I went with cete DynamicPDF Print Manager.NET. It was by far the most efficient in terms of system resources, namely RAM. The other products I tried were from Tall Components, Gnostice, and BCL EasyPDF SDK. All of these used large amounts of RAM compared to cete's product. The Print Manger has good documentation is was easy to use.

You may also be able to call gsprint from .NET, part of gsview, which is FOSS GUI for GhostScript. I did not go this route, but also noticed it seemed to use more system resources than Dynamic PDF. If you could probably have package it with your software so to the user it's more transparent. I know it doesn't fit your criteria, but this seems to be the only possible free solution available.

In case you come across PDFSharp, note that it uses Adobe Reader to print.

Apache's PDFBox has a command line PrintPDF utility that you may also be able to call from .NET. I came across it after I purchased Print Manager, so I haven't tried it yet.

Update: You can use Sumatra PDF to print silently from the command line. I suspect it rasterizes the PDF before sending to the printer, but for smaller files that should work.


I hope this will help someone. After looking online I found this great open source library (C#) and it works perfect for me.

https://github.com/tonyedgecombe/RawPrint

    using RawPrint;

    Printer.PrintFile("Printer Name", @"C:\Path\To\Print\File.prn");

Best of luck,


I created a small .Net 4.0 library called PDFFilePrint, you can fetch this through the nuget package manager or you can call "install-package PDFFilePrint" in the nuget package manager console. Here is a link to the package.


You can try PDFView4NET. It supports printing of PDF files and conversion of PDF pages to images.

Disclaimer: I work for the company that develops PDFView4NET.


There are a few commercial libraries out there. I for example would recommend http://pdfprinting.net.

P.S. I work for the company offering that solution.


Free PDFiumViewer comes via Nuget and has print capabilities, see code sample here.

Real easy to use - took me long time to find though - so I post it for people searching in the "wrong" question:

https://stackoverflow.com/a/41751184/586754

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜