翻譯|行業(yè)資訊|編輯:胡濤|2024-07-24 10:11:36.210|閱讀 78 次
概述:本指南適用于正在尋找PostScript Java庫(kù)以編程方式將 PostScript 轉(zhuǎn)換為GIF 的Java 程序員。您幾乎可以在所有流行的操作系統(tǒng)上輕松打開(kāi) GIF 圖像,而無(wú)需安裝軟件。
# 界面/圖表報(bào)表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
現(xiàn)在將PostScript文件轉(zhuǎn)換為高質(zhì)量圖像并不是一件難事。Aspose.Page為多種編程語(yǔ)言提供高代碼 API,以便以編程方式轉(zhuǎn)換和操作 PS 文件。此外,它還支持企業(yè)級(jí)在線PS文件轉(zhuǎn)換器,以將 PS 文件轉(zhuǎn)換為其他流行的文件格式。但是,本指南適用于正在尋找PostScript Java庫(kù)以編程方式將 PostScript 轉(zhuǎn)換為GIF 的Java 程序員。您幾乎可以在所有流行的操作系統(tǒng)上輕松打開(kāi) GIF 圖像,而無(wú)需安裝軟件。那么,讓我們開(kāi)始吧。
Aspose.Page for Java - 用于XPS,PS和EPS的Java文件操作API,允許用戶創(chuàng)建,解析和保存XPS文件,以及在文檔中添加和刪除頁(yè)面。允許將PS和EPS文件轉(zhuǎn)換為PDF和光柵圖像格式。允許開(kāi)發(fā)人員為XPS文檔創(chuàng)建畫(huà)布,路徑和字形元素,并執(zhí)行諸如添加或刪除頁(yè)面,創(chuàng)建矢量和字符串,使用畫(huà)筆以及操縱元素外觀等操
為了安裝Aspose.Page for Java,您可以 下載JAR 文件或使用以下 Maven 配置:
<repositories> <repository> <id>AsposeJavaAPI</id> <name>Aspose Java API</name> <url>//releases.aspose.com/java/repo/</url> </repository> </repositories> <dependencies> <dependency> <groupId>com.aspose</groupId> <artifactId>aspose-page</artifactId> <version>23.12</version> </dependency> </dependencies>
此外,您可以訪問(wèn)此指南來(lái)了解完整的詳細(xì)信息。
現(xiàn)在,您可以開(kāi)發(fā)一款 PS 轉(zhuǎn) GIF 制作器,用于商業(yè)軟件。因此,請(qǐng)按照以下步驟操作:
以下代碼示例演示了如何以編程方式在 Java 中將 PostScript 轉(zhuǎn)換為 GIF:
package com.example; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import com.aspose.eps.PsDocument; import com.aspose.eps.device.ImageDevice; import com.aspose.eps.device.ImageSaveOptions; public class Main { // High Code Java API to Convert PostScript to GIF public static void main(String[] args) throws Exception { // Set the ImageFormat to GIF. com.aspose.page.ImageFormat imageFormat = com.aspose.page.ImageFormat.GIF; // Load the source PostScript file. FileInputStream psStream = new FileInputStream("/input.ps"); // Initialize an object of the PsDocument class with the PostScript input stream. PsDocument document = new PsDocument(psStream); // Set the value of suppressErrors if you want to convert the Postscript file despite minor errors. boolean suppressErrors = true; // Instantiate a new object of ImageSaveOptions class with suppressErrors parameter. ImageSaveOptions options = new ImageSaveOptions(suppressErrors); // Create an instance of the ImageDevice class. ImageDevice device = new ImageDevice(); try { // Call the save method to save the GIF file on the disk. document.save(device, options); } finally { psStream.close(); } // Invoke the getImagesBytes method to get the resulting images in bytes. byte[][] imagesBytes = device.getImagesBytes(); int i = 0; for (byte [] imageBytes : imagesBytes) { String imagePath = "/PSToGIF" + i + "." + imageFormat.toString().toLowerCase(); // Create output stream by initializing an instance of the FileOutputStream class with the output image path. FileOutputStream fs = new FileOutputStream(imagePath); try { fs.write(imageBytes, 0, imageBytes.length); } catch (IOException ex) { System.out.println(ex.getMessage()); } finally { fs.close(); } i++; } //Review errors if (suppressErrors) { for (Exception ex : options.getExceptions()) { System.out.println(ex.getMessage()); } } } }
您可以在下圖中看到輸出:
此提供支持,是一款免費(fèi)工具。此外,它在轉(zhuǎn)換為其他文件格式時(shí)保持文本和圖形數(shù)據(jù)的質(zhì)量。我們強(qiáng)烈建議您使用此PS 文件轉(zhuǎn)換器來(lái)提高工作效率。
綜上所述,我們已經(jīng)了解了如何以編程方式在 Java 中將 PostScript 轉(zhuǎn)換為 GIF。此外,我們還實(shí)現(xiàn)了開(kāi)發(fā)高效PS 文件轉(zhuǎn)換器的功能。同樣,您可以通過(guò)訪問(wèn)文檔、GitHub repo和 API參考來(lái)進(jìn)一步探索此 PostScript Java 庫(kù)。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請(qǐng)務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請(qǐng)郵件反饋至chenjj@fc6vip.cn