GemBox Support Forum

Save the PDF page as an image, but comes out black and white.

Currently, development under the Trial License is in progress.

I am trying to save only the first page of the PDF as an image.

I followed a simple sample example, but the image continues to be saved in black and white.

What is the problem?

private bool CreateThumbnail(string inputPath, string outputPath)

        using (var document = GemBox.Pdf.PdfDocument.Load(inputPath))
            GemBox.Pdf.ImageSaveOptions options = new GemBox.Pdf.ImageSaveOptions();
            options.Format = GemBox.Pdf.ImageSaveFormat.Png;
            options.PageCount = 1;
            options.PageNumber = 0;
            //options.DpiX = 300;
            //options.DpiY = 300;
            //options.PixelFormat = GemBox.Pdf.PixelFormat.
            // Save the PDF document as a file.
            document.Save(outputPath, options);

        return true;
        return false;

I also have some additional questions regarding the full functionality.

  1. Do you support UWP C#?

  2. Can I freely change the black and white reverse mode in the PDF viewer?

  3. Is there a function to select/enlarge a specific area by dragging in the PDF viewer?


Is the resulting image in grayscale or completely black (empty)?

I’m familiar with the issue of getting a black (or empty) image, this can occur in the ASP.NET Core 3.1 (or above) that is hosted on IIS. To resolve this issue, you’ll need to set Switch.System.Windows.Media.ShouldRenderEvenWhenNoDisplayDevicesAreAvailable to true with either a “runtimeconfig.template.json” file or AppContext class.

If the result is indeed black and white, then I believe this issue is probably specific to your input PDF. Can you send it to us so that we can try reproducing the same?

Regarding your additional questions.

  1. Yes, GemBox.Pdf does support UWP.
  2. I’m not sure what you mean by this, what PDF Viewer are you referring to?
    Note, GemBox.Pdf enables you to convert PDF to an image or XPS. You can combine this together with some existing control that supports rendering an image or XPS in order to create your PDF Viewer.
  3. Again, I’m afraid that GemBox.Pdf doesn’t provide PDF Viewer control. We have examples that demonstrate how you can create one in the WPF application using DocumentViewer control and Image control.


resulting Image in grayscale.

My Application is WPF C# WIndows App .NetFramework 4.8

Could you please elaborate on how I can solve the problem of saving as grayscale when saving as an image in a WPF C# Windows application?

.Net Framework 4.8
Windows Application

Hi Jinhyeon,

Again, I’m afraid I was unable to reproduce this issue.
Please send us your PDF file so that we can try reproducing this issue and resolving it for you.