Example usage for com.itextpdf.text.pdf PdfContentByte addImage

List of usage examples for com.itextpdf.text.pdf PdfContentByte addImage

Introduction

In this page you can find the example usage for com.itextpdf.text.pdf PdfContentByte addImage.

Prototype

public void addImage(final Image image) throws DocumentException 

Source Link

Document

Adds an Image to the page.

Usage

From source file:NPRImpl.java

@Override
public boolean saveRegistrationToPdf(RegistrationImpl registrationImpl, ResidentImpl residentImpl)
        throws RemoteException {
    try {//from  w  w  w.  j a  v  a  2 s.co  m
        BufferedReader br = new BufferedReader(new FileReader("dir\\defaults.txt"));
        String path = "";
        try {
            StringBuilder sb = new StringBuilder();
            String line = br.readLine();

            while (line != null) {
                sb.append(line);
                sb.append(System.lineSeparator());
                line = br.readLine();
            }
            path = sb.toString().trim();
        } finally {
            br.close();
        }
        String gend = "";
        Document doc = new Document();
        FileOutputStream fos = new FileOutputStream(path + "\\registration\\" + residentImpl.getLName().trim()
                + ", " + residentImpl.getFName().trim() + "RegistrationResidentForm.pdf");
        PdfWriter pdfWriter = PdfWriter.getInstance(doc, fos);

        PdfReader pdfReader = new PdfReader("RegistrationResidentForm.pdf");

        PdfStamper pdfStamper = new PdfStamper(pdfReader, fos);

        for (int i = 1; i <= pdfReader.getNumberOfPages(); i++) {
            PdfContentByte content = pdfStamper.getOverContent(i);
            if (residentImpl.getPicture() != null) {
                Image image1 = Image.getInstance(residentImpl.getPicture());
                image1.scaleAbsolute(95, 105);
                image1.setAbsolutePosition(465f, 635f);
                content.addImage(image1);
            }

            //Text over the existing page
            BaseFont bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.WINANSI, BaseFont.EMBEDDED);
            content.beginText();
            content.setFontAndSize(bf, 10);
            //last name
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, residentImpl.getLName().trim(), 175, 610, 0);
            //first name
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, residentImpl.getFName().trim(), 325, 610, 0);
            //middle name
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, residentImpl.getMName().trim(), 470, 610, 0);
            //college
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getCollege().trim(), 180, 582,
                    0);
            //Course and year
            content.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    registrationImpl.getCourse().trim() + " - " + registrationImpl.getYear().trim(), 180, 568,
                    0);
            //department
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getDepartment().trim(), 400,
                    582, 0);
            //Sex
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, residentImpl.getGender().trim(), 400, 568, 0);
            //Home address
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getAddress().trim(), 110, 540,
                    0);
            //resident mobile no1
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getMobile_number().trim(), 187,
                    485, 0);
            //resident mobile no2
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getMobile_number2().trim(), 187,
                    470, 0);
            //student email
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getEmail().trim(), 397, 485, 0);
            //fathers name
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getFatherName().trim(), 110,
                    443, 0);
            //fathers area code
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getFatherAreaCode().trim(), 300,
                    443, 0);
            //father landline
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getFatherPhone().trim(), 355,
                    443, 0);
            //father mobile
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getFatherMobile().trim(), 490,
                    443, 0);
            //father email
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getFatherEmail().trim(), 110,
                    430, 0);
            //mother name
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getMotherName().trim(), 110,
                    402, 0);
            //mother area code
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getMotherAreaCode().trim(), 300,
                    402, 0);
            //mother landline
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getMotherPhone().trim(), 355,
                    402, 0);
            //mother mobile
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getMotherMobile().trim(), 490,
                    402, 0);
            //mother email
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getMotherEmail().trim(), 110,
                    387, 0);
            //guardian name
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getGuardianName().trim(), 170,
                    335, 0);
            //guardian contact number
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getGuardianMobile().trim(), 470,
                    335, 0);
            //guardian address
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getGuardianAddress().trim(),
                    125, 322, 0);
            //guardian relation
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, registrationImpl.getGuardianRelation().trim(),
                    170, 307, 0);
            content.setFontAndSize(bf, 12);
            //room details
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, "Room No.: "
                    + registrationImpl.getRoom_number().trim() + " - " + registrationImpl.getRoom_type().trim(),
                    355, 235, 0);
            content.endText();

        }
        pdfStamper.close();
        pdfReader.close();
        fos.close();
        pdfWriter.close();
    } catch (DocumentException | FileNotFoundException ex) {
        //            Logger.getLogger(NPRImpl.class.getName()).log(Level.SEVERE, null, ex);
        label.setText(ex.getMessage());
        return false;
    } catch (IOException ex) {
        //            Logger.getLogger(NPRImpl.class.getName()).log(Level.SEVERE, null, ex);
        label.setText(ex.getMessage());
        return false;
    }
    return true;
}

From source file:Registration_Tenant.java

private void saveToPdf() {
    try {//from   w  w w .  j  a v a  2  s  .c o m
        String gend = "";
        Document doc = new Document();
        BufferedReader br = new BufferedReader(new FileReader("dir\\defaults.txt"));
        String path = "";
        try {
            StringBuilder sb = new StringBuilder();
            String line = br.readLine();

            while (line != null) {
                sb.append(line);
                sb.append(System.lineSeparator());
                line = br.readLine();
            }
            path = sb.toString().trim();
        } finally {
            br.close();
        }
        FileOutputStream fos = new FileOutputStream(
                path + "\\registration\\" + lastNameTextField.getText().trim() + ", "
                        + firstNameTextField.getText().trim() + "RegistrationResidentForm.pdf");
        PdfWriter pdfWriter = PdfWriter.getInstance(doc, fos);

        PdfReader pdfReader = new PdfReader("RegistrationResidentForm.pdf");

        PdfStamper pdfStamper = new PdfStamper(pdfReader, fos);

        for (int i = 1; i <= pdfReader.getNumberOfPages(); i++) {
            PdfContentByte content = pdfStamper.getOverContent(i);

            byte[] cc = null;
            if (file != null) {
                File thisFile = new File(file);
                cc = Files.readAllBytes(thisFile.toPath());
            }
            if (cc != null) {
                Image image1 = Image.getInstance(cc);
                image1.scaleAbsolute(95, 105);
                image1.setAbsolutePosition(465f, 635f);
                content.addImage(image1);
            }

            //Text over the existing page
            BaseFont bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.WINANSI, BaseFont.EMBEDDED);
            content.beginText();
            content.setFontAndSize(bf, 10);
            //last name
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, lastNameTextField.getText().trim(), 175, 610, 0);
            //first name
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, firstNameTextField.getText().trim(), 325, 610,
                    0);
            //middle name
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, middleNameTextField.getText().trim(), 470, 610,
                    0);
            //college
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, collegeTextField.getText().trim(), 180, 582, 0);
            //Course and year
            content.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    courseTextField.getText().trim() + " - " + yearTextField.getText().trim(), 180, 568, 0);
            //department
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, departmentTextField.getText().trim(), 400, 582,
                    0);
            String g;
            if (male.isSelected()) {
                g = "Male";//6
            } else {
                g = "Female";//6
            }
            //Sex
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, g, 400, 568, 0);
            //Home address
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, homeAddressTextArea.getText(), 110, 540, 0);
            //resident mobile no1
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, MobileNumber1.getText().trim(), 187, 485, 0);
            //resident mobile no2
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, MobileNumber2.getText().trim(), 187, 470, 0);
            //student email
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, email.getText().trim(), 397, 485, 0);
            //fathers name
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, fatherNameTextField.getText().trim(), 110, 443,
                    0);
            //fathers area code
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, fACodeTextField.getText().trim(), 300, 443, 0);
            //father landline
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, fphoneNumberTextField.getText().trim(), 355, 443,
                    0);
            //father mobile
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, fMobileNumberTextField.getText().trim(), 490,
                    443, 0);
            //father email
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, fEmailTextField.getText().trim(), 110, 430, 0);
            //mother name
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, motherNameTextField.getText().trim(), 110, 402,
                    0);
            //mother area code
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, mACodeTextField.getText().trim(), 300, 402, 0);
            //mother landline
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, mphoneNumberTextField.getText().trim(), 355, 402,
                    0);
            //mother mobile
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, mMobileNumberTextField.getText().trim(), 490,
                    402, 0);
            //mother email
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, mEmailTextField.getText().trim(), 110, 387, 0);
            //guardian name
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, guardianNameTextField.getText().trim(), 170, 335,
                    0);
            //guardian contact number
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, gContactNumber1.getText().trim(), 470, 335, 0);
            //guardian address
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, guardianAddress.getText().trim(), 125, 322, 0);
            //guardian relation
            content.showTextAligned(PdfContentByte.ALIGN_LEFT, relationToGuardian.getText().trim(), 170, 307,
                    0);
            content.setFontAndSize(bf, 12);
            //room details
            content.showTextAligned(PdfContentByte.ALIGN_LEFT,
                    "Room No.: " + roomNumberTextField.getSelectedItem().toString().trim() + " - "
                            + roomTypeTextField.getText().trim(),
                    355, 235, 0);
            content.endText();

        }
        pdfStamper.close();
        pdfReader.close();
        fos.close();
        pdfWriter.close();
    } catch (DocumentException ex) {
        //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
        new MessageDialog().error(this, ex.getMessage());
    } catch (FileNotFoundException ex) {
        //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
        new MessageDialog().error(this, ex.getMessage());
    } catch (IOException ex) {
        //            Logger.getLogger(Registration_Tenant.class.getName()).log(Level.SEVERE, null, ex);
        new MessageDialog().error(this, ex.getMessage());
    }
}

From source file:adams.flow.transformer.pdfstamp.Image.java

License:Open Source License

/**
 * Performs the actual stamping.//from  w  ww .  j  av  a 2s .  c  om
 *
 * @param stamper   the stamper to use
 * @param page   the page to apply the stamp to
 */
protected void doStamp(PdfStamper stamper, int page) {
    PdfContentByte canvas;
    com.itextpdf.text.Image image;

    canvas = stamper.getOverContent(page + 1);
    try {
        image = com.itextpdf.text.Image.getInstance(m_Image.getAbsolutePath());
        image.setAbsolutePosition(m_X, m_Y);
        if (m_Rotation != 0) {
            image.setRotationDegrees(m_Rotation);
            image.rotate();
        }
        if (m_Scale > 0) {
            image.scaleToFit(stamper.getReader().getPageSize(page + 1).getWidth() * m_Scale,
                    stamper.getReader().getPageSize(page + 1).getHeight() * m_Scale);
        }
        canvas.addImage(image);
    } catch (Exception e) {
        getLogger().log(Level.SEVERE, "Failed to insert image: " + m_Image, e);
    }
}

From source file:bouttime.report.bracketsheet.BracketSheetReport.java

License:Open Source License

public static boolean generateReport(Dao dao, List<Group> list, String outputFile, boolean doBoutNumbers,
        boolean doTimestamp) {

    if (list.isEmpty()) {
        return false;
    }/*from   www.ja  v a 2s .  c om*/

    // step 1: creation of a document-object
    Document document = new Document();

    try {

        // step 2: creation of the writer
        FileOutputStream fos = createOutputFile(outputFile);
        if (fos == null) {
            return false;
        }
        PdfWriter writer = PdfWriter.getInstance(document, fos);

        // step 3: we open the document
        document.open();

        // step 4: we grab the ContentByte and do some stuff with it
        PdfContentByte cb = writer.getDirectContent();

        String timestamp = "";
        if (doTimestamp) {
            timestamp = DateFormat.getInstance().format(new Date());
        }

        int rv;
        int i = 0;
        int size = list.size();
        for (Group g : list) {
            rv = addBracket(cb, dao, g, doBoutNumbers);
            if (rv != PAGE_ERROR) {
                // Print the watermark, if necessary
                boolean doWatermark = false;
                String gClass = g.getClassification();
                String wmValues = dao.getBracketsheetWatermarkValues();
                if ((wmValues != null) && !wmValues.isEmpty()) {
                    String[] tokens = wmValues.split(",");
                    for (String s : tokens) {
                        if (s.trim().equalsIgnoreCase(gClass)) {
                            doWatermark = true;
                            break;
                        }
                    }
                }

                int rotation = (rv == PAGE_ROUNDROBIN) ? 45 : 135;

                if (doWatermark) {
                    PdfContentByte ucb = writer.getDirectContentUnder();
                    BaseFont helv = BaseFont.createFont("Helvetica", BaseFont.WINANSI, false);
                    ucb.saveState();
                    ucb.setColorFill(BaseColor.LIGHT_GRAY);
                    ucb.beginText();
                    ucb.setFontAndSize(helv, 86);
                    ucb.showTextAligned(Element.ALIGN_CENTER, gClass, document.getPageSize().getWidth() / 2,
                            document.getPageSize().getHeight() / 2, rotation);
                    ucb.endText();
                    ucb.restoreState();
                }

                if (doTimestamp) {
                    rotation -= 45;
                    float width = cb.getPdfWriter().getPageSize().getWidth();
                    int x = (rv == PAGE_ROUNDROBIN) ? 15 : (int) (width - 15);
                    int y = 15;
                    BracketSheetUtil.drawTimestamp(cb, null, x, y, 10, timestamp, rotation);
                }

                // If not doing bout numbers, this is an 'award' type of
                // bracket.  So print an image/logo, if configured.
                if (!doBoutNumbers && (dao.getBracketsheetAwardImage() != null)
                        && !dao.getBracketsheetAwardImage().isEmpty()) {
                    Image image = Image.getInstance(Image.getInstance(dao.getBracketsheetAwardImage()));
                    image.setRotationDegrees((rv == PAGE_ROUNDROBIN) ? 0 : 90);
                    PositionOnPage positionOnPage = dao.getBracketsheetAwardImagePosition();
                    if (PositionOnPage.UPPER_RIGHT == positionOnPage) {
                        float x = (rv == PAGE_ROUNDROBIN)
                                ? document.getPageSize().getWidth() - 10 - image.getWidth()
                                : 10;
                        float y = document.getPageSize().getHeight() - 10 - image.getHeight();
                        image.setAbsolutePosition(x, y);
                        cb.addImage(image);
                    } else if (PositionOnPage.CENTER == positionOnPage) {
                        // put the image in the background, in the middle of the page
                        PdfContentByte ucb = writer.getDirectContentUnder();
                        float pageX = document.getPageSize().getWidth() / 2;
                        float pageY = document.getPageSize().getHeight() / 2;
                        float imageX = image.getWidth() / 2;
                        float imageY = image.getHeight() / 2;
                        image.setAbsolutePosition(pageX - imageX, pageY - imageY);
                        ucb.addImage(image);
                    }
                }

                if (++i < size) {
                    document.newPage();
                }
            }
        }

    } catch (DocumentException de) {
        logger.error("Document Exception", de);
        return false;
    } catch (IOException ioe) {
        logger.error("IO Exception", ioe);
        return false;
    }

    // step 5: we close the document
    document.close();

    return true;
}

From source file:com.kohmiho.mpsr.export.PDFGenerator.java

private void generatePageHeader(Document document, PdfContentByte directContentUnder, Image image,
        Phrase[] headerTexts) {// w w  w  .  j a  v  a2s . com

    float left = document.getPageSize().getLeft(36);
    float top = document.getPageSize().getTop(36);
    float right = document.getPageSize().getRight(36);

    try {
        image.setAbsolutePosition(right - 150, top - 20);
        // image.setAlignment(Element.ALIGN_RIGHT);
        image.scalePercent(25);
        directContentUnder.addImage(image);
    } catch (DocumentException e) {
    }

    int i = 0;
    for (Phrase headerText : headerTexts) {
        ColumnText.showTextAligned(directContentUnder, Element.ALIGN_LEFT, headerText, left + 36,
                top - 10 * (i++), 0);
    }
}

From source file:com.swayam.bhasha.engine.io.writers.impl.PDFImageGenerator.java

License:Apache License

private void makePDFPage(HTMLDocModel htmlDoc, String fileName) throws DocGenerationException, IOException {

    BufferedImage image = getImage(pageDim, htmlDoc);

    /*/* www . j a  va2  s.c o  m*/
     * ByteArrayOutputStream bos = new ByteArrayOutputStream();
     * 
     * ImageIO.write(image, "JPG", bos);
     * 
     * byte[] imageData = bos.toByteArray();
     * 
     * System.out.println("PDFImageGenerator.makePDFPage() " +
     * imageData.length);
     */

    Rectangle pageSize = PageSize.A4;

    if (image.getHeight() > pageSize.getHeight()) {
        pageSize = new Rectangle(image.getWidth(), image.getHeight());
    }

    Document pdfDoc = new Document(pageSize, MARGINS, MARGINS, MARGINS, MARGINS);

    FileOutputStream pdfStream = null;

    try {
        pdfStream = new FileOutputStream(fileName);

        PdfWriter pdfWriter = PdfWriter.getInstance(pdfDoc, pdfStream);

        pdfDoc.addAuthor("Bhasha PDF Generator (Powered by IText)");

        pdfDoc.open();

        PdfContentByte contentByte = pdfWriter.getDirectContent();

        Image pdfImage = Image.getInstance(image, null);

        pdfImage.setAbsolutePosition(0, 0);
        contentByte.addImage(pdfImage);

    } catch (Exception e) {
        throw new DocGenerationException(e);
    } finally {

        pdfDoc.close();

        if (pdfStream != null) {
            try {
                pdfStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }
}

From source file:com.vectorprint.report.itext.style.stylers.Image.java

License:Open Source License

/**
 * Adds an image to a canvas applying the transform if it is not null. Calls {@link DebugHelper#debugAnnotation(com.itextpdf.text.Rectangle, java.lang.String, com.itextpdf.text.pdf.PdfWriter)
 * }.//from  w  w w. j  a  va2 s .  co m
 *
 * @param tf may be null, the transform matrix to apply to the image
 * @param img
 * @param canvas
 * @throws DocumentException
 */
public void addToCanvas(float[] tf, com.itextpdf.text.Image img, PdfContentByte canvas)
        throws DocumentException {
    if (tf == null) {
        canvas.addImage(img);
    } else {
        canvas.addImage(img, img.getWidth() * tf[TRANSFORMMATRIX.SCALEX.getIndex()],
                tf[TRANSFORMMATRIX.SHEARX.getIndex()], tf[TRANSFORMMATRIX.SHEARY.getIndex()],
                img.getHeight() * tf[TRANSFORMMATRIX.SCALEY.getIndex()],
                img.getAbsoluteX() + tf[TRANSFORMMATRIX.TRANSLATEX.getIndex()],
                img.getAbsoluteY() + tf[TRANSFORMMATRIX.TRANSLATEY.getIndex()]);
    }
    if (getSettings().getBooleanProperty(Boolean.FALSE, ReportConstants.DEBUG) && !isDrawShadow()) {
        if (tf == null) {
            DebugHelper
                    .debugAnnotation(
                            new Rectangle(img.getAbsoluteX(), img.getAbsoluteY(),
                                    img.getAbsoluteX() + img.getWidth(), img.getAbsoluteY() + img.getHeight()),
                            getStyleClass(), getWriter());
        } else {
            DebugHelper.debugAnnotation(
                    new Rectangle(img.getAbsoluteX() + tf[TRANSFORMMATRIX.TRANSLATEX.getIndex()],
                            img.getAbsoluteY() + tf[TRANSFORMMATRIX.TRANSLATEY.getIndex()],
                            img.getAbsoluteX() + tf[TRANSFORMMATRIX.TRANSLATEX.getIndex()]
                                    + img.getWidth() * tf[TRANSFORMMATRIX.SCALEX.getIndex()],
                            img.getAbsoluteY() + tf[TRANSFORMMATRIX.TRANSLATEY.getIndex()]
                                    + img.getHeight() * tf[TRANSFORMMATRIX.SCALEY.getIndex()]),
                    getStyleClass(), getWriter());
        }
    }
}

From source file:de.earthdawn.ECEPdfExporter.java

License:Open Source License

public void exportRedbrickExtended(EDCHARACTER edCharakter, File outFile)
        throws DocumentException, IOException {
    PdfReader reader = new PdfReader(
            new FileInputStream(new File("./templates/ed3_extended_character_sheet.pdf")));
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outFile));
    acroFields = stamper.getAcroFields();
    CharacterContainer character = new CharacterContainer(edCharakter);
    // +++ DEBUG +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
    //Set<String> fieldNames = acroFields.getFields().keySet();
    //fieldNames = new TreeSet<String>(fieldNames);
    //for( String fieldName : fieldNames ) {
    //   acroFields.setField( fieldName, fieldName );
    //   System.out.println( fieldName );
    //}/*ww w. j  a  v a2 s .  c  o  m*/
    // +++ ~DEBUG ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    exportCommonFields(character, 16, 55);
    setButtons(character.getWound().getNormal(), "WoundPenalties.", 9);
    acroFields.setField("Shield", "none");
    acroFields.setField("ShieldDeflectionBonus", "na");

    // Charakter Potrait-Bild einfgen
    List<Base64BinaryType> potraits = character.getPortrait();
    if (!potraits.isEmpty()) {
        Image image = Image.getInstance(potraits.get(0).getValue());
        image.setAbsolutePosition(35f, 517f);
        image.scaleAbsolute(165f, 200f);
        PdfContentByte overContent = stamper.getOverContent(2);
        overContent.addImage(image);
    }

    int armor_max = 0;
    int shield_max = 0;
    for (ARMORType armor : character.getProtection().getARMOROrSHIELD()) {
        if (!armor.getUsed().equals(YesnoType.YES))
            continue;
        if (armor.getClass().getSimpleName().equals("ARMORType")) {
            if (armor.getPhysicalarmor() > armor_max) {
                armor_max = armor.getPhysicalarmor();
                acroFields.setField("Armor", armor.getName());
            }
        } else if (armor.getClass().getSimpleName().equals("SHIELDType")) {
            SHIELDType shield = (SHIELDType) armor;
            if (shield.getPhysicalarmor() > shield_max) {
                shield_max = armor.getPhysicalarmor();
                acroFields.setField("Shield", shield.getName());
                acroFields.setField("ShieldDeflectionBonus",
                        shield.getPhysicaldeflectionbonus() + "/" + shield.getMysticdeflectionbonus());
            }
        } else {
            System.err.println("Unbekannte Rstungstyp: " + armor.getClass().getSimpleName());
        }
    }
    acroFields.setField("Discipline", concat(" / ", character.getDisciplineNames()));
    acroFields.setField("Circle", concat(" / ", character.getDisciplineCircles()));
    int counterKarmaritual = 0;
    for (String karmaritual : character.getAllKarmaritual()) {
        for (String description : wrapString(50, karmaritual)) {
            if (counterKarmaritual > 11) {
                System.err.println("Karmaritual description is to long. Only first 12 lines were displayed.");
                break;
            }
            acroFields.setField("KarmaRitual." + counterKarmaritual, description);
            counterKarmaritual++;
        }
    }
    List<DISCIPLINEType> disciplines = character.getDisciplines();
    if (!disciplines.isEmpty()) {
        DISCIPLINEType discipline1 = disciplines.get(0);
        int counter = 0;
        List<TALENTType> disziplinetalents = discipline1.getDISZIPLINETALENT();
        Collections.sort(disziplinetalents, new TalentComparator());
        HashMap<String, ATTRIBUTEType> attributes = character.getAttributes();
        for (TALENTType talent : disziplinetalents) {
            if ((talent.getCircle() > 4) && (counter < 9))
                counter = 9;
            if ((talent.getCircle() > 8) && (counter < 13))
                counter = 13;
            if ((talent.getCircle() > 12) && (counter < 17))
                counter = 17;
            setTalent(counter, talent, attributes);
            counter++;
        }
        List<TALENTType> optionaltalents = discipline1.getOPTIONALTALENT();
        Collections.sort(optionaltalents, new TalentComparator());
        counter = 0;
        for (TALENTType talent : optionaltalents) {
            if ((talent.getCircle() > 4) && (counter < 7))
                counter = 7;
            if ((talent.getCircle() > 8) && (counter < 13))
                counter = 13;
            setTalent(20 + counter, talent, attributes);
            // Optionale Talente knnen Karma erfordern
            if (talent.getKarma().equals(YesnoType.YES)) {
                acroFields.setField("KarmaRequired." + counter, "Yes");
            } else {
                acroFields.setField("KarmaRequired." + counter, "");
            }
            counter++;
        }
    }
    if (disciplines.size() > 1) {
        DISCIPLINEType discipline2 = disciplines.get(1);
        int counter = 36;
        List<TALENTType> disziplinetalents = discipline2.getDISZIPLINETALENT();
        Collections.sort(disziplinetalents, new TalentComparator());
        HashMap<String, ATTRIBUTEType> attributes = character.getAttributes();
        for (TALENTType talent : disziplinetalents) {
            if ((talent.getCircle() > 4) && (counter < 44))
                counter = 44;
            if ((talent.getCircle() > 8) && (counter < 48))
                counter = 48;
            if ((talent.getCircle() > 12) && (counter < 52))
                counter = 52;
            setTalent(counter, talent, attributes);
            counter++;
        }
        List<TALENTType> optionaltalents = discipline2.getOPTIONALTALENT();
        Collections.sort(optionaltalents, new TalentComparator());
        counter = 16;
        for (TALENTType talent : optionaltalents) {
            if ((talent.getCircle() > 4) && (counter < 22))
                counter = 22;
            if ((talent.getCircle() > 8) && (counter < 26))
                counter = 26;
            setTalent(39 + counter, talent, attributes);
            // Optionale Talente knnen Karma erfordern
            if (talent.getKarma().equals(YesnoType.YES)) {
                acroFields.setField("KarmaRequired." + counter, "Yes");
            } else {
                acroFields.setField("KarmaRequired." + counter, "");
            }
            counter++;
        }
    }
    List<WEAPONType> weapons = character.getWeapons();
    if (weapons != null) {
        int counter_melee = 0;
        int counter_range = 0;
        for (WEAPONType weapon : weapons) {
            if (weapon.getShortrange() > 0) {
                acroFields.setField("RangedWeapon." + counter_range, weapon.getName());
                acroFields.setField("RangedWeaponDmgStep." + counter_range,
                        String.valueOf(weapon.getDamagestep()));
                acroFields.setField("RangedWeapon Size." + counter_range, String.valueOf(weapon.getSize()));
                acroFields.setField("RangedWeaponTimesForged." + counter_range,
                        String.valueOf(weapon.getTimesforged()));
                acroFields.setField("WeaponShortRange." + counter_range,
                        String.valueOf(weapon.getShortrange()));
                acroFields.setField("Weapon Long Range." + counter_range,
                        String.valueOf(weapon.getLongrange()));
                counter_range++;
            } else {
                acroFields.setField("Weapon." + counter_melee, weapon.getName());
                acroFields.setField("WeaponDmgStep." + counter_melee, String.valueOf(weapon.getDamagestep()));
                acroFields.setField("Weapon Size." + counter_melee, String.valueOf(weapon.getSize()));
                acroFields.setField("WeaponTimesForged." + counter_melee,
                        String.valueOf(weapon.getTimesforged()));
                counter_melee++;
            }
        }
    }

    List<List<SPELLType>> spellslist = new ArrayList<List<SPELLType>>();
    spellslist.add(character.getOpenSpellList());
    for (DISCIPLINEType discipline : disciplines)
        spellslist.add(discipline.getSPELL());
    setSpellRedbrick(spellslist);

    counterEquipment = 0;
    for (ITEMType item : listArmorAndWeapon(character))
        addEquipment(item.getName(), item.getWeight());
    for (ITEMType item : character.getItems())
        addEquipment(item.getName(), item.getWeight());
    for (MAGICITEMType item : character.getMagicItem()) {
        StringBuffer text = new StringBuffer(item.getName());
        text.append(" (");
        text.append(item.getBlooddamage());
        text.append("/");
        text.append(item.getDepatterningrate());
        text.append("/");
        text.append(item.getEnchantingdifficultynumber());
        text.append(")");
        addEquipment(text.toString(), item.getWeight());
    }

    int copperPieces = 0;
    int goldPieces = 0;
    int silverPieces = 0;
    for (COINSType coins : character.getAllCoins()) {
        addEquipment(coinsToString(coins), coins.getWeight());
        copperPieces += coins.getCopper();
        silverPieces += coins.getSilver();
        goldPieces += coins.getGold();
    }
    acroFields.setField("CopperPieces", String.valueOf(copperPieces));
    acroFields.setField("SilverPieces", String.valueOf(silverPieces));
    acroFields.setField("GoldPieces", String.valueOf(goldPieces));

    int counterDescription = 0;
    for (String description : wrapString(60, character.getDESCRIPTION())) {
        acroFields.setField("ShortDescription." + counterDescription, description);
        counterDescription++;
        if (counterDescription > 7) {
            System.err.println("Character description to long. Only first 8 lines were displayed.");
            break;
        }
    }

    int counterMagicItem = 0;
    int counterThreadItem = 0;
    for (THREADITEMType item : character.getThreadItem()) {
        int weaventhreadrank = item.getWeaventhreadrank();
        acroFields.setField("MagicalTreasureName." + counterMagicItem, item.getName());
        acroFields.setField("MagicalTreasureSpellDefense." + counterMagicItem,
                String.valueOf(item.getSpelldefense()));
        acroFields.setField("MagicalTreasureMaxThreads." + counterMagicItem,
                String.valueOf(item.getMaxthreads()));
        int counterMagicItemDescription = 0;
        for (String description : wrapString(55, item.getDESCRIPTION())) {
            acroFields.setField("MagicalTreasureDesc." + counterMagicItemDescription + "." + counterMagicItem,
                    description);
            counterMagicItemDescription++;
            if (counterMagicItemDescription > 2) {
                System.err.println("MagicItem description to long. Only first 3 lines were displayed.");
                break;
            }
        }
        int counterMagicItemRank = 0;
        for (THREADRANKType rank : item.getTHREADRANK()) {
            acroFields.setField("MagicalTreasureRank." + counterMagicItemRank + "." + counterMagicItem,
                    String.valueOf(counterMagicItemRank + 1));
            acroFields.setField("MagicalTreasureLPCost." + counterMagicItemRank + "." + counterMagicItem,
                    String.valueOf(rank.getLpcost()));
            acroFields.setField("MagicalTreasureKeyKnowledge." + counterMagicItemRank + "." + counterMagicItem,
                    rank.getKeyknowledge());
            acroFields.setField("MagicalTreasureEffect." + counterMagicItemRank + "." + counterMagicItem,
                    rank.getEffect());
            if (counterMagicItemRank < weaventhreadrank) {
                acroFields.setField("ThreadMagicTarget." + counterThreadItem, item.getName());
                acroFields.setField("ThreadMagicEffect." + counterThreadItem, rank.getEffect());
                acroFields.setField("ThreadMagicLPCost." + counterThreadItem, String.valueOf(rank.getLpcost()));
                acroFields.setField("ThreadMagicRank." + counterThreadItem,
                        String.valueOf(counterMagicItemRank + 1));
                counterThreadItem++;
            }
            counterMagicItemRank++;
        }
        counterMagicItem++;
    }

    int counterBloodCharms = 0;
    for (MAGICITEMType item : character.getBloodCharmItem()) {
        acroFields.setField("BloodMagicType." + counterBloodCharms, item.getName());
        if (item.getUsed().equals(YesnoType.YES)) {
            acroFields.setField("BloodMagicDamage." + counterBloodCharms,
                    String.valueOf(item.getBlooddamage()));
        } else {
            acroFields.setField("BloodMagicDamage." + counterBloodCharms, "(" + item.getBlooddamage() + ")");
        }
        acroFields.setField("BloodMagicDR." + counterBloodCharms, String.valueOf(item.getDepatterningrate()));
        acroFields.setField("BloodMagicEffect." + counterBloodCharms, item.getEffect());
        counterBloodCharms++;
    }

    stamper.close();
}

From source file:de.earthdawn.ECEPdfExporter.java

License:Open Source License

public void exportAjfelMordom(EDCHARACTER edCharakter, int pdftype, File outFile)
        throws DocumentException, IOException {
    File pdfinputfile;/* www  .j a  va2 s  .  c  o m*/
    if (pdftype == 1)
        pdfinputfile = new File("templates/ed3_character_sheet_Ajfel+Mordom_pl.pdf");
    else
        pdfinputfile = new File("templates/ed3_character_sheet_Ajfel+Mordom.pdf");
    PdfReader reader = new PdfReader(new FileInputStream(pdfinputfile));
    PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(outFile));
    acroFields = stamper.getAcroFields();
    CharacterContainer character = new CharacterContainer(edCharakter);
    // +++ DEBUG +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
    //Set<String> fieldNames = acroFields.getFields().keySet();
    //fieldNames = new TreeSet<String>(fieldNames);
    //for( String fieldName : fieldNames ) {
    //   acroFields.setField( fieldName, fieldName );
    //}
    // +++ ~DEBUG ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
    exportCommonFields(character, 16, 40);
    setButtons(character.getWound().getNormal(), "Wound.", 7);
    acroFields.setField("BloodWound", "D:" + character.getHealth().getBlooddamage() + ", W:"
            + character.getWound().getBlood() + ", DR:" + character.getHealth().getDepatterningrate());

    // Charakter Potrait-Bild einfgen
    List<Base64BinaryType> potraits = character.getPortrait();
    if (!potraits.isEmpty()) {
        Image image = Image.getInstance(potraits.get(0).getValue());
        if (image != null) {
            image.setAbsolutePosition(18.5f, 702.5f);
            image.scaleAbsolute(91.5f, 93f);
            PdfContentByte overContent = stamper.getOverContent(2);
            if (overContent != null)
                overContent.addImage(image);
            else
                errorout.println("Unable to insert character image.");
        }
    }

    int counterArmor = 0;
    for (ARMORType armor : character.getProtection().getARMOROrSHIELD()) {
        if (!armor.getUsed().equals(YesnoType.YES))
            continue;
        int physicalarmor = armor.getPhysicalarmor();
        int mysticarmor = armor.getMysticarmor();
        int penalty = armor.getPenalty();
        if ((physicalarmor == 0) && (mysticarmor == 0) && (penalty == 0))
            continue;
        acroFields.setField("ArmorName." + counterArmor, armor.getName());
        acroFields.setField("ArmorPhysical." + counterArmor, String.valueOf(physicalarmor));
        acroFields.setField("ArmorMystic." + counterArmor, String.valueOf(mysticarmor));
        acroFields.setField("ArmorPenalty." + counterArmor, String.valueOf(penalty));
        counterArmor++;
    }

    acroFields.setField("Discipline", concat(" / ", character.getDisciplineNames()));
    acroFields.setField("Circle", concat(" / ", character.getDisciplineCircles()));
    acroFields.setField("HalfMagic", character.getAllHalfMagic());

    List<WEAPONType> weapons = character.getWeapons();
    if (weapons != null) {
        int counter = 0;
        ATTRIBUTEType str = character.getAttributes().get("STR");
        for (WEAPONType weapon : weapons) {
            acroFields.setField("Weapon." + counter, weapon.getName());
            acroFields.setField("WeaponStrength." + counter, String.valueOf(str.getStep()));
            acroFields.setField("WeaponDamage.0." + counter, String.valueOf(weapon.getDamagestep()));
            acroFields.setField("WeaponDamage.1." + counter,
                    String.valueOf(weapon.getDamagestep() + str.getStep()));
            acroFields.setField("WeaponRange." + counter,
                    weapon.getShortrange() + " / " + weapon.getLongrange());
            counter++;
        }
    }

    counterEquipment = 0;
    for (ITEMType item : listArmorAndWeapon(character))
        addEquipment(item.getName(), item.getWeight());
    for (ITEMType item : character.getItems())
        addEquipment(item.getName(), item.getWeight());
    for (MAGICITEMType item : character.getMagicItem()) {
        StringBuffer text = new StringBuffer(item.getName());
        text.append(" (");
        text.append(item.getBlooddamage());
        text.append("/");
        text.append(item.getDepatterningrate());
        text.append("/");
        text.append(item.getEnchantingdifficultynumber());
        text.append(")");
        addEquipment(text.toString(), item.getWeight());
    }

    String copperPieces = null;
    String goldPieces = null;
    String silverPieces = null;
    int otherPieces = 0;
    for (COINSType coins : character.getAllCoins()) {
        StringBuffer other = new StringBuffer();
        if (coins.getEarth() > 0)
            other.append(" earth:" + coins.getEarth());
        if (coins.getWater() > 0)
            other.append(" water:" + coins.getWater());
        if (coins.getAir() > 0)
            other.append(" air:" + coins.getAir());
        if (coins.getFire() > 0)
            other.append(" fire:" + coins.getFire());
        if (coins.getOrichalcum() > 0)
            other.append(" orichalcum:" + coins.getOrichalcum());
        if (coins.getGem50() > 0)
            other.append(" gem50:" + coins.getGem50());
        if (coins.getGem100() > 0)
            other.append(" gem100:" + coins.getGem100());
        if (coins.getGem200() > 0)
            other.append(" gem200:" + coins.getGem200());
        if (coins.getGem500() > 0)
            other.append(" gem500:" + coins.getGem500());
        if (coins.getGem1000() > 0)
            other.append(" gem1000:" + coins.getGem1000());
        if (!other.toString().isEmpty()) {
            if (!coins.getName().isEmpty())
                other.append(" [" + coins.getName() + "]");
            acroFields.setField("Coins." + String.valueOf(otherPieces), other.toString());
            otherPieces++;
        }
        if (coins.getCopper() != 0) {
            if (copperPieces == null) {
                copperPieces = String.valueOf(coins.getCopper());
            } else {
                copperPieces += "+" + String.valueOf(coins.getCopper());
            }
        }
        if (coins.getSilver() != 0) {
            if (silverPieces == null) {
                silverPieces = String.valueOf(coins.getSilver());
            } else {
                silverPieces += "+" + String.valueOf(coins.getSilver());
            }
        }
        if (coins.getGold() != 0) {
            if (goldPieces == null) {
                goldPieces = String.valueOf(coins.getGold());
            } else {
                goldPieces += "+" + String.valueOf(coins.getGold());
            }
        }
    }
    acroFields.setField("CopperPieces", copperPieces);
    acroFields.setField("SilverPieces.0", silverPieces);
    acroFields.setField("GoldPieces", goldPieces);

    List<List<SPELLType>> spellslist = new ArrayList<List<SPELLType>>();
    spellslist.add(character.getOpenSpellList());
    int counterDisciplinetalent = 0;
    int counterOthertalent = 0;
    int counterKnack = 0;
    for (DISCIPLINEType discipline : character.getDisciplines()) {
        List<TALENTType> disziplinetalents = discipline.getDISZIPLINETALENT();
        Collections.sort(disziplinetalents, new TalentComparator());
        for (TALENTType talent : disziplinetalents) {
            // Fr mehr als 20 Disziplintalente ist kein Platz!
            if (counterDisciplinetalent > 20)
                break;
            setTalent(counterDisciplinetalent, talent, character.getAttributes());
            counterDisciplinetalent++;
            for (KNACKType knack : talent.getKNACK()) {
                acroFields.setField("TalentKnackTalent." + counterKnack, talent.getName());
                acroFields.setField("TalentKnackName." + counterKnack,
                        knack.getName() + " [" + knack.getStrain() + "]");
                counterKnack++;
            }
        }
        List<TALENTType> optionaltalents = discipline.getOPTIONALTALENT();
        Collections.sort(optionaltalents, new TalentComparator());
        for (TALENTType talent : optionaltalents) {
            setTalent(20 + counterOthertalent, talent, character.getAttributes());
            if (talent.getKarma().equals(YesnoType.YES)) {
                acroFields.setField("KarmaRequired." + counterOthertalent, "Yes");
            } else {
                acroFields.setField("KarmaRequired." + counterOthertalent, "");
            }
            counterOthertalent++;
            for (KNACKType knack : talent.getKNACK()) {
                acroFields.setField("TalentKnackTalent." + counterKnack, talent.getName());
                acroFields.setField("TalentKnackName." + counterKnack,
                        knack.getName() + " [" + knack.getStrain() + "]");
                counterKnack++;
            }
        }
        spellslist.add(discipline.getSPELL());
    }
    setSpellAjfelMordom(spellslist);

    // Die eventuell gesetzte KarmaBentigtHarken lschen
    while (counterOthertalent < 17) {
        acroFields.setField("KarmaRequired." + counterOthertalent, "");
        counterOthertalent++;
    }

    int counterMagicItem = 0;
    for (THREADITEMType item : character.getThreadItem()) {
        int counterMagicItemRank = 0;
        for (THREADRANKType rank : item.getTHREADRANK()) {
            counterMagicItemRank++;
            acroFields.setField("ThreadMagicObject." + counterMagicItem, item.getName());
            acroFields.setField("ThreadMagicRank." + counterMagicItem, String.valueOf(counterMagicItemRank));
            acroFields.setField("ThreadMagicLPCost." + counterMagicItem, String.valueOf(rank.getLpcost()));
            acroFields.setField("ThreadMagicEffect." + counterMagicItem, rank.getEffect());
            counterMagicItem++;
        }
    }

    int counterBloodCharms = 0;
    for (MAGICITEMType item : character.getBloodCharmItem()) {
        acroFields.setField("BloodMagicType." + counterBloodCharms, item.getName());
        String used = "";
        if (item.getUsed().equals(YesnoType.YES))
            used = " (in use)";
        acroFields.setField("BloodMagicDamage." + counterBloodCharms, item.getBlooddamage() + used);
        acroFields.setField("BloodMagicEffect." + counterBloodCharms, item.getEffect());
        counterBloodCharms++;
    }

    acroFields.setField("ShortDescription", character.getDESCRIPTION());

    int counterLanguageSpeak = 0;
    int counterLanguageReadwrite = 0;
    for (CHARACTERLANGUAGEType language : character.getLanguages().getLanguages()) {
        if (!language.getSpeak().equals(LearnedbyType.NO)) {
            acroFields.setField("LanguagesSpeak." + counterLanguageSpeak, language.getLanguage());
            counterLanguageSpeak++;
        }
        if (!language.getReadwrite().equals(LearnedbyType.NO)) {
            acroFields.setField("LanguagesReadWrite." + counterLanguageReadwrite, language.getLanguage());
            counterLanguageReadwrite++;
        }
    }

    stamper.close();
}

From source file:EplanPrinter.PDFPrint.java

License:Open Source License

public String insertStamp(String loc, float x, float y, int width, int height, int set, String date,
        int pageNum, int masterHeight, int masterWidth, String projNo)
        throws BadElementException, MalformedURLException, IOException, DocumentException {
    Image image = Image.getInstance(loc);
    float[] scalar = scale(x, y, width, height, masterHeight, masterWidth, pageNum);
    float[] trans = translate(x, y, r[pageNum - 1].getHeight(), r[pageNum - 1].getWidth(), masterHeight,
            masterWidth, pageNum);//from  ww  w  .  j a va 2  s  .c  o  m
    float[] f = commentTrans(x, y, masterHeight, masterWidth, pageNum);

    float shift = 0;

    /* Addition. ftorres - 7/22/2015 - Added to account for rotated pages 
     *   with the origin (0,0) not set to the bottom-left of the page. [1400] */
    trans = translateRotation(trans[0], trans[1], pageNum);

    if (set == 1) {
        float m = image.getPlainHeight();
        float pageChunk = r[pageNum - 1].getHeight() / 10;
        shift = r[pageNum - 1].getHeight() / 100;
        scalar[1] = (int) (pageChunk);
        scalar[0] = (int) (image.getPlainWidth() * pageChunk) / image.getPlainHeight();
        trans[0] = (int) (0 + (pageChunk * widthScalar));
        trans[1] = (int) (r[pageNum - 1].getHeight() - (pageChunk * heightScalar)
                - (shift * (heightScalar + 2)));
        heightScalar = heightScalar + 1;
        if (heightScalar == 8) {
            heightScalar = 0;
            widthScalar = widthScalar + 2;
        }
    }

    if (set == 1) {
        image.setAbsolutePosition(trans[0] + shift, trans[1] - scalar[1]);
        image.scaleAbsoluteHeight(scalar[1]);
        image.scaleAbsoluteWidth(scalar[0]);
        image.setRotationDegrees(rot);
    } else {
        //swap stamp dimensions for rotated drawings
        if (rot > 0) {
            image.setAbsolutePosition(trans[0] - 2 * scalar[1], trans[1] - 2 * scalar[0]);
        } else {
            image.setAbsolutePosition(trans[0], trans[1] - 2 * scalar[1]);
        }
        image.scaleAbsoluteHeight(scalar[1] * 2);
        image.scaleAbsoluteWidth(scalar[0] * 2);
        image.setRotationDegrees(rot);
    }

    PdfContentByte fg = pds.getOverContent(pageNum);
    fg.addImage(image);

    //Added by tmittelstadt on 09/21/2012 for ticket #698
    //draws a box around the date
    fg.setColorFill(BaseColor.WHITE);
    fg.setLineWidth(0f);

    //dmoody removed box.  ticket 900
    /*fg.moveTo(trans[0], trans[1] - scalar[1] * 2);
       fg.lineTo(trans[0], trans[1] - scalar[1] * 2 - 10);
       fg.lineTo(trans[0] + scalar[0] * 2, trans[1] - scalar[1] * 2 - 10);
       fg.lineTo(trans[0] + scalar[0] * 2, trans[1] - scalar[1] * 2);
       fg.lineTo(trans[0], trans[1] - scalar[1] * 2);*/

    fg.closePathFillStroke();
    fg.fill();

    //adds the date the stamp was added to the document to the pdf
    Phrase p = new Phrase(date);
    p.getFont().setColor(BaseColor.BLACK);
    //Modification zreeve 10/11/2012.  set font size to 11.
    p.getFont().setSize(9f);
    //p.getChunks().get(0).setAnnotation(PdfAnnotation.createText(pds.getWriter(), new Rectangle(trans[0],trans[1], trans[0]+5f, trans[1]+5f), id, comment, true, id));
    ColumnText.showTextAligned(fg, Element.ALIGN_CENTER, p, (float) (trans[0]),
            (float) (trans[1] - scalar[1] * 2 - 12), 0);
    Phrase pn = new Phrase("#[" + projNo + "]");
    pn.getFont().setColor(BaseColor.BLACK);
    pn.getFont().setSize(10f);
    pn.getFont().setStyle("bold");
    ColumnText.showTextAligned(fg, Element.ALIGN_CENTER, pn, (float) (trans[0]),
            (float) (trans[1] - scalar[1] * 2 - 22), 0);

    return "";
}