翻譯|行業資訊|編輯:胡濤|2023-07-24 11:20:16.100|閱讀 123 次
概述:在這篇博文中,我們將探討 Java 中的文檔查看器以及它如何簡化文檔查看和協作流程,歡迎查閱~
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
文檔管理和共享已成為各個行業的重要方面。Java 提供了強大的框架,使開發人員能夠構建功能豐富的應用程序。在這篇博文中,我們將探討 Java 中的文檔查看器以及它如何簡化文檔查看和協作流程。
支持流行文件格式處理,并允許將各類文檔導出或轉換為固定布局文件格式和最常用的圖像/多媒體格式。
文檔查看器是一個應用程序,允許用戶查看不同類型的文檔并與之交互,而無需安裝專用軟件。Aspose提供對不同文件格式的支持,使您能夠在 Java 應用程序中操作和查看文檔。
Aspose.Page for Java API 可用于操作或轉換 XPS、PS、EPS 等。您可以將這些文件格式渲染為任何流行的圖像格式,如 PNG、JPG、TIFF 等,以便快速查看文件內容。
// initialize PostScript input stream FileInputStream psStream = new FileInputStream("input.eps"); // load EPS document PsDocument document = new PsDocument(psStream); //create an instance of JpegSaveOptions JpegSaveOptions options = new JpegSaveOptions(); //create rendering device for EPS format ImageDevice device = new ImageDevice(); //save EPS as JPG document.save(device, options);
使用Aspose.CAD for Java可以輕松地將 DWG 繪圖轉換為 JPG 圖像。輸出圖像可以在任何設備或操作系統上查看,無需任何專用軟件。只需使用以下代碼片段即可在 Java 中將 DWG 轉換為 JPG 圖像:
// Load input DWG file Image image = Image.load("Test.dwg"); // Create an instance of CadRasterizationOptions CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions(); // Set page width & height rasterizationOptions.setPageWidth(1200); rasterizationOptions.setPageHeight(1200); // Create an instance of JpegOptions for the resultant image ImageOptionsBase options = new JpegOptions(); // Set rasterization options options.setVectorRasterizationOptions(rasterizationOptions); // Convert CAD DWG DXF file to JPG image image.save("output_image.jpg" , options);
Java 中的 PUB 查看器可以開啟高效處理 Microsoft Publisher 文件的無限可能。使用Aspose.PUB for Java,您可以創建功能強大的 PUB 查看器,使您能夠無縫查看、導航 .pub 文件并與之交互。下面的代碼片段展示了如何用 Java 創建 PUB Viewer:
// Load input PUB file IPubParser parser = PubFactory.createParser("Test.pub"); Document doc = parser.parse(); // Convert PUB to PDF file PubFactory.createPdfConverter().convertToPdf(doc, "Test.pdf"); // Load the PDF file Document document = new Document("Test.pdf"); facades.PdfFileInfo info = new facades.PdfFileInfo(document); for (Page page : document.getPages()) { // Get page dimensions from the PDF document int width = (int) info.getPageWidth(page.getNumber()); int height = (int) (info.getPageHeight(page.getNumber())); // Set resolution for the output image devices.Resolution resolution = new devices.Resolution(300); // Create JPEG device with specified Width and Height devices.JpegDevice jpegDevice = new devices.JpegDevice(width, height , resolution); // Convert PUB to JPG image jpegDevice.process(page, "Page" + page.getNumber() + ".jpg"); }
您可以使用 Java 創建 PSD 查看器來輕松查看和使用 .psd 文件。以下代碼片段演示了如何使用 [Aspose.PSD for Java]在 Java 中創建 PSD 查看器。
import com.aspose.psd.Image; import com.aspose.psd.License; import com.aspose.psd.fileformats.psd.PsdImage; import com.aspose.psd.imageoptions.JpegOptions; public class PSDToJPG { public static void main(String[] args) throws Exception { String path= "/Users/Documents/KB/TestData/"; // Apply the API license to convert PSD to JPEG License psdLicence = new License(); psdLicence.setLicense(path + "Conholdate.Total.Product.Family.lic"); //Load a PSD file into PsdImage object PsdImage psdFile = (PsdImage)Image.load(path + "AllAdjustments.psd"); // Set the desired output JPEG options JpegOptions jpegOpts = new JpegOptions(); jpegOpts.setQuality(80); jpegOpts.setJpegLsAllowedLossyError (10); // Save the exported JPG on the disk psdFile.save(path + "ConvertedPsd.jpg", jpegOpts); } }
然而,下面的列表編譯了 Java 中 PSD 文檔查看器的一些功能:
在科學和學術寫作領域,LaTeX已成為創建精美排版文檔的事實上的標準。您可以將 LTX 或 TeX 文件渲染為圖像以預覽其內容,而無需任何專門的軟件或插件。以下示例代碼展示了如何在 Java 中將 LaTeX 文件轉換為 PNG 圖像:
// Create conversion options for Object LaTeX format on Object TeX engine extension. TeXOptions options = TeXOptions.consoleAppOptions(TeXConfig.objectLaTeX()); // Specify the file system working directory for the output. options.setOutputWorkingDirectory(new OutputFileSystemDirectory(Utils.getOutputDirectory())); // Initialize the options for saving in JPG format. options.setSaveOptions(new JpegSaveOptions()); // Run LaTeX to JPG conversion. new TeXJob(Utils.getInputDirectory() + "helloworld.ltx", new ImageDevice(), options).run();
在線文檔查看器徹底改變了我們與文檔交互的方式。它們提供了多種優勢,從可訪問性和簡化的管理到輕松的協作和增強的安全性。采用這些數字工具可以讓個人和企業利用便利和高效的力量。您可以訪問在線文檔查看器,從任何設備或操作系統打開和查看文件。
歡迎下載|體驗更多Aspose文檔管理產品
獲取更多信息請咨詢 或 加入Aspose技術交流群(761297826)
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn