Skip to content

Rebase on .NET Standard 2.0 #39

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

Closed
wants to merge 1 commit into from

Conversation

danielgindi
Copy link

I know that iText 5 is EOL, but for people who are trying to migrate to newer technologies, it becomes very complex do it all at once.
Allowing itextsharp to compile for .NET Standard removes this obstacle from the way.

@andreycha
Copy link

Hi @danielgindi . I've tried your packages from Nuget.org (https://www.nuget.org/packages/Portable.itextsharp and https://www.nuget.org/packages/Portable.itextsharp.xmlworker) and found out that converting HTML to PDF using XmlWorkerHelper does not work. Calling Document.Close() throws "System.IOException: The document has no pages." (using this sample from SO). Have you tried it out and could you maybe advise anything?

@danielgindi
Copy link
Author

Hi @danielgindi . I've tried your packages from Nuget.org (https://www.nuget.org/packages/Portable.itextsharp and https://www.nuget.org/packages/Portable.itextsharp.xmlworker) and found out that converting HTML to PDF using XmlWorkerHelper does not work. Calling Document.Close() throws "System.IOException: The document has no pages." (using this sample from SO). Have you tried it out and could you maybe advise anything?

I did not try the helper specifically, but found out that when using in .NET Core env, I needed to register the used codepages with the system encoding, as it only had just about utf8 out of the box, so iText could not load fonts. It might be related.

@andreycha
Copy link

andreycha commented Mar 7, 2022

Could you please share relevant code sample? If you meant using System.Text.Encoding.CodePages package and adding Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); then unfortunately it doesn't help...

@danielgindi
Copy link
Author

Could you please share relevant code sample? If you meant using System.Text.Encoding.CodePages package and adding Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); then unfortunately it doesn't help...

Exactly what I meant...
Maybe try to debug it? You can download the fork and compile locally easily.
Then you could perhaps find what's the source of the issue. I can say that manual pdf generation works perfectly.

@andreycha
Copy link

So the issue was in DefaultTagProcessorFactory.Load(): there is no overload of Activator.CreateInstance() in .NET Standard which accepts class name. The call was throwing an exception, unable to create tag processors which resulted into an empty document. The call should look like Activator.CreateInstance(Type.GetType(className)). Now HTML to PDF conversion works.

I've double checked other calls of Activator.CreateInstance(), they look good.

Feel free to include this fix into your PR/republish packages. Thanks for quick response and help!

@danielgindi
Copy link
Author

@andreycha Fixing, rebasing on 5.5.13.3, and releasing :-)

@danielgindi danielgindi closed this Mar 8, 2022
@danielgindi danielgindi deleted the 5.5.13.2-portable branch March 8, 2022 17:58
@danielgindi danielgindi restored the 5.5.13.2-portable branch March 8, 2022 17:59
@danielgindi danielgindi deleted the 5.5.13.2-portable branch March 8, 2022 17:59
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

Successfully merging this pull request may close these issues.

2 participants