Skip to content

YetaWF/PDFsharp-.netcoreapp2.0

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ASP.NET Core PDFSharp

ASP.NET Core 2.2

NOTE: It appears that as of ASP.NET Core 2.2, PDFSharp (for .NET 4.6.1) simply works and none of this is required any longer. Just add the PDFSharp Nuget package to your project. Done. (It's great when Microsoft catches up with the promises made with ASP.NET Core/NETStandard.)

UPDATE 9/29/2019 PDFSharp .NET 4.6.1 only works with ASP.NET Core 2.2 on Windows "out of the box". On Linux or a Linux Docker container, it does not work. At this point I give up as this is a minor part of my app and I can just display the invoice as a simple (HTML) page. The error on Linux is "Unable to load shared library 'user32.dll' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: libuser32.dll: cannot open shared object file: No such file or directory". Using the PDFsharp-.netcoreapp2.0 might actually work on Linux, but I'm tired of chasing workarounds, so I'll just go with the plain HTML page (for invoices).

So I really needed PDFSharp for netcoreapp2.0 (or netstandard2.0), but the current release version 1.32.3057 and the prerelease version 1.50.4845-RC2a did not support ASP.NET Core, nor would they magically work.

I looked for alternatives (around April 20, 2018), but there was nothing out there. Rolling my own could have been an option, but I really wasn't looking forward to that. Why reinvent the wheel. But I needed netcoreapp2.0 support.

Fortunately, it took a mere 20 minutes to fix this. Here are the steps to add PDFSharp to a netcoreapp2.0 project.

It may not be pretty, but it works. If you're just using PDFSharp to render a PDF, this should work for you too. This is obviously a stop-gap solution, until the fine folks at Empira Software GmbH (the makers of PDFSharp) catch up.

Step By Step

  • Clone this repo
  • Open the solution file BuildAll-PdfSharp.sln (you'll need the SDK, etc, but if you need PDFSharp for netcoreapp2.0, you have it already)
  • Rebuild all, you probably want a Release build
  • In the project where you need PDFSharp (an netcoreapp2.0 project), add the following to you csproj. Make sure to adjust the path and Debug/Release as needed:
  <ItemGroup>
    <Reference Include="PdfSharp.netcoreapp">
      <HintPath>..\..\..\..\PDFSharp.netcoreapp\src\PdfSharp\bin\Debug\netcoreapp2.0\PdfSharp.netcoreapp.dll</HintPath>
    </Reference>
  </ItemGroup>
  • Build your project
  • Run it and rejoice
  • Send beer money to me

If it doesn't work, sorry.

** Original Readme Text Below **

PDFsharp

A .NET library for processing PDF

Resources

The official project web site:
http://pdfsharp.net/

The official peer-to-peer support forum:
http://forum.pdfsharp.net/

Release Notes for PDFsharp/MigraDoc 1.50 (stable)

The stable version of PDFsharp 1.32 was published in 2013.
So a new stable version is long overdue.

I really hope the stable version does not have any regressions versus 1.50 beta 3b or later.

And I hope there are no regressions versus version 1.32 stable. But several bugs have been fixed.
There are a few breaking changes that require code updates.

To use PDFsharp with Medium Trust you have to get the source code and make some changes. The NuGet packages do not support Medium Trust.
Azure servers do not require Medium Trust.

I'm afraid that many users who never tried any beta version of PDFsharp 1.50 will now switch from version 1.32 stable to version 1.50 stable.
Nothing wrong about that. I hope we don't get an avalanche of bug reports now.

Which Version to Get?

The naming convention for the packages has changed.

If you are using "PdfSharp -Version 1.32.3057" then the version you need now is "PDFsharp-gdi -Version 1.50".
Or get the corresponding package " PDFsharp-MigraDoc-GDI -Version 1.50".

About

PDFSharp Library with Support for ASP.NET Core 2.0

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%