Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pdf generation and manipulation library in Net Core 2 with permissive license #888

Closed
guylando opened this issue Aug 23, 2017 · 14 comments
Closed

Comments

@guylando
Copy link

guylando commented Aug 23, 2017

The ITextSharp library has the AGPL license which is problematic for commercial use.
The pdfsharp library does not have a maintained support for net core yet: empira/PDFsharp#6

Are there any plans to build some pdf handling package by the core team or by the net foundation team?

Anybody is aware of some pdf manipulation library in net core 2 with permissive license for commercial use?

This is currently a major issue for our company which prevents us converting our projects to netcoreapp2.0 and forces us to keep compiling for net461.

@richlander
Copy link
Member

We don't have any plans to provide a PDF library. I'm also not aware of one to recommend. Hopefully the community will work more of PDFSharp.

@aqibgatoo
Copy link

@guylando though late to the party but here is a good one for pdf generation
Rotativa .NetCore

@Phyrom
Copy link

Phyrom commented Jan 3, 2018

@aqibgatoo, can we convert a .doc file to pdf using Rotativ .NetCore?

@aqibgatoo
Copy link

@Phyrom i don't think so . You can generate images and pdf files from it. The pdf generator that i ended using up is a slighlty modifed running version of it with the package reference as. <PackageReference Include="RotativaCore" Version="2.1.1" />

@guylando
Copy link
Author

guylando commented Jan 7, 2018

@aqibgatoo we are looking to generate a pdf document describing a list of objects (a page for each object) including inserting text, images, styling, bullets. Rotative can be used for that? (basically export objects to pdf)

@aqibgatoo
Copy link

@guylando yes, it has different ActionResults available which you can easily use. For the example below you have to just design your view and pass the model accordingly.

public ActionResult TestViewWithModel(string id)
{
    var model = new TestViewModel {DocTitle = id, DocContent = "This is a test"};
    return new ViewAsPdf(model);
}

link to the one that i am using.

@ValentinaNelson
Copy link

hey , you can try zetpdf.com.. By using it you can edit , view and manipulate PDF easily.

@jnm2
Copy link
Contributor

jnm2 commented Apr 7, 2019

I'm just starting to look into this myself, and it looks like the SkiaSharp library can generate PDFs.

https://docs.microsoft.com/en-us/dotnet/api/SkiaSharp.SKDocument.CreatePdf
https://www.nuget.org/packages/SkiaSharp
https://github.com/mono/SkiaSharp

@guylando
Copy link
Author

guylando commented Apr 7, 2019

@jnm2 the pdf abilities of SkiaSharp as far as I understand are more for exporting images into pdf and not for normal pdf textual documents creation. And the documentation and examples online are very poor. It is not made for pdf's and do not provide the desired abilities as good as libraries like pdfsharp which specialize in pdf.

@jnm2
Copy link
Contributor

jnm2 commented Apr 7, 2019

@guylando I'm getting nice vectors and text out of it with a simple sample. This is what I expected because the drawing commands provide the information to generate the PDF properly.

I'm sure Skia does some advanced things that aren't representable in a PDF except as raster graphics. The documentation for the dpi parameter of CreatePdf says, "The DPI (pixels-per-inch) at which features without native PDF support will be rasterized."

Found https://skia.org/dev/design/pdftheory which might also help.

@guylando
Copy link
Author

guylando commented Apr 8, 2019

@jnm2 It might be possible but I mean we try to avoid using things which we will be of the few who use it for the use-case and will have a lot of overhead over using some popular library for the use-case and I get the feeling that SkiaSharp is not popular for this use case. The basic google search shows that the pdf related code of SkiaSharp is mostly dealing with drawing on canvas. So yes you can draw text on canvas however that is far from the simple methods such as "AddPage" available in pdfsharp if we want to create a multi page pdf export of some data. I can also write pdf generator myself in C if I put enough time into it but that is not the goal :) So we are looking not only at the fact of whether it is possible or not.

@jnm2
Copy link
Contributor

jnm2 commented Apr 8, 2019

@guylando SkiaSharp has BeginPage/EndPage and lets you set PDF metadata. It's pretty high level, nothing like if you wrote a PDF generator yourself. I do understand that it's not a PDF-centric library; we still need something that can manipulate PDFs. But for folks looking to generate, this may be one of the easiest options depending on your use cas.

@guylando
Copy link
Author

guylando commented Apr 8, 2019

@jnm2 Thanks, I will check this out when I get to the conversion to net core (which will be a must when asp.net 3 is out since it only supports net core from what I understood).
The apis we use in pdfsharp are:

  1. Set document title
  2. AddPage
  3. AddSection
  4. AddParagraph including the ability to declare space after and space before (in cm or similar)
  5. AddImage
  6. AddText
  7. fonts, font sizes, margins
  8. DrawString
  9. GetTextHeight

@guylando
Copy link
Author

guylando commented Apr 8, 2019

@jnm2 Note however that pdfsharp already has some net standard ports (and even a claim that it works as is in net core 2.2) as written in the final comments here empira/PDFsharp#6 but they are not official (unless the claim it works with net core 2.2 is true) and not as well supported as SkiaSharp which turns SkiaSharp into a better option probably

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants