Java Code Examples for com.lowagie.text.pdf.PdfTemplate#getWidth()
The following examples show how to use
com.lowagie.text.pdf.PdfTemplate#getWidth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImgTemplate.java From gcs with Mozilla Public License 2.0 | 6 votes |
/** Creates an Image from a PdfTemplate. * * @param template the PdfTemplate * @throws BadElementException on error */ public ImgTemplate(PdfTemplate template) throws BadElementException{ super((URL)null); if (template == null) throw new BadElementException("The template can not be null."); if (template.getType() == PdfTemplate.TYPE_PATTERN) throw new BadElementException("A pattern can not be used as a template to create an image."); type = IMGTEMPLATE; scaledHeight = template.getHeight(); setTop(scaledHeight); scaledWidth = template.getWidth(); setRight(scaledWidth); setTemplateData(template); plainWidth = getWidth(); plainHeight = getHeight(); }
Example 2
Source File: ImgTemplate.java From itext2 with GNU Lesser General Public License v3.0 | 6 votes |
/** Creates an Image from a PdfTemplate. * * @param template the PdfTemplate * @throws BadElementException on error */ public ImgTemplate(PdfTemplate template) throws BadElementException{ super((URL)null); if (template == null) throw new BadElementException("The template can not be null."); if (template.getType() == PdfTemplate.TYPE_PATTERN) throw new BadElementException("A pattern can not be used as a template to create an image."); type = IMGTEMPLATE; scaledHeight = template.getHeight(); setTop(scaledHeight); scaledWidth = template.getWidth(); setRight(scaledWidth); setTemplateData(template); plainWidth = getWidth(); plainHeight = getHeight(); }
Example 3
Source File: PDFPage.java From birt with Eclipse Public License 1.0 | 6 votes |
protected void drawImage( PdfTemplate image, float imageX, float imageY, float height, float width, String helpText ) throws DocumentException { imageY = transformY( imageY, height ); contentByte.saveState( ); contentByte.concatCTM( 1, 0, 0, 1, imageX, imageY ); float w = image.getWidth( ); float h = image.getHeight( ); contentByte.addTemplate( image, width / w, 0f / w, 0f / h, height / h, 0f, 0f ); if ( helpText != null ) { showHelpText( imageX, imageY, width, height, helpText ); } contentByte.restoreState( ); }
Example 4
Source File: ImgTemplate.java From MesquiteCore with GNU Lesser General Public License v3.0 | 6 votes |
/** Creats an Image from a PdfTemplate. * * @param template the PdfTemplate * @throws BadElementException on error */ public ImgTemplate(PdfTemplate template) throws BadElementException{ super((URL)null); if (template == null) throw new BadElementException("The template can not be null."); if (template.getType() == PdfTemplate.TYPE_PATTERN) throw new BadElementException("A pattern can not be used as a template to create an image."); type = IMGTEMPLATE; scaledHeight = template.getHeight(); setTop(scaledHeight); scaledWidth = template.getWidth(); setRight(scaledWidth); setTemplateData(template); plainWidth = width(); plainHeight = height(); }
Example 5
Source File: PDFPage.java From birt with Eclipse Public License 1.0 | 4 votes |
protected void drawBackgroundImage( float x, float y, float width, float height, float imageWidth, float imageHeight, int repeat, String imageUrl, byte[] imageData, float offsetX, float offsetY ) throws Exception { contentByte.saveState( ); clip( x, y, width, height ); PdfTemplate image = null; if ( imageUrl != null ) { if ( pageDevice.getImageCache( ).containsKey( imageUrl ) ) { image = pageDevice.getImageCache( ).get( imageUrl ); } } if ( image == null ) { Image img = Image.getInstance( imageData ); if ( imageHeight == 0 || imageWidth == 0 ) { int resolutionX = img.getDpiX( ); int resolutionY = img.getDpiY( ); if ( 0 == resolutionX || 0 == resolutionY ) { resolutionX = 96; resolutionY = 96; } imageWidth = img.getPlainWidth( ) / resolutionX * 72; imageHeight = img.getPlainHeight( ) / resolutionY * 72; } image = contentByte.createTemplate( imageWidth, imageHeight ); image.addImage( img, imageWidth, 0, 0, imageHeight, 0, 0 ); if ( imageUrl != null && image != null ) { pageDevice.getImageCache( ).put( imageUrl, image ); } } boolean xExtended = ( repeat & BackgroundImageInfo.REPEAT_X ) == BackgroundImageInfo.REPEAT_X; boolean yExtended = ( repeat & BackgroundImageInfo.REPEAT_Y ) == BackgroundImageInfo.REPEAT_Y; imageWidth = image.getWidth( ); imageHeight = image.getHeight( ); float originalX = offsetX; float originalY = offsetY; if ( xExtended ) { while ( originalX > 0 ) originalX -= imageWidth; } if ( yExtended ) { while ( originalY > 0 ) originalY -= imageHeight; } float startY = originalY; do { float startX = originalX; do { drawImage( image, x + startX, y + startY, imageWidth, imageHeight ); startX += imageWidth; } while ( startX < width && xExtended ); startY += imageHeight; } while ( startY < height && yExtended ); contentByte.restoreState( ); }