Skip to content

Instantly share code, notes, and snippets.

@GroupDocsGists
Last active March 25, 2022 16:04
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save GroupDocsGists/f9048bda36bd429f32e816b530244a77 to your computer and use it in GitHub Desktop.
Convert Document to Grayscale Images in Java
// Convert PDF to Grayscale PNG in Java
Converter converter = new Converter("path/document.pdf");
ImageConvertOptions options = new ImageConvertOptions();
options.setFormat(ImageFileType.Jpg);
options.setGrayscale(true);
/*
options.setFlipMode(ImageFlipModes.FlipY);
options.setBrightness(50);
options.setContrast(50);
options.setGamma(0.5F);
*/
converter.convert("path/grayscaleDocument.jpg", options);
// Convert PDF to Grayscale PNG in Java
Converter converter = new Converter("path/document.pdf");
ImageConvertOptions options = new ImageConvertOptions();
options.setFormat(ImageFileType.Png);
options.setGrayscale(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