Use a System.Drawing.Printing.PrintDocument to generate a PDF in memory

后端 未结 6 1029
忘了有多久
忘了有多久 2020-12-30 14:47

Does anyone know if the following is possible and if so what the best way of doing it is for free?

I am generating a PrintDocument in a project I am currently workin

相关标签:
6条回答
  • 2020-12-30 14:57

    The System.Drawing code for a PrintDocument can be reused to generate a PDF document with ABCpdf .NET. See the System.Drawing example...

    0 讨论(0)
  • 2020-12-30 14:58

    You're in a world of hurt if you think you're going to run the "same code" that deals with printers in both a forms app and an ASP.NET app.

    You might be in luck, however, as it appears that PDFsharp + MigraDoc might be able to do this for you.

    0 讨论(0)
  • 2020-12-30 14:58

    I think you will find there is not any tools that will take a PrintDocument as input and render a PDF as output. The only way to do what you want is to "print" the PrintDocument to a "PDF printer driver" that will generate PDF. Basically a virtual printer that will generate PDF instead of printing the actual output. There are a plethora of products on the market for that. A couple that are cheap and widely used are as follows:

    • Ghostscript with RedMon (open source/GPL or commercial licenses available)
    • Foxit Software's PDF Creator ($29)
    0 讨论(0)
  • 2020-12-30 15:12

    You would have to use a 3rd party component in order to generate the PDF. The following article has some links to some such components: Generating PDF Files from .Net

    0 讨论(0)
  • 2020-12-30 15:12

    There are several ports of iText for .NET (A very popular open-source PDF library for Java).

    http://www.ujihara.jp/iTextdotNET/en/

    0 讨论(0)
  • 2020-12-30 15:22

    You really should be looking at iTextSharp (it is mentioned on the iText.NET page recommended earlier)

    http://itextsharp.sourceforge.net/

    PrintDocument is meant for Windows Forms applications but is up and coming in SilverLight, see this video... http://silverlight.net/learn/videos/all/printing-api-basics/

    If you wish to continue with the PrintDocument and a web application, I think SilverLight 4 (which is beta right now) is the only way to go, or your going to have to have a lite weight windows form application installed locally for the end user that maybe uses web services.

    iTextSharp is a great tool for generating PDFs with .NET on the Internet. I highly recommend it; I've used iText with Java...and have been using iTextSharp for the past few years.

    0 讨论(0)
提交回复
热议问题