We are building and Azure App function and we would like to do an in-memory transition from PDF to PNG. A nuget distributed dll would be ideal.
            Asked
            
        
        
            Active
            
        
            Viewed 1,094 times
        
    0
            
            
        - 
                    Related: https://stackoverflow.com/questions/23905169/how-to-convert-pdf-files-to-image – StayOnTarget Mar 27 '19 at 18:49
 
2 Answers
3
            
            
        Patagames PDF SDK is suitable for Azure very well. Also it's distributed via NUGET
PM> Install-Package Pdfium.Net.SDK
code snippet:
PdfCommon.Initialize()
using (var doc = PdfDocument.Load(@"d:\0\test_big.pdf"))
{
    int dpi = 96;
    foreach (var page in doc.Pages)
    {
        int width = (int)(page.Width / 72.0  * dpi);
        int height = (int)(page.Height / 72.0 * dpi);
        using (var bitmap = new PdfBitmap(width, height, true))
        {
            bitmap.FillRect(0, 0, width, height, Color.White);
            page.Render(bitmap, 0, 0, width, height, PageRotate.Normal, RenderFlags.FPDF_LCD_TEXT);
            bitmap.Image.Save(...);
        }
        page.Dispose();
    }
}
        Oldman
        
- 29
 - 2
 
0
            I preferred Xfinium PDF Library as it also worked with Mono and was pretty easy to use. It is a commercial solution, though.
        StayOnTarget
        
- 11,743
 - 10
 - 52
 - 81
 
        mbnx
        
- 912
 - 5
 - 11