我寫了一個應用程序來創建PDF文件到PDDocument文件它工作正常。我用的是PDFBOX庫如何使用Java從PDF文件創建PS文件?
PDDocument pdfDoc = PDDocument.load(pdfFile);
現在我想從PDF文件創建PS(後腳本)文件。在java中有任何方法。我可以使用任何免費的API。
非常感謝。
我寫了一個應用程序來創建PDF文件到PDDocument文件它工作正常。我用的是PDFBOX庫如何使用Java從PDF文件創建PS文件?
PDDocument pdfDoc = PDDocument.load(pdfFile);
現在我想從PDF文件創建PS(後腳本)文件。在java中有任何方法。我可以使用任何免費的API。
非常感謝。
Adobe似乎有一個庫。這裏有一些說明。請注意,我沒有這個嘗試自己:http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=000761.html
此鏈接有一個更詳細的解決方案: http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=000074.html
您可以使用PDFDocument加載您PDF然後使用PSConverter到PDF文檔轉換成一個OutputStream 。
我使用的庫稱爲ghost4j:
import org.ghost4j.converter.PSConverter;
import org.ghost4j.document.PDFDocument;
這裏有一個小片斷:
private ByteArrayOutputStream convertPDFtoPS(){
ByteArrayOutputStream outstreamFile = new ByteArrayOutputStream();
try{
PDFDocument document = new PDFDocument();
//getPDFFile just returns an InputStream of the PDF file
document.load(getPDFFile());
PSConverter converter = new PSConverter();
converter.convert(document, outstreamFile);
outstreamFile.close();
}
catch(Exception e)
{
e.printStackTrace();
}
return outstreamFile;
}
的Adobe的LiveCycle是不是免費的(甚至開放)。你可以使用Ghostscript,但我不知道如何從Java中做到這一點。 – KenS
簡單的Google搜索找到了這個:http://www.ghost4j.org/。它被描述爲「Ghost4J綁定Ghostscript C API以將Ghostscript功能引入Java世界,它還提供了一個高級API來處理PDF和Postscript文檔。」對不起,我沒有意識到Adobe庫不是免費的。說實話,我沒有發現很多。 – lordoku