0
我想生成第一頁的縮略圖。試圖用下面的頁面生成,不能打印具有良好分辨率的圖像,應該在縮放時顯示具有良好分辨率的圖像。即使我們有選擇打印縮略圖的前幾列也沒有問題。請建議。Aspose:爲第一頁生成縮略圖
Workbook book = new Workbook(new ByteArrayInputStream(documentData));
// Define ImageOrPrintOptions
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
// Set the vertical and horizontal resolution
imgOptions.setVerticalResolution(200);
imgOptions.setHorizontalResolution(200);
// Set the image's format
imgOptions.setImageFormat(ImageFormat.getJpeg());
// One page per sheet is enabled
imgOptions.setOnePagePerSheet(true);
// Get the first worksheet
Worksheet sheet = book.getWorksheets().get(0);
// Render the sheet with respect to specified image/print options
SheetRender sr = new SheetRender(sheet, imgOptions);
// Render the image for the sheet
sr.toImage(0, "mythumb.jpg");
// Creating Thumbnail
java.awt.Image img = ImageIO.read(new File("mythumb.jpg")).getScaledInstance(100, 100, BufferedImage.SCALE_SMOOTH);
BufferedImage img1 = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
img1.createGraphics().drawImage(
ImageIO.read(new File("mythumb.jpg")).getScaledInstance(100, 100, img.SCALE_SMOOTH), 0, 0, null);
return img1;