Java 类com.lowagie.text.ExceptionConverter 实例源码

项目:itext2    文件:XmpReader.java   
/**
    * Constructs an XMP reader
    * @param    bytes   the XMP content
    * @throws ExceptionConverter 
    * @throws IOException 
    * @throws SAXException 
    */
public XmpReader(byte[] bytes) throws SAXException, IOException {
    try {
        DocumentBuilderFactory fact = DocumentBuilderFactory.newInstance();
        fact.setNamespaceAware(true);
        DocumentBuilder db = fact.newDocumentBuilder();
        db.setEntityResolver(new EntityResolver() {
            @Override
            public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
                return new InputSource(new StringReader(""));
            }           
        });
        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
        domDocument = db.parse(bais);
    } catch (ParserConfigurationException e) {
        throw new ExceptionConverter(e);
    }
}
项目:docx4j-export-FO    文件:Conversion.java   
/**
 * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document)
 */
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();

        if (headerFooterPolicy.getHeader(writer.getPageNumber())!=null) {
         Hdr hdr = headerFooterPolicy.getHeader(writer.getPageNumber()).getJaxbElement();
         PdfPTable head = new PdfPTable(1); // num cols             
         // TODO - no cell borders
         traverseBlockLevelContent( hdr.getEGBlockLevelElts(), head);
         head.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
         head.writeSelectedRows(0, -1, document.leftMargin(), page.getHeight() - document.topMargin() + head.getTotalHeight(),
             writer.getDirectContent());
        }

        if (headerFooterPolicy.getFooter(writer.getPageNumber())!=null) {
         Ftr ftr = headerFooterPolicy.getFooter(writer.getPageNumber()).getJaxbElement();               
         PdfPTable foot = new PdfPTable(1);
         traverseBlockLevelContent( ftr.getEGBlockLevelElts(), foot);
         foot.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
         foot.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin(),
             writer.getDirectContent());
        }
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:PdfSigGenericPKCS.java   
/**
 * Sets the crypto information to sign.
 * @param privKey the private key
 * @param certChain the certificate chain
 * @param crlList the certificate revocation list. It can be <CODE>null</CODE>
 */    
public void setSignInfo(PrivateKey privKey, Certificate[] certChain, CRL[] crlList) {
    try {
        pkcs = new PdfPKCS7(privKey, certChain, crlList, hashAlgorithm, provider, PdfName.ADBE_PKCS7_SHA1.equals(get(PdfName.SUBFILTER)));
        pkcs.setExternalDigest(externalDigest, externalRSAdata, digestEncryptionAlgorithm);
        if (PdfName.ADBE_X509_RSA_SHA1.equals(get(PdfName.SUBFILTER))) {
            ByteArrayOutputStream bout = new ByteArrayOutputStream();
            for (int k = 0; k < certChain.length; ++k) {
                bout.write(certChain[k].getEncoded());
            }
            bout.close();
            setCert(bout.toByteArray());
            setContents(pkcs.getEncodedPKCS1());
        }
        else
            setContents(pkcs.getEncodedPKCS7());
        name = PdfPKCS7.getSubjectFields(pkcs.getSigningCertificate()).getField("CN");
        if (name != null)
            put(PdfName.NAME, new PdfString(name, PdfObject.TEXT_UNICODE));
        pkcs = new PdfPKCS7(privKey, certChain, crlList, hashAlgorithm, provider, PdfName.ADBE_PKCS7_SHA1.equals(get(PdfName.SUBFILTER)));
        pkcs.setExternalDigest(externalDigest, externalRSAdata, digestEncryptionAlgorithm);
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:PdfReader.java   
/**
 * @param idx
 * @return aPdfObject
 */
public PdfObject getPdfObject(int idx) {
    try {
        lastXrefPartial = -1;
        if (idx < 0 || idx >= xrefObj.size())
            return null;
        PdfObject obj = (PdfObject)xrefObj.get(idx);
        if (!partial || obj != null)
            return obj;
        if (idx * 2 >= xref.length)
            return null;
        obj = readSingleObject(idx);
        lastXrefPartial = -1;
        if (obj != null)
            lastXrefPartial = idx;
        return obj;
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:OutputStreamEncryption.java   
/** Creates a new instance of OutputStreamCounter */
public OutputStreamEncryption(OutputStream out, byte key[], int off, int len, int revision) {
    try {
        this.out = out;
        aes = revision == AES_128;
        if (aes) {
            byte[] iv = IVGenerator.getIV();
            byte[] nkey = new byte[len];
            System.arraycopy(key, off, nkey, 0, len);
            cipher = new AESCipher(true, nkey, iv);
            write(iv);
        }
        else {
            arcfour = new ARCFOUREncryption();
            arcfour.prepareARCFOURKey(key, off, len);
        }
    } catch (Exception ex) {
        throw new ExceptionConverter(ex);
    }
}
项目:itext2    文件:PdfICCBased.java   
/**
 * Creates an ICC stream.
 *
 * @param   compressionLevel    the compressionLevel
 *
 * @param   profile an ICC profile
 * @since   2.1.3   (replacing the constructor without param compressionLevel)
 */
public PdfICCBased(ICC_Profile profile, int compressionLevel) {
    super();
    try {
        int numberOfComponents = profile.getNumComponents();
        switch (numberOfComponents) {
            case 1:
                put(PdfName.ALTERNATE, PdfName.DEVICEGRAY);
                break;
            case 3:
                put(PdfName.ALTERNATE, PdfName.DEVICERGB);
                break;
            case 4:
                put(PdfName.ALTERNATE, PdfName.DEVICECMYK);
                break;
            default:
                throw new PdfException(numberOfComponents + " component(s) is not supported in PDF1.4");
        }
        put(PdfName.N, new PdfNumber(numberOfComponents));
        bytes = profile.getData();
        flateCompress(compressionLevel);
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:Barcode39.java   
/** Creates a new Barcode39.
 */    
public Barcode39() {
    try {
        x = 0.8f;
        n = 2;
        font = BaseFont.createFont("Helvetica", "winansi", false);
        size = 8;
        baseline = size;
        barHeight = size * 3;
        textAlignment = Element.ALIGN_CENTER;
        generateChecksum = false;
        checksumText = false;
        startStopText = true;
        extended = false;
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:PdfEncodings.java   
/** Loads a CJK cmap to the cache with the option of associating
 * sequences to the newline.
 * @param name the CJK cmap name
 * @param newline the sequences to be replaced by a newline in the resulting CID. See <CODE>CRLF_CID_NEWLINE</CODE>
 */    
public static void loadCmap(String name, byte newline[][]) {
    try {
        char planes[][] = null;
        synchronized (cmaps) {
            planes = (char[][])cmaps.get(name);
        }
        if (planes == null) {
            planes = readCmap(name, newline);
            synchronized (cmaps) {
                cmaps.put(name, planes);
            }
        }
    }
    catch (IOException e) {
        throw new ExceptionConverter(e);
    }        
}
项目:itext2    文件:DocumentFont.java   
private void processType0(PdfDictionary font) {
    try {
        PdfObject toUniObject = PdfReader.getPdfObjectRelease(font.get(PdfName.TOUNICODE));
        PdfArray df = (PdfArray)PdfReader.getPdfObjectRelease(font.get(PdfName.DESCENDANTFONTS));
        PdfDictionary cidft = (PdfDictionary)PdfReader.getPdfObjectRelease(df.getPdfObject(0));
        PdfNumber dwo = (PdfNumber)PdfReader.getPdfObjectRelease(cidft.get(PdfName.DW));
        int dw = 1000;
        if (dwo != null)
            dw = dwo.intValue();
        IntHashtable widths = readWidths((PdfArray)PdfReader.getPdfObjectRelease(cidft.get(PdfName.W)));
        PdfDictionary fontDesc = (PdfDictionary)PdfReader.getPdfObjectRelease(cidft.get(PdfName.FONTDESCRIPTOR));
        fillFontDesc(fontDesc);
        if (toUniObject != null){
            fillMetrics(PdfReader.getStreamBytes((PRStream)toUniObject), widths, dw);
        }

    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:HtmlWriter.java   
/**
* Signals that an new page has to be started.
*
* @return  <CODE>true</CODE> if this action succeeded, <CODE>false</CODE> if not.
*/

   public boolean newPage() {
       try {
           writeStart(HtmlTags.DIV);
           write(" ");
           write(HtmlTags.STYLE);
           write("=\"");
           writeCssProperty(Markup.CSS_KEY_PAGE_BREAK_BEFORE, Markup.CSS_VALUE_ALWAYS);
           write("\" /");
           os.write(GT);
       }
       catch(IOException ioe) {
           throw new ExceptionConverter(ioe);
       }
       return true;
   }
项目:itext2    文件:PdfDocument.java   
/**
 * Closes the document.
 * <B>
 * Once all the content has been written in the body, you have to close
 * the body. After that nothing can be written to the body anymore.
 */
public void close() {
    if (close) {
        return;
    }
    try {
        boolean wasImage = (imageWait != null);
        newPage();
        if (imageWait != null || wasImage) newPage();
        if (annotationsImp.hasUnusedAnnotations())
            throw new RuntimeException("Not all annotations could be added to the document (the document doesn't have enough pages).");
        PdfPageEvent pageEvent = writer.getPageEvent();
        if (pageEvent != null)
            pageEvent.onCloseDocument(writer, this);
        super.close();

        writer.addLocalDestinations(localDestinations);
        calculateOutlineCount();
        writeOutlines();
    }
    catch(Exception e) {
        throw ExceptionConverter.convertException(e);
    }

    writer.close();
}
项目:itext2    文件:PdfAnnotationsImp.java   
public PdfArray rotateAnnotations(PdfWriter writer, Rectangle pageSize) {
    PdfArray array = new PdfArray();
    int rotation = pageSize.getRotation() % 360;
    int currentPage = writer.getCurrentPageNumber();
    for (int k = 0; k < annotations.size(); ++k) {
        PdfAnnotation dic = (PdfAnnotation)annotations.get(k);
        int page = dic.getPlaceInPage();
        if (page > currentPage) {
            delayedAnnotations.add(dic);
            continue;
        }
        if (dic.isForm()) {
            if (!dic.isUsed()) {
                HashMap templates = dic.getTemplates();
                if (templates != null)
                    acroForm.addFieldTemplates(templates);
            }
            PdfFormField field = (PdfFormField)dic;
            if (field.getParent() == null)
                acroForm.addDocumentField(field.getIndirectReference());
        }
        if (dic.isAnnotation()) {
            array.add(dic.getIndirectReference());
            if (!dic.isUsed()) {
                PdfRectangle rect = (PdfRectangle)dic.get(PdfName.RECT);
                if (rect != null) {
                    switch (rotation) {
                        case 90:
                            dic.put(PdfName.RECT, new PdfRectangle(
                                    pageSize.getTop() - rect.bottom(),
                        rect.left(),
                        pageSize.getTop() - rect.top(),
                        rect.right()));
                            break;
                        case 180:
                            dic.put(PdfName.RECT, new PdfRectangle(
                                    pageSize.getRight() - rect.left(),
                        pageSize.getTop() - rect.bottom(),
                        pageSize.getRight() - rect.right(),
                        pageSize.getTop() - rect.top()));
                            break;
                        case 270:
                            dic.put(PdfName.RECT, new PdfRectangle(
                                    rect.bottom(),
                        pageSize.getRight() - rect.left(),
                        rect.top(),
                        pageSize.getRight() - rect.right()));
                            break;
                    }
                }
            }
        }
        if (!dic.isUsed()) {
            dic.setUsed();
            try {
                writer.addToBody(dic, dic.getIndirectReference());
            }
            catch (IOException e) {
                throw new ExceptionConverter(e);
            }
        }
    }
    return array;
}
项目:itext2    文件:PdfPKCS7.java   
/**
 * Verifies a signature using the sub-filter adbe.x509.rsa_sha1.
 * @param contentsKey the /Contents key
 * @param certsKey the /Cert key
 * @param provider the provider or <code>null</code> for the default provider
 */    
public PdfPKCS7(byte[] contentsKey, byte[] certsKey, String provider) {
    try {
        this.provider = provider;
        X509CertParser cr = new X509CertParser();
        cr.engineInit(new ByteArrayInputStream(certsKey));
        certs = cr.engineReadAll();
        signCerts = certs;
        signCert = (X509Certificate)certs.iterator().next();
        crls = new ArrayList();
        ASN1InputStream in = new ASN1InputStream(new ByteArrayInputStream(contentsKey));
        digest = ((DEROctetString)in.readObject()).getOctets();
        if (provider == null)
            sig = Signature.getInstance("SHA1withRSA");
        else
            sig = Signature.getInstance("SHA1withRSA", provider);
        sig.initVerify(signCert.getPublicKey());
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:PdfPKCS7.java   
/**
 * Loads the default root certificates at &lt;java.home&gt;/lib/security/cacerts.
 * @param provider the provider or <code>null</code> for the default provider
 * @return a <CODE>KeyStore</CODE>
 */    
public static KeyStore loadCacertsKeyStore(String provider) {
    File file = new File(System.getProperty("java.home"), "lib");
    file = new File(file, "security");
    file = new File(file, "cacerts");
    FileInputStream fin = null;
    try {
        fin = new FileInputStream(file);
        KeyStore k;
        if (provider == null)
            k = KeyStore.getInstance("JKS");
        else
            k = KeyStore.getInstance("JKS", provider);
        k.load(fin, null);
        return k;
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
    finally {
        try{if (fin != null) {fin.close();}}catch(Exception ex){}
    }
}
项目:itext2    文件:HtmlWriter.java   
/**
* Constructs a <CODE>HtmlWriter</CODE>.
*
* @param doc     The <CODE>Document</CODE> that has to be written as HTML
* @param os      The <CODE>OutputStream</CODE> the writer has to write to.
*/

   protected HtmlWriter(Document doc, OutputStream os) {
       super(doc, os);

       document.addDocListener(this);
       this.pageN = document.getPageNumber();
       try {
           os.write(LT);
           os.write(getISOBytes(HtmlTags.HTML));
           os.write(GT);
           os.write(NEWLINE);
           os.write(TAB);
           os.write(LT);
           os.write(getISOBytes(HtmlTags.HEAD));
           os.write(GT);
       }
       catch(IOException ioe) {
           throw new ExceptionConverter(ioe);
       }
   }
项目:itext2    文件:PdfPKCS7.java   
/**
 * Gets the bytes for the PKCS#1 object.
 * @return a byte array
 */
public byte[] getEncodedPKCS1() {
    try {
        if (externalDigest != null)
            digest = externalDigest;
        else
            digest = sig.sign();
        ByteArrayOutputStream   bOut = new ByteArrayOutputStream();

        ASN1OutputStream dout = new ASN1OutputStream(bOut);
        dout.writeObject(new DEROctetString(digest));
        dout.close();

        return bOut.toByteArray();
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:PdfWriter.java   
protected PdfDictionary getCatalog(PdfIndirectReference rootObj)
{
    PdfDictionary catalog = pdf.getCatalog(rootObj);
    // [F12] tagged PDF
    if (tagged) {
        try {
            getStructureTreeRoot().buildTree();
        }
        catch (Exception e) {
            throw new ExceptionConverter(e);
        }
        catalog.put(PdfName.STRUCTTREEROOT, structureTreeRoot.getReference());
        PdfDictionary mi = new PdfDictionary();
        mi.put(PdfName.MARKED, PdfBoolean.PDFTRUE);
        if (userProperties)
            mi.put(PdfName.USERPROPERTIES, PdfBoolean.PDFTRUE);
        catalog.put(PdfName.MARKINFO, mi);
    }
    // [F13] OCG
    if (!documentOCG.isEmpty()) {
        fillOCProperties(false);
        catalog.put(PdfName.OCPROPERTIES, OCProperties);
    }
    return catalog;
}
项目:itext2    文件:PdfWriter.java   
/**
 * Signals that the <CODE>Document</CODE> has been opened and that
 * <CODE>Elements</CODE> can be added.
 * <P>
 * When this method is called, the PDF-document header is
 * written to the outputstream.
 * @see com.lowagie.text.DocWriter#open()
 */
public void open() {
    super.open();
    try {
        pdf_version.writeHeader(os);
        body = new PdfBody(this);
        if (pdfxConformance.isPdfX32002()) {
            PdfDictionary sec = new PdfDictionary();
            sec.put(PdfName.GAMMA, new PdfArray(new float[]{2.2f,2.2f,2.2f}));
            sec.put(PdfName.MATRIX, new PdfArray(new float[]{0.4124f,0.2126f,0.0193f,0.3576f,0.7152f,0.1192f,0.1805f,0.0722f,0.9505f}));
            sec.put(PdfName.WHITEPOINT, new PdfArray(new float[]{0.9505f,1f,1.089f}));
            PdfArray arr = new PdfArray(PdfName.CALRGB);
            arr.add(sec);
            setDefaultColorspace(PdfName.DEFAULTRGB, addToBody(arr).getIndirectReference());
        }
    }
    catch(IOException ioe) {
        throw new ExceptionConverter(ioe);
    }
}
项目:itext2    文件:PdfWriter.java   
/**
 * Writes a <CODE>PdfImage</CODE> to the outputstream.
 *
 * @param pdfImage the image to be added
 * @return a <CODE>PdfIndirectReference</CODE> to the encapsulated image
 * @throws PdfException when a document isn't open yet, or has been closed
 */

PdfIndirectReference add(PdfImage pdfImage, PdfIndirectReference fixedRef) throws PdfException {
    if (! imageDictionary.contains(pdfImage.name())) {
        PdfXConformanceImp.checkPDFXConformance(this, PdfXConformanceImp.PDFXKEY_IMAGE, pdfImage);
        if (fixedRef instanceof PRIndirectReference) {
            PRIndirectReference r2 = (PRIndirectReference)fixedRef;
            fixedRef = new PdfIndirectReference(0, getNewObjectNumber(r2.getReader(), r2.getNumber(), r2.getGeneration()));
        }
        try {
            if (fixedRef == null)
                fixedRef = addToBody(pdfImage).getIndirectReference();
            else
                addToBody(pdfImage, fixedRef);
        }
        catch(IOException ioe) {
            throw new ExceptionConverter(ioe);
        }
        imageDictionary.put(pdfImage.name(), fixedRef);
        return fixedRef;
    }
    return (PdfIndirectReference) imageDictionary.get(pdfImage.name());
}
项目:itext2    文件:BarcodeEAN.java   
/** Creates new BarcodeEAN */
public BarcodeEAN() {
    try {
        x = 0.8f;
        font = BaseFont.createFont("Helvetica", "winansi", false);
        size = 8;
        baseline = size;
        barHeight = size * 3;
        guardBars = true;
        codeType = EAN13;
        code = "";
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:FieldPositioningEvents.java   
/**
 * @see com.lowagie.text.pdf.PdfPageEvent#onGenericTag(com.lowagie.text.pdf.PdfWriter, com.lowagie.text.Document, com.lowagie.text.Rectangle, java.lang.String)
 */
public void onGenericTag(PdfWriter writer, Document document,
        Rectangle rect, String text) {
    rect.setBottom(rect.getBottom() - 3);
    PdfFormField field = (PdfFormField) genericChunkFields.get(text);
    if (field == null) {
        TextField tf = new TextField(writer, new Rectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)), text);
        tf.setFontSize(14);
        try {
            field = tf.getTextField();
        } catch (Exception e) {
            throw new ExceptionConverter(e);
        }
    }
    else {
        field.put(PdfName.RECT,  new PdfRectangle(rect.getLeft(padding), rect.getBottom(padding), rect.getRight(padding), rect.getTop(padding)));
    }
    if (parent == null)
        writer.addAnnotation(field);
    else
        parent.addKid(field);
}
项目:itext2    文件:BarcodeCodabar.java   
/** Creates a new BarcodeCodabar.
 */    
public BarcodeCodabar() {
    try {
        x = 0.8f;
        n = 2;
        font = BaseFont.createFont("Helvetica", "winansi", false);
        size = 8;
        baseline = size;
        barHeight = size * 3;
        textAlignment = Element.ALIGN_CENTER;
        generateChecksum = false;
        checksumText = false;
        startStopText = false;
        codeType = CODABAR;
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:EndPageTest.java   
/**
 * @see com.lowagie.text.pdf.PdfPageEventHelper#onEndPage(com.lowagie.text.pdf.PdfWriter,
 *      com.lowagie.text.Document)
 */
public void onEndPage(PdfWriter writer, Document document) {
    try {
        Rectangle page = document.getPageSize();
        PdfPTable head = new PdfPTable(3);
        for (int k = 1; k <= 6; ++k)
            head.addCell("head " + k);
        head.setTotalWidth(page.getWidth() - document.leftMargin()
                - document.rightMargin());
        head.writeSelectedRows(
                0,
                -1,
                document.leftMargin(),
                page.getHeight() - document.topMargin()
                        + head.getTotalHeight(), writer.getDirectContent());
        PdfPTable foot = new PdfPTable(3);
        for (int k = 1; k <= 6; ++k)
            foot.addCell("foot " + k);
        foot.setTotalWidth(page.getWidth() - document.leftMargin()
                - document.rightMargin());
        foot.writeSelectedRows(0, -1, document.leftMargin(),
                document.bottomMargin(), writer.getDirectContent());
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:PRStream.java   
/**
 * Sets the data associated with the stream, either compressed or
 * uncompressed. Note that the data will never be compressed if
 * Document.compress is set to false.
 * 
 * @param data raw data, decrypted and uncompressed.
 * @param compress true if you want the stream to be compressed.
 * @param compressionLevel  a value between -1 and 9 (ignored if compress == false)
 * @since   iText 2.1.3
 */
public void setData(byte[] data, boolean compress, int compressionLevel) {
    remove(PdfName.FILTER);
    this.offset = -1;
    if (Document.compress && compress) {
        try {
            ByteArrayOutputStream stream = new ByteArrayOutputStream();
            Deflater deflater = new Deflater(compressionLevel);
            DeflaterOutputStream zip = new DeflaterOutputStream(stream, deflater);
            zip.write(data);
            zip.close();
            deflater.end();
            bytes = stream.toByteArray();
            this.compressionLevel = compressionLevel;
        }
        catch (IOException ioe) {
            throw new ExceptionConverter(ioe);
        }
        put(PdfName.FILTER, PdfName.FLATEDECODE);
    }
    else
        bytes = data;
    setLength(bytes.length);
}
项目:itext2    文件:TagMap.java   
protected void init(InputStream in) {
    try {
        SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
        parser.parse(new InputSource(in), new AttributeHandler(this));
    }
    catch(Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:PdfAcroForm.java   
/**
 * @param field
 * @param value
 * @param llx
 * @param lly
 * @param urx
 * @param ury
 */
public void drawCheckBoxAppearences(PdfFormField field, String value, float llx, float lly, float urx, float ury) {
    BaseFont font = null;
    try {
        font = BaseFont.createFont(BaseFont.ZAPFDINGBATS, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
    }
    catch(Exception e) {
        throw new ExceptionConverter(e);
    }
    float size = (ury - lly);
    PdfAppearance tpOn = PdfAppearance.createAppearance(writer, urx - llx, ury - lly);
    PdfAppearance tp2 = (PdfAppearance)tpOn.getDuplicate();
    tp2.setFontAndSize(font, size);
    tp2.resetRGBColorFill();
    field.setDefaultAppearanceString(tp2);
    tpOn.drawTextField(0f, 0f, urx - llx, ury - lly);
    tpOn.saveState();
    tpOn.resetRGBColorFill();
    tpOn.beginText();
    tpOn.setFontAndSize(font, size);
    tpOn.showTextAligned(PdfContentByte.ALIGN_CENTER, "4", (urx - llx) / 2, (ury - lly) / 2 - (size * 0.3f), 0);
    tpOn.endText();
    tpOn.restoreState();
    field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, value, tpOn);
    PdfAppearance tpOff = PdfAppearance.createAppearance(writer, urx - llx, ury - lly);
    tpOff.drawTextField(0f, 0f, urx - llx, ury - lly);
    field.setAppearance(PdfAnnotation.APPEARANCE_NORMAL, "Off", tpOff);
}
项目:itext2    文件:XmlParser.java   
/**
* Parses a given file.
* @param document   The document that will listen to the parser
* @param is The InputStream with the contents
*/

   public void go(DocListener document, InputSource is) {
       try {
           parser.parse(is, new SAXiTextHandler(document));
       }
       catch(SAXException se) {
           throw new ExceptionConverter(se);
       }
       catch(IOException ioe) {
           throw new ExceptionConverter(ioe);
       }
   }
项目:itext2    文件:XmlParser.java   
/**
* Parses a given file.
* @param document The document that will listen to the parser
* @param is The inputsource with the content
* @param tagmap A user defined tagmap
*/

   public void go(DocListener document, InputSource is, String tagmap) {
       try {
           parser.parse(is, new SAXmyHandler(document, new TagMap(tagmap)));
       }
       catch(SAXException se) {
           throw new ExceptionConverter(se);
       }
       catch(IOException ioe) {
           throw new ExceptionConverter(ioe);
       }
   }
项目:itext2    文件:XmlParser.java   
/**
* Parses a given file.
* @param document The document that will listen to the parser
* @param is the inputsource with the content
* @param tagmap an inputstream to a user defined tagmap
*/

   public void go(DocListener document, InputSource is, InputStream tagmap) {
       try {
           parser.parse(is, new SAXmyHandler(document, new TagMap(tagmap)));
       }
       catch(SAXException se) {
           throw new ExceptionConverter(se);
       }
       catch(IOException ioe) {
           throw new ExceptionConverter(ioe);
       }
   }
项目:itext2    文件:XmlParser.java   
/**
* Parses a given file.
* @param document The document that will listen to the parser
* @param is the inputsource with the content
* @param tagmap a user defined tagmap
*/

   public void go(DocListener document, InputSource is, HashMap tagmap) {
       try {
           parser.parse(is, new SAXmyHandler(document, tagmap));
       }
       catch(SAXException se) {
           throw new ExceptionConverter(se);
       }
       catch(IOException ioe) {
           throw new ExceptionConverter(ioe);
       }
   }
项目:itext2    文件:XmlParser.java   
/**
* Parses a given file.
* @param document The document that will listen to the parser
* @param file The path to a file with the content
*/

   public void go(DocListener document, String file) {
       try {
           parser.parse(file, new SAXiTextHandler(document));
       }
       catch(SAXException se) {
           throw new ExceptionConverter(se);
       }
       catch(IOException ioe) {
           throw new ExceptionConverter(ioe);
       }
   }
项目:itext2    文件:TrueTypeFont.java   
/** Reads a <CODE>String</CODE> from the font file as bytes using the Cp1252
 *  encoding.
 * @param length the length of bytes to read
 * @return the <CODE>String</CODE> read
 * @throws IOException the font file could not be read
 */
protected String readStandardString(int length) throws IOException {
    byte buf[] = new byte[length];
    rf.readFully(buf);
    try {
        return new String(buf, WINANSI);
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:PdfContentStreamProcessor.java   
/**
    * Processes PDF syntax
    * @param contentBytes   the bytes of a content stream
    * @param resources      the resources that come with the content stream
    */
public void processContent(byte[] contentBytes, PdfDictionary resources) {
    this.resources.push(resources);
    try {
        PdfContentParser ps = new PdfContentParser(new PRTokeniser(contentBytes));
        ArrayList operands = new ArrayList();
        while (ps.parse(operands).size() > 0) {
            PdfLiteral operator = (PdfLiteral) operands.get(operands.size() - 1);
            invokeOperator(operator, operands);
        }
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
    this.resources.pop();
}
项目:itext2    文件:RadioCheckField.java   
/**
 * Sets the checked symbol. It can be
 * <CODE>TYPE_CHECK</CODE>,
 * <CODE>TYPE_CIRCLE</CODE>,
 * <CODE>TYPE_CROSS</CODE>,
 * <CODE>TYPE_DIAMOND</CODE>,
 * <CODE>TYPE_SQUARE</CODE> and
 * <CODE>TYPE_STAR</CODE>.
 * @param checkType the checked symbol
 */
public void setCheckType(int checkType) {
    if (checkType < TYPE_CHECK || checkType > TYPE_STAR)
        checkType = TYPE_CHECK;
    this.checkType = checkType;
    setText(typeChars[checkType - 1]);
    try {
        setFont(BaseFont.createFont(BaseFont.ZAPFDINGBATS, BaseFont.WINANSI, false));
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:HtmlParser.java   
/**
* Parses a given file.
* @param document the document the parser will write to
* @param is the InputSource with the content
*/

   public void go(DocListener document, InputSource is) {
       try {
           parser.parse(is, new SAXmyHtmlHandler(document));
       }
       catch(SAXException se) {
           throw new ExceptionConverter(se);
       }
       catch(IOException ioe) {
           throw new ExceptionConverter(ioe);
       }
   }
项目:itext2    文件:CFFFont.java   
char getCard16() {
    try {
        return buf.readChar();
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:CFFFont.java   
void seek(int offset) {
    try {
        buf.seek(offset);
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:CFFFont.java   
short getShort() {
    try {
        return buf.readShort();
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:CFFFont.java   
int getInt() {
    try {
        return buf.readInt();
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}
项目:itext2    文件:CFFFont.java   
int getPosition() {
    try {
        return buf.getFilePointer();
    }
    catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}