Is ther any open tool to convert XPS to PDF? [closed]
Asked Answered
N

1

6

I did a lot of digging to figure out an easy way to convert an XPS document into a PDF. There are many tools that can do this but they are not free. Is there a free alternative?

Name answered 17/3, 2015 at 19:45 Comment(1)
I found a way to do this natively in Windows using the Microsoft PDF Printer. Check it out: https://mcmap.net/q/281931/-print-fixeddocument-xps-to-pdf-without-showing-file-save-dialogLonergan
N
9

A quick google search led me to this: http://www.nathanpjones.com/wp/2013/03/output-to-pdf-in-wpf-for-free/

I was able to get it to work after I trimmed down some of the code I did not need. Here is the result:

using (PdfSharp.Xps.XpsModel.XpsDocument pdfXpsDoc = PdfSharp.Xps.XpsModel.XpsDocument.Open(xpsPath))
{
    PdfSharp.Xps.XpsConverter.Convert(pdfXpsDoc, pdfPath, 0);
}

The 2 path variables are just strings.

You need to reference these 2 dll's: http://www.nathanpjones.com/wp/wp-content/uploads/2013/03/PdfSharpXpsBin.zip

Many thanks to Nathan for sharing this information!

Edit: Nathan work is available as a NuGet package here.

Name answered 17/3, 2015 at 19:45 Comment(8)
Note: If you need to convert documents that have more than 50 pages you will need to edit the PDFSharp source codeName
Not sure why people are down voting without an explanation or alternative solution, especially since this is a working solution. Am I missing something?Name
I did not downvote. You asked a question - and provided the answer minutes later. And the tag for the answer (PDFsharp) is already set for the question. That looks odd to me. Some folks downvote questions that show little or no effort and even downvote answers given to such questions. What are the intentions behind your question and your answer?Beilul
When I created the question I marked it as a question/answer where you answer your own question. I thought the point of those was to help share knowledge? When i did a google search i did not find anything on this site so I thought there might be value to add this information here. Now that I looked more thoroughly I did find where on this site the issue was fixed: https://mcmap.net/q/732436/-wpf-to-xps-to-pdf I guess I could remove it but I I still maintain that this Q/A will be much easier to use than sifting thru all the posts in that other thread.Name
I have used this site for years but have never really contributed anything so I guess I need to "catch up" with everyone else on how things work. Thanks @PDFsharp-team for your feedback and great product!.Name
It's OK for SO to answer your own question immediately and it's OK for me. But questions asking to find a tool are considered off-topic - maybe that's the problem here.Beilul
BCLs could be considered tools: Encryption, Compression, and more. This question/answer is not a debugging tool, or a standalone converter application, it's a software library and particular configuration which solves a problem.Howlyn
idk why these ppl are against this post, but this is awesome, saved me today boss!!!!!!!! don't listen to themWeller

© 2022 - 2024 — McMap. All rights reserved.