Skip to content

Support for .NetCore #6

Closed
Closed

Description

@davzucky

I'm starting to use your library to parse pdf and extract data from it. This is working perfectly for windows, however I'm not able to even compile with .Net core because of all the GUI library ( like silverlight or Winform) dependency that the base library has.
Do you thing it would be possible to have a base pdfSharp.Core library that only contain parsing and creation of of pdf ?
I'm would be happy to help if you need

Activity

  1. shontykov commented on Sep 15, 2016

    @shontykov

    I havent bumped to .Net.core yet. But, yes it would be an amazing idea to
    have pdfsharp.core library.

    On Wed, Sep 14, 2016 at 7:09 PM, David Zucker notifications@github.com
    wrote:

    I'm starting to use your library to parse pdf and extract data from it.
    This is working perfectly for windows, however I'm not able to even compile
    with .Net core because of all the GUI library ( like silverlight or
    Winform) dependency that the base library has.
    Do you thing it would be possible to have a base pdfSharp.Core library
    that only contain parsing and creation of of pdf ?
    I'm would be happy to help if you need

    —
    You are receiving this because you are subscribed to this thread.
    Reply to this email directly, view it on GitHub
    empira/PDFsharp#6, or mute the thread
    https://github.com/notifications/unsubscribe-auth/AJidmFOeZS0lCtYt66OnDUSfyr8GNbCvks5qp_IagaJpZM4J8wMw
    .

  2. daniellor commented on Sep 15, 2016

    @daniellor
  3. ThomasHoevel commented on Sep 15, 2016

    @ThomasHoevel
    Member

    PDFsharp uses the GUI for image handling. We have plans to handle images in own code, but this is not going to happen soon. Creating PDFs without images is of little use in most cases.
    Parsing PDFs is a different story. This should be rather simple with .NET Core.
    I don't know if Stefan has any plans to support .NET Core.

  4. charabaruk commented on Oct 6, 2016

    @charabaruk

    It would definitely be very helpful to remove dependencies on GDI+ and WPF for PDF generation.

  5. andekande commented on Dec 8, 2016

    @andekande

    There is already a conditional build flag #Core spread in the code. I don't assume its specifically for .Net Core but a first step to get what we want. Even if Image handling won't work - we could use Vectors instead. Sufficient for creating invoices and reports.
    There is currently no dependency-less solution available for creating PDFs in .Net Core ! This one has a great potential.
    I also offer help. Glad to hear back from the maintainers if we can count on theirs support.

  6. ThomasHoevel commented on Dec 8, 2016

    @ThomasHoevel
    Member

    There already is a CORE flag with a different meaning from a time before .NET Core was announced. The CORE build is not yet fully implemented and still has some dependencies on GDI+.

  7. finnsea commented on Feb 9, 2017

    @finnsea

    Has anyone been working on a port that is usable in a UWP application? We have a UWP app for one of our clients that creates PDF documents using Component One that need to be merged before printing and uploading to a server. Component One unfortunately for us does not have the functionality to merge existing PDFs.

  8. groege commented on Mar 13, 2017

    @groege

    I've started on a port
    https://github.com/groege/PdfSharpCore
    Though I have to warn you that it works for me in my case for creating a delivery note pdf, it might not work for you - but you can try anyway ;)
    Examples are also not up to date - but if you want to try it out you can always create an issue ;)

  9. o-leary commented on Apr 10, 2017

    @o-leary

    Any chance you could share a built version? I can't get this to compile in VS 2015.

  10. groege commented on Apr 10, 2017

    @groege

    Ah yes - I'm using VS2017 and new C# features ;)
    https://github.com/groege/PdfSharpCore/blob/master/Example/PdfSharpCore.7z

    Be aware of changes which I didn't include in the examples:
    For images you must define the source by (i.e. Android):
    ImageSource.ImageSourceImpl = new AndroidImageSource();
    (Sadly I don't know how I can set it up to automatically use the right implementation)

    For Fonts look at the example project.

    Hope this helps ;)

  11. o-leary commented on Apr 10, 2017

    @o-leary

    Thank you, I have got it working with a UWP app now, so far just simple text to test it. I'm sure I'll be able to figure the rest out on my own. Thank you very much for your help.

  12. groege commented on Apr 10, 2017

    @groege

    No problem - let me know if you run into any issues ;)

  13. groege commented on Apr 10, 2017

    @groege

    Actually i just remembered - if you install the latest nuget package "Microsoft.Net.Compilers" on the projects you should be able to compile it yourself ;)

  14. guylando commented on Aug 23, 2017

    @guylando

    It is not clear to me from this discussion if the original pdfsharp library is considering supporting .net core or they rely on groege to maintain the net core version? Similar questions were referenced here (empira/PDFsharp#9) but there is no clear answer here to this question.

    In my company, we want to use a stable well maintained library and if this library will not support net core we will have to search an alternative which is undesired.

  15. 24 remaining items

  16. guylando commented on Jan 9, 2019

    @guylando

    Interesting, I now see that net core developers worked on porting System.Drawing:
    https://github.com/dotnet/corefx/issues/20325
    https://developers.de/2018/01/22/how-to-use-system-drawing-in-net-core/
    Also there is windows compatability pack having System.Drawing inside:
    https://blogs.msdn.microsoft.com/dotnet/2017/11/16/announcing-the-windows-compatibility-pack-for-net-core/
    And in net core 3.0 it will be FULLY supported: dotnet/corefx#33092

  17. ststeiger commented on Jan 9, 2019

    @ststeiger

    @guylando:
    https://github.com/ststeiger/PdfSharpCore
    is a port for .NET Core 1.6+
    It doesn't use System.Drawing.dll.
    It is based on PdfSharp 1.32 and has some missing and some half-working features.

    https://github.com/ststeiger/PdfSharpNetStandard
    Is for NetStandard 2.1+, and is based on PdfSharp 1.5.
    Very few things are missing (https://github.com/ststeiger/PdfSharpNetStandard/tree/master/PdfSharp_Removed https://github.com/ststeiger/PdfSharpNetStandard/tree/master/MigraDoc_Rendering_Removed).
    PdfSharpNetStandard should work work just like PdfSharp.

    PdfSharpCore has changed PdfSharp to be based on the .NET-Core High-Performance implementations.
    It should have a better/higher performance - in theory.

    If you have mono installed (libgdiplus.so) then System.Drawing should work on Linux, too (not sure if this is true).

  18. brentboden1 commented on Jul 18, 2019

    @brentboden1

    Is there any known date when we can expect an official release of pdfsharp for .net standard ?

  19. ThomasHoevel commented on Jul 18, 2019

    @ThomasHoevel
    Member

    An official version for .NET Core is not in the queue yet. So do not expect official versions for .NET Standard or .NET Core soon.

  20. guylando commented on Jul 19, 2019

    @guylando

    @ThomasHoevel Asp.net core 3 does not compile to .Net framework which would prevent using pdfsharp

  21. ststeiger commented on Jul 19, 2019

    @ststeiger

    @guylando: ASP.NET Core will be .NET Framework 5.0.
    There will be nothing else anymore afterwards.
    Only ASP.NET Core < 3 can be used with FULL .NET Framework < 5.

    https://devblogs.microsoft.com/dotnet/introducing-net-5/
    https://devblogs.microsoft.com/dotnet/net-core-is-the-future-of-net/

    .NET Framework 4.8 will be the last major version of .NET Framework. If you have existing .NET Framework applications that you are maintaining, there is no need to move these applications to .NET Core. We will continue to both service and support .NET Framework, which includes bug–, reliability– and security fixes. It will continue to ship with Windows (much of Windows depends on .NET Framework) and we will continue to improve the tooling support for .NET in Visual Studio (Visual Studio is written on .NET Framework).

  22. Methuselah96 commented on Jul 19, 2019

    @Methuselah96

    @ststeiger That's not entirely accurate. ASP.NET Core will (eventually) be .NET 5, which is not .NET Framework, it's just the next version of .NET Core that's being re-branded.

    When ASP.NET Core uses .NET 5, it will still be able to depend on packages that use .NET Standard <=2.1. So in order to be compatible with the most number of frameworks, this library should be ported to .NET Standard 2.0. Then this library would support existing applications that are already written .NET Framework >=4.6.1 and also support new applications that will be written in .NET Core >=2.0 as well as .NET 5 when it comes out.

  23. B2alex commented on Aug 22, 2019

    @B2alex

    This is a long chain, just wanted to check in and see if what I am understanding is correct.

    PdfSharpCore
    https://github.com/ststeiger/PdfSharpCore

    Is the only port that supports .net core and got off of System.Drawing, for in favor of ImageSharp?

    Also, has anyone been successful in getting a GDI based port to work on a linux container?

  24. flipchart commented on Aug 22, 2019

    @flipchart

    @B2alex We use it in production on a docker container running under Ubuntu linux on Azure. We modified to get it working and packaged it on nuget here https://www.nuget.org/packages/Drive.MigraDocPdfSharp

    Basic code to get things running

    using System;
    using System.Collections.Generic;
    using System.IO;
    using MigraDoc.DocumentObjectModel;
    using MigraDoc.Rendering;
    using PdfSharp.Drawing;
    
    namespace PdfEg
    {
        internal class PdfExample
        {
            private void RunPdfExample()
            {
                var fonts = new List<string>();
    
                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    fonts.AddRange(Directory.EnumerateFiles("/usr/share/fonts/truetype/msttcorefonts"));
                    fonts.AddRange(Directory.EnumerateFiles("/usr/share/fonts/truetype"));
                }
                else if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                {
                    fonts.AddRange(Directory.EnumerateFiles(Path.Combine(System.Environment.GetEnvironmentVariable("windir"), "Fonts")));
                }
    
                foreach (var font in fonts)
                {
                    try
                    {
                        XPrivateFontCollection.Add(File.ReadAllBytes(font));
                    }
                    catch
                    {
                        // todo: log
                    }
                }
    
                var document = new Document();
                var section = document.AddSection();
    
                document.Styles.Normal.Font = new Font("Arial", Unit.FromPoint(8));
    
                var h1 = document.AddStyle("h1", "Normal");
                h1.Font.Bold = true;
                h1.Font.Size = Unit.FromPoint(15);
    
                // add to page here :)
    
                var renderer = new PdfDocumentRenderer(true)
                {
                    Document = document,
                };
                renderer.RenderDocument();
    
                using (var stream = new MemoryStream())
                {
                    renderer.PdfDocument.Save(stream);
    
                    var data = stream.ToArray();
                }
            }
        }
    }

    Dockerfile which we use. Note the entrypoint.sh file just runs the dotnet command on the main dll. Replace with your use

    FROM mcr.microsoft.com/dotnet/core/aspnet:2.2
    
    ARG source=.
    
    WORKDIR .
    ENV ASPNETCORE_URLS http://*:5000
    EXPOSE 5000/tcp
    
    ARG NODEREPO="node_9.x"
    ARG DISTRO="stretch"
    
    RUN apt-get update -q && apt-get install -q -y \
     curl \
     apt-transport-https \
     apt-utils \
     dialog \
     gnupg
    
    RUN curl -sSO https://deb.nodesource.com/gpgkey/nodesource.gpg.key
    RUN apt-key add nodesource.gpg.key
    RUN echo "deb https://deb.nodesource.com/${NODEREPO} ${DISTRO} main" > /etc/apt/sources.list.d/nodesource.list
    RUN echo "deb-src https://deb.nodesource.com/${NODEREPO} ${DISTRO} main" >> /etc/apt/sources.list.d/nodesource.list
    
    RUN (echo "deb http://http.debian.net/debian/ ${DISTRO} main contrib non-free" > /etc/apt/sources.list) && (echo "deb http://http.debian.net/debian ${DISTRO}-backports main" > /etc/apt/sources.list.d/backports.list) && (echo "deb http://http.debian.net/debian/ ${DISTRO}-updates main contrib non-free" >> /etc/apt/sources.list) && (echo "deb http://security.debian.org/ ${DISTRO}/updates main contrib non-free" >> /etc/apt/sources.list)
    RUN echo ttf-mscorefonts-installer msttcorefonts/accepted-mscorefonts-eula select true | debconf-set-selections
    RUN apt-get update && apt-get -y install \
      libgdiplus \
      ttf-mscorefonts-installer \
      nodejs
    RUN cd /usr/lib && ln -s libgdiplus.so gdiplus.dll
    RUN ln -s /lib/x86_64-linux-gnu/libdl.so.2 /lib/libdl.so
    RUN ln -s /usr/lib/x86_64-linux-gnu/libX11.so.6 /lib/libX11.so
    
    COPY $source .
    
    RUN ["chmod", "+x", "/entrypoint.sh"]
    
    ENTRYPOINT ["/entrypoint.sh"]
    
  25. added a commit that references this issue on Jun 15, 2020
  26. jespersh commented on Sep 18, 2020

    @jespersh

    The TFM concepts netstandard and netcoreapp has been merged into the net5.0 and its platform specific TargetFramework net5.0-windows, net5.0-watchos, net5.0-tvos, net5.0-macos, net5.0-ios, net5.0-android

  27. flensrocker commented on Sep 18, 2020

    @flensrocker

    But with a target of net5.0 you can't use that package in classic .Net Framework projects. netstandard2.0 would be the most flexible one. And Pdfsharp doesn't use anything outside of .Net Standard 2.0.

  28. ststeiger commented on Sep 22, 2020

    @ststeiger

    Agree with @flensrocker.
    Anything but NETSTANDARD_2_0 is pointless.

  29. ThomasHoevel commented on Apr 18, 2023

    @ThomasHoevel
    Member

    As of PDFsharp 6.0.0, PDFsharp is now using .NET 6.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions