I am encountering issues while attempting to convert a PDF file to images using C# in a custom plugin for a model-driven app. Below are the details of the approaches I've taken and the problems I've faced:
Approaches Tried:
1) Using PDFtoImage and SkiaSharp Packages:
Unit Tests: The code works fine when executed via unit tests.
Plugin Registration Tool: When trying to update the plugin using the Plugin Registration Tool, I get the following error:
"The module was expected to contain an assembly manifest. Exception from HRESULT: 0x8013018 (mscorlib)
Investigation: It seems the issue arises because the .nupkg files for these packages include "Content" and "ContentFiles" folders containing .dlls, which cause the error during plugin update.
2) Using .NET Core Open Source Packages:
- I tried using .NET Core packages to avoid the previous issue, and while I was able to update the plugin, new issues emerged.
- Unit Tests: Again, the code works fine with unit tests.
- Model-Driven App Execution: Encounter different issues that seem to stem from similar underlying problems.
1st Approach)
PDFtoSvg and SVG Packages:- Process: Convert PDF to SVG and then SVG to JPEG.
- Error: Encountered the following exception: System.Runtime.InteropServices.ExternalException (0x80004005): A generic error occurred in GDI+. at System.Drawing.FontFamily.GetGdipGenericSansSerif()
2nd Appoach)
PDFtoPNG Package:
Error:The conversion results in an empty array of images.
Observations:
- All approaches work in unit tests but fail when running in the model-driven app.
- The issue seems related to the Draw() methods, potentially involving System.Drawing.
- For the first approach, using SVG images is not a viable solution for my requirements because it is needed one of the below types: PNG , JPEG (.jpeg and .jpg), WEBP (.webp), and non-animated GIF (.gif).
Has anyone faced a similar issue or have insights on why the code behaves differently in a model-driven app compared to unit tests? Any suggestions on resolving this would be greatly appreciated.