Skip to content

Instantly share code, notes, and snippets.

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 atirtahirgroupdocs/83198cffebc13d5f28883274bfb56f57 to your computer and use it in GitHub Desktop.
Save atirtahirgroupdocs/83198cffebc13d5f28883274bfb56f57 to your computer and use it in GitHub Desktop.
// For complete examples and data files, please go to https://github.com/groupdocs-signature/GroupDocs.Signature-for-Java
// setup Signature configuration
SignatureConfig signConfig = CommonUtilities.getConfiguration();
// instantiating the conversion handler
SignatureHandler<String> handler = new SignatureHandler<String>(signConfig);
DocumentDescription docInfo = handler.getDocumentDescription(CommonUtilities.getStoragePath(fileName), "");
System.out.println("Document " + docInfo.getGuid() + " contains " + docInfo.getPageCount() + " pages");
System.out.println("Width of first page is " + docInfo.getPages().get(0).getWidth()) ;
// Image from specified page
byte[] bytesImage = handler.getPageImage(CommonUtilities.getStoragePath(fileName), 1, null, null, null);
InputStream memoryStream = new ByteArrayInputStream(bytesImage);
FileOutputStream out = new FileOutputStream(CommonUtilities.getOutputPath("image_from_page.png"));
BufferedImage imBuff = ImageIO.read(memoryStream);
System.out.println("Height of image is " + imBuff.getHeight());
ImageIO.write(imBuff, "png",out );
memoryStream.close();
// Page size
java.awt.Dimension pageSize = handler.getDocumentPageSize(CommonUtilities.getStoragePath(fileName), 1, "", (double)0, (double)0, null);
System.out.println("Page size is " + pageSize.getHeight() + " x " + pageSize.getWidth());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment