Java 类com.itextpdf.text.Chunk 实例源码

项目:FOXopen    文件:ImageComponentBuilder.java   
@Override
public void buildComponent(SerialisationContext pSerialisationContext, PDFSerialiser pSerialiser, EvaluatedHtmlPresentationNode pEvalNode) {
  Map<String, StringAttributeResult> lNodeAttributes = pEvalNode.getAttributeMap(false);
  String lSourceURI = Optional.ofNullable(lNodeAttributes.get(IMAGE_SOURCE_ATTRIBUTE))
                              .map(StringAttributeResult::getString)
                              .flatMap(Optional::ofNullable)
                              .orElseThrow(() -> new ExInternal("Could not find '" + IMAGE_SOURCE_ATTRIBUTE + "' attribute on HTML image"));
  Image lImage = getImage(pSerialisationContext, lSourceURI);

  // Set the image dimensions if specified in the node attributes, using the current element attributes if dimensions
  // are specified in relative units e.g. ems
  setImageDimensions(lImage, lNodeAttributes, pSerialiser.getElementAttributes());

  // Add the image within a chunk so it appears inline and changes the line leading to fit the image
  pSerialiser.add(new Chunk(lImage, IMAGE_X_OFFSET, IMAGE_Y_OFFSET, true));
}
项目:testarea-itext5    文件:AnnotationIcons.java   
/**
 * <a href="https://stackoverflow.com/questions/46204693/cant-get-itext-rectangle-to-work-correctly-with-annotations">
 * Can't get itext Rectangle to work correctly with annotations
 * </a>
 * <p>
 * This test looks at a <b>Text</b> annotation added via a {@link Chunk}
 * as done by the OP. As this way of adding annotations resets the
 * annotation <b>Rect</b> to the bounding box of the rendered {@link Chunk},
 * it is not really what the OP wants.
 * </p>
 */
@Test
public void testAnnotationIconForTYD() throws FileNotFoundException, DocumentException {
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(new File(RESULT_FOLDER, "annotationIcons.pdf")));
    document.open();

    // Not "new Rectangle(164, 190, 164, 110)" which would be empty
    Rectangle rect = new Rectangle(164, 190, 328, 300);

    // Annotation added like the OP does
    Chunk chunk_text = new Chunk("Let's test a Text annotation...");
    chunk_text.setAnnotation(PdfAnnotation.createText(writer, rect, "Warning", "This is a Text annotation with Comment icon.", false, "Comment"));        

    document.add(chunk_text);

    // Annotation added to the document without Chunk
    writer.addAnnotation(PdfAnnotation.createText(writer, rect, "Warning 2", "This is another Text annotation with Comment icon.", false, "Comment"));

    document.close();
}
项目:tellervo    文件:SeriesReport.java   
/**
 * Get an iText Paragraph for the Title 
 * 
 * @return Paragraph
 */
private Paragraph getTitlePDF()
{
    Paragraph p = new Paragraph();

    p.add(new Chunk(s.getDisplayTitle()+"\n", titleFont));

    // Add object name if this is a mSeries
    if(s.getSeries() instanceof TridasMeasurementSeries)
    {
        TridasObject tobj = s.getMeta(Metadata.OBJECT, TridasObject.class);

        p.add(new Chunk(tobj.getTitle(), subTitleFont));
    }       
    return p;       
}
项目:tellervo    文件:SeriesReport.java   
/**
 * iText paragraph containing created and lastmodified timestamps
 * 
 * @return Paragraph
 */
private Paragraph getTimestampPDF()
{
    // Set up calendar
    Date createdTimestamp = s.getSeries().getCreatedTimestamp().getValue()
            .toGregorianCalendar().getTime();
    Date lastModifiedTimestamp = s.getSeries().getLastModifiedTimestamp()
            .getValue().toGregorianCalendar().getTime();
    DateFormat df1 = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT);

    Paragraph p = new Paragraph();


    p.add(new Chunk("Created: ", subSubSectionFont));
    p.add(new Chunk(df1.format(createdTimestamp), bodyFont));
    p.add(new Chunk("\nLast Modified: ", subSubSectionFont));
    p.add(new Chunk(df1.format(lastModifiedTimestamp), bodyFont));


    return p;

}
项目:tellervo    文件:SeriesReport.java   
private Paragraph getSeriesComments() 
{


    Paragraph p = new Paragraph();

    if(s.getSeries().getComments()!=null){

        p.setLeading(0, 1.2f);
        p.add(new Chunk("Comments: \n", subSubSectionFont));
        p.add(new Chunk(s.getSeries().getComments(), bodyFont));
        return p;
    }
    else
    {
        return p;
    }


}
项目:tellervo    文件:SeriesReport.java   
private Chunk certaintyToNaturalString(String certainty)
{
    Chunk c = new Chunk();

    if(certainty.equalsIgnoreCase("exact")){
        c.append("in exactly ");
    }
    else if (certainty.equalsIgnoreCase("after")){
        c.append("after ");
    }
    else if (certainty.equalsIgnoreCase("before")){
        c.append("before ");
    }       
    else{
        c.append("in "+certainty.toLowerCase() + " ");
    }

    c.setFont(bodyFont);
    return c;
}
项目:tellervo    文件:SeriesReport.java   
/**
 * iText paragraph of element and sample info
 * @return Paragraph
 */
private Paragraph getElementAndSampleInfo()
{
    Paragraph p = new Paragraph();

    TridasElement telem = s.getMeta(Metadata.ELEMENT, TridasElement.class);
    TridasSample tsamp = s.getMeta(Metadata.SAMPLE, TridasSample.class);

    p.add(new Chunk("Element and sample details:\n", subSubSectionFont));

    p.add(new Chunk("- Taxon:  ", bodyFont));
    p.add(new Chunk(telem.getTaxon().getNormal()+"\n", bodyFontItalic));
    p.add(new Chunk("- Element type: "+ telem.getType().getNormal()+"\n", bodyFont));
    p.add(new Chunk("- Sample type: "+ tsamp.getType().getNormal()+"\n", bodyFont));
    return p;

}
项目:tellervo    文件:ProSheet.java   
private Paragraph getObjectDescription() 
{

    Paragraph p = new Paragraph();
    p.setLeading(0, 1.2f);
    p.setAlignment(Element.ALIGN_JUSTIFIED);
       p.setSpacingAfter(10);
       p.setSpacingBefore(50);

    if(o.getDescription()!=null){
        p.add(new Chunk(o.getDescription(), bodyFont));
    }
    else{
        p.add(new Chunk("No description recorded", bodyFont));
    }

    return p;
}
项目:tellervo    文件:ProSheet.java   
private Paragraph getObjectComments() 
{

    Paragraph p = new Paragraph();
    p.setLeading(0, 1.2f);
    p.setAlignment(Element.ALIGN_JUSTIFIED);
       p.setSpacingAfter(10);

    if(o.getComments()!=null){
        p.add(new Chunk("Notes: ", commentFont));
        p.add(new Chunk(o.getComments(), commentFont));
    }


    return p;
}
项目:tellervo    文件:CompleteBoxLabel.java   
/**
 * iText paragraph containing created and lastmodified timestamps
 * 
 * @return Paragraph
 */
private Paragraph getTimestampPDF(WSIBox b)
{
    // Set up calendar
    Date createdTimestamp = b.getCreatedTimestamp().getValue()
            .toGregorianCalendar().getTime();
    Date nowTimestamp = new Date();

    DateFormat df1 = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT);

    Paragraph p = new Paragraph();


    p.add(new Chunk("Created: ", subSubSectionFont));
    p.add(new Chunk(df1.format(createdTimestamp), bodyFont));
    //p.add(new Chunk("\nLast Modified: ", subSubSectionFont));
    //p.add(new Chunk(df1.format(lastModifiedTimestamp), bodyFontLarge));
    p.add(new Chunk("\nLabel updated: ", subSubSectionFont));
    p.add(new Chunk(df1.format(nowTimestamp), bodyFont));


    return p;

}
项目:tellervo    文件:CompleteBoxLabel.java   
private Paragraph getComments(WSIBox b) throws DocumentException
{

    Paragraph p = new Paragraph();
    p.setLeading(0, 1.2f);

    p.add(new Chunk("Comments: \n", subSubSectionFont));
    if(b.getComments()!=null){
        p.add(new Chunk(b.getComments(), bodyFont));
    }
    else{
        p.add(new Chunk("No comments recorded", bodyFont));
    }

    return(p);
}
项目:tellervo    文件:BasicBoxLabel.java   
/**
 * iText paragraph containing created and lastmodified timestamps
 * 
 * @return Paragraph
 */
private Paragraph getTimestampPDF(WSIBox b)
{
    // Set up calendar
    Date createdTimestamp = b.getCreatedTimestamp().getValue()
            .toGregorianCalendar().getTime();
    Date nowTimestamp = new Date();

    DateFormat df1 = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.SHORT);

    Paragraph p = new Paragraph();


    p.add(new Chunk("Created: ", subSubSectionFont));
    p.add(new Chunk(df1.format(createdTimestamp), bodyFont));
    //p.add(new Chunk("\nLast Modified: ", subSubSectionFont));
    //p.add(new Chunk(df1.format(lastModifiedTimestamp), bodyFontLarge));
    p.add(new Chunk("\nLabel updated: ", subSubSectionFont));
    p.add(new Chunk(df1.format(nowTimestamp), bodyFont));


    return p;

}
项目:tellervo    文件:BasicBoxLabel.java   
private Paragraph getComments(WSIBox b) throws DocumentException
{

    Paragraph p = new Paragraph();
    p.setLeading(0, 1.2f);

    p.add(new Chunk("Comments: \n", subSubSectionFont));
    if(b.getComments()!=null){
        p.add(new Chunk(b.getComments(), bodyFont));
    }
    else{
        p.add(new Chunk("No comments recorded", bodyFont));
    }

    return(p);
}
项目:weplantaforest    文件:PdfReceiptView.java   
private void createReceiptHeaderAndTextBelow(PdfContentByte cb) throws DocumentException {
    PdfPTable headerTable = new PdfPTable(1);
    float[] rows = { 450f };
    headerTable.setTotalWidth(rows);
    headerTable.getDefaultCell()
               .setBorder(Rectangle.NO_BORDER);

    headerTable.addCell(new Phrase(new Chunk("Bestätigung über Geldzuwendungen", textFontForReceiptHeader)));

    headerTable.writeSelectedRows(0, 1, 75f, 625, cb);

    PdfPTable table = new PdfPTable(1);
    table.setTotalWidth(rows);
    table.getDefaultCell()
         .setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell()
         .setLeading(8f, 0);

    table.addCell(new Phrase(new Chunk("im Sinne des §10b des Einkommensteuergesetzes", textFont)));
    table.addCell(new Phrase(new Chunk("an eine der in §5 Abs. 1 Nr. 9 des Körperschaftsteuergesetzes bezeichneten", textFont)));
    table.addCell(new Phrase(new Chunk("Körperschaften, Personenvereinigungen oder Vermögensmassen", textFont)));

    table.writeSelectedRows(0, 3, 75f, 590, cb);
}
项目:weplantaforest    文件:PdfReceiptView.java   
private PdfPTable createPriceTable(PdfContentByte cb, Receipt receipt) throws DocumentException {
    PdfPTable tableForPrices = new PdfPTable(1);
    float[] rowForTotalPrice = { 250f };
    tableForPrices.setTotalWidth(rowForTotalPrice);
    tableForPrices.getDefaultCell()
                  .setBorder(Rectangle.NO_BORDER);

    tableForPrices.addCell(new Phrase(new Chunk("Betrag der Zuwendung in Ziffern:", textFont)));
    tableForPrices.addCell(new Phrase(new Chunk(" ", textFont)));
    Double totalPrice = 0.0;
    for (final Cart cart : receipt.getCarts()) {
        tableForPrices.addCell(new Phrase(new Chunk(cart.getTotalPrice()
                                                        .toString()
                + " €", textFontUserData)));
        totalPrice += cart.getTotalPrice()
                          .doubleValue();
    }
    String formattedPrice = priceFormat.format(totalPrice)
                                       .toString();
    tableForPrices.addCell(new Phrase(new Chunk("Gesamt: " + formattedPrice + " €", textFontUserData)));
    return tableForPrices;
}
项目:weplantaforest    文件:PdfReceiptView.java   
private PdfPTable createDateTable(PdfContentByte cb, Receipt receipt) throws DocumentException {
    PdfPTable tableForDate = new PdfPTable(1);
    float[] rowForDate = { 110f };
    tableForDate.setTotalWidth(rowForDate);
    tableForDate.getDefaultCell()
                .setBorder(Rectangle.NO_BORDER);

    tableForDate.addCell(new Phrase(new Chunk("Datum der Zuwendung:", textFont)));
    tableForDate.addCell(new Phrase(new Chunk(" ", textFont)));
    final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT+2"), Locale.GERMAN);
    for (final Cart cart : receipt.getCarts()) {
        cal.setTimeInMillis(cart.getTimeStamp());
        final String date = cal.get(Calendar.DAY_OF_MONTH) + "." + (cal.get(Calendar.MONTH) + 1) + "." + cal.get(Calendar.YEAR);
        PdfPCell cell = new PdfPCell(new Phrase(new Chunk(date, textFontUserData)));
        cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT);
        cell.setBorder(PdfPCell.NO_BORDER);
        tableForDate.addCell(cell);
    }
    return tableForDate;
}
项目:weplantaforest    文件:PdfReceiptView.java   
private PdfPTable createLawTable(PdfContentByte cb) throws DocumentException {
    PdfPTable table = new PdfPTable(1);
    float[] rows = { 445f };
    table.setTotalWidth(rows);
    table.getDefaultCell()
         .setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell()
         .setLeading(8f, 0);

    table.addCell(new Phrase(new Chunk("Es handelt sich nicht um den Verzicht auf Erstattung von Aufwendungen.", textFontLawText)));
    table.addCell(new Phrase(new Chunk("Die Gesellschaft ist wegen Förderung (begünstigter Zweck: Umweltschutz (§52 (2) S. 1 Nr.(n) 8 AO)) durch", textFontLawText)));
    table.addCell(new Phrase(new Chunk("Bescheinigung des Finanzamt Halle (Saale)-Nord, StNr. 110/108/91169, vom 19.11.2008 ab 01.01.2009", textFontLawText)));
    table.addCell(new Phrase(new Chunk("als gemeinnützig anerkannt. Letzter Freistellungsbescheid datiert auf den 20.06.2013.", textFontLawText)));
    table.addCell(new Phrase(new Chunk("Es wird bestätigt, dass die Zuwendung nur zur Förderung des Umweltschutzes verwendet wird.", textFontLawText)));

    PdfPCell emptyCell = new PdfPCell();
    emptyCell.setBorder(Rectangle.BOTTOM);
    emptyCell.setFixedHeight(15f);
    table.addCell(emptyCell);

    return table;
}
项目:weplantaforest    文件:PdfHelper.java   
public static void createCircleAndText(PdfContentByte cb, String text, float xCoord, float yCoord, float radius, Font textFont, int circleColorRed, int circleColorGreen, int circleColorBlue)
        throws DocumentException, IOException {
    cb.saveState();
    cb.setRGBColorFill(circleColorRed, circleColorGreen, circleColorBlue);
    cb.circle(xCoord, yCoord, radius);
    cb.fill();
    cb.stroke();
    cb.restoreState();

    PdfPTable table = new PdfPTable(1);
    float[] rows = { 595f };
    table.setTotalWidth(rows);
    table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
    table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
    table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
    table.getDefaultCell().setFixedHeight(radius * 2);
    table.addCell(new Phrase(new Chunk(text, textFont)));
    table.writeSelectedRows(0, 1, 0, yCoord + radius, cb);
}
项目:rolp    文件:PdfStreamSource.java   
private void addContent(PdfWriter writer) throws DocumentException, PdfFormatierungsException {     
    Anchor anchor = new Anchor("Lernentwicklungsbericht", lernentwicklungsberichtUeberschriftFont);
    Chapter chapterLEB = new Chapter(new Paragraph(anchor), 1);
    chapterLEB.setNumberDepth(0);
    Paragraph paragraphHeader = new Paragraph();
    paragraphHeader.setLeading(FIXED_LEADING_TEXT, 1);
    sectionCount += 1;
    Section headerSection = chapterLEB.addSection(paragraphHeader);
    headerSection.setNumberDepth(0);

    paragraphHeader.add(Chunk.NEWLINE);
    paragraphHeader.add(PdfFormatHelper.buildHeaderNameLine(lebData.getSchuelername() , headerFont));
    paragraphHeader.add(Chunk.NEWLINE);
    paragraphHeader.add(PdfFormatHelper.buildHeaderKlassendatenLine(lebData, headerFont));
    headerSection.add(Chunk.NEWLINE);       
    headerSection.add(Chunk.NEWLINE);
    document.add(chapterLEB);
    insertDummyLineIfNecessary(writer);

    addKlassenbrief(chapterLEB, writer);
    addIndividuelleEinschaetzung(chapterLEB, writer);
    addFacheinschaetzungen(chapterLEB, writer);
}
项目:rolp    文件:PdfStreamSource.java   
private void addKlassenbrief(Chapter chapterLEB, PdfWriter writer) throws DocumentException, PdfFormatierungsException {
    if (!lebData.getKlassenbrief().isEmpty()) {
        sectionCount += 1;
        breakSchusterjunge(writer);
        Paragraph paragraphKlassenbrief = new Paragraph();
        Section klassenbriefSection = chapterLEB.addSection(paragraphKlassenbrief);
        klassenbriefSection.setNumberDepth(0);
        Paragraph klasseneinschaetzungParapgraph = new Paragraph(lebData.getKlassenbrief().replace('\t', '\0'), standardTextFont);
        klasseneinschaetzungParapgraph.setAlignment(Element.ALIGN_JUSTIFIED);
        klasseneinschaetzungParapgraph.setLeading(FIXED_LEADING_TEXT, zeilenabstandsfaktor);
        klasseneinschaetzungParapgraph.add(Chunk.NEWLINE);
        if (lebData.getIndividuelleEinschaetzung().isEmpty()) {
            klassenbriefSection.add(klasseneinschaetzungParapgraph);
            document.add(klassenbriefSection);
            document.add(getKlassenlehrerunterschrift(chapterLEB));
        } else {
            klasseneinschaetzungParapgraph.add(Chunk.NEWLINE);
            klassenbriefSection.add(klasseneinschaetzungParapgraph);
            document.add(klassenbriefSection);
        }
        alertLonelyHeader(writer);
        insertDummyLineIfNecessary(writer);
    }
}
项目:iTextTutorial    文件:T03_Phrase.java   
public void createPdf(String filename) throws DocumentException, IOException {

        Document document = new Document(PageSize.LETTER);
        PdfWriter.getInstance(document, new FileOutputStream(filename));
        document.open();

        // step 4 - add content into document
        for (int i = 0; i < 5; i++) {
            document.add(new Phrase("Hello", new Font(FontFamily.HELVETICA, 32, Font.BOLD)));
            document.add(new Phrase("World", new Font(FontFamily.COURIER, 40, Font.ITALIC)));
            document.add(new Phrase("!!!", new Font(FontFamily.TIMES_ROMAN, 40)));

            document.add(Chunk.NEWLINE);
        }

        document.close();
    }
项目:iTextTutorial    文件:T14_TOC.java   
@SuppressWarnings("unchecked")
protected void fillColumnText(List<HashMap<String, Object>> bookmarkList, ColumnText ct, float leftIndent, int depth) {
    if (null != bookmarkList) {
        for (int i = 0; i < bookmarkList.size(); i++) {
            HashMap<String, Object> bookmark = bookmarkList.get(i);

            String title = (String) bookmark.get("Title");
            String pageNum = ((String) bookmark.get("Page")).split(" ")[0];
            Paragraph paragraph = new Paragraph(title);
            paragraph.add(new Chunk(new DottedLineSeparator()));
            paragraph.add(Integer.toString((Integer.parseInt(pageNum))));
            paragraph.setIndentationLeft(leftIndent * depth);
            paragraph.setSpacingBefore(0 == depth ? 9 : 0);
            ct.addElement(paragraph);

            fillColumnText(((List<HashMap<String, Object>>) bookmark.get("Kids")), ct, leftIndent, depth + 1);
        }
    }
}
项目:fll-sw    文件:RankingReport.java   
private void outputCategory(final Paragraph para,
                            final TeamRanking teamRanks,
                            final String category,
                            boolean useQuartiles) {
  para.add(new Chunk(category
      + ": ", RANK_TITLE_FONT));

  final CategoryRank catRank = teamRanks.getRankForCategory(category);

  final int rank = catRank.getRank();
  if (CategoryRank.NO_SHOW_RANK == rank) {
    para.add(new Chunk("No Show", RANK_VALUE_FONT));
  } else {
    final double percentage = (double) rank
        / catRank.getNumTeams();
    if (useQuartiles) {
      para.add(new Chunk(String.format("%s in %s", convertPercentageToQuartile(percentage), catRank.getGroup()),
                         RANK_VALUE_FONT));
    } else {
      para.add(new Chunk(String.format("%d out of %d teams in %s", rank, catRank.getNumTeams(), catRank.getGroup()),
                         RANK_VALUE_FONT));
    }
  }
  para.add(Chunk.NEWLINE);
}
项目:fll-sw    文件:FinalComputedScores.java   
private PdfPTable createHeader(final String challengeTitle,
                               final String tournamentName,
                               final String division) {
  // initialization of the header table
  final PdfPTable header = new PdfPTable(2);

  final Phrase p = new Phrase();
  p.add(new Chunk(challengeTitle, TIMES_12PT_NORMAL));
  p.add(Chunk.NEWLINE);
  p.add(new Chunk("Final Computed Scores", TIMES_12PT_NORMAL));
  header.getDefaultCell().setBorderWidth(0);
  header.addCell(p);
  header.getDefaultCell().setHorizontalAlignment(com.itextpdf.text.Element.ALIGN_RIGHT);

  final Phrase p2 = new Phrase();
  p2.add(new Chunk("Tournament: "
      + tournamentName, TIMES_12PT_NORMAL));
  p2.add(Chunk.NEWLINE);
  p2.add(new Chunk("Award Group: "
      + division, TIMES_12PT_NORMAL));
  header.addCell(p2);

  return header;
}
项目:IMSQTI2PDF    文件:HeaderFooter.java   
public HeaderFooter(int maximumPageNumber)
{
    _maximumPageNumber = maximumPageNumber;

    Chunk c = new Chunk("" + (char) 229);
    c.setFont(new Font(FontFamily.SYMBOL, 28));
    _sumSymbol = new Phrase(c);
}
项目:IMSQTI2PDF    文件:HeaderFooter.java   
private void pageNumberFooter(PdfWriter writer, Rectangle rect)
{
    Chunk c = new Chunk(String.format(LocaleStrings.getString("page"), writer.getPageNumber(), _maximumPageNumber));
    c.setFont(new Font(FontFamily.HELVETICA, 10));
    Phrase pagephrase = new Phrase(c);

    ColumnText.showTextAligned(writer.getDirectContent(), Element.ALIGN_CENTER, pagephrase, rect.getRight() - 60,
            rect.getBottom() - 30, 0);
}
项目:IMSQTI2PDF    文件:PDFCreator.java   
private Chunk getQuestionNumberChunk(Font f, int number)
{
    Chunk c = new Chunk((number + 1) + ". ");
    Font ff = new Font(f);
    ff.setStyle(Font.BOLD);
    c.setFont(ff);
    return c;
}
项目:IMSQTI2PDF    文件:PDFCreator.java   
private Chunk getPointsChunk(Font f, Question question)
{
    int points = (int) question.getPointsPerAnswer();
    String punkteText = LocaleStrings.getString(points == 1 ?"point":"points");

    String text;
    if (question.basetype == BaseType.STRING)
    {
        text = " " + LocaleStrings.getString("maximum"); //(maximal %d %s)
        text = String.format(text, points, punkteText);
    }
    else
    {
        if (question.type.equalsIgnoreCase("single"))
        {
            text = " "+ LocaleStrings.getString("correctAnswer"); //" (1 richtige Antwort";

            if (points == 1)
            {
                text += ")";
            }
            else
            {
                text += ", %d %s)";
                text = String.format(text, points, punkteText);
            }
        }
        else
        { // MUTLIPLE
            text = " "+ LocaleStrings.getString("perCorrectAnswer"); //(%d %s pro richtige Antwort)";
            text = String.format(text, points, punkteText);
        }
    }

    Chunk c = new Chunk(text);
    Font ff = new Font(f);
    ff.setSize(OVERALLFONTSIZE);
    c.setFont(ff);
    return c;
}
项目:bdf2    文件:PdfReportBuilder.java   
public void addNewline(Document doc, int i) throws DocumentException {
    if (i > 0) {
        for (int j = 0; j < i; j++) {
            doc.add(Chunk.NEWLINE);
        }
    }
}
项目:bdf2    文件:AbstractPdfReportBuilder.java   
protected Paragraph createReportTitle(ReportTitle reportTitle) {
    Paragraph paragraph = new Paragraph();
    paragraph.setAlignment(Element.ALIGN_CENTER);
    if (reportTitle != null && reportTitle.isShowTitle()) {
        TextChunk titleChunk = new TextChunk();
        titleChunk.setText(reportTitle.getTitle());
        titleChunk.setFontSize(reportTitle.getStyle().getFontSize());
        titleChunk.setFontColor(reportTitle.getStyle().getFontColor());
        paragraph.add(createChunk(titleChunk));
        paragraph.add(Chunk.NEWLINE);
        paragraph.add(Chunk.NEWLINE);
    }
    return paragraph;
}
项目:pdf-renderer    文件:DottedFillPhrase.java   
@Override
public void onRender(com.itextpdf.text.Paragraph paragraph) {
    DottedLineSeparator sep = new DottedLineSeparator();
    sep.setAlignment( Element.ALIGN_LEFT );
    sep.setGap( gap );
    sep.setLineColor( getBaseColor());
    com.itextpdf.text.Font f = new com.itextpdf.text.Font( getBaseFont(), getFontSize()  );
    f.setColor( getBaseColor() );
    Chunk separator = new Chunk( sep );
    separator.setFont(  f );
    paragraph.add( separator );
}
项目:BudgetMaster    文件:ReportGenerator.java   
private Chapter generateHeader()
{   
    Font font = FontFactory.getFont(FONT, BaseFont.IDENTITY_H, BaseFont.EMBEDDED, 16, Font.BOLDITALIC, BaseColor.BLACK);
    Chunk chunk = new Chunk(Localization.getString(Strings.REPORT_HEADLINE, date.toString("MMMM yyyy")), font);
    Chapter chapter = new Chapter(new Paragraph(chunk), 1);
    chapter.setNumberDepth(0);
    chapter.add(Chunk.NEWLINE);
    return chapter;
}
项目:SEGP_Group10    文件:AllocatedPATsController.java   
/**
     * 
     * @param selectedDirectory 
     * this method will make the pdf tables.
     */
    public void getTables(String selectedDirectory) {

        Document document = new Document();
        try {

            PdfWriter.getInstance(document, new FileOutputStream(selectedDirectory + "/Allocated Students.pdf"));
            document.open();

            Image imageNamalCollege = Image.getInstance("/home/abdul/NetBeansProjects/SEGP_Group10/src/icons/Logo5_1.png");
            document.add(imageNamalCollege);

            for (int i = 0; i < studentsRefrences.length; i++) {

                document.add(new Paragraph("Group Number: " + (i + 1)));
                document.add(new Paragraph("Personal Accademic Tutor Name: " + (teachersInformation.get(i).split(",")[1])));
                ArrayList<String> students = studentsRefrences[i];
                document.add(Chunk.NEWLINE);
                document.add(getATable(students));
                document.add(Chunk.NEWLINE);
                document.add(Chunk.NEWLINE);

            }

            document.close();
//
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
项目:SEGP_Group10    文件:Studentsinformation.java   
public void getTables(String selectedDirectory) {

        Document document = new Document();
        try {
            PdfWriter.getInstance(document, new FileOutputStream(selectedDirectory + "/Students_Record.pdf"));
            document.open();

            Image imageNamalCollege = Image.getInstance("/home/abdul/NetBeansProjects/SEGP_Group10/src/icons/Logo5_1.png");
            document.add(imageNamalCollege);
            document.add(new Paragraph("The Record for All Students are: "));

            ArrayList<String> students = new ArrayList<>();
            if (whichPDFToGenrate == 1 || whichPDFToGenrate == 2 || whichPDFToGenrate == 3 || whichPDFToGenrate == 13
                    || whichPDFToGenrate == 14 || whichPDFToGenrate == 15) {
                getYear1Data(students);
            }
            if (whichPDFToGenrate == 4 || whichPDFToGenrate == 5 || whichPDFToGenrate == 6 || whichPDFToGenrate == 13
                    || whichPDFToGenrate == 14 || whichPDFToGenrate == 15) {
                getYear2Data(students);
            }
            if (whichPDFToGenrate == 7 || whichPDFToGenrate == 8 || whichPDFToGenrate == 9 || whichPDFToGenrate == 13
                    || whichPDFToGenrate == 14 || whichPDFToGenrate == 15) {
                getYear3Data(students);
            }
            if (whichPDFToGenrate == 10 || whichPDFToGenrate == 11 || whichPDFToGenrate == 12 || whichPDFToGenrate == 13
                    || whichPDFToGenrate == 14 || whichPDFToGenrate == 15) {
                getYear4Data(students);
            }

            document.add(Chunk.NEWLINE);
            document.add(getATable(students));
            document.close();

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
项目:FOXopen    文件:HorizontalRuleComponentBuilder.java   
@Override
public void buildComponent(SerialisationContext pSerialisationContext, PDFSerialiser pSerialiser, EvaluatedHtmlPresentationNode pEvalNode) {
  Paragraph lParagraph = pSerialiser.getElementFactory().getParagraph();
  LineSeparator lLineSeparator = pSerialiser.getElementFactory().getLineSeparator();

  lParagraph.add(new Chunk(lLineSeparator));
  pSerialiser.add(lParagraph);
}
项目:testarea-itext5    文件:InterlineSpace.java   
/**
 * <a href="http://stackoverflow.com/questions/34681893/itextsharp-extra-space-between-lines">
 * iTextSharp: Extra space between lines
 * </a>
 * <p>
 * Indeed, the OP's {@link Phrase#setLeading(float, float)} calls are ignored.
 * The reason is that the op is working in text mode. Thus, he has to use
 * {@link ColumnText#setLeading(float, float)} instead, cf.
 * {@link #testLikeUser3208131Fixed()}.
 * </p>
 */
@Test
public void testLikeUser3208131() throws DocumentException, FileNotFoundException
{
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(new File(RESULT_FOLDER, "interline-user3208131.pdf")));
    document.open();

    Font font = new Font(FontFamily.UNDEFINED, 4, Font.UNDEFINED, null);
    PdfContentByte cb = writer.getDirectContent();
    ColumnText ct = new ColumnText(cb);

    float gutter = 15;
    float colwidth = (document.getPageSize().getRight() - document.getPageSize().getLeft() - gutter) / 2;

    float[] left = { document.getPageSize().getLeft() + 133, document.getPageSize().getTop() - 35,
            document.getPageSize().getLeft() + 133, document.getPageSize().getBottom() };
    float[] right = { document.getPageSize().getLeft() + colwidth, document.getPageSize().getTop() - 35,
            document.getPageSize().getLeft() + colwidth, document.getPageSize().getBottom() };

    for (int i = 0; i < 3; i++)
    {
        Phrase Ps = new Phrase("Test " + i + "\n", font);
        Ps.setLeading(0.0f, 0.6f);
        ct.addText(Ps);
        ct.addText(Chunk.NEWLINE);
    }
    ct.setColumns(left, right);
    ct.go();

    document.close();
}
项目:testarea-itext5    文件:InterlineSpace.java   
/**
 * <a href="http://stackoverflow.com/questions/34681893/itextsharp-extra-space-between-lines">
 * iTextSharp: Extra space between lines
 * </a>
 * <p>
 * Indeed, the OP's {@link Phrase#setLeading(float, float)} calls are ignored,
 * cf. {@link #testLikeUser3208131()}. The reason is that the op is working in
 * text mode. Thus, he has to use {@link ColumnText#setLeading(float, float)}
 * instead.
 * </p>
 */
@Test
public void testLikeUser3208131Fixed() throws DocumentException, FileNotFoundException
{
    Document document = new Document();
    PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(new File(RESULT_FOLDER, "interline-user3208131-fixed.pdf")));
    document.open();

    Font font = new Font(FontFamily.UNDEFINED, 4, Font.UNDEFINED, null);
    PdfContentByte cb = writer.getDirectContent();
    ColumnText ct = new ColumnText(cb);

    float gutter = 15;
    float colwidth = (document.getPageSize().getRight() - document.getPageSize().getLeft() - gutter) / 2;

    float[] left = { document.getPageSize().getLeft() + 133, document.getPageSize().getTop() - 35,
            document.getPageSize().getLeft() + 133, document.getPageSize().getBottom() };
    float[] right = { document.getPageSize().getLeft() + colwidth, document.getPageSize().getTop() - 35,
            document.getPageSize().getLeft() + colwidth, document.getPageSize().getBottom() };

    ct.setLeading(0.0f, 0.3f);
    for (int i = 0; i < 3; i++)
    {
        Phrase Ps = new Phrase("Test " + i + "\n", font);
        ct.addText(Ps);
        ct.addText(Chunk.NEWLINE);
    }
    ct.setColumns(left, right);
    ct.go();

    document.close();
}
项目:tellervo    文件:SeriesReport.java   
/**
 * iText Paragraph containing the various authorship fields
 * @return Paragraph
 */
private Paragraph getAuthorshipPDF()
{
    Paragraph p = new Paragraph();

    ITridasSeries sss = s.getSeries();
    TridasMeasurementSeries mseries = null;
    TridasDerivedSeries dseries = null;

    if(sss instanceof TridasMeasurementSeries) 
    { 
        mseries = (TridasMeasurementSeries) sss; 
        if(mseries.getAnalyst()!=null) {
        p.add(new Chunk("Measured by: ", subSubSectionFont));
        p.add(new Chunk(mseries.getAnalyst(), bodyFont));
        }

        if(mseries.getDendrochronologist()!=null){
        p.add(new Chunk("\nSupervised by: ", subSubSectionFont));
        p.add(new Chunk(mseries.getDendrochronologist(), bodyFont));
        }
    }
    else
    {
        dseries = (TridasDerivedSeries) sss;
        p.add(new Chunk("Created by: ", subSubSectionFont));
        p.add(new Chunk(dseries.getAuthor(), bodyFont));

    }

    return p;       

}
项目:tellervo    文件:ReportBase.java   
/**
 * Blank iText paragraph used for padding 
 * @return Paragraph
 */
protected Paragraph getParagraphSpace()
{
    Paragraph p = new Paragraph();

    p.add(new Chunk(" "));
    return p;
}
项目:tellervo    文件:ProSheet.java   
/**
 * Get an iText Paragraph for the Title 
 * 
 * @return Paragraph
 */
private Paragraph getTitlePDF()
{
    Paragraph p = new Paragraph();

    p.add(new Chunk(o.getLabCode()+" - "+o.getTitle()+"\n", titleFont));

    //p.add(new Chunk(i.getCode(), subTitleFont));

    return p;       
}