Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active March 22, 2022 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GroupDocsGists/3e3c9f756ece5d6f94f90603ec2798bd to your computer and use it in GitHub Desktop.
Save GroupDocsGists/3e3c9f756ece5d6f94f90603ec2798bd to your computer and use it in GitHub Desktop.
Convert Document to Grayscale Images in C#
// Convert PDF to Grayscale JPG in C#
using (Converter converter = new Converter("path/document.pdf"))
{
ImageConvertOptions options = new ImageConvertOptions
{
Format = ImageFileType.Jpg,
Grayscale = true,
// Aditional Conversion Options
Height = 1024,
Width = 1024,
FlipMode = ImageFlipModes.FlipX,
RotateAngle = 90,
/*
Brightness = 50,// Brightness
Gamma = 0.5F, // Gamma Settings
Contrast = 50 // Contrast
*/
};
converter.Convert("path/grayscaleDocument.jpg", options);
}
// Convert PDF to Grayscale PNG in C#
using (Converter converter = new Converter("path/document.pdf"))
{
ImageConvertOptions options = new ImageConvertOptions
{
Format = ImageFileType.Png,
Grayscale = true
};
converter.Convert("path/grayscaleDocument.png", options);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment