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();}
sample.docx is the sample file used in this example. Click here to download it.