In GroupDocs.Redaction, Redactor class supports rendering of the document preview in on of these image formats:
JPEG Image
Portable Network Graphics
Bitmap Image File
The following example demonstrates how to get a single page preview of the document. Preview streaming uses ICreatePageStream and PreviewOptions from the Java API, wrapped with java.newProxy:
constredaction=require('@groupdocs/groupdocs.redaction');constjava=require('java');constFileOutputStream=java.import('java.io.FileOutputStream');consttestFile='sample.docx';consttestPageNumber=1;constpreviewFileName=`sample_page${testPageNumber}.png`;constcreatePageStream=java.newProxy('com.groupdocs.redaction.options.ICreatePageStream',{createPageStream:function(_pageNumber){returnnewFileOutputStream(previewFileName);}});constredactor=newredaction.Redactor(testFile);try{constoptions=newredaction.PreviewOptions(createPageStream);options.setHeight(640);options.setWidth(480);options.setPageNumbers(java.newArray('int',[testPageNumber]));options.setPreviewFormat(redaction.PreviewFormats.Png);redactor.generatePreview(options);console.log(`Preview for page ${testPageNumber} was saved to "${previewFileName}"`);}finally{redactor.close();}
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.