原創(chuàng)|行業(yè)資訊|編輯:何躍|2021-12-23 09:58:14.847|閱讀 608 次
概述:PDF壓縮原理是什么呢,識(shí)別出PDF中各種布局層、圖像和文字資源等,通過(guò)技術(shù)手段對(duì)布局進(jìn)行優(yōu)化、刪除pdf中不需要的資源。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門(mén)軟控件火熱銷(xiāo)售中 >>
PDF Optimizer 在各方面對(duì)PDF文件進(jìn)行優(yōu)化。各種復(fù)雜功能的組合允許在沒(méi)有或最小的視覺(jué)質(zhì)量損失的情況下實(shí)現(xiàn)高壓縮。另一個(gè)應(yīng)用是為打印優(yōu)化PDF,通過(guò)合并嵌入式字體來(lái)減少線軸文件的大小,并應(yīng)用設(shè)備特定的色彩空間轉(zhuǎn)換。
PDF Optimizer 有不同的使用版本:作為Shell在命令行上使用,作為被監(jiān)視的文件夾服務(wù)和作為API在C#、Visual Basic、Java、C/C++中使用。
主要優(yōu)化項(xiàng)目
在代碼實(shí)現(xiàn)中,操作比較方便,也支持Windows和Linux開(kāi)發(fā)包,具體的類(lèi)庫(kù)和實(shí)現(xiàn)代碼看下面:
// c#代碼 using (Optimizer optimizer = new Optimizer()) { // Choose the optimization profile for archiving optimizer.Profile = PDFOptimizationProfile.eOptimizationProfileArchive; // Open input file if (!optimizer.Open(inputPath, "")) throw new Exception(String.Format("Input file {0} cannot be opened. " + "{1} (ErrorCode: 0x{2:x}).", inputPath, optimizer.ErrorMessage, optimizer.ErrorCode)); // Save output file if (!optimizer.SaveAs(outputPath, "", "", PDFPermission.ePermNoEncryption)) throw new Exception(String.Format("Output file {0} cannot be created. " + "{1} (ErrorCode: 0x{2:x}).", outputPath, optimizer.ErrorMessage, optimizer.ErrorCode)); // Close input file if (!optimizer.Close()) throw new Exception(String.Format("Input file {0} cannot be closed. " + "{1} (ErrorCode: 0x{2:x}).", inputPath, optimizer.ErrorMessage, optimizer.ErrorCode)); }
// Java代碼 optimizer = new PdfOptimize(); // Choose the optimization profile for archiving optimizer.setProfile(PdfOptimize.OPTIMIZATIONPROFILE.eOptimizationProfileArchive); // Open input file if (!optimizer.open(inputPath, "")) throw new IOException(String.format("Input file %s cannot be opened. %s (ErrorCode: 0x%08x).", inputPath, optimizer.getErrorMessage(), optimizer.getErrorCode())); // Save output file if (!optimizer.saveAs(outputPath, "", "", NativeLibrary.PERMISSION.ePermNoEncryption)) throw new IOException(String.format("Output file %s cannot be created. %s (ErrorCode: 0x%08x).", outputPath, optimizer.getErrorMessage(), optimizer.getErrorCode())); // Close input file if (!optimizer.close()) throw new IOException(String.format("Input file %s cannot be closed. %s (ErrorCode: 0x%08x).", inputPath, optimizer.getErrorMessage(), optimizer.getErrorCode()));
// C++代碼 pOptimizer = PdfOptimizeCreateObject(); // Choose the optimization profile for archiving PdfOptimizeSetProfile(pOptimizer, eOptimizationProfileArchive); // Open input file if (!PdfOptimizeOpen(pOptimizer, szInputPath, _T(""))) { _tprintf(_T("Input file %s cannot be opened. %s (ErrorCode: 0x%08x).\n"), szInputPath, PdfOptimizeGetErrorMessage(pOptimizer), PdfOptimizeGetErrorCode(pOptimizer)); iReturnValue = 1; goto cleanup; } // Save output file if (!PdfOptimizeSaveAs(pOptimizer, szOutputPath, _T(""), _T(""), ePermNoEncryption)) { _tprintf(_T("Output file %s cannot be created. %s (ErrorCode: 0x%08x).\n"), szOutputPath, PdfOptimizeGetErrorMessage(pOptimizer), PdfOptimizeGetErrorCode(pOptimizer)); iReturnValue = 1; goto cleanup; } // Close input amd output files if (!PdfOptimizeClose(pOptimizer)) { _tprintf(_T("Input file %s cannot be closed. %s (ErrorCode: 0x%08x).\n"), szInputPath, PdfOptimizeGetErrorMessage(pOptimizer), PdfOptimizeGetErrorCode(pOptimizer)); iReturnValue = 1; goto cleanup; }
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn