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

Replace iTextSharp with a new PDF library #4622

Closed
AndreiMaz opened this issue Apr 29, 2020 · 9 comments
Closed

Replace iTextSharp with a new PDF library #4622

AndreiMaz opened this issue Apr 29, 2020 · 9 comments

Comments

@AndreiMaz
Copy link
Member

AndreiMaz commented Apr 29, 2020

iTextSharp is EOL. So we have to find a replacement

let's just ensure that iText 7 has an appropriate license for us. For example, please see https://itextpdf.com/en/how-buy/agpl-license. One important note: "When using iText 7 Community under AGPL, you must prominently mention iText and include the iText copyright and AGPL license in output file metadata, and also retain the producer line in every PDF that is created or manipulated using iText."

Originally suggested by @ecommerce-tester in #196 (comment)

Let's also investigate the approach with conversion to HTML and then to PDF (so we have to find a library that supports export from HTML to PDF)

@DmitriyKulagin
Copy link
Contributor

DmitriyKulagin commented Nov 6, 2020

After some investigation, we came to the conclusion that iText 7 is not suitable for us, since RTL support for this library is in the paid pdfCalligraph module.
I think that we need to move away from the principle of generating PDF directly, and first generate HTML and then convert it to PDF with some tool.

Here is a benchmark test of some of the tools. This is just for thought.

@AndreiMaz AndreiMaz modified the milestones: Version 4.40, Version 4.50 Dec 8, 2020
@AndreiMaz AndreiMaz changed the title Replace iTextSharp to iText 7 Replace iTextSharp to iText 7 (or any other alternative) Dec 11, 2020
@AndreiMaz AndreiMaz assigned exileDev and unassigned DmitriyKulagin Apr 18, 2021
@RomanovM RomanovM modified the milestones: Version 4.50, Version 4.60 Nov 22, 2021
@purplepiranha
Copy link
Contributor

I've been doing a lot of work with writing customised reports this week and have faced quite a few challenges trying to use iTextSharp 5. Looking at iText 7, as well as the RTL support mentioned above being a problem, I think there is a bigger issue that developers working on NopCommerce sites may well want to use in library in their own implementations and this wouldn't be covered by the license unless those implementations were also open-sourced.

I was quite surprised that there seems to be a lack of open source PDF generation libraries for C#. There are a few about but most haven't been updated for several years and aren't compatible with NET5/6.

I have though found QuestPDF which is open-source and available under MIT license. In 4 hours I've managed to recreate using QuestPDF what has taken me over 3 days using iTextSharp 5. It seems quite impressive and uses a simple FluentAPI syntax.

@AndreiMaz AndreiMaz modified the milestones: Version 4.60, Version 4.70 Mar 17, 2022
@AndreiMaz AndreiMaz modified the milestones: Version 4.70, Version 4.60 Nov 18, 2022
@AndreiMaz AndreiMaz changed the title Replace iTextSharp to iText 7 (or any other alternative) Replace iTextSharp with a new PDF library Nov 18, 2022
@iwhp
Copy link
Contributor

iwhp commented Dec 1, 2022

The current implementation for creating PDF invoices etc. does not follow separation of concerns. There are many calculations that are performed site by site with creating the PDF files. To be more flexible it would be helpful if the calculation of the values were separated from the output to be created. I hope this will be taken into account when implementing a replacement for iTextSharp 5.

@purplepiranha
Copy link
Contributor

The current implementation for creating PDF invoices etc. does not follow separation of concerns. There are many calculations that are performed site by site with creating the PDF files. To be more flexible it would be helpful if the calculation of the values were separated from the output to be created. I hope this will be taken into account when implementing a replacement for iTextSharp 5.

I fully agree with this. I find this a big problem in a lot of other areas in NopCommerce too.

The logic for the invoice calculation needs to be totally decoupled from the logic to generate the final invoice document.

exileDev added a commit that referenced this issue Dec 2, 2022
@exileDev
Copy link
Contributor

exileDev commented Dec 2, 2022

I hope this is what you mean :)

Closed #4622

@alextretij
Copy link

I tried to find the convertor from HTML to PDF and I could not do it.
This convertor has to work on Windows/Linux/Azure application, etc.
But ....
I found only wrappers for l wkhtmltopdf
Example
https://github.com/rdvojmoc/DinkToPdf
But they work only common (simple HTML markups)
Example for links in Linux
https://stackoverflow.com/questions/73342471/dinktopdf-on-linux-doesnt-show-images/73527372#73527372

@jaroslav-sykora
Copy link

jaroslav-sykora commented Oct 2, 2023

I've been doing a lot of work with writing customised reports this week and have faced quite a few challenges trying to use iTextSharp 5. Looking at iText 7, as well as the RTL support mentioned above being a problem, I think there is a bigger issue that developers working on NopCommerce sites may well want to use in library in their own implementations and this wouldn't be covered by the license unless those implementations were also open-sourced.

I was quite surprised that there seems to be a lack of open source PDF generation libraries for C#. There are a few about but most haven't been updated for several years and aren't compatible with NET5/6.

I have though found QuestPDF which is open-source and available under MIT license. In 4 hours I've managed to recreate using QuestPDF what has taken me over 3 days using iTextSharp 5. It seems quite impressive and uses a simple FluentAPI syntax.

This QuestPDF MIT free license is applicable only for companies and individuals with less than $1M USD annual gross revenue, or projects using the library as a transitive dependency, or non-profit projects.

I'm confused about iTextSharp 5 licence. Does it mean if i create website for my customer based on nopCommerce do i have to buy iTextSharp licence or not? Lets say i do some customizations to original nopCommerce design and i create some plugin do i have to make my source public?

@purplepiranha
Copy link
Contributor

I've been doing a lot of work with writing customised reports this week and have faced quite a few challenges trying to use iTextSharp 5. Looking at iText 7, as well as the RTL support mentioned above being a problem, I think there is a bigger issue that developers working on NopCommerce sites may well want to use in library in their own implementations and this wouldn't be covered by the license unless those implementations were also open-sourced.
I was quite surprised that there seems to be a lack of open source PDF generation libraries for C#. There are a few about but most haven't been updated for several years and aren't compatible with NET5/6.
I have though found QuestPDF which is open-source and available under MIT license. In 4 hours I've managed to recreate using QuestPDF what has taken me over 3 days using iTextSharp 5. It seems quite impressive and uses a simple FluentAPI syntax.

This QuestPDF MIT free license is applicable only for companies and individuals with less than $1M USD annual gross revenue, or projects using the library as a transitive dependency, or non-profit projects.

I'm confused about iTextSharp 5 licence. Does it mean if i create website for my customer based on nopCommerce do i have to buy iTextSharp licence or not? Lets say i do some customizations to original nopCommerce design and i create some plugin do i have to make my source public?

QuestPDF licensing unfortunately changed a while back. Before then it was all under MIT license. If your customer's revenue is above $1M USD then I doubt they would have a problem paying it though.

The iTextSharp license is a pain. As the library is a dependency of your project (note: Nop isn't packaged, so it's not part of Nop) then yes you project has to be open source.

Also, QuestPDF is far easier to use than iTextSharp. There is a problem though with larger files due to the lack of font subsetting.

@AndreiMaz
Copy link
Member Author

nopCommerce does not use the latest version of QuestPDF that introduced dual licensing. Hence this the new license with the requirement of $1M is not applicable to nopCommerce

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

No branches or pull requests

8 participants