Ruby での PDF ファイルサイズの最適化
Contents
[
Hide
]
Aspose.PDF - PDF ファイルサイズの最適化
Aspose.PDF Java for Ruby を使用して PDF ドキュメントのファイルサイズを最適化するには、Optimize モジュールの optimize_filesize メソッドを呼び出してください。
Ruby コード
def optimize_filesize()
В В В # The path to the documents directory.
В В В data_dir = File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) + '/data/'
В В В # Open a pdf document.
В В В doc = Rjb::import('com.aspose.pdf.Document').new(data_dir + "input1.pdf")
В В В # Optimize the file size by removing unused objects
В В В opt = Rjb::import('aspose.document.OptimizationOptions').new
В В В opt.setRemoveUnusedObjects(true)
В В В opt.setRemoveUnusedStreams(true)
В В В opt.setLinkDuplcateStreams(true)
В В В doc.optimizeResources(opt)
В В В # Save output document
В В В doc.save(data_dir + "Optimized_Filesize.pdf")
В В В puts "Optimized PDF Filesize, please check output file."
endВ
実行コードのダウンロード
ダウンロード PDF ファイルサイズの最適化 (Aspose.PDF) から、以下に記載されたソーシャルコーディングサイトのいずれか: