web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Converting PDF Files t...
Power Apps
Answered

Converting PDF Files to Images in a Model-Driven App Custom Plugin

(0) ShareShare
ReportReport
Posted on by 27

 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.

 

I have the same question (0)
  • cchannon Profile Picture
    4,702 Moderator on at

    I am pretty sure you are saying that you are deploying a plugin package and not a normal plugin, but would you please confirm?

  • SGbron Profile Picture
    27 on at

    yes, exactly...

  • Verified answer
    SGbron Profile Picture
    27 on at

    @cchannon  finally the solution came from another resource...

    I used the Azure Functions for this reason. 

    With this solution all the code that I am using and had compatibility issues with the .net framework or the Power Platform runs outside the solution with Azure Function. 

  • cchannon Profile Picture
    4,702 Moderator on at

    That would have been precisely my suggestion. Glad you sorted it out!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 316 Most Valuable Professional

#2
11manish Profile Picture

11manish 242

#3
Valantis Profile Picture

Valantis 198

Last 30 days Overall leaderboard