当前位置: 首页>>代码示例>>Java>>正文


Java LosslessFactory类代码示例

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


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

示例1: barCode

import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory; //导入依赖的package包/类
public PaymentPdfBuilder barCode(final String barCodeMessage,
                                 final float x,
                                 final float y) throws IOException {
    final float scale = 100f / BAR_CODE_DPI;
    final Code128Bean code128Bean = new Code128Bean();
    code128Bean.setCodeset(Code128Constants.CODESET_C);
    code128Bean.setMsgPosition(HumanReadablePlacement.HRP_NONE);
    code128Bean.setBarHeight(scale * BAR_CODE_HEIGHT_MM);

    final BitmapCanvasProvider canvas = new BitmapCanvasProvider(
            BAR_CODE_DPI, BufferedImage.TYPE_BYTE_BINARY, false, 0);
    code128Bean.generateBarcode(canvas, barCodeMessage);
    canvas.finish();

    final PDImageXObject pdImage = LosslessFactory.createFromImage(pdfDocument, canvas.getBufferedImage());

    try (final PDPageContentStream contentStream = new PDPageContentStream(
            pdfDocument, pdfDocument.getPage(0), PDPageContentStream.AppendMode.APPEND, true)) {
        contentStream.drawImage(pdImage, x, y, scale * pdImage.getWidth(), scale * pdImage.getHeight());
    }

    return this;
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-web,代码行数:24,代码来源:HunterPaymentPdfFeature.java

示例2: insertImagePDFBox

import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory; //导入依赖的package包/类
/**
 * Inserts image to recent PDF page using PDFBox
 */
private int insertImagePDFBox (BufferedImage img, float x, float y, float width, float height) {
	// transform X,Y coordinates to Apache PDFBox format
    y = pageFormat.getHeight() - height - y;

    try {
        //PDXObjectImage ximage = new PDPixelMap(doc, img);
        //content.drawXObject(ximage, x, y, width, height);
        PDImageXObject ximage = LosslessFactory.createFromImage(doc, img);
        content.drawImage(ximage, x, y, width, height);
    } catch (IOException e) {
    	e.printStackTrace();
        return -1;	
    }
    return 0;
}
 
开发者ID:radkovo,项目名称:CSSBoxPdf,代码行数:19,代码来源:PDFRenderer.java

示例3: getXObject

import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory; //导入依赖的package包/类
@Override
@Nonnull
protected PDImageXObject getXObject (@Nonnull final PagePreRenderContext aCtx) throws IOException
{
  switch (getImageType ())
  {
    case CCITT:
      return CCITTFactory.createFromImage (aCtx.getDocument (), m_aImage);
    case JPEG:
      return JPEGFactory.createFromImage (aCtx.getDocument (), m_aImage);
    case LOSSLESS:
      return LosslessFactory.createFromImage (aCtx.getDocument (), m_aImage);
    default:
      throw new IllegalStateException ("Unsupported image type: " + toString ());
  }
}
 
开发者ID:phax,项目名称:ph-pdf-layout,代码行数:17,代码来源:PLImage.java

示例4: addPageToDocument

import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory; //导入依赖的package包/类
protected void addPageToDocument(final PDDocument document, final ImageWithDimension image) throws IOException {
    PDPage page = new PDPage(new PDRectangle(image.width, image.height));
    document.addPage(page);
    final PDImageXObject imageXObject = LosslessFactory.createFromImage(document, image.bufferedImage);
    try (PDPageContentStream contentStream = new PDPageContentStream(document, page)) {
        contentStream.drawImage(imageXObject, 0, 0, image.width, image.height);
    }
}
 
开发者ID:red6,项目名称:pdfcompare,代码行数:9,代码来源:CompareResult.java

示例5: getCachedImage

import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory; //导入依赖的package包/类
private static synchronized PDImageXObject getCachedImage(
    final PDDocument document, final BufferedImage image)
    throws IOException {
Map<BufferedImage, PDImageXObject> imageCache = getImageCache(document);
PDImageXObject pdxObjectImage = imageCache.get(image);
if (pdxObjectImage == null) {
    pdxObjectImage = LosslessFactory.createFromImage(document, image);
    imageCache.put(image, pdxObjectImage);
}
return pdxObjectImage;
   }
 
开发者ID:ralfstuckert,项目名称:pdfbox-layout,代码行数:12,代码来源:CompatibilityHelper.java

示例6: attatchToPDF

import org.apache.pdfbox.pdmodel.graphics.image.LosslessFactory; //导入依赖的package包/类
/**
	 * 
	 * @param _doc
	 * @param _bi
	 * @param _pageindex 		index of page to which the BufferedImage is 
	 * 							inserted.
	 * 							If it is equal to -1, new page is created.
	 * 						
	 */
	public void attatchToPDF(
			final PDDocument _doc, 
			final BufferedImage _bi,
			final int _pageindex){
	    PDPage page = null;
	    try {
	    	if (_pageindex == -1) {
	    		page = new PDPage(new PDRectangle(State.getImageSize().width, State.getImageSize().height));

		        _doc.addPage(page);
	    	} else {
	    		page = _doc.getPage(_pageindex);
//	    		page.setCropBox(new PDRectangle(State.getImageSize().width , 
//	    				State.getImageSize().height ));
	    		
	    	}
	    	
	    	

	        int width = (int) page.getCropBox().getWidth();
	        int height = (int) page.getCropBox().getHeight();
	        
	        
	        PDImageXObject ximage =  LosslessFactory.createFromImage(_doc, 
//	        		_bi);
	        		Utils.resizeImage(width, height, _bi));

		        PDPageContentStream content = new PDPageContentStream(_doc, page, true, true);

	            // contentStream.drawImage(ximage, 20, 20 );
	            // better method inspired by http://stackoverflow.com/a/22318681/535646
	            // reduce this value if the image is too large
	            float scale = 1f;
	            content.drawImage(ximage, 20, 20, ximage.getWidth()*scale, ximage.getHeight()*scale);

	            content.close();
		        //  LosslessFactory.createFromImage(doc, bim)
//		        content.drawImage(ximage, 0, 0);
//		        content.close();
	    }
	    catch (IOException ie){
	        //handle exception
	    }
	}
 
开发者ID:juliusHuelsmann,项目名称:paint,代码行数:54,代码来源:Project.java


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