delegate for each page stream creation (see event handler CreatePageStream);
image preview format - PNG / JPG / BMP;
page numbers to process;
custom size of preview images (if needed).
Note
Stream that were created by CreatePageStream delegate will be disposed automatically once after generation of preview image. If you need to implement custom image preview stream disposing you have to pass additional argument ReleasePageStream to clean up resources.
privatestaticvoidReleasePageStream(intpageNumber,StreampageStream){pageStream.Dispose();stringimageFilePath=Path.Combine("GeneratePreviewFolder","image-"+pageNumber.ToString()+".jpg");Console.WriteLine("Image file {0} is ready for preview",imageFilePath);}
Generate document preview from stream with custom stream releasing delegate
publicstaticvoidGetPreview(){stringfilePath=@"c:\sample.xlsx";using(Mergermerger=newMerger(filePath)){IPreviewOptionspreviewOption=newPreviewOptions(CreatePageStream,ReleasePageStream,PreviewMode.JPEG);merger.GeneratePreview(previewOption);}}privatestaticStreamCreatePageStream(intpageNumber){stringimageFilePath=Path.Combine("GeneratePreviewFolder","image-"+pageNumber.ToString()+".jpg");varfolder=Path.GetDirectoryName(imageFilePath);if(!Directory.Exists(folder)){Directory.CreateDirectory(folder);}returnnewSystem.IO.FileStream(imageFilePath,FileMode.Create);}privatestaticvoidReleasePageStream(intpageNumber,StreampageStream){pageStream.Dispose();stringimageFilePath=Path.Combine("GeneratePreviewFolder","image-"+pageNumber.ToString()+".jpg");Console.WriteLine("Image file {0} is ready for preview",imageFilePath);}
Note
NOTE: Stream that was created over CreatePageStream delegate will be disposed automatically once after generation of preview image. If you need to implement custom image preview stream disposing you have to pass additional argument ReleasePageStream to clean up resources.
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.