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#?
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.
If you only need to do it once, then a mixture of custom code and existing solutions could work:
"C:\Program Files (x86)\Foxit Software\Foxit Reader\Foxit Reader.exe" -t C:\documents\document1.pdf "Microsoft XPS Document Writer"
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With