• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PdfDecoder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jpedal.PdfDecoder的典型用法代码示例。如果您正苦于以下问题:Java PdfDecoder类的具体用法?Java PdfDecoder怎么用?Java PdfDecoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PdfDecoder类属于org.jpedal包,在下文中一共展示了PdfDecoder类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: JPedalExtractor

import org.jpedal.PdfDecoder; //导入依赖的package包/类
public JPedalExtractor(AbstractModelFactory modelFactory)
		throws Exception {

	DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
	docBuilder = dbfac.newDocumentBuilder();
	
	this.modelFactory = modelFactory;
	this.PDFDecoder = new PdfDecoder(false);

	PDFDecoder.setExtractionMode(PdfDecoder.TEXT); // extract just text
	PDFDecoder.init(true);
	PdfGroupingAlgorithms.useUnrotatedCoords = true;
	// if you do not require XML content, pure text extraction is much
	// faster.
	PDFDecoder.useXMLExtraction();

	System.setProperty("hacked", "true");

}
 
开发者ID:GullyAPCBurns,项目名称:lapdftext,代码行数:20,代码来源:JPedalExtractor.java


示例2: print

import org.jpedal.PdfDecoder; //导入依赖的package包/类
public void print() {
    PrinterJob printJob = PrinterJob.getPrinterJob();
    //decoder.enableScaledPrinting(false);
    printJob.setPageable(decoder);
    final PageFormat pf = printJob.defaultPage();
    decoder.setPageFormat(pf);
    decoder.setTextPrint(PdfDecoder.TEXTGLYPHPRINT);
    printJob.setPrintable(decoder, pf);
    if (printJob.printDialog()) {
        final Cursor oldCursor = getCursor();
        try {
            setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
            printJob.print();
        } catch (PrinterException e) {
            e.printStackTrace();
        } finally {
            setCursor(oldCursor);
        }
    }
}
 
开发者ID:metasfresh,项目名称:metasfresh,代码行数:21,代码来源:PDFViewerBean.java


示例3: run

import org.jpedal.PdfDecoder; //导入依赖的package包/类
@Override
public final void run() {
	PdfDecoder pdfDecoder = new PdfDecoder();
	try {
		pdfDecoder.openPdfFile(source.getAbsolutePath());
	} catch (PdfException e1) {
		e1.printStackTrace();
	}

	for (PageCluster cluster : clusters.getClusterList()) {
		for (Integer pageNumber : cluster.getPagesToMerge()) {
			// TODO jpedal isn't able to render big images
			// correctly, so let's check if the image is big an
			// throw it away
			try {
				if (cluster.getImageData().isRenderable()) {
					BufferedImage renderedPage = pdfDecoder.getPageAsImage(pageNumber);
					cluster.getImageData().addImageToPreview(renderedPage);
					workerUnitCounter++;
				}
			} catch (PdfException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}
	// now close the reader as it's not used anymore
	pdfDecoder.closePdfFile();
}
 
开发者ID:mbaeuerle,项目名称:Briss-2.0,代码行数:31,代码来源:ClusterRenderWorker.java


示例4: writeImage

import org.jpedal.PdfDecoder; //导入依赖的package包/类
private static void writeImage(PdfDecoder dec, int page, Resource destination,String format, int scale,
		boolean overwrite, boolean goodQuality, boolean transparent) throws PageException, IOException {
	if(scale<1 || scale>100) 
		throw new ExpressionException("invalid scale definition ["+Caster.toString(scale)+"], value should be in range from 1 to 100");
	
	
	Image img=null;
	try {
		img = new Image(transparent?dec.getPageAsTransparentImage(page):dec.getPageAsImage(page));
	} catch (PdfException e) {
		throw Caster.toPageException(e);
	}
	if(scale!=100)
		img.resize(scale, goodQuality?"highestquality":"highperformance", 1);
	img.writeOut(destination,format, overwrite, 1f);
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:17,代码来源:PDF2ImageJPedal.java


示例5: extractBookmarks

import org.jpedal.PdfDecoder; //导入依赖的package包/类
private List<Integer> extractBookmarks(PdfDecoder decoder) {
	Document outline = decoder.getOutlineAsXML();
	final List<Integer> bookmarks = new ArrayList<Integer>();
	if (outline != null) {
		NodeList titles = outline.getElementsByTagName("title");
		for (int i = 0; i < titles.getLength(); i++) {
			Node pageAttribute = titles.item(i).getAttributes()
					.getNamedItem("page");
			if (pageAttribute != null) {
				bookmarks.add(Integer.parseInt(pageAttribute
						.getTextContent()));
			}
		}
	}
	return bookmarks;
}
 
开发者ID:schierla,项目名称:jbeagle,代码行数:17,代码来源:BeagleRenderer.java


示例6: run

import org.jpedal.PdfDecoder; //导入依赖的package包/类
@Override
public void run() {
	PdfDecoder pdfDecoder = new PdfDecoder(true);
	try {
		pdfDecoder.openPdfFile(clusterJob.getSource().getAbsolutePath());
	} catch (PdfException e1) {
		e1.printStackTrace();
	}

	for (SingleCluster cluster : clusterJob.getClusterCollection().getAsList()) {
		for (Integer pageNumber : cluster.getPagesToMerge()) {
			// TODO jpedal isn't able to render big images
			// correctly, so let's check if the image is big an
			// throw it away
			try {
				if (cluster.getImageData().isRenderable()) {
					BufferedImage renderedPage = pdfDecoder.getPageAsImage(pageNumber);
					cluster.getImageData().addImageToPreview(renderedPage);
					workerUnitCounter++;
				}
			} catch (PdfException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}

	}
	// now close the reader as it's not used anymore
	pdfDecoder.closePdfFile();
}
 
开发者ID:mbaeuerle,项目名称:Briss-2.0,代码行数:31,代码来源:ClusterManager.java


示例7: writeImages

import org.jpedal.PdfDecoder; //导入依赖的package包/类
public void writeImages(byte[] input,Set pages,Resource outputDirectory, String prefix,String format, int scale,
	 boolean overwrite, boolean goodQuality,boolean transparent) throws  PageException, IOException {
 PdfDecoder dec = createPdfDecoder(input);
 Resource res;
 int count = dec.getPageCount();
 
 for(int page=1;page<=count;page++) {
	 if(pages!=null && !pages.contains(Integer.valueOf(page)))continue;
	 //res=outputDirectory.getRealResource(prefix+"_page_"+page+"."+format);
	 res=createDestinationResource(outputDirectory,prefix,page,format,overwrite);
	 writeImage(dec,page,res,format,scale,overwrite,goodQuality, transparent);
 }

}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:15,代码来源:PDF2ImageJPedal.java


示例8: createPdfDecoder

import org.jpedal.PdfDecoder; //导入依赖的package包/类
private static PdfDecoder createPdfDecoder(byte[] input) throws PageException  {
	 PdfDecoder decoder = new PdfDecoder(true);
	 decoder.useHiResScreenDisplay(true);
	 try {
		decoder.openPdfArray(input);
	} catch (PdfException e) {
		throw Caster.toPageException(e);
	}
	 return decoder;
}
 
开发者ID:lucee,项目名称:Lucee4,代码行数:11,代码来源:PDF2ImageJPedal.java


示例9: getPageImages

import org.jpedal.PdfDecoder; //导入依赖的package包/类
@Override
public List<BufferedImage> getPageImages(ExamPaper examPaper) throws PdfException {
    PdfDecoder pdf = new PdfDecoder(false);
    pdf.setExtractionMode(PdfDecoder.FINALIMAGES);
    InputStream is = new ByteArrayInputStream(examPaper.getPdf());
    pdf.openPdfFileFromInputStream(is, true);

    ArrayList<BufferedImage> pageImages = new ArrayList<>();
    for (int i = 1; i <= pdf.getPageCount(); i++) {
        pageImages.add(pdf.getPageAsImage(i));
    }
    return pageImages;
}
 
开发者ID:ohtuprojekti,项目名称:OKKoPa,代码行数:14,代码来源:PDFProcessorImpl.java


示例10: getMetadata

import org.jpedal.PdfDecoder; //导入依赖的package包/类
private static String getMetadata(PdfDecoder decoder, String key,
		String defaultValue) {
	String[] fieldNames = PdfFileInformation.getFieldNames();
	String[] metadata = decoder.getFileInformationData().getFieldValues();

	for (int i = 0; i < fieldNames.length; i++) {
		if (key.equals(fieldNames[i])) {
			String value = metadata[i];
			if (value == null || value.isEmpty())
				return defaultValue;
			return value;
		}
	}
	return defaultValue;
}
 
开发者ID:schierla,项目名称:jbeagle,代码行数:16,代码来源:BeagleUtil.java


示例11: BeagleRenderer

import org.jpedal.PdfDecoder; //导入依赖的package包/类
public BeagleRenderer(PdfDecoder decoder, String author, String title) {
	this.decoder = decoder;
	this.author = author;
	this.title = title;
	this.pages = decoder.getPageCount();
	this.bookmarks = extractBookmarks(decoder);
}
 
开发者ID:schierla,项目名称:jbeagle,代码行数:8,代码来源:BeagleRenderer.java


示例12: JPedalPageImageExtractor

import org.jpedal.PdfDecoder; //导入依赖的package包/类
public JPedalPageImageExtractor()
{
	this.decoder = new PdfDecoder(true);
	//PdfDecoder.s
	//PdfDecoder.setTextPrint(PdfDecoder.);
	//decoder.setExtractionMode(PdfDecoder.TEXT); // extract just text
	decoder.init(true);
	PdfGroupingAlgorithms.useUnrotatedCoords = true;
	// if you do not require XML content, pure text extraction is much
	// faster.
	decoder.useXMLExtraction();
}
 
开发者ID:GullyAPCBurns,项目名称:lapdftext,代码行数:13,代码来源:JPedalPageImageExtractor.java


示例13: createImagesForPdf

import org.jpedal.PdfDecoder; //导入依赖的package包/类
public static int createImagesForPdf(String docDir, String fileName)
{
  File documentCacheDir = getDocumentCacheDir(docDir);
  String pdffileName = fileName;
  if (!fileName.endsWith(".pdf")) pdffileName = new StringBuilder().append(fileName).append(".pdf").toString();
  File file = new File(docDir, pdffileName);
  PdfDecoder decode_pdf = new PdfDecoder(true);
  File ofile = null;
  int numberOfPages = 0;
  try
  {
    FontMappings.setFontReplacements();

    decode_pdf.useHiResScreenDisplay(true);

    decode_pdf.setExtractionMode(0, 96, 1.333333F);

    FileInputStream is = new FileInputStream(file);

    decode_pdf.openPdfFileFromInputStream(is, false);

    RandomAccessFile raf = new RandomAccessFile(file, "r");
    FileChannel channel = raf.getChannel();
    ByteBuffer buf = channel.map(FileChannel.MapMode.READ_ONLY, 0L, channel.size());
    PDFFile pdffile = new PDFFile(buf);
    numberOfPages = pdffile.getNumPages();
    for (int p = 1; p <= numberOfPages; p++) {
      BufferedImage image_to_save = decode_pdf.getPageAsImage(p);

      String imageFileName = null;
      if (fileName.endsWith(".pdf")) imageFileName = fileName.split(".pdf")[0]; else {
        imageFileName = fileName;
      }
      File outfile = new File(documentCacheDir, new StringBuilder().append(imageFileName).append("_").append(p).append(".png").toString());
      if (!outfile.exists()) {
        decode_pdf.getObjectStore().saveStoredImage(new StringBuilder().append(documentCacheDir.getCanonicalPath()).append("/").append(imageFileName).append("_").append(p).append(".png").toString(), image_to_save, true, false, "png");
      }
      decode_pdf.flushObjectValues(true);

      decode_pdf.closePdfFile();
    }
  }
  catch (Exception e)
  {
    logger.error(new StringBuilder().append("Error decoding pdf file ").append(fileName).toString());
    MiscUtils.getLogger().error("Error", e);
    decode_pdf.closePdfFile();
  }

  return numberOfPages;
}
 
开发者ID:oscarservice,项目名称:oscar-old,代码行数:52,代码来源:Utilities.java


示例14: generateImages

import org.jpedal.PdfDecoder; //导入依赖的package包/类
/**
 * Generates one JPEG image per page of the input PDFs. The images are named
 * according to the leaf filename and page number of the input. E.g. for
 * page 2 of "/tmp/Heidinger_1997_767_279.pdf", the output file would be
 * "/path/to/output/Heidinger_1997_767_279_2.jpg".
 * 
 * @return A list of all generated files.
 */
public List<File> generateImages(File pdf, File outputDir) 
		throws IOException, PdfException {

	int startPage = 1;
	int endPage;
	double h = -0.01;
	double w = -0.01;
	List<File> generatedFiles = new ArrayList<File>();

	String pdfName = pdf.getName();
	String pdfStem = pdfName.substring(0, pdfName.lastIndexOf("."));

	PdfDecoder decoder = new PdfDecoder(true);

	// decoder.setExtractionMode(0, DPI, DPI/72);
	decoder.setExtractionMode(PdfDecoder.TEXT + PdfDecoder.RAWIMAGES
				+ PdfDecoder.FINALIMAGES, DPI, DPI / 72);
	decoder.openPdfFile(pdf.getPath());

	endPage = decoder.getPageCount();
	for (int pageNumber = startPage; pageNumber <= endPage; pageNumber++) {
		String outputImageName = pdfStem + "_" + pageNumber + ".png";
		File outputImageFile = new File( outputImageName );
		generatedFiles.add(outputImageFile);

		PdfFileInformation currentFileInformation = decoder
				.getFileInformationData();
		
		String values[] = currentFileInformation.getFieldValues();
		String fields[] = PdfFileInformation.getFieldNames();
		
		for (int i = 0; i < fields.length; i++) {
			if (fields[i].equals("Creator")) {
				for (int j = 0; j < ocr.length; j++) {
					if (values[i].equals(ocr[j])) {
						decoder.setRenderMode(PdfDecoder.RENDERIMAGES);
						//decoder.setsetEnableLegacyJPEGConversion(true);
					}
				}
			}
		}

		BufferedImage image_to_save = decoder
					.getPageAsImage(pageNumber);
		h = image_to_save.getHeight();
		w = image_to_save.getWidth();

		ImageIO.write(image_to_save, "png", outputImageFile);


	}

	return generatedFiles;

}
 
开发者ID:GullyAPCBurns,项目名称:lapdftext,代码行数:64,代码来源:JPedalPDFRenderer.java


示例15: createCacheVersion2

import org.jpedal.PdfDecoder; //导入依赖的package包/类
public File createCacheVersion2(Document d, Integer pageNum) {
	File documentCacheDir = getDocumentCacheDir(oscar.OscarProperties.getInstance().getProperty("DOCUMENT_DIR"));
	File file = new File(EDocUtil.getDocumentPath(d.getDocfilename()));

	PdfDecoder decode_pdf  = new PdfDecoder(true);
	File ofile = null;
	try {

		FontMappings.setFontReplacements();

		decode_pdf.useHiResScreenDisplay(true);

		decode_pdf.setExtractionMode(0, 96, 96/72f);

		FileInputStream is = new FileInputStream(file);

		decode_pdf.openPdfFileFromInputStream(is, false);

		BufferedImage image_to_save = decode_pdf.getPageAsImage(pageNum);



		decode_pdf.getObjectStore().saveStoredImage( documentCacheDir.getCanonicalPath() + "/" + d.getDocfilename() + "_" + pageNum + ".png", image_to_save, true, false, "png");

		decode_pdf.flushObjectValues(true);

		decode_pdf.closePdfFile();

		ofile = new File(documentCacheDir, d.getDocfilename() + "_" + pageNum + ".png");



	}catch(Exception e) {
		log.error("Error decoding pdf file " + d.getDocfilename());
		decode_pdf.closePdfFile();
	}

	return ofile;

}
 
开发者ID:oscarservice,项目名称:oscar-old,代码行数:41,代码来源:ManageDocumentAction.java


示例16: createIncomingCacheVersion

import org.jpedal.PdfDecoder; //导入依赖的package包/类
public File createIncomingCacheVersion(String queueId, String pdfDir, String pdfName, Integer pageNum) throws Exception {


        String incomingDocPath = IncomingDocUtil.getIncomingDocumentFilePath(queueId, pdfDir);
        File documentDir = new File(incomingDocPath);
        File documentCacheDir = getDocumentCacheDir(incomingDocPath);
        File file = new File(documentDir, pdfName);

        PdfDecoder decode_pdf = new PdfDecoder(true);
        File ofile = null;
        FileInputStream is = null;
        
        try {

            FontMappings.setFontReplacements();

            decode_pdf.useHiResScreenDisplay(true);

            decode_pdf.setExtractionMode(0, 96, 96 / 72f);

            is = new FileInputStream(file);

            decode_pdf.openPdfFileFromInputStream(is, false);

            BufferedImage image_to_save = decode_pdf.getPageAsImage(pageNum);

            decode_pdf.getObjectStore().saveStoredImage(documentCacheDir.getCanonicalPath() + "/" + pdfName + "_" + pageNum + ".png", image_to_save, true, false, "png");

            decode_pdf.flushObjectValues(true);

        } catch (Exception e) {
            log.error("Error decoding pdf file " + pdfDir + pdfName);
        } finally {
            if (decode_pdf != null) {
                decode_pdf.closePdfFile();
            }
            if (is!=null) {
                is.close();
            }
                
        }
        
        ofile = new File(documentCacheDir, pdfName + "_" + pageNum + ".png");
        
        return ofile;

    }
 
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:48,代码来源:ManageDocumentAction.java



注:本文中的org.jpedal.PdfDecoder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java FileTypes类代码示例发布时间:2022-05-22
下一篇:
Java DNSQuestion类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap