PDFsharp missing the Xps namespace
Asked Answered
L

2

7

I need PDFsharp's XPS functionality to convert from WPF -> XPS -> PDF. I've tried referencing PDFsharp 1.20, 1.30, 1.31 and also 1.32, but none of these contain the mystical PdfSharp.Xps namespace that everyone is talking about. Apparently 1.31 was the last version to include the XPS functionality, but I didn't find anything in there either.

This is the one line of code I need it for:

//error: 'Xps' is not a member of 'PdfSharp'
var test = PdfSharp.Xps.XpsModel.XpsDocument.Open(_MemoryStream);
Lake answered 21/5, 2014 at 14:10 Comment(2)
Did you add a ref to PdfSharp.Xps.dll assembly?Bijugate
@Bijugate I didn't get that dll with any of the versions I downloaded.Lake
S
4

The latest version that includes the XPS project is version 1.31.

Downloads are available here:
https://sourceforge.net/projects/pdfsharp/files/pdfsharp/

Get the file PDFSharp-MigraDocFoundation-1_31.zip and add the C# projects to your solution and reference these projects from your project.

Schoenfeld answered 21/5, 2014 at 14:39 Comment(8)
The Pdfsharp.Xps.dll is nowhere to be found, not in version 1.31 nor 1.32. Can you please point us to the link that contains mentioned dll?Veg
@Veg Wolf: Nobody mentioned a DLL. You can download the source code and use that to compile a DLL.Schoenfeld
@PDFsharpTeam, well the library is not included in version 1.32. It is slightly disingenuous to make the fact you went commercial extremely opaque. For all who look for PdfSharp.Xps.dll it can be found here: nathanpjones.com/wp/2013/03/output-to-pdf-in-wpf-for-free)Veg
@Veg Wolf: PDFsharp is Open Source and will remain Open Source. A beta version of the XPS code was included with version 1.31 and it was not updated with version 1.32. It's a beta version and therefore no DLL was included in the DLL package. It is a beta version and people who cannot manage to include a reference to a C# project in their solution are not in the target group of that beta version. Why do you think we "went commercial"?Schoenfeld
@PDFsharpTeam, so just wondering, did you implement a simpler way in version 1.32 to go from WPF content (or for that matter any .Net content) -> PDF ? So far the only way to go via XPS and the missing dll disables one from converting xps-> pdf.Veg
@PDFsharpTeam can you answer Matt Wolf's question?Coriss
@Coriss To answer that question: There is no simpler way than XPS at the moment. The "missing dll" does not prevent people from using it (adding the PDFsharp source projects to your solution makes helps authoring and debugging code - and you get the "missing dll" automatically). And to answer the next question: I cannot say when a new version of the XPS code will be released.Schoenfeld
For those of you who might be even vaguely interested, I have spent the last 10? years trying to develop a product which works on Winforms, WPF, Xamarin Android and Xamarin UWP. 99.99% of that time has been spent fighting Microsoft's 'development' systems. Only 00.01% of the time has been spent fighting the actual problem ....Lavender
T
1

For anyone trying to use this with .NET6 or later there seem to be changes to how the XpsDocument is formatted by default resulting in PdfSharp failing to render parts of the document. Particularly numbers seems to fail frequently.

The solution we found was to create the XpsDocument without compression.

new XpsDocument(package, CompressionOption.NotCompressed)

That way PdfSharp seems able to parse it correctly afaik.

Towers answered 15/9, 2022 at 12:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.