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

[SDK] PDFSharpCore dependency #371

Open
nataz77 opened this issue Apr 17, 2024 · 1 comment
Open

[SDK] PDFSharpCore dependency #371

nataz77 opened this issue Apr 17, 2024 · 1 comment
Labels

Comments

@nataz77
Copy link

nataz77 commented Apr 17, 2024

Describe the bug
When trying to export a pdf, using NAPS2.Sdk and having installed PDFSharpCore 1.3.63 as a dependency on the same project, calling

await pdfExporter.Export(outputPath, images, ocrParams: null);

throws
TypeLoadException: Could not load type 'PdfSharpCore.Drawing.IImageSource' from assembly 'PdfSharpCore, Version=1.3.63.0, Culture=neutral, PublicKeyToken=null'.

To Reproduce
Install both NAPS2.Sdk and PDFSharpCore:

...
	    <PackageReference Include="NAPS2.Images.Gdi" Version="1.0.1" />
		<PackageReference Include="NAPS2.Pdfium.Binaries" Version="1.1.0" />
		<PackageReference Include="NAPS2.Sdk" Version="1.0.0" />
		<PackageReference Include="NAPS2.Tesseract.Binaries" Version="1.2.0" />
		<PackageReference Include="PdfSharpCore" Version="1.3.63" />
...

and try to import and export a PDF file:

        PdfImporter pdfImporter = new(scanningContext);
        List<ProcessedImage> images = [];
        await foreach (ProcessedImage image in pdfImporter.Import(pdfPath))
        {
            images.Add(image.WithTransform(new RotationTransform(180), true).Clone());
        }

        PdfExporter pdfExporter = new(scanningContext);
       await pdfExporter.Export(outputPath, images, ocrParams: null);

Expected behavior
The pdf file should export correctly.

Desktop (please complete the following information):

  • OS: Windows 11 (throws the same when hosting in a Ubuntu container)
  • Version: SDK 1.0.0
  • .NET: 8.0.104

Additional context
Removing the PDFSharpCore dependency or referencing directly the version 1.0.0 works,
image
but also induces memory leaks when exporting documents with 1000+ pages and in other parts of my code.

@800903
Copy link

800903 commented May 6, 2024

may be some dlls need add your project.

@cyanfish cyanfish added the sdk label Aug 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants