C# - How to convert an image to a PDF (using a free library)

Viewed 19283

I've researched quite a bit but most answers I've found involve using iText which is only free for authors of open source software.

My question is how to utilise a free (preferably well maintained) PDF library to convert an image into PDF. More specifically I'm using Selenium to test a webpage and part of the requirements are for a screenshot of a results page to be saved in PDF format.

What I have at the moment:

        Screenshot screenshot = ((ITakesScreenshot)WebDriver).GetScreenshot();
        fileName =  filePath + fileName;

        screenshot.SaveAsFile($"{fileName}.png", ImageFormat.Png);

        // Convert to PDF and delete image
        // ?
2 Answers
Related