Example usage for com.lowagie.text Phrase Phrase

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

Introduction

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

Prototype

public Phrase(float leading, String string) 

Source Link

Document

Constructs a Phrase with a certain leading and a certain String.

Usage

From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java

License:Open Source License

public void createAddressContent(String addressString, PdfWriter writer) throws DocumentException {
    IWBundle iwb = getIWApplicationContext().getIWMainApplication()
            .getBundle(is.idega.idegaweb.egov.message.business.MessageConstants.IW_BUNDLE_IDENTIFIER);
    checkBundleDimensions(iwb);/* w ww. j av  a2  s . co  m*/
    Phrase Ph0 = new Phrase(addressString, getAddressFont());
    ColumnText ct = new ColumnText(writer.getDirectContent());
    /*
     * public void setSimpleColumn(Phrase phrase, float llx, float lly, float urx, float ury, float leading, int alignment) Parameters: phrase - a
     * Phrase llx - the lower left x corner lly - the lower left y corner urx - the upper right x corner ury - the upper right y corner leading - the
     * leading alignment - the column alignment
     * 
     */
    float llx = getPointsFromMM(addressLowerLeftX);// getPointsFromMM((20f+95f));
    float lly = getPointsFromMM(addressLowerLeftY);// 655f;
    float urx = getPointsFromMM(addressUpperRightX);// getPointsFromMM((193f));
    float ury = getPointsFromMM(addressUpperRightY);// getPointsFromMM(257f);
    // ct.setSimpleColumn(Ph0,getPointsFromMM((20f+95f)), 655f,
    // getPointsFromMM((193f)), getPointsFromMM(257f), 15, Element.ALIGN_LEFT);
    // ct.setSimpleColumn(Ph0,getPointsFromMM(new
    // Float(addressLowerLeftX).floatValue()), new
    // Float(addressLowerLeftY).floatValue(), new
    // Float(addressUpperRightX).floatValue(), new
    // Float(addressUpperRightY).floatValue(), 15, Element.ALIGN_LEFT);
    ct.setSimpleColumn(Ph0, llx, lly, urx, ury, 15, Element.ALIGN_LEFT);
    ct.go();
}

From source file:is.idega.idegaweb.egov.printing.business.DocumentBusinessBean.java

License:Open Source License

public void createCommuneFooter(PdfWriter writer) throws Exception {

    PdfContentByte cb = writer.getDirectContent();
    Font nameFont = getDefaultParagraphFont();
    nameFont.setSize(9);/*w w w  .ja  v a2s. c om*/
    Font textFont = getDefaultTextFont();
    textFont.setSize(9);

    PdfPTable table = new PdfPTable(4);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setNoWrap(true);

    IWBundle iwb = getIWApplicationContext().getIWMainApplication()
            .getBundle(is.idega.idegaweb.egov.message.business.MessageConstants.IW_BUNDLE_IDENTIFIER);

    table.addCell(new Phrase(iwb.getProperty("commune.name_mailaddr", "Mailaddress"), nameFont));
    table.addCell(new Phrase(iwb.getProperty("commune.name_visitaddr", "Visitaddress"), nameFont));
    table.addCell(new Phrase(iwb.getProperty("commune.name_contact", "Contact"), nameFont));
    table.addCell(new Phrase(iwb.getProperty("commune.name_org_nr", "Organizationsnr"), nameFont));

    table.addCell(new Phrase(iwb.getProperty("commune.mail_name", "Mail name"), getTextFont()));
    table.addCell(new Phrase(iwb.getProperty("commune.visit_name", "Visit name"), textFont));
    table.addCell(new Phrase(iwb.getProperty("commune.website", "www.some-place.com"), textFont));
    table.addCell(new Phrase(iwb.getProperty("commune.org_number", "XXXXXX-XXXX"), textFont));

    table.addCell(new Phrase(iwb.getProperty("commune.mail_zip", "Zip code"), textFont));
    table.addCell(new Phrase(iwb.getProperty("commune.visit_streetaddr", "Street and number,"), textFont));
    table.addCell(new Phrase(iwb.getProperty("commune.support_email", "email@someplace.com"), textFont));
    table.addCell(new Phrase(" ", textFont));

    table.addCell(new Phrase(" ", textFont));
    table.addCell(new Phrase(iwb.getProperty("commune.visit_zip", "Visit zip"), textFont));
    table.addCell(new Phrase(iwb.getProperty("commune.office_phone", "office phone"), textFont));
    table.addCell(new Phrase(" ", textFont));

    int distFromBottomMM = 30;
    int[] widths = { 20, 20, 30, 20 };
    table.setWidths(widths);
    table.setTotalWidth(getPointsFromMM(210 - 25 - 20));
    table.writeSelectedRows(0, -1, getPointsFromMM(25), getPointsFromMM(distFromBottomMM), cb);

    PdfContentByte linebyte = new PdfContentByte(writer);
    // we add some crosses to visualize the destinations

    linebyte.moveTo(getPointsFromMM(25), getPointsFromMM(distFromBottomMM + 2));
    linebyte.lineTo(getPointsFromMM(210 - 25), getPointsFromMM(distFromBottomMM + 2));

    linebyte.stroke();

    // we add the template on different positions
    cb.add(linebyte);
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * sets the header in the specified document
 * /*from  w  w w  . j ava2s.  com*/
 * @param document
 * @throws Exception
 */
private void setHeader(Document document) throws Exception {
    HeaderFooter header;
    String h = "Data Collections for Proposal: " + proposalCode + proposalNumber;
    if (name != null) {
        h += "  ---  Sample: " + name;
    } else if (slv != null) {
        h += " on Beamline: " + (slv.getBeamlineName() == null ? "" : slv.getBeamlineName())
                + "  ---  Session start date: "
                + (slv.getStartDate() == null ? "" : Formatter.formatDate(slv.getStartDate()));
    }
    header = new HeaderFooter(new Phrase(h, FONT_HELVETICA_10), false);
    header.setAlignment(Element.ALIGN_CENTER);
    header.setBorderWidth(1);
    header.getBefore().getFont().setSize(SIZE_FONT);
    document.setHeader(header);
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * sets the header in the specified document
 * /* w  w  w .j a  v a  2 s.  c  o  m*/
 * @param document
 * @throws Exception
 */
private void setHeaderForDetails(Document document) throws Exception {
    HeaderFooter header;
    String h = "Screening report for Proposal: " + proposalCode + proposalNumber;
    if (name != null) {
        h += "  ---  Sample: " + name;
    } else if (slv != null) {
        h += " on Beamline: " + (slv.getBeamlineName() == null ? "" : slv.getBeamlineName())
                + "  ---  Session start date: "
                + (slv.getStartDate() == null ? "" : Formatter.formatDate(slv.getStartDate()));
    }
    header = new HeaderFooter(new Phrase(h, FONT_HELVETICA_10), false);
    header.setAlignment(Element.ALIGN_CENTER);
    header.setBorderWidth(1);
    header.getBefore().getFont().setSize(SIZE_FONT);
    document.setHeader(header);
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * sets the header in the specified document
 * //from ww  w  .  ja  v a2s .c  o m
 * @param document
 * @throws Exception
 */
private void setHeaderMXPressO(Document document) throws Exception {
    HeaderFooter header;
    String h = "MXPressO/MXPressE for Proposal: " + proposalCode + proposalNumber;
    if (name != null) {
        h += "  ---  Sample: " + name;
    } else if (slv != null) {
        h += " on Beamline: " + (slv.getBeamlineName() == null ? "" : slv.getBeamlineName())
                + "  ---  Session start date: "
                + (slv.getStartDate() == null ? "" : Formatter.formatDate(slv.getStartDate()));
    }
    header = new HeaderFooter(new Phrase(h, FONT_HELVETICA_10), false);
    header.setAlignment(Element.ALIGN_CENTER);
    header.setBorderWidth(1);
    header.getBefore().getFont().setSize(SIZE_FONT);
    document.setHeader(header);
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * returns the cell for the result of a workflow: status of this workflow
 * /*from w  ww .j  av  a2  s  .c  o m*/
 * @param workflow
 * @param mRequest
 * @return
 * @throws BadElementException
 * @throws MalformedURLException
 * @throws IOException
 */
private Cell getWorkflowResult(Workflow3VO workflow, HttpServletRequest mRequest)
        throws BadElementException, MalformedURLException, IOException {
    Cell resultsCell = new Cell();
    Paragraph p = new Paragraph();

    if (workflow != null && workflow.getWorkflowType() != null) {
        p.add(new Phrase(workflow.getWorkflowType() + " ", FONT_DOC_BOLD));
        String img = mRequest.getRealPath(Constants.IMAGE_BLANK);
        String wfStatus = workflow.getStatus();
        if (wfStatus != null) {
            if (wfStatus.equals("Failure")) {
                img = mRequest.getRealPath(Constants.IMAGE_FAILED);
            } else if (wfStatus.equals("Launched")) {
                img = mRequest.getRealPath(Constants.IMAGE_LAUNCHED);
            } else if (wfStatus.equals("Success")) {
                img = mRequest.getRealPath(Constants.IMAGE_SUCCESS);
            }
        }
        p.add(getChunkImage(img));
        p.add(new Phrase("  "));
    }

    resultsCell.add(p);
    return resultsCell;
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * get Status for Characterization (indexing and Strategy)
 * //w  ww . j a va 2s.c om
 * @param dcInfo
 * @param mRequest
 * @return
 * @throws BadElementException
 * @throws MalformedURLException
 * @throws IOException
 */
private Cell getCharacterizationResultStatus(DataCollectionInformation dcInfo, HttpServletRequest mRequest)
        throws BadElementException, MalformedURLException, IOException {
    Cell resultsCell = new Cell();
    Paragraph p = new Paragraph();
    if (dcInfo != null && dcInfo.getScreeningIndexingSuccess() != null) {
        p.add(new Phrase("Indexing ", FONT_DOC_BOLD));
        String img = mRequest.getRealPath(Constants.IMAGE_FAILED);
        if (dcInfo.getScreeningIndexingSuccess() == 1) {
            img = mRequest.getRealPath(Constants.IMAGE_SUCCESS);
        }
        p.add(getChunkImage(img));
        p.add(new Phrase("  "));
    }

    if (dcInfo != null && dcInfo.getScreeningStrategySuccess() != null) {
        p.add(new Phrase("Strategy ", FONT_DOC_BOLD));
        String img = mRequest.getRealPath(Constants.IMAGE_FAILED);
        if (dcInfo.getScreeningStrategySuccess() == 1) {
            img = mRequest.getRealPath(Constants.IMAGE_SUCCESS);
        }
        p.add(getChunkImage(img));
        p.add(new Phrase("  "));
    }

    resultsCell.add(p);
    return resultsCell;
}

From source file:ispyb.client.mx.collection.PdfRtfExporter.java

License:Open Source License

/**
 * return the cell with the status of the different autoProc
 * //w ww .j  av  a 2 s  . c om
 * @param dcInfo
 * @return
 * @throws IOException
 * @throws MalformedURLException
 * @throws BadElementException
 */
private Cell getAutoProcResultStatus(DataCollectionInformation dcInfo)
        throws BadElementException, MalformedURLException, IOException {
    Cell resultsCell = new Cell();
    Paragraph p = new Paragraph();
    // edna
    if (dcInfo != null && dcInfo.getAutoProcEdnaStatus() != null) {
        p.add(new Phrase("EDNA_proc ", FONT_DOC_BOLD));
        p.add(getChunkImage(dcInfo.getAutoProcEdnaStatus()));
        p.add(new Phrase("  "));
    }

    // fastproc
    if (dcInfo != null && dcInfo.getAutoProcFastStatus() != null) {
        p.add(new Phrase("grenades_fastproc ", FONT_DOC_BOLD));
        p.add(getChunkImage(dcInfo.getAutoProcFastStatus()));
        p.add(new Phrase("  "));
    }

    // parallelproc
    if (dcInfo != null && dcInfo.getAutoProcParallelStatus() != null) {
        p.add(new Phrase("grenades_parallelproc ", FONT_DOC_BOLD));
        p.add(getChunkImage(dcInfo.getAutoProcParallelStatus()));
        p.add(new Phrase("  "));
    }
    resultsCell.add(p);
    return resultsCell;
}

From source file:ispyb.client.mx.results.ExportAutoProcAction.java

License:Open Source License

/**
 * sets the header in the specified document
 * /*from w ww.  ja  v  a 2s . c  o m*/
 * @param document
 * @throws Exception
 */
private void setHeader(Document document) throws Exception {
    HeaderFooter header;
    String h = "Auto Processing for Proposal: " + proposalCode + proposalNumber;
    if (slv != null) {
        h += " on Beamline: " + (slv.getBeamlineName() == null ? "" : slv.getBeamlineName())
                + "  ---  Session start date: "
                + (slv.getStartDate() == null ? "" : Formatter.formatDate(slv.getStartDate()));
    }
    header = new HeaderFooter(new Phrase(h, PdfRtfExporter.FONT_HELVETICA_10), false);
    header.setAlignment(Element.ALIGN_CENTER);
    header.setBorderWidth(1);
    header.getBefore().getFont().setSize(PdfRtfExporter.SIZE_FONT);
    document.setHeader(header);
}

From source file:ispyb.common.util.export.ExiPdfRtfExporter.java

License:Open Source License

/**
 * sets the header in the specified document
 * //  w  w w.jav  a  2s.co m
 * @param document
 * @throws Exception
 */
private void setHeader(Document document) throws Exception {
    HeaderFooter header;
    String h = "Data Collections for Proposal: " + proposalDesc;
    if (slv != null) {
        h += " on Beamline: " + (slv.getBeamlineName() == null ? "" : slv.getBeamlineName())
                + "  ---  Session start date: "
                + (slv.getStartDate() == null ? "" : Formatter.formatDate(slv.getStartDate()));
    }
    header = new HeaderFooter(new Phrase(h, FONT_HELVETICA_10), false);
    header.setAlignment(Element.ALIGN_CENTER);
    header.setBorderWidth(1);
    header.getBefore().getFont().setSize(SIZE_FONT);
    document.setHeader(header);
}