Excel から PDF への変換用のリサンプル画像
Contents
[
Hide
]
大量の画像を含む大きな Microsoft Excel ファイルを操作している場合、出力される PDF ファイル サイズを縮小し、全体的な変換パフォーマンスを向上させるために、追加された画像を圧縮する必要がある場合があります。 Aspose.Cells は、追加された画像の再サンプリングをサポートして、出力 PDF ファイル サイズを縮小し、パフォーマンスを向上させます。
Excel から PDF への変換用のリサンプル画像
Aspose.Cells API を使用してタスクを実行する方法を説明する次のサンプル コードを参照してください。この例では、ファイル内の画像を圧縮しながら、Microsoft Excel ファイルを PDF ファイルに変換します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(ResampleImagesforExceltoPDFConversion.class); | |
// Initialize a new Workbook | |
// Open an Excel file | |
Workbook workbook = new Workbook(dataDir + "Book1.xlsx"); | |
// Instantiate the PdfSaveOptions | |
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); | |
// Set Image Resample properties | |
pdfSaveOptions.setImageResample(300, 70); | |
// Save the PDF file | |
workbook.save(dataDir + "output.pdf", pdfSaveOptions); |
を使用してPdfSaveOptions.setImageResample オプションは、出力 PDF のサイズを最小化しますが、画質に少し影響を与える可能性があります。
スプレッドシートに数式が含まれている場合は、[Workbook.calculateFormula()](https://reference.aspose.com/cells/java/com.aspose.cells/workbook#calculateFormula()スプレッドシートを PDF 形式にレンダリングする直前。そうすることで、式に依存する値が再計算され、正しい値が PDF に表示されるようになります。