首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > PowerDesigner >

应用JPedal取代PDFBox

2012-10-28 
使用JPedal取代PDFBox????? 之前都是使用PDFBOX0.8版本来实现PDF转为Image,0.8版本的PDFBox转为Image还有N

使用JPedal取代PDFBox

????? 之前都是使用PDFBOX0.8版本来实现PDF转为Image,0.8版本的PDFBox转为Image还有N多问题,比如部分扫描PDF无法转换、缺少字体等等问题。而且我们是修改PDFBox源代码来解决上述问题,但是还是不能解决全部问题。

???? JPedal是一个商业的处理PDF软件,但是JPedal有一个裁切版,裁切版JPedal使用LGPL协议进行开源,可免费使用。如下摘抄官方说明:

                                                               /** instance of PdfDecoder to convert PDF into image */                              PdfDecoder decode_pdf = new PdfDecoder(true);                                 /** set mappings for non-embedded fonts to use */                                PdfDecoder.setFontReplacements(decode_pdf);/** open the PDF file - can also be a URL or a byte array */decode_pdf.openPdfFileFromInputStream(in, false);// decode_pdf.openPdfFile("C:/myPDF.pdf", "password"); //encrypted// file// decode_pdf.openPdfArray(bytes); //bytes is byte[] array with PDF// decode_pdf.openPdfFileFromURL("http://www.mysite.com/myPDF.pdf",false);/** get page 1 as an image */// page range if you want to extract all pages with a loop// int start = 1, end = decode_pdf.getPageCount();int pageCount = decode_pdf.getPageCount();if (curPage > pageCount || curPage <= 0)curPage = pageCount;BufferedImage img = null;img = decode_pdf.getPageAsImage(curPage );pageCnt=String.valueOf(pageCount);FileOutputStream out;out = new FileOutputStream(file);JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);encoder.encode(img);out.close();

?

?

1 楼 melin 2011-12-12   我现在最新版本的jpedal,转换为png的时候,中文不能显示。你是怎么处理的?

发现最新版本的API有些变化,PdfDecoder.setFontReplacements(decode_pdf);  变为:FontMappings.setFontReplacements(); 但是没有带参数。你的decode_pdf值是“UTF-8”? 2 楼 jinxiongyi 2012-05-10   转成图片的质量是怎么调的?我转的,,感觉不够清晰

热点排行