com.lowagie.text.pdf.codec.wmf.MetaDo Java Examples

The following examples show how to use com.lowagie.text.pdf.codec.wmf.MetaDo. 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: ImgWMF.java    From gcs with Mozilla Public License 2.0 6 votes vote down vote up
/** Reads the WMF into a template.
 * @param template the template to read to
 * @throws IOException on error
 * @throws DocumentException on error
 */    
public void readWMF(PdfTemplate template) throws IOException, DocumentException {
    setTemplateData(template);
    template.setWidth(getWidth());
    template.setHeight(getHeight());
    InputStream is = null;
    try {
        if (rawData == null){
            is = url.openStream();
        }
        else{
            is = new java.io.ByteArrayInputStream(rawData);
        }
        MetaDo meta = new MetaDo(is, template);
        meta.readAll();
    }
    finally {
        if (is != null) {
            is.close();
        }
    }
}
 
Example #2
Source File: ImgWMF.java    From itext2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** Reads the WMF into a template.
 * @param template the template to read to
 * @throws IOException on error
 * @throws DocumentException on error
 */    
public void readWMF(PdfTemplate template) throws IOException, DocumentException {
    setTemplateData(template);
    template.setWidth(getWidth());
    template.setHeight(getHeight());
    InputStream is = null;
    try {
        if (rawData == null){
            is = url.openStream();
        }
        else{
            is = new java.io.ByteArrayInputStream(rawData);
        }
        MetaDo meta = new MetaDo(is, template);
        meta.readAll();
    }
    finally {
        if (is != null) {
            is.close();
        }
    }
}
 
Example #3
Source File: ImgWMF.java    From MesquiteCore with GNU Lesser General Public License v3.0 6 votes vote down vote up
/** Reads the WMF into a template.
 * @param template the template to read to
 * @throws IOException on error
 * @throws DocumentException on error
 */    
public void readWMF(PdfTemplate template) throws IOException, DocumentException {
    setTemplateData(template);
    template.setWidth(width());
    template.setHeight(height());
    InputStream is = null;
    try {
        if (rawData == null){
            is = url.openStream();
        }
        else{
            is = new java.io.ByteArrayInputStream(rawData);
        }
        MetaDo meta = new MetaDo(is, template);
        meta.readAll();
    }
    finally {
        if (is != null) {
            is.close();
        }
    }
}
 
Example #4
Source File: RtfImage.java    From itext2 with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Extracts the image data from the Image.
 * 
 * @param image The image for which to extract the content
 * @return The raw image data, not formated
 * @throws DocumentException If an error occurs accessing the image content
 */
private byte[][] getImageData(Image image) throws DocumentException 
{
	final int WMF_PLACEABLE_HEADER_SIZE = 22;
    final RtfByteArrayBuffer bab = new RtfByteArrayBuffer();
    
    try {
        if(imageType == Image.ORIGINAL_BMP) {
        	bab.append(MetaDo.wrapBMP(image));
        } else {            	
        	final byte[] iod = image.getOriginalData();
        	if(iod == null) {
        		
            	final InputStream imageIn = image.getUrl().openStream();
                if(imageType == Image.ORIGINAL_WMF) { //remove the placeable header first
                	for(int k = 0; k < WMF_PLACEABLE_HEADER_SIZE; k++) {
			if(imageIn.read() < 0) throw new EOFException("while removing wmf placeable header");
		}
                }
                bab.write(imageIn);
            	imageIn.close();
                
            } else {
            	
            	if(imageType == Image.ORIGINAL_WMF) {
            		//remove the placeable header                		
            		bab.write(iod, WMF_PLACEABLE_HEADER_SIZE, iod.length - WMF_PLACEABLE_HEADER_SIZE);
            	} else {
            		bab.append(iod);
            	}
            	
            }
        }
        
        return bab.toByteArrayArray();
        
    } catch(IOException ioe) {
        throw new DocumentException(ioe.getMessage());
    }
}