Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch Converting PDF to XPS

Tags:

c#

pdf

wpf

I'm looking for an inexpensive way of batch converting 1300 PDF documents to XPS documents. I know that I can simply print them in that format, but that would take a very long time. Is there a way to do this programmatically in C#?

like image 871
Jordan Avatar asked Feb 10 '11 20:02

Jordan


2 Answers

Depending on your definition of inexpensive there are a couple of options:

inexpensive = less than $1000:

You can use PDF2XPS for about $550: http://www.pdftron.com/pdf2xps/index.html

inexpensive = "free":

You can follow the suggestions in this thread to use GhostScript to convert your PDFs to image files, then you can use the XpsDocumentWriter class to create your documents.

like image 130
theChrisKent Avatar answered Oct 05 '22 09:10

theChrisKent


If you only need to do it once, then a mixture of custom code and existing solutions could work:

  1. Get FoxIt Reader for free
  2. For each document, execute this command:

    "C:\Program Files (x86)\Foxit Software\Foxit Reader\Foxit Reader.exe" -t C:\documents\document1.pdf "Microsoft XPS Document Writer"

  3. Detect when the "Save the file as" dialog box pops up (Maybe a Process.GetProcessesByName against aplwow64.exe in a Timer?) and use SendKeys to populate the file name and save

    Alternatively, go down the p/invoke route to call FindWindow and SendMessage directly.

like image 24
Michael Stum Avatar answered Oct 05 '22 10:10

Michael Stum