locked
PDF to XPS Conversion programatically in c#

    Question

  • Have anyone figure out a way to convert PDF to XPS programatically in c#?
    Wednesday, August 08, 2007 4:10 PM

All replies

  • I cheat.  I use ghostscript to convert the PDF to Images, from those images I can then create an XPS document.

     

    Hope this helps.

    Thursday, September 27, 2007 12:54 PM
  • I thought I would add two observations on methods that I have tried.

     

    (1) I looked at using ghostscript to convert pdf to xps, but if I were to go down this route I would need to agree that my product would become "opensource".

     

    (2) I looked at using adobe reader to print to the ms xps document writer, but have found that the licensing terms in v8 of the reader prohibit its use to convert to a different file format.  I assume that this does not include pcl or postscript if this is being used for transit to the printer but it does not say this.  It would include xps.

    Thursday, September 27, 2007 3:53 PM
  • How do you use ghostscript to conver the PDF to images?
    Thanks,
    Thursday, October 11, 2007 2:05 PM
  • Run the command line against the PDF like this...

     

    gswin32c.exe -Z, -sDEVICE=png16m-sOutputFile="%04do.png" "temp.pdf"

     

    That will give you X amount of PNG images that you can then use as a basis for your xps.

    Tuesday, October 16, 2007 12:56 PM
  •  petersoftware wrote:

    (1) I looked at using ghostscript to convert pdf to xps, but if I were to go down this route I would need to agree that my product would become "opensource".

     

    You can use the ghostscript binaries "As Is" without having to make your product open source.  You must state that you use the software, and if asked, give the binary out.  If you make any modifications to the ghoscript source code then you MUST inform them of your changes.

    Tuesday, October 16, 2007 1:07 PM
  • Yes I do it using a 3rd party command line PDV2Vec works ok but requires a cmd call so it is ascronys in nature so I loop and check to see if the process is running to make it syncronys.  Only 20 lines of code and works well.  Let me know if you need more info.
    Tuesday, February 12, 2008 11:26 PM
  •  Keith Ball wrote:
    You can use the ghostscript binaries "As Is" without having to make your product open source.  You must state that you use the software, and if asked, give the binary out.  If you make any modifications to the ghoscript source code then you MUST inform them of your changes.

     

    Does that only work if you use the command line to call ghostscript, or can that apply to use of the gs_api?

     

    I read somewhere that if you use the cmd line then you must have a mechanism that allows the user to use something other than ghostscript without the need for a recompile (something as simple as a batch file that can be modified I suppose)

    Wednesday, February 13, 2008 11:14 AM
  • A company named Amyuni has a product called PDFConverter:

     

    http://www.amyuni.com/en/developer/pdfconverter/trial.html

     

     

    Thursday, February 21, 2008 6:16 PM
  • hi Keith,

     

    Your solution seems really good. I would like to do the same thing : send to printer Pdf Files using System.Printing NameSpace. It would really help me a lot if you could give me code you use to do this.  Does it work for multiples pages PDF document ? (I'm new in Framework 3.0).

     

     

    It would help me too if you  have information of robustess of this solution. Is it appropriate for batch printing ? (to print about 2 000 pdf files) ?

     

    And maybe would you know if there would be any problem to host this in a Windows Service Application ?

     

    regards,

    Myriam

     

    Thursday, April 24, 2008 12:49 PM
  •  - You can find out how to use GhostScript to convert PDF into images, HERE

     - Download GhostScript HERE

     

    Note:

    You should add the bin directory of GhostScript into your path Environmental Variable to run GS Commands directly from cmd.

     

    Hope this information will help someone in the future.

    Thursday, October 09, 2008 5:01 AM
  •  GHFatal wrote:
    Have anyone figure out a way to convert PDF to XPS programatically in c#?


    We can convert PDF to XPS programmatically but currently we only support doing so via our custom XPS printer driver. We are currently looking at adding support for native PDF to XPS conversion. It's far from an ideal solution, it just depends on your application.

    Regards,

    Tim Haughton
    www.convert2xps.com
    Tuesday, October 14, 2008 8:40 AM


  • You can use PDF2XPS from PDFTron (http://www.pdftron.com/pdf2xps/index.html) or PDFNet SDK ((http://www.pdftron.com/pdfnet).

    Aki
    Tuesday, February 16, 2010 2:43 AM
  • A company named Amyuni has a product called PDFConverter:

     

    http://www.amyuni.com/en/developer/pdfconverter/trial.html

     

     


    Cannot recommend this converter, too bugy... bad support...waste of money! we have tested this one... so save your money!
    Tuesday, February 16, 2010 10:42 AM
  • I'd use TallComponents PDF Kit. For printing I wrote a hack to open Adobe, and force it to print the document the installed printer. Works like a charm.
    Monday, March 15, 2010 8:36 PM


  • You can use PDF2XPS from PDFTron (http://www.pdftron.com/pdf2xps/index.html ) or PDFNet SDK ((http://www.pdftron.com/pdfnet ).

    Aki


    tested the PdfNet library and I can highly recommend this one... great conversion results, good looking API...sure one of the best around!
    Tuesday, March 16, 2010 8:32 AM
  • Hi GHFatal,

    Maybe I don't answer correctly to your question, but I have found a product that can give a solution to your problem.

    You can find a pdf to xps converter here and you can try it here

    Wednesday, June 01, 2011 9:38 AM