I am trying to convert xps to pdf using PDFsharp. I have gone through
But not able to find steps to convert XPS to PDF. Can anybody suggest me the informative link to convert xps to pdf?
I have downloaded the source of PDFSharp from here
But what should be next step? Please help me. Thanks.
P.S. I have visited all the links related to converting xps to pdf here but as I have low reputation I am not able to post more than 2 links.
UPDATE : Finally I figured it out.
I followed this.
use following code
MemoryStream lMemoryStream = new MemoryStream();
Package package = Package.Open(lMemoryStream, FileMode.Create);
XpsDocument doc = new XpsDocument(package);
XpsDocumentWriter writer = XpsDocument.CreateXpsDocumentWriter(doc);
writer.Write(dp);
doc.Close();
package.Close();
var pdfXpsDoc = PdfSharp.Xps.XpsModel.XpsDocument.Open(lMemoryStream);
PdfSharp.Xps.XpsConverter.Convert(pdfXpsDoc, FileName, 0);
where dp should be your wpf control.
THEN
PdfSharp.Xps.XpsConverter.Convert(sourceXpsFile, destPdfFile, 0);
DONE :)
Based on this question and Nathan Jones work there is now a NuGet package available to do the trick.