Example usage for com.itextpdf.text Chunk NEWLINE

List of usage examples for com.itextpdf.text Chunk NEWLINE

Introduction

In this page you can find the example usage for com.itextpdf.text Chunk NEWLINE.

Prototype

Chunk NEWLINE

To view the source code for com.itextpdf.text Chunk NEWLINE.

Click Source Link

Document

This is a Chunk containing a newline.

Usage

From source file:pdf.CoverLetterUtility.java

License:Apache License

private void addIntroduction(Document document) {
    TitlePhrase introTitle = new TitlePhrase("Introduction", LifetimeFonts.FONT_BOLD);
    ValuePhrase introduction = new ValuePhrase(letter.getIntroduction(), LifetimeFonts.FONT_DEFAULT);

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Paragraph.ALIGN_JUSTIFIED);
    //current.setSpacingBefore(10f);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);//from  w w  w.  j ava2s . c  om
    paragraph.add(introTitle);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(introduction);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);
    try {
        document.add(paragraph);
    } catch (DocumentException ex) {
        Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:pdf.CoverLetterUtility.java

License:Apache License

private void addSalutation(Document document) {
    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Paragraph.ALIGN_JUSTIFIED);
    //current.setSpacingBefore(10f);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);/*from   ww  w .  j  ava  2  s  . co m*/
    paragraph.add(new ValuePhrase("Dear " + jobOffer.getContactTitle() + " " + jobOffer.getContactName()));
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);
    try {
        document.add(paragraph);
    } catch (DocumentException ex) {
        Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:pdf.CoverLetterUtility.java

License:Apache License

private void addWhyMe(Document document) {
    TitlePhrase title = new TitlePhrase("Why Me", LifetimeFonts.FONT_BOLD);
    ValuePhrase text = new ValuePhrase(letter.getWhyMe(), LifetimeFonts.FONT_DEFAULT);

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Paragraph.ALIGN_JUSTIFIED);
    //current.setSpacingBefore(10f);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);//from   ww w. j  av a  2  s.  c  om
    paragraph.add(title);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(text);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);
    try {
        document.add(paragraph);
    } catch (DocumentException ex) {
        Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:pdf.CoverLetterUtility.java

License:Apache License

private void addWhyYou(Document document) {
    TitlePhrase title = new TitlePhrase("Why You", LifetimeFonts.FONT_BOLD);
    ValuePhrase text = new ValuePhrase(letter.getWhyYou(), LifetimeFonts.FONT_DEFAULT);

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Paragraph.ALIGN_JUSTIFIED);
    //current.setSpacingBefore(10f);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);/*  w ww  .  j a  v  a  2s .  c  om*/
    paragraph.add(title);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(text);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);
    try {
        document.add(paragraph);
    } catch (DocumentException ex) {
        Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:pdf.CoverLetterUtility.java

License:Apache License

private void addConclusion(Document document) {
    TitlePhrase title = new TitlePhrase("Conclusion", LifetimeFonts.FONT_BOLD);
    ValuePhrase text = new ValuePhrase(letter.getConclusion(), LifetimeFonts.FONT_DEFAULT);

    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Paragraph.ALIGN_JUSTIFIED);
    //current.setSpacingBefore(10f);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);//from w  w  w.  j  a  va 2 s  . c om
    paragraph.add(title);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(text);
    paragraph.add(Chunk.NEWLINE);
    paragraph.add(Chunk.NEWLINE);
    try {
        document.add(paragraph);
    } catch (DocumentException ex) {
        Logger.getLogger(CoverLetterUtility.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:pdf.PdfCreator.java

public String createPdf(String path, String ingredients, String recipeTitle, String recipeDescription)
        throws DocumentException, IOException {
    path += "shoppingList.pdf";
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(path));
    document.open();//from  w ww  .  j ava 2  s . co m
    String[] ings = ingredients.split(";");

    PdfContentByte cb = writer.getDirectContent();
    BaseFont bf = BaseFont.createFont();
    cb.beginText();
    Paragraph p = new Paragraph("Ingredients you'll need to buy:",
            new Font(FontFamily.HELVETICA, 20, Font.BOLD, new BaseColor(38, 165, 154)));
    p.add(Chunk.NEWLINE);
    document.add(p);

    cb.moveText(36, 750);
    cb.setFontAndSize(bf, 15);
    cb.endText();

    p = new Paragraph();
    for (String str : ings) {
        p.add(" ");
        p.add(str);
        p.add(Chunk.NEWLINE);
    }
    p.add(Chunk.NEWLINE);
    p.add(Chunk.NEWLINE);
    document.add(p);

    p = new Paragraph(recipeTitle, new Font(FontFamily.HELVETICA, 20, Font.BOLD, new BaseColor(38, 165, 154)));
    p.add(Chunk.NEWLINE);
    document.add(p);
    p = new Paragraph(recipeDescription, new Font(bf, 12));
    p.add(Chunk.NEWLINE);
    document.add(p);

    document.close();
    return path;
}

From source file:PDF.PDFTrackGenerator.java

License:Open Source License

/**
 * Metda generateTrackPDFA4 sli na samotn vygenerovanie PDF dokumentu trasy na formt A4.
 * @param lineWeight - hrbka ?iary trasy na mape
 * @param color - farba ?iary trasy na mape
 * @param width - rka mapy/* w w w  .  jav a  2s  .  co m*/
 * @param height - vka mapy
 * @param scale - klovacia kontanta mapy (n x rozlenie mapy)
 * @param startDate - dtum a ?as prvho bodu trasy
 * @param endDate - dtum a ?as poslednho bodu trasy
 * @param activity - aktivita trasy
 * @param user - pouvate (majite) trasy
 */
public void generateTrackPDFA4(int lineWeight, String color, int width, int height, int scale, String startDate,
        String endDate, String activity, String user) {
    try {
        Document doc = new Document();
        PdfWriter.getInstance(doc, new FileOutputStream(path + fileName + ".pdf"));
        doc.open();

        Font nadpisFont = new Font(Font.FontFamily.HELVETICA, 25, Font.BOLD);

        Font detailyFont = new Font(Font.FontFamily.HELVETICA, 9, Font.NORMAL);

        Paragraph nadpisPar = new Paragraph();

        nadpisPar.setAlignment(Element.ALIGN_CENTER);

        Phrase nadpis = new Phrase(fileName, nadpisFont);

        nadpisPar.add(nadpis);

        nadpisPar.add("");

        doc.add(nadpisPar);
        doc.add(Chunk.NEWLINE);

        PdfPTable tabulka = new PdfPTable(2);
        tabulka.setWidthPercentage(100);
        float[] columnWidth = { 6f, 4f };
        tabulka.setWidths(columnWidth);

        StaticMapResolver res = new StaticMapResolver(loader);

        String mapUrl = res.getStaticMapTrackURLWithMultimedia(lineWeight, color, width, height, scale);

        Image img = Image.getInstance(new URL(mapUrl));
        //img.scalePercent(50);
        PdfPCell riadokSObr = new PdfPCell(img, true);
        riadokSObr.setBorder(Rectangle.NO_BORDER);
        riadokSObr.setPaddingBottom(10f);
        PdfPCell riadokSText = new PdfPCell(new Phrase("Description: " + loader.getTrackDescription()
                + "\n\n\nTrack activity: " + activity.substring(4) + "\n\n\nStart place: "
                + loader.getStartAddress() + "\n\n\nEnd Place: " + loader.getEndAddress()
                + "\n\n\nTrack length: " + loader.getLength() + " km\n\n\nMin elevation: "
                + loader.getMinElevation() + " m\n\n\nMax elevation: " + loader.getMaxElevation()
                + " m\n\n\nHeight difference: " + loader.getHeightDiff() + " m\n\n\nStart: " + startDate
                + "\n\n\nEnd: " + endDate + "\n\n\nDuration: " + loader.getDuration(), detailyFont));
        riadokSText.setBorder(Rectangle.NO_BORDER);
        riadokSText.setPaddingLeft(20f);
        riadokSText.setPaddingTop(5f);
        riadokSText.setPaddingBottom(10f);
        tabulka.addCell(riadokSObr);
        tabulka.addCell(riadokSText);

        doc.add(tabulka);
        //doc.add(new Phrase("\n", detailyFont));

        PdfPTable obrTabulka = new PdfPTable(3);
        obrTabulka.setWidthPercentage(100);

        ArrayList<String> goodFiles = new ArrayList<String>();
        for (int i = 0; i < loader.getMultimediaFiles().size(); i++) {
            if (!loader.getMultimediaFiles().get(i).getPath().startsWith("YTB")) {
                String extension = loader.getMultimediaFiles().get(i).getPath().substring(
                        loader.getMultimediaFiles().get(i).getPath().lastIndexOf("."),
                        loader.getMultimediaFiles().get(i).getPath().length());
                String newPath = loader.getMultimediaFiles().get(i).getPath().substring(0,
                        loader.getMultimediaFiles().get(i).getPath().lastIndexOf(".")) + "_THUMB" + extension;
                goodFiles.add(newPath);
            }
        }

        if (!goodFiles.isEmpty()) {
            int freeCount = 9;
            if (goodFiles.size() <= 9) {
                for (int i = 0; i < goodFiles.size(); i++) {
                    Image tempImg = Image.getInstance(goodFiles.get(i));
                    tempImg.scalePercent(10f);
                    PdfPCell tempCell = new PdfPCell(tempImg, true);
                    tempCell.setPadding(3f);
                    //tempCell.setPaddingTop(5f);
                    tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    tempCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tempCell.setFixedHeight(130f);
                    tempCell.setBackgroundColor(BaseColor.BLACK);
                    tempCell.setBorderColor(BaseColor.WHITE);
                    tempCell.setBorderWidth(4f);
                    //tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                }
                for (int i = 0; i < 9 - goodFiles.size(); i++) {
                    PdfPCell tempCell = new PdfPCell();
                    tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                }
            } else if (goodFiles.size() <= 18) {
                for (int i = 0; i < 9; i++) {
                    Image tempImg = Image.getInstance(goodFiles.get(i));
                    tempImg.scalePercent(10f);
                    PdfPCell tempCell = new PdfPCell(tempImg, true);
                    tempCell.setPadding(3f);
                    //tempCell.setPaddingTop(5f);
                    tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    tempCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tempCell.setFixedHeight(130f);
                    tempCell.setBackgroundColor(BaseColor.BLACK);
                    tempCell.setBorderColor(BaseColor.WHITE);
                    tempCell.setBorderWidth(4f);
                    //tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                }
            } else {
                for (int i = 0; i < (goodFiles.size() % 9); i++) {
                    goodFiles.remove(goodFiles.size() - 1 - i);
                }

                int counting = (goodFiles.size() / 9);

                for (int i = 0; i < goodFiles.size(); i = i + counting) {
                    Image tempImg = Image.getInstance(goodFiles.get(i));
                    tempImg.scalePercent(10f);
                    PdfPCell tempCell = new PdfPCell(tempImg, true);
                    tempCell.setPadding(3f);
                    //tempCell.setPaddingTop(5f);
                    tempCell.setVerticalAlignment(Element.ALIGN_MIDDLE);
                    tempCell.setHorizontalAlignment(Element.ALIGN_CENTER);
                    tempCell.setFixedHeight(130f);
                    tempCell.setBackgroundColor(BaseColor.BLACK);
                    tempCell.setBorderColor(BaseColor.WHITE);
                    tempCell.setBorderWidth(4f);
                    //tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                    freeCount--;
                }
                for (int i = 0; i < freeCount; i++) {
                    PdfPCell tempCell = new PdfPCell();
                    tempCell.setBorder(Rectangle.NO_BORDER);
                    obrTabulka.addCell(tempCell);
                }
            }
        }

        doc.add(obrTabulka);

        Font lastFont = new Font(Font.FontFamily.HELVETICA, 7, Font.ITALIC);
        Phrase lastText = new Phrase("This PDF document was generated by gTrax app for user " + user, lastFont);
        doc.add(lastText);

        doc.close();
    } catch (Exception ex) {
        FileLogger.getInstance()
                .createNewLog("ERROR: Cannot CREATE PDF for track " + fileName + " for user " + user + " !!!");
        System.out.println("pruser");
    }

}

From source file:pdf.SummaryPhrase.java

License:Apache License

public SummaryPhrase(Academic aux) {
    super();//from w w w  .java 2 s. c o m
    if (aux.getDegree() != null) {
        add(new DegreePhrase(aux.getDegree().getFullname()));
        add(new KeyPhrase(" in ", aux.getLanguage()));
    }
    add(new CoursePhrase(aux.getCourse().getName()));
    add(Chunk.NEWLINE);
    add(new OrganizationPhrase(aux.getOrganization()));
}

From source file:pdf.SummaryPhrase.java

License:Apache License

public SummaryPhrase(Professional aux) {
    super();/*from w ww  . j av a  2 s .c o m*/
    add(new PositionPhrase(aux.getPosition().getName()));
    add(Chunk.NEWLINE);
    add(new OrganizationPhrase(aux.getOrganization()));
}

From source file:pdf.SummaryPhrase.java

License:Apache License

public SummaryPhrase(Certification aux) {
    super();//from  w ww  .j  a  v  a2s  .c o m
    if (aux.getDegree() != null) {
        add(new DegreePhrase(aux.getDegree().getFullname()));
        add(new KeyPhrase(" in ", aux.getLanguage()));
    }
    add(new CoursePhrase(aux.getCourse().getName()));
    add(Chunk.NEWLINE);
    add(new OrganizationPhrase(aux.getOrganization()));
}