Example usage for com.lowagie.text Rectangle Rectangle

List of usage examples for com.lowagie.text Rectangle Rectangle

Introduction

In this page you can find the example usage for com.lowagie.text Rectangle Rectangle.

Prototype

public Rectangle(float llx, float lly, float urx, float ury) 

Source Link

Document

Constructs a Rectangle -object.

Usage

From source file:eu.europa.ec.markt.dss.signature.pdf.StatefulITextPDFSignatureService.java

License:Open Source License

@SuppressWarnings({ "unchecked", "rawtypes" })
private PdfStamper prepareStamper(InputStream pdfData, OutputStream output, SignatureParameters parameters)
        throws IOException, DocumentException {

    if (stp != null) {
        return stp;
    }/* w w w.  j  a va2  s. c o  m*/

    PdfReader reader = new PdfReader(pdfData);
    stp = PdfStamper.createSignature(reader, output, '\0', null, true);

    PdfSignatureAppearance sap = stp.getSignatureAppearance();
    sap.setAcro6Layers(true);
    sap.setLayer2Text("");
    if (parameters.getSignatureAppearance() != null) {
        sap.setRender(PdfSignatureAppearance.SignatureRenderGraphic);
        sap.setImage(null);
        PdfReader stampReader = new PdfReader(parameters.getSignatureAppearance());
        PdfTemplate stamp = stp.getWriter().getImportedPage(stampReader, 1);
        //stamp.setBoundingBox(new Rectangle(200, 100));
        sap.setTemplate(stamp);
        sap.setSignatureGraphic(Image.getInstance(stamp));

        float[] pos = parameters.getSignaturePosition();
        Rectangle rect = new Rectangle(pos[0], pos[1], pos[2], pos[3]);
        sap.setVisibleSignature(rect, 1, parameters.getSignatureName());
    } else {
        sap.setRender(PdfSignatureAppearance.SignatureRenderDescription);
    }

    PdfSignature dic = new PdfSignature(PdfName.ADOBE_PPKLITE, new PdfName("ETSI.CAdES.detached"));
    Calendar cal = Calendar.getInstance();
    cal.setTime(parameters.getSigningDate());
    sap.setSignDate(cal);
    dic.setDate(new PdfDate(cal));

    if (parameters.getReason() != null) {
        dic.setReason(parameters.getReason());
    }
    if (parameters.getLocation() != null) {
        dic.setLocation(parameters.getLocation());
    }
    if (parameters.getContactInfo() != null) {
        dic.setContact(parameters.getContactInfo());
    }

    sap.setCryptoDictionary(dic);

    int csize = getSignatureSize();
    HashMap exc = new HashMap();
    exc.put(PdfName.CONTENTS, new Integer(csize * 2 + 2));

    sap.preClose(exc);

    return stp;
}

From source file:fr.aliasource.webmail.server.export.ConversationPdfEventHandler.java

License:GNU General Public License

/**
 * @see com.lowagie.text.pdf.PdfPageEventHelper#onOpenDocument(com.lowagie.text.pdf.PdfWriter,
 *      com.lowagie.text.Document)//from   w  w w  .  ja  va  2  s.  c o m
 */
public void onOpenDocument(PdfWriter writer, Document document) {
    try {
        headerImage = Image.getInstance(getLogoUrl());
        table = new PdfPTable(new float[] { 1f, 2f });
        Phrase p = new Phrase();
        Chunk ck = new Chunk(cr.getTitle(), new Font(Font.HELVETICA, 16, Font.BOLD));
        p.add(ck);
        p.add(Chunk.NEWLINE);
        ck = new Chunk(ConversationExporter.formatName(account), new Font(Font.HELVETICA, 12, Font.BOLDITALIC));
        p.add(ck);
        p.add(Chunk.NEWLINE);
        ck = new Chunk(cm.length + " messages", new Font(Font.HELVETICA, 10));
        p.add(ck);
        table.getDefaultCell().setBorder(0);
        table.addCell(new Phrase(new Chunk(headerImage, 0, 0)));
        table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
        table.addCell(p);
        // initialization of the template
        tpl = writer.getDirectContent().createTemplate(100, 100);
        tpl.setBoundingBox(new Rectangle(-20, -20, 100, 100));
        // initialization of the font
        helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
    } catch (Exception e) {
        throw new ExceptionConverter(e);
    }
}

From source file:mpv5.utils.export.PDFFile.java

License:Open Source License

private void setImage(PdfStamper stamper, String key, java.awt.Image oimg) {
    try {//  w  ww .  j  a v a  2s .com
        Log.Debug(this, "Write Image.." + key);
        float[] photograph = acroFields.getFieldPositions(key);
        Rectangle rect = new Rectangle(photograph[1], photograph[2], photograph[3], photograph[4]);
        Image img = Image.getInstance(oimg, null);

        img.setAbsolutePosition(photograph[1] + (rect.getWidth() - img.getScaledWidth()) / 2,
                photograph[2] + (rect.getHeight() - img.getScaledHeight()) / 2);
        PdfContentByte cb = stamper.getOverContent((int) photograph[0]);
        cb.addImage(img);
    } catch (Exception iOException) {
        Log.Debug(iOException);
    }
}

From source file:net.refractions.udig.printing.ui.internal.template.A0LandscapeTemplate.java

License:Open Source License

protected Rectangle getPaperSize() {
    Rectangle a0 = PageSize.A0;// w w w . java 2 s. c o  m
    Rectangle a0Landscape = new Rectangle(0f, 0f, a0.getHeight(), a0.getWidth());
    return a0Landscape;
}

From source file:net.refractions.udig.printing.ui.internal.template.A1LandscapeTemplate.java

License:Open Source License

protected Rectangle getPaperSize() {
    Rectangle a1 = PageSize.A1;//from   ww  w  . j  a v  a 2  s .  co  m
    Rectangle a1Landscape = new Rectangle(0f, 0f, a1.getHeight(), a1.getWidth());
    return a1Landscape;
}

From source file:net.refractions.udig.printing.ui.internal.template.A2LandscapeTemplate.java

License:Open Source License

protected Rectangle getPaperSize() {
    Rectangle a2 = PageSize.A2;/*from   www  .  j av  a  2  s  .  co  m*/
    Rectangle a2Landscape = new Rectangle(0f, 0f, a2.getHeight(), a2.getWidth());
    return a2Landscape;
}

From source file:net.refractions.udig.printing.ui.internal.template.A3LandscapeTemplate.java

License:Open Source License

protected Rectangle getPaperSize() {
    Rectangle a3 = PageSize.A3;/*ww  w  .ja  v a2  s . co m*/
    Rectangle a3Landscape = new Rectangle(0f, 0f, a3.getHeight(), a3.getWidth());
    return a3Landscape;
}

From source file:net.refractions.udig.printing.ui.internal.template.A4LandscapeTemplate.java

License:Open Source License

protected Rectangle getPaperSize() {
    Rectangle a4 = PageSize.A4;/*from  w w w  .j  a v  a2 s.c  o m*/
    Rectangle a4Landscape = new Rectangle(0f, 0f, a4.getHeight(), a4.getWidth());
    return a4Landscape;
}

From source file:net.refractions.udig.printing.ui.internal.template.LegalLandscapeTemplate.java

License:Open Source License

protected Rectangle getPaperSize() {
    Rectangle legal = PageSize.LEGAL;
    Rectangle legalLandscape = new Rectangle(0f, 0f, legal.getHeight(), legal.getWidth());
    return legalLandscape;
}

From source file:net.refractions.udig.printing.ui.internal.template.LetterLandscapeTemplate.java

License:Open Source License

protected Rectangle getPaperSize() {
    Rectangle letter = PageSize.LETTER;
    Rectangle letterLandscape = new Rectangle(0f, 0f, letter.getHeight(), letter.getWidth());
    return letterLandscape;
}