Example usage for com.lowagie.text Font UNDERLINE

List of usage examples for com.lowagie.text Font UNDERLINE

Introduction

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

Prototype

int UNDERLINE

To view the source code for com.lowagie.text Font UNDERLINE.

Click Source Link

Document

this is a possible style.

Usage

From source file:org.oscarehr.common.service.PdfRecordPrinter.java

License:Open Source License

public void printEyeformMeasurements(MeasurementFormatter mf) throws DocumentException {
    /*//w  ww .  j  a  v a2s  .  co m
    if( getNewPage() )
    getDocument().newPage();
     else
    setNewPage(true);
     */

    Font obsfont = new Font(getBaseFont(), FONTSIZE, Font.UNDERLINE);

    Paragraph p = new Paragraph();
    p.setAlignment(Paragraph.ALIGN_LEFT);
    Phrase phrase = new Phrase(LEADING, "\n", getFont());
    // p.add(phrase);
    phrase = new Phrase(LEADING, "Ocular Examination", obsfont);
    p.add(phrase);
    getDocument().add(p);

    p = new Paragraph();
    boolean addVisionAssessment = false;
    p.add(new Phrase("VISION ASSESSMENT:  ", getFont()));
    if (mf.getVisionAssessmentAutoRefraction().length() > 0) {
        p.add(new Phrase("Auto-refraction ", boldFont));
        p.add(new Phrase(mf.getVisionAssessmentAutoRefraction(), getFont()));
        addVisionAssessment = true;
    }
    if (mf.getVisionAssessmentKeratometry().length() > 0) {
        p.add(new Phrase(" Keratometry ", boldFont));
        p.add(new Phrase(mf.getVisionAssessmentKeratometry(), getFont()));
        addVisionAssessment = true;
    }
    if (mf.getVisionAssessmentVision("distance", "sc").length() > 0) {
        p.add(new Phrase(" Distance vision (sc) ", boldFont));
        p.add(new Phrase(mf.getVisionAssessmentVision("distance", "sc"), getFont()));
        addVisionAssessment = true;
    }
    if (mf.getVisionAssessmentVision("distance", "cc").length() > 0) {
        p.add(new Phrase(" Distance vision (cc) ", boldFont));
        p.add(new Phrase(mf.getVisionAssessmentVision("distance", "cc"), getFont()));
        addVisionAssessment = true;
    }
    if (mf.getVisionAssessmentVision("distance", "ph").length() > 0) {
        p.add(new Phrase(" Distance vision (ph) ", boldFont));
        p.add(new Phrase(mf.getVisionAssessmentVision("distance", "ph"), getFont()));
        addVisionAssessment = true;
    }
    if (mf.getVisionAssessmentVision("near", "sc").length() > 0) {
        p.add(new Phrase(" Near vision (sc) ", boldFont));
        p.add(new Phrase(mf.getVisionAssessmentVision("near", "sc"), getFont()));
        addVisionAssessment = true;
    }
    if (mf.getVisionAssessmentVision("near", "cc").length() > 0) {
        p.add(new Phrase(" Near vision (cc) ", boldFont));
        p.add(new Phrase(mf.getVisionAssessmentVision("near", "cc"), getFont()));
        addVisionAssessment = true;
    }
    p.add(new Phrase("\n\n"));
    if (addVisionAssessment) {
        getDocument().add(p);
    }

    p = new Paragraph();
    boolean addManifestVision = false;
    p.add(new Phrase("MANIFEST VISION:  ", getFont()));
    if (mf.getManifestDistance().length() > 0) {
        p.add(new Phrase("Manifest distance ", boldFont));
        p.add(new Phrase(mf.getManifestDistance(), getFont()));
        addManifestVision = true;
    }
    if (mf.getManifestNear().length() > 0) {
        p.add(new Phrase(" Manifest near ", boldFont));
        p.add(new Phrase(mf.getManifestNear(), getFont()));
        addManifestVision = true;
    }
    if (mf.getCycloplegicRefraction().length() > 0) {
        p.add(new Phrase(" Cycloplegic refraction ", boldFont));
        p.add(new Phrase(mf.getCycloplegicRefraction(), getFont()));
        addManifestVision = true;
    }
    p.add(new Phrase("\n\n"));
    if (addManifestVision) {
        getDocument().add(p);
    }

    p = new Paragraph();
    boolean addIop = false;
    p.add(new Phrase("INTRAOCULAR PRESSURE:  ", getFont()));
    if (mf.getNCT().length() > 0) {
        p.add(new Phrase("NCT ", boldFont));
        p.add(new Phrase(mf.getNCT(), getFont()));
        addIop = true;
    }
    if (mf.getApplanation().length() > 0) {
        p.add(new Phrase(" Applanation ", boldFont));
        p.add(new Phrase(mf.getApplanation(), getFont()));
        addIop = true;
    }
    if (mf.getCCT().length() > 0) {
        p.add(new Phrase(" Central corneal thickness ", boldFont));
        p.add(new Phrase(mf.getCCT(), getFont()));
        addIop = true;
    }
    p.add(new Phrase("\n\n"));
    if (addIop) {
        getDocument().add(p);
    }

    p = new Paragraph();
    boolean addOtherExam = false;
    p.add(new Phrase("OTHER EXAM:  ", getFont()));
    if (mf.getColourVision().length() > 0) {
        p.add(new Phrase("Colour vision ", boldFont));
        p.add(new Phrase(mf.getColourVision(), getFont()));
        addOtherExam = true;
    }
    if (mf.getPupil().length() > 0) {
        p.add(new Phrase(" Pupil ", boldFont));
        p.add(new Phrase(mf.getPupil(), getFont()));
        addOtherExam = true;
    }
    if (mf.getAmslerGrid().length() > 0) {
        p.add(new Phrase(" Amsler grid ", boldFont));
        p.add(new Phrase(mf.getAmslerGrid(), getFont()));
        addOtherExam = true;
    }
    if (mf.getPAM().length() > 0) {
        p.add(new Phrase(" Potential acuity meter ", boldFont));
        p.add(new Phrase(mf.getPAM(), getFont()));
        addOtherExam = true;
    }
    if (mf.getConfrontation().length() > 0) {
        p.add(new Phrase(" Confrontation fields ", boldFont));
        p.add(new Phrase(mf.getConfrontation(), getFont()));
        addOtherExam = true;
    }
    p.add(new Phrase("\n\n"));
    if (addOtherExam) {
        getDocument().add(p);
    }

    p = new Paragraph();
    boolean addEom = false;
    p.add(new Phrase("EOM/STEREO:  ", getFont()));
    if (mf.getEomStereo().length() > 0) {
        p.add(new Phrase(mf.getEomStereo(), getFont()));
        addEom = true;
    }
    p.add(new Phrase("\n\n"));
    if (addEom) {
        getDocument().add(p);
    }

    p = new Paragraph();
    boolean addAnteriorSegment = false;
    p.add(new Phrase("ANTERIOR SEGMENT:  ", getFont()));
    if (mf.getCornea().length() > 0) {
        p.add(new Phrase("Cornea ", boldFont));
        p.add(new Phrase(mf.getCornea(), getFont()));
        addAnteriorSegment = true;
    }
    if (mf.getConjuctivaSclera().length() > 0) {
        p.add(new Phrase(" Conjunctiva/Sclera ", boldFont));
        p.add(new Phrase(mf.getConjuctivaSclera(), getFont()));
        addAnteriorSegment = true;
    }
    if (mf.getAnteriorChamber().length() > 0) {
        p.add(new Phrase(" Anterior chamber ", boldFont));
        p.add(new Phrase(mf.getAnteriorChamber(), getFont()));
        addAnteriorSegment = true;
    }
    if (mf.getAngle().length() > 0) {
        p.add(new Phrase(" Angle ", boldFont));
        p.add(new Phrase(mf.getAngle(), getFont()));
        addAnteriorSegment = true;
    }
    if (mf.getIris().length() > 0) {
        p.add(new Phrase(" Iris ", boldFont));
        p.add(new Phrase(mf.getIris(), getFont()));
        addAnteriorSegment = true;
    }
    if (mf.getLens().length() > 0) {
        p.add(new Phrase(" Lens ", boldFont));
        p.add(new Phrase(mf.getLens(), getFont()));
        addAnteriorSegment = true;
    }
    p.add(new Phrase("\n\n"));
    if (addAnteriorSegment) {
        getDocument().add(p);
    }

    p = new Paragraph();
    boolean addPosteriorSegment = false;
    p.add(new Phrase("POSTERIOR SEGMENT:  ", getFont()));
    if (mf.getDisc().length() > 0) {
        p.add(new Phrase("Optic disc ", boldFont));
        p.add(new Phrase(mf.getDisc(), getFont()));
        addPosteriorSegment = true;
    }
    if (mf.getCdRatio().length() > 0) {
        p.add(new Phrase(" C/D ratio ", boldFont));
        p.add(new Phrase(mf.getCdRatio(), getFont()));
        addPosteriorSegment = true;
    }
    if (mf.getMacula().length() > 0) {
        p.add(new Phrase(" Macula ", boldFont));
        p.add(new Phrase(mf.getMacula(), getFont()));
        addPosteriorSegment = true;
    }
    if (mf.getRetina().length() > 0) {
        p.add(new Phrase(" Retina ", boldFont));
        p.add(new Phrase(mf.getRetina(), getFont()));
        addPosteriorSegment = true;
    }
    if (mf.getVitreous().length() > 0) {
        p.add(new Phrase(" Vitreous ", boldFont));
        p.add(new Phrase(mf.getVitreous(), getFont()));
        addPosteriorSegment = true;
    }
    p.add(new Phrase("\n\n"));
    if (addPosteriorSegment) {
        getDocument().add(p);
    }

    p = new Paragraph();
    boolean addExternal = false;
    p.add(new Phrase("EXTERNAL/ORBIT:  ", getFont()));
    if (mf.getFace().length() > 0) {
        p.add(new Phrase("Face ", boldFont));
        p.add(new Phrase(mf.getFace(), getFont()));
        addExternal = true;
    }
    if (mf.getUpperLid().length() > 0) {
        p.add(new Phrase(" Upper lid ", boldFont));
        p.add(new Phrase(mf.getUpperLid(), getFont()));
        addExternal = true;
    }
    if (mf.getLowerLid().length() > 0) {
        p.add(new Phrase(" Lower lid ", boldFont));
        p.add(new Phrase(mf.getLowerLid(), getFont()));
        addExternal = true;
    }
    if (mf.getPunctum().length() > 0) {
        p.add(new Phrase(" Punctum ", boldFont));
        p.add(new Phrase(mf.getPunctum(), getFont()));
        addExternal = true;
    }
    if (mf.getLacrimalLake().length() > 0) {
        p.add(new Phrase(" Lacrimal lake ", boldFont));
        p.add(new Phrase(mf.getLacrimalLake(), getFont()));
        addExternal = true;
    }
    if (mf.getRetropulsion().length() > 0) {
        p.add(new Phrase(" Retropulsion ", boldFont));
        p.add(new Phrase(mf.getRetropulsion(), getFont()));
        addExternal = true;
    }
    if (mf.getHertel().length() > 0) {
        p.add(new Phrase(" Hertel ", boldFont));
        p.add(new Phrase(mf.getHertel(), getFont()));
        addExternal = true;
    }
    p.add(new Phrase("\n\n"));
    if (addExternal) {
        getDocument().add(p);
    }

    p = new Paragraph();
    boolean addNasolacrimal = false;
    p.add(new Phrase("NASOLACRIMAL DUCT:  ", getFont()));
    if (mf.getLacrimalIrrigation().length() > 0) {
        p.add(new Phrase("Lacrimal irrigation ", boldFont));
        p.add(new Phrase(mf.getLacrimalIrrigation(), getFont()));
        addNasolacrimal = true;
    }
    if (mf.getNLD().length() > 0) {
        p.add(new Phrase(" Nasolacrimal duct ", boldFont));
        p.add(new Phrase(mf.getNLD(), getFont()));
        addNasolacrimal = true;
    }
    if (mf.getDyeDisappearance().length() > 0) {
        p.add(new Phrase(" Dye disappearance ", boldFont));
        p.add(new Phrase(mf.getDyeDisappearance(), getFont()));
        addNasolacrimal = true;
    }
    p.add(new Phrase("\n\n"));
    if (addNasolacrimal) {
        getDocument().add(p);
    }

    p = new Paragraph();
    boolean addEyelidMeasurement = false;
    p.add(new Phrase("EYELID MEASUREMENT:  ", getFont()));
    if (mf.getMarginReflexDistance().length() > 0) {
        p.add(new Phrase("Margin reflex distance ", boldFont));
        p.add(new Phrase(mf.getMarginReflexDistance(), getFont()));
        addEyelidMeasurement = true;
    }
    if (mf.getLevatorFunction().length() > 0) {
        p.add(new Phrase(" Levator function ", boldFont));
        p.add(new Phrase(mf.getLevatorFunction(), getFont()));
        addEyelidMeasurement = true;
    }
    if (mf.getInferiorScleralShow().length() > 0) {
        p.add(new Phrase(" Inferior scleral show ", boldFont));
        p.add(new Phrase(mf.getInferiorScleralShow(), getFont()));
        addEyelidMeasurement = true;
    }
    if (mf.getLagophthalmos().length() > 0) {
        p.add(new Phrase(" Lagophthalmos ", boldFont));
        p.add(new Phrase(mf.getLagophthalmos(), getFont()));
        addEyelidMeasurement = true;
    }
    if (mf.getBlink().length() > 0) {
        p.add(new Phrase(" Blink ", boldFont));
        p.add(new Phrase(mf.getBlink(), getFont()));
        addEyelidMeasurement = true;
    }
    if (mf.getCNVii().length() > 0) {
        p.add(new Phrase(" Cranial Nerve VII function ", boldFont));
        p.add(new Phrase(mf.getCNVii(), getFont()));
        addEyelidMeasurement = true;
    }
    if (mf.getBells().length() > 0) {
        p.add(new Phrase(" Bell's phenonmenon ", boldFont));
        p.add(new Phrase(mf.getBells(), getFont()));
        addEyelidMeasurement = true;
    }
    p.add(new Phrase("\n\n"));
    if (addEyelidMeasurement) {
        getDocument().add(p);
    }

}

From source file:org.oscarehr.common.service.PdfRecordPrinter.java

License:Open Source License

public void printPhotos(String contextPath, List<org.oscarehr.common.model.Document> photos)
        throws DocumentException {
    writer.setStrictImageSequence(true);

    if (photos.size() > 0) {
        Font obsfont = new Font(getBaseFont(), FONTSIZE, Font.UNDERLINE);
        Paragraph p = new Paragraph();
        p.setAlignment(Paragraph.ALIGN_LEFT);
        Phrase phrase = new Phrase(LEADING, "\n\n", getFont());
        p.add(phrase);//from   www  . ja va  2 s  .co m
        phrase = new Phrase(LEADING, "Photos:", obsfont);
        p.add(phrase);
        getDocument().add(p);
    }

    for (org.oscarehr.common.model.Document doc : photos) {
        Image img = null;
        try {
            //             String location = oscar.OscarProperties.getInstance().getProperty("DOCUMENT_DIR").trim() + doc.getDocfilename();
            String location = EDocUtil.getDocumentPath(doc.getDocfilename());
            logger.info("adding image " + location);
            img = Image.getInstance(location);
        } catch (IOException e) {
            MiscUtils.getLogger().error("error:", e);
            continue;
        }
        img.scaleToFit(getDocument().getPageSize().getWidth() - getDocument().leftMargin()
                - getDocument().rightMargin(), getDocument().getPageSize().getHeight());

        Chunk chunk = new Chunk(img, getDocument().getPageSize().getWidth() - getDocument().leftMargin()
                - getDocument().rightMargin(), getDocument().getPageSize().getHeight());

        Paragraph p = new Paragraph();
        p.add(img);
        p.add(new Phrase("Description:" + doc.getDocdesc(), getFont()));
        getDocument().add(p);

    }
}

From source file:org.oscarehr.common.service.PdfRecordPrinter.java

License:Open Source License

public void printDiagrams(List<EFormValue> diagrams) throws DocumentException {
    writer.setStrictImageSequence(true);

    EFormValueDao eFormValueDao = (EFormValueDao) SpringUtils.getBean("EFormValueDao");

    if (diagrams.size() > 0) {
        Font obsfont = new Font(getBaseFont(), FONTSIZE, Font.UNDERLINE);
        Paragraph p = new Paragraph();
        p.setAlignment(Paragraph.ALIGN_LEFT);
        Phrase phrase = new Phrase(LEADING, "\n\n", getFont());
        p.add(phrase);//from  w w  w .j a  va2 s. c  o m
        phrase = new Phrase(LEADING, "Diagrams:", obsfont);
        p.add(phrase);
        getDocument().add(p);
    }

    for (EFormValue value : diagrams) {
        //this is a form from our group, and our appt
        String imgPath = OscarProperties.getInstance().getProperty("eform_image");
        EFormValue imageName = eFormValueDao.findByFormDataIdAndKey(value.getFormDataId(), "image");
        EFormValue drawData = eFormValueDao.findByFormDataIdAndKey(value.getFormDataId(), "DrawData");
        EFormValue subject = eFormValueDao.findByFormDataIdAndKey(value.getFormDataId(), "subject");

        String image = imgPath + File.separator + imageName.getVarValue();
        logger.debug("image for eform is " + image);
        GraphicalCanvasToImage convert = new GraphicalCanvasToImage();
        File tempFile = null;
        try {
            tempFile = File.createTempFile("graphicImg", ".png");
            FileOutputStream fos = new FileOutputStream(tempFile);
            convert.convertToImage(image, drawData.getVarValue(), "PNG", fos);
            logger.debug("converted image is " + tempFile.getName());
            fos.close();
        } catch (IOException e) {
            logger.error("Error", e);
            if (tempFile != null) {
                tempFile.delete();
            }
            continue;
        }

        Image img = null;
        try {
            logger.info("adding diagram " + tempFile.getAbsolutePath());
            img = Image.getInstance(tempFile.getAbsolutePath());
        } catch (IOException e) {
            logger.error("error:", e);
            continue;
        }
        img.scaleToFit(getDocument().getPageSize().getWidth() - getDocument().leftMargin()
                - getDocument().rightMargin(), getDocument().getPageSize().getHeight());
        Paragraph p = new Paragraph();
        p.add(img);
        p.add(new Phrase("Subject:" + subject.getVarValue(), getFont()));
        getDocument().add(p);

        tempFile.deleteOnExit();
    }

}

From source file:org.oscarehr.eyeform.web.OcularProcPrint.java

License:Open Source License

@Override
public void printExt(CaseManagementPrintPdf engine, HttpServletRequest request)
        throws IOException, DocumentException {
    logger.info("ocular procedure print!!!!");
    String startDate = request.getParameter("pStartDate");
    String endDate = request.getParameter("pEndDate");
    String demographicNo = request.getParameter("demographicNo");

    logger.info("startDate = " + startDate);
    logger.info("endDate = " + endDate);
    logger.info("demographicNo = " + demographicNo);

    OcularProcDao dao = (OcularProcDao) SpringUtils.getBean("OcularProcDAO");
    ProviderDao providerDao = (ProviderDao) SpringUtils.getBean("providerDao");

    List<EyeformOcularProcedure> procs = null;

    if (startDate.equals("") && endDate.equals("")) {
        procs = dao.getByDemographicNo(Integer.parseInt(demographicNo));
    } else {/*from  w w  w . ja  v  a2s  .  c  o m*/
        try {
            SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
            Date dStartDate = formatter.parse(startDate);
            Date dEndDate = formatter.parse(endDate);
            procs = dao.getByDateRange(Integer.parseInt(demographicNo), dStartDate, dEndDate);
        } catch (Exception e) {
            logger.error(e);
        }

    }

    if (engine.getNewPage())
        engine.getDocument().newPage();
    else
        engine.setNewPage(true);

    Font obsfont = new Font(engine.getBaseFont(), engine.FONTSIZE, Font.UNDERLINE);

    Paragraph p = new Paragraph();
    p.setAlignment(Paragraph.ALIGN_CENTER);
    Phrase phrase = new Phrase(engine.LEADING, "\n\n", engine.getFont());
    p.add(phrase);
    phrase = new Phrase(engine.LEADING, "Ocular Procedures", obsfont);
    p.add(phrase);
    engine.getDocument().add(p);

    for (EyeformOcularProcedure proc : procs) {
        p = new Paragraph();
        phrase = new Phrase(engine.LEADING, "", engine.getFont());
        Chunk chunk = new Chunk("Documentation Date: " + engine.getFormatter().format(proc.getDate()) + "\n",
                obsfont);
        phrase.add(chunk);
        p.add(phrase);
        p.add("Name:" + proc.getProcedureName() + "\n");
        p.add("Location:" + proc.getLocation() + "\n");
        p.add("Eye:" + proc.getEye() + "\n");
        p.add("Doctor:" + providerDao.getProviderName(proc.getDoctor()) + "\n");
        p.add("Note:" + proc.getProcedureNote() + "\n");

        engine.getDocument().add(p);
    }

}

From source file:org.oscarehr.eyeform.web.SpecsHistoryPrint.java

License:Open Source License

@Override
public void printExt(CaseManagementPrintPdf engine, HttpServletRequest request)
        throws IOException, DocumentException {
    logger.info("specs history print!!!!");
    String startDate = request.getParameter("pStartDate");
    String endDate = request.getParameter("pEndDate");
    String demographicNo = request.getParameter("demographicNo");

    logger.info("startDate = " + startDate);
    logger.info("endDate = " + endDate);
    logger.info("demographicNo = " + demographicNo);

    ProviderDao providerDao = (ProviderDao) SpringUtils.getBean("providerDao");
    SpecsHistoryDao dao = (SpecsHistoryDao) SpringUtils.getBean("SpecsHistoryDAO");

    List<EyeformSpecsHistory> specs = null;

    if (startDate.equals("") && endDate.equals("")) {
        specs = dao.getByDemographicNo(Integer.parseInt(demographicNo));
    } else {/*  w  w  w. j  a va2  s .  c o m*/
        try {
            SimpleDateFormat formatter = new SimpleDateFormat("dd-MMM-yyyy");
            Date dStartDate = formatter.parse(startDate);
            Date dEndDate = formatter.parse(endDate);
            specs = dao.getByDateRange(Integer.parseInt(demographicNo), dStartDate, dEndDate);
        } catch (Exception e) {
            logger.error(e);
        }

    }

    if (engine.getNewPage())
        engine.getDocument().newPage();
    else
        engine.setNewPage(true);

    Font obsfont = new Font(engine.getBaseFont(), engine.FONTSIZE, Font.UNDERLINE);

    Paragraph p = new Paragraph();
    p.setAlignment(Paragraph.ALIGN_CENTER);
    Phrase phrase = new Phrase(engine.LEADING, "\n\n", engine.getFont());
    p.add(phrase);
    phrase = new Phrase(engine.LEADING, "Specs History", obsfont);
    p.add(phrase);
    engine.getDocument().add(p);

    for (EyeformSpecsHistory spec : specs) {
        p = new Paragraph();
        phrase = new Phrase(engine.LEADING, "", engine.getFont());
        Chunk chunk = new Chunk("Documentation Date: " + engine.getFormatter().format(spec.getDate()) + "\n",
                obsfont);
        phrase.add(chunk);
        p.add(phrase);
        p.add("Type:" + spec.getType() + "\n");
        p.add("Details:" + spec.toString().replaceAll("<br/>", "    ") + "\n");
        p.add("Doctor:" + providerDao.getProviderName(spec.getDoctor()) + "\n");

        engine.getDocument().add(p);
    }

}

From source file:org.pentaho.reporting.engine.classic.core.modules.output.pageable.pdf.internal.PdfLogicalPageDrawable.java

License:Open Source License

private int computeStyle(final TypedMapWrapper<Attribute, Object> attributes, final PdfTextSpec pdfTextSpec) {
    final Float weight = attributes.get(TextAttribute.WEIGHT, TextAttribute.WEIGHT_REGULAR, Float.class);
    final Float italics = attributes.get(TextAttribute.POSTURE, TextAttribute.POSTURE_OBLIQUE, Float.class);
    final boolean underlined = attributes.exists(TextAttribute.UNDERLINE);
    final boolean strikethrough = attributes.exists(TextAttribute.STRIKETHROUGH);

    FontNativeContext nativeContext = pdfTextSpec.getFontMetrics().getNativeContext();

    int style = 0;
    if (nativeContext.isNativeBold() == false && weight >= TextAttribute.WEIGHT_DEMIBOLD) {
        style |= Font.BOLD;/*from w w w  . j a  v a  2  s  . c o m*/
    }
    if (nativeContext.isNativeItalics() == false && italics >= TextAttribute.POSTURE_OBLIQUE) {
        style |= Font.ITALIC;
    }
    if (underlined) {
        style |= Font.UNDERLINE;
    }
    if (strikethrough) {
        style |= Font.STRIKETHRU;
    }
    return style;
}

From source file:org.unitime.timetable.util.PdfFont.java

License:Open Source License

public static Font getFont(boolean bold, boolean italic, boolean underline, Color color) {
    Font font = getFont(bold, italic);
    if (underline)
        font.setStyle(font.getStyle() + Font.UNDERLINE);
    if (color != null)
        font.setColor(color);//from   w ww. ja v a2  s  .  co  m
    return font;
}

From source file:org.unitime.timetable.util.PdfFont.java

License:Open Source License

public static Font getSmallFont(boolean bold, boolean italic, boolean underline, Color color) {
    Font font = getSmallFont(bold, italic);
    if (underline)
        font.setStyle(font.getStyle() + Font.UNDERLINE);
    if (color != null)
        font.setColor(color);//from  w w w  .j  a va2 s  .  c o  m
    return font;
}

From source file:rollyroll.com.servlet.ModuloServlet.java

private void exportar_ModulosaPDF(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {

    try {//w ww .j av  a2  s  .co  m
        //            String[] headers = new String[]{"CODIGO", "NOMBRE", "ACCION", "ORDEN", "ICONO", "ESTADO"};
        String[] headers = new String[] { "NOMBRE", "ACCION", "ICONO" };

        ArrayList<Modulo> lista = null;
        lista = moduloService.listar_Modulos();

        PdfPTable table = new PdfPTable(headers.length);
        table.setHorizontalAlignment(0);
        table.setWidthPercentage(95);
        float[] espaciocolumna = new float[] { 25f, 38f, 50f };
        table.setWidths(espaciocolumna);
        for (int i = 0; i < headers.length; i++) {
            String header = headers[i];
            PdfPCell cell = new PdfPCell();
            cell.setBackgroundColor(Color.YELLOW);
            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
            cell.setPhrase(new Phrase(header.toUpperCase(), new Font(Font.HELVETICA, 10, Font.BOLD)));
            table.addCell(cell);
        }
        table.completeRow();
        PdfPCell cell;

        //            int codigomodulo = 0;
        String nombremodulo = "";
        String accionmodulo = "";
        //            int ordenmodulo = 0;
        String iconomodulo = "";
        //            int estadomodulo = 0;

        for (Modulo modulo : lista) {
            //                codigomodulo += Integer.parseInt(modulo.getCodigomodulo());
            nombremodulo += modulo.getNombremodulo();
            accionmodulo += modulo.getAccionmodulo();
            //                ordenmodulo += Integer.parseInt(modulo.getOrdenmoduloS());
            iconomodulo += modulo.getIconomodulo();
            //                estadomodulo += Byte.parseByte(modulo.getEstadomoduloS());

            //                cell = new PdfPCell();
            //                cell.setPhrase(new Phrase(modulo.getCodigomoduloS(), new Font(Font.HELVETICA, 10, Font.NORMAL)));
            //                cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
            //                table.addCell(cell);
            //                
            cell = new PdfPCell();
            cell.setPhrase(new Phrase(modulo.getNombremodulo(), new Font(Font.HELVETICA, 10, Font.NORMAL)));
            cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
            table.addCell(cell);

            cell = new PdfPCell();
            cell.setPhrase(new Phrase(modulo.getAccionmodulo(), new Font(Font.HELVETICA, 10, Font.NORMAL)));
            cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
            table.addCell(cell);

            //                cell = new PdfPCell();
            //                cell.setPhrase(new Phrase(modulo.getOrdenmoduloS(), new Font(Font.HELVETICA, 10, Font.NORMAL)));
            //                cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
            //                table.addCell(cell);
            cell = new PdfPCell();
            cell.setPhrase(new Phrase(modulo.getIconomodulo(), new Font(Font.HELVETICA, 10, Font.NORMAL)));
            cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
            table.addCell(cell);

            //                cell = new PdfPCell();
            //                cell.setPhrase(new Phrase(modulo.getEstadomoduloS(), new Font(Font.HELVETICA, 10, Font.NORMAL)));
            //                cell.setHorizontalAlignment(PdfPTable.ALIGN_CENTER);
            //                table.addCell(cell);
        }

        table.completeRow();

        //incia diseo de documento exportado
        Document document = new Document(PageSize.A4.rotate(), 20, 5, 5, 5);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PdfWriter.getInstance(document, baos);
        document.open();

        document.addTitle("Reporte de Ventas Generales");
        document.add(
                new Paragraph("Reporte: Ventas Generales 2016", new Font(Font.HELVETICA, 16, Font.UNDERLINE)));
        document.add(new Paragraph("_"));
        document.add(table);
        document.add(Chunk.NEWLINE);
        document.add(new Paragraph(
                "Leyenda: AB: Inicio, BA: Retorno (Importante: No se consideran unidades sin GPS)"));
        document.addAuthor("Quispe Roque Alex Christian");

        table = new PdfPTable(4);
        table.setHorizontalAlignment(0);
        table.setWidthPercentage(40);
        espaciocolumna = new float[] { 10f, 40f, 20f, 20f };
        table.setWidths(espaciocolumna);

        cell = new PdfPCell();
        cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        cell.setPhrase(new Phrase("RESUMEN", new Font(Font.HELVETICA, 10, Font.BOLD)));
        cell.setColspan(7);
        table.addCell(cell);
        table.completeRow();

        //aqui iniciamos asignacion de datos
        //===================================================================
        //            cell = new PdfPCell();
        //            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        //            cell.setPhrase(new Phrase("", new Font(Font.HELVETICA, 10, Font.BOLD)));
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell();
        //            cell.setBackgroundColor(Color.yellow);
        //            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        //            cell.setPhrase(new Phrase("FLOTA OPERATIVA", new Font(Font.HELVETICA, 10, Font.BOLD)));
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell();
        //            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        //            cell.setPhrase(new Phrase(lista.size() + "", new Font(Font.HELVETICA, 10, Font.BOLD)));
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell();
        //            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        //            cell.setPhrase(new Phrase("UNIDADES", new Font(Font.HELVETICA, 10, Font.BOLD)));
        //            table.addCell(cell);
        //            table.completeRow();
        //
        //            //==================================================================================
        //            cell = new PdfPCell();
        //            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        //            cell.setPhrase(new Phrase("2", new Font(Font.HELVETICA, 10, Font.BOLD)));
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell();
        //            cell.setBackgroundColor(Color.yellow);
        //            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        //            cell.setPhrase(new Phrase("NRO DE VIAJES", new Font(Font.HELVETICA, 10, Font.BOLD)));
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell();
        //            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        //            cell.setPhrase(new Phrase((totalAB + totalBA) + "", new Font(Font.HELVETICA, 10, Font.BOLD)));
        //            table.addCell(cell);
        //
        //            cell = new PdfPCell();
        //            cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
        //            cell.setPhrase(new Phrase("VIAJES", new Font(Font.HELVETICA, 10, Font.BOLD)));
        //            table.addCell(cell);
        //
        //            table.completeRow();
        //==================================================================================
        document.add(Chunk.NEWLINE);
        document.add(table);

        document.left(1);
        document.top(1);
        document.close();
        response.setHeader("Expires", "0");
        response.setHeader("Cache-Control", "must-revalidate, post-check=0, pre-check=0");
        //            response.setHeader("Content-Disposition", "attachment; filename=ReporteGeneraldeModulos.pdf");
        response.setHeader("Content-Disposition", "filename=ReporteGeneraldeModulos.pdf");
        response.setHeader("Pragma", "public");
        response.setContentType("application/pdf");
        response.setContentLength(baos.size());
        ServletOutputStream out = response.getOutputStream();
        baos.writeTo(out);
        out.flush();

    } catch (Exception e) {
        RequestDispatcher rd2;
        rd2 = request.getRequestDispatcher("vista/include/error_404.jsp");
        rd2.forward(request, response);
        System.out.println(
                "rollyroll.com.servlet.ModuloServlet.exportar_ModulosaPDF() => ERROR GRAVE AL GENERAR PDF");
        e.getMessage();
    }
}

From source file:test.itext.html.AimsPdf.java

License:Open Source License

public static void addScreenShorts(Document doc, String text)
        throws BadElementException, IOException, DocumentException {

    Paragraph heading = new Paragraph("Screenshots",
            FontFactory.getFont("arial", 10, Font.UNDERLINE | Font.BOLDITALIC));
    heading.setSpacingAfter(12f);// w ww .j av a 2  s  .c om
    doc.add(heading);

    PdfPTable table = new PdfPTable(3);
    table.setWidthPercentage(80);
    table.setHorizontalAlignment(Element.ALIGN_CENTER);

    Image image = Image.getInstance("screen_shoot1.gif");
    image.scalePercent(70);
    PdfPCell cell = new PdfPCell(image);
    cell.setPadding(1);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    image = Image.getInstance("screen_shoot2.gif");
    image.scalePercent(70);
    cell = new PdfPCell(image);
    cell.setPadding(1);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    image = Image.getInstance("screen_shoot3.gif");
    image.scalePercent(70);
    cell = new PdfPCell(image);
    cell.setPadding(1);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    image = Image.getInstance("screen_shoot4.gif");
    image.scalePercent(70);
    cell = new PdfPCell(image);
    cell.setPadding(1);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    image = Image.getInstance("screen_shoot5.gif");
    image.scalePercent(70);
    cell = new PdfPCell(image);
    cell.setPadding(1);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    image = Image.getInstance("screen_shoot6.gif");
    image.scalePercent(70);
    cell = new PdfPCell(image);
    cell.setPadding(1);
    cell.setHorizontalAlignment(Element.ALIGN_CENTER);
    cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.addCell(cell);

    //      doc.add(new Paragraph("\n"));
    doc.add(table);
}