本文整理匯總了Java中com.lowagie.text.Paragraph.add方法的典型用法代碼示例。如果您正苦於以下問題:Java Paragraph.add方法的具體用法?Java Paragraph.add怎麽用?Java Paragraph.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.lowagie.text.Paragraph
的用法示例。
在下文中一共展示了Paragraph.add方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
/**
* Tab stops in paragraphs.
*
*
*/
@Test
public void main() throws Exception {
Document document = new Document();
RtfWriter2.getInstance(document, PdfTestBase.getOutputStream("BasicTabs.rtf"));
document.open();
// Define the Paragraph to add tab stops to
Paragraph par = new Paragraph();
// Add the tab stops to the paragraph
par.add(new RtfTab(70, RtfTab.TAB_LEFT_ALIGN));
par.add(new RtfTab(400, RtfTab.TAB_RIGHT_ALIGN));
// Add the text to the paragraph, placing the tab stops with \t
par.add("\tFirst the text on the left-hand side\tThis text is right aligned.");
document.add(par);
document.close();
}
示例2: getInfoCell
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
/**
* This method creates the information cell.
*
* @param post
* VO holding all information about the note to process ======= The note.
* @param dateFormatter
* Date formatter.
* @param resourcesManager
* the resource bundle manager to use for localization
* @param locale
* The locale to use.
* @return The information cell as {@link Cell}.
*/
private Cell getInfoCell(NoteData post, Locale locale, DateFormat dateFormatter,
ResourceBundleManager resourcesManager) {
Paragraph paragraph = new Paragraph();
paragraph.setLeading(10);
paragraph.setFont(FONT_META_INFORMATION);
paragraph.add(RtfElementFactory.createChunk("\n", FONT_META_INFORMATION));
paragraph
.add(RtfElementFactory.createChunk(
resourcesManager.getText("export.post.title.author", locale),
FONT_META_INFORMATION));
paragraph.add(RtfElementFactory.createChunk(":\t" + post.getUser().getFirstName() + " "
+ post.getUser().getLastName() + " (" + post.getUser().getAlias() + ")",
FONT_META_INFORMATION));
handleUsersToBeNotified(post.getNotifiedUsers(), paragraph, locale, resourcesManager);
paragraph.add(RtfElementFactory.createChunk("\n", FONT_META_INFORMATION));
paragraph.add(RtfElementFactory.createChunk(
resourcesManager.getText("export.post.title.blog", locale), FONT_META_INFORMATION));
paragraph.add(RtfElementFactory.createChunk(":\t" + post.getBlog().getTitle(),
FONT_META_INFORMATION));
handleTags(post.getTags(), locale, resourcesManager, paragraph);
handleParentNote(post, locale, dateFormatter, resourcesManager, paragraph);
handleModificationDate(post, locale, dateFormatter, resourcesManager, paragraph);
Cell infoCell = new Cell();
infoCell.setBorder(Cell.BOTTOM | Cell.RIGHT);
infoCell.add(paragraph);
return infoCell;
}
示例3: main
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
/**
* Extended font styles example.
*
*
*/
@Test
public void main() throws Exception {
Document document = new Document();
RtfWriter2.getInstance(document, PdfTestBase.getOutputStream("ExtendedFontStyles.rtf"));
document.open();
// Use the RtfFont.STYLE_* instead of the Font styles.
RtfFont doubleStrikethrough = new RtfFont("Arial", RtfFont.UNDEFINED,
RtfFont.STYLE_DOUBLE_STRIKETHROUGH);
RtfFont shadow = new RtfFont("Arial", RtfFont.UNDEFINED,
RtfFont.STYLE_SHADOW);
// Or combine them with Font styles.
RtfFont engravedItalic = new RtfFont("Arial", RtfFont.UNDEFINED,
RtfFont.STYLE_ENGRAVED | Font.ITALIC);
// The hidden style is special since it hides text.
RtfFont hidden = new RtfFont("Arial", RtfFont.UNDEFINED,
RtfFont.STYLE_HIDDEN);
Paragraph paragraph = new Paragraph("This text is ", new RtfFont("Arial", 12));
// Use the RtfFonts when creating the text.
paragraph.add(new Chunk("deleted,", doubleStrikethrough));
paragraph.add(new Chunk(" shady,", shadow));
paragraph.add(new Chunk(" engraved and italic", engravedItalic));
paragraph.add(" and");
paragraph.add(new Chunk(" you won't see this", hidden));
paragraph.add(" nothing.");
document.add(paragraph);
document.close();
}
示例4: main
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
/**
* Creates a document with some goto actions.
*
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
Document remote = new Document();
// step 2:
PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("Actions.pdf"));
PdfWriter.getInstance(remote, PdfTestBase.getOutputStream("remote.pdf"));
// step 3:
document.open();
remote.open();
// step 4: we add some content
PdfAction action = PdfAction.gotoLocalPage(2, new PdfDestination(PdfDestination.XYZ, -1, 10000, 0), writer);
writer.setOpenAction(action);
document.add(new Paragraph("Page 1"));
document.newPage();
document.add(new Paragraph("Page 2"));
document.add(new Chunk("goto page 1").setAction(PdfAction.gotoLocalPage(1, new PdfDestination(
PdfDestination.FITH, 500), writer)));
document.add(Chunk.NEWLINE);
document.add(new Chunk("goto another document").setAction(PdfAction.gotoRemotePage("remote.pdf", "test", false,
true)));
remote.add(new Paragraph("Some remote document"));
remote.newPage();
Paragraph p = new Paragraph("This paragraph contains a ");
p.add(new Chunk("local destination").setLocalDestination("test"));
remote.add(p);
// step 5: we close the document
document.close();
remote.close();
}
示例5: main
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
/**
* Demonstrates some Paragraph functionality.
*
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
// step 2:
// we create a writer that listens to the document
PdfWriter.getInstance(document, PdfTestBase.getOutputStream("Paragraphs.pdf"));
// step 3: we open the document
document.open();
// step 4:
Paragraph p1 = new Paragraph(new Chunk("This is my first paragraph. ", FontFactory.getFont(
FontFactory.HELVETICA, 10)));
p1.add("The leading of this paragraph is calculated automagically. ");
p1.add("The default leading is 1.5 times the fontsize. ");
p1.add(new Chunk("You can add chunks "));
p1.add(new Phrase("or you can add phrases. "));
p1.add(new Phrase(
"Unless you change the leading with the method setLeading, the leading doesn't change if you add text with another leading. This can lead to some problems.",
FontFactory.getFont(FontFactory.HELVETICA, 18)));
document.add(p1);
Paragraph p2 = new Paragraph(new Phrase("This is my second paragraph. ", FontFactory.getFont(
FontFactory.HELVETICA, 12)));
p2.add("As you can see, it started on a new line.");
document.add(p2);
Paragraph p3 = new Paragraph("This is my third paragraph.", FontFactory.getFont(FontFactory.HELVETICA, 12));
document.add(p3);
// step 5: we close the document
document.close();
}
示例6: main
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
/**
* Using FontSelector.
*/
@Test
public void main() throws Exception {
// step 1
Document document = new Document();
// step 2
PdfWriter.getInstance(document, PdfTestBase.getOutputStream("differentfonts.pdf"));
// step 3
document.open();
// step 4
Paragraph p = new Paragraph();
p.add(new Chunk("This text is in Times Roman. This is ZapfDingbats: ", new Font(Font.TIMES_ROMAN, 12)));
p.add(new Chunk("abcdefghijklmnopqrstuvwxyz", new Font(Font.ZAPFDINGBATS, 12)));
p.add(new Chunk(". This is font Symbol: ", new Font(Font.TIMES_ROMAN, 12)));
p.add(new Chunk("abcdefghijklmnopqrstuvwxyz", new Font(Font.SYMBOL, 12)));
document.add(new Paragraph(p));
// step 5
document.close();
}
示例7: main
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
/**
* Demonstrates how to measure and scale the width of a Chunk.
*
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
// step 2:
// we create a writer that listens to the document
PdfWriter.getInstance(document, PdfTestBase.getOutputStream("Width.pdf"));
// step 3: we open the document
document.open();
// step 4:
Chunk c = new Chunk("quick brown fox jumps over the lazy dog");
float w = c.getWidthPoint();
Paragraph p = new Paragraph("The width of the chunk: '");
p.add(c);
p.add("' is ");
p.add(String.valueOf(w));
p.add(" points or ");
p.add(String.valueOf(w / 72f));
p.add(" inches.");
document.add(p);
document.add(c);
document.add(Chunk.NEWLINE);
c.setHorizontalScaling(0.5f);
document.add(c);
document.add(c);
// step 5: we close the document
document.close();
}
示例8: main
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
/**
* Demonstrates creating a footer with the current page number
*
*
*/
@Test
public void main() throws Exception {
Document document = new Document();
RtfWriter2.getInstance(document, PdfTestBase.getOutputStream("PageNumber.rtf"));
// Create a new Paragraph for the footer
Paragraph par = new Paragraph("Page ");
par.setAlignment(Element.ALIGN_RIGHT);
// Add the RtfPageNumber to the Paragraph
par.add(new RtfPageNumber());
// Create an RtfHeaderFooter with the Paragraph and set it
// as a footer for the document
RtfHeaderFooter footer = new RtfHeaderFooter(par);
document.setFooter(footer);
document.open();
for (int i = 1; i <= 300; i++) {
document.add(new Paragraph("Line " + i + "."));
}
document.close();
}
示例9: main
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
/**
* Demonstrates creating a header with page number and total number of pages
*
*
*/
@Test
public void main() throws Exception {
Document document = new Document();
RtfWriter2.getInstance(document, PdfTestBase.getOutputStream("TotalPageNumber.rtf"));
// Create a new Paragraph for the footer
Paragraph par = new Paragraph("Page ");
// Add the RtfPageNumber to the Paragraph
par.add(new RtfPageNumber());
// Add the RtfTotalPageNumber to the Paragraph
par.add(" of ");
par.add(new RtfTotalPageNumber());
// Create an RtfHeaderFooter with the Paragraph and set it
// as a header for the document
RtfHeaderFooter header = new RtfHeaderFooter(par);
document.setHeader(header);
document.open();
for (int i = 1; i <= 300; i++) {
document.add(new Paragraph("Line " + i + "."));
}
document.close();
}
示例10: addTitlePage
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
/**
* Título del documento.
* @param document Documento en cuestión
* @throws DocumentException Excepcion generada por algún problema
*/
private void addTitlePage(Document document) throws DocumentException {
Paragraph preface = new Paragraph();
addEmptyLine(preface, 1);
preface.add(new Paragraph("CitizensLoader PDF", catFont));
// addEmptyLine(preface, 1);
// // Will create: Report generated by: _name, _date
// preface.add(new Paragraph("Report generated by: " + System.getProperty("user.name") + ", " + new Date(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// smallBold));
// addEmptyLine(preface, 3);
// preface.add(new Paragraph("This document describes something which is very important ", smallBold));
//
// addEmptyLine(preface, 8);
//
// preface.add(new Paragraph(
// "This document is a preliminary version and not subject to your license agreement or any other agreement with vogella.com ;-).",
// redFont));
//
// document.add(preface);
// // Start a new page
// document.newPage();
document.add(preface);
addEmptyLine(preface, 2);
}
示例11: addEmptyLine
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
private void addEmptyLine(Paragraph paragraph, int number) {
for (int i = 0; i < number; i++) {
paragraph.add(new Paragraph(" "));
}
}
示例12: generateContent
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
private Paragraph generateContent(Grade grade) throws BadElementException {
Paragraph content = new Paragraph();
Table table = createTable(grade);
content.add(table);
return content;
}
示例13: RtfHeaderFooter
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
/**
* Constructs a RtfHeaderFooter based on a HeaderFooter with a certain type and displayAt
* location. For internal use only.
*
* @param doc The RtfDocument this RtfHeaderFooter belongs to
* @param headerFooter The HeaderFooter to base this RtfHeaderFooter on
* @param type The type of RtfHeaderFooter
* @param displayAt The display location of this RtfHeaderFooter
*/
protected RtfHeaderFooter(RtfDocument doc, HeaderFooter headerFooter, int type, int displayAt) {
super(new Phrase(""), false);
this.document = doc;
this.type = type;
this.displayAt = displayAt;
Paragraph par = new Paragraph();
par.setAlignment(headerFooter.alignment());
if (headerFooter.getBefore() != null) {
par.add(headerFooter.getBefore());
}
if (headerFooter.isNumbered()) {
par.add(new RtfPageNumber(this.document));
}
if (headerFooter.getAfter() != null) {
par.add(headerFooter.getAfter());
}
try {
this.content = new Object[1];
if(this.document != null) {
this.content[0] = this.document.getMapper().mapElement(par)[0];
((RtfBasicElement) this.content[0]).setInHeader(true);
} else {
this.content[0] = par;
}
} catch(DocumentException de) {
de.printStackTrace();
}
}
示例14: main
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
/**
* Draws different things into different layers.
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
// step 2: creation of the writer
PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("layers.pdf"));
// step 3: we open the document
document.open();
// step 4:
// high level
Paragraph p = new Paragraph();
for (int i = 0; i < 100; i++)
p.add(new Chunk("Blah blah blah blah blah. "));
document.add(p);
Image img = Image.getInstance(PdfTestBase.RESOURCES_DIR
+ "hitchcock.png");
img.setAbsolutePosition(100, 500);
document.add(img);
// low level
PdfContentByte cb = writer.getDirectContent();
PdfContentByte cbu = writer.getDirectContentUnder();
cb.setRGBColorFill(0xFF, 0xFF, 0xFF);
cb.circle(250.0f, 500.0f, 50.0f);
cb.fill();
cb.sanityCheck();
cbu.setRGBColorFill(0xFF, 0x00, 0x00);
cbu.circle(250.0f, 500.0f, 100.0f);
cbu.fill();
cbu.sanityCheck();
// step 5: we close the document
document.close();
}
示例15: main
import com.lowagie.text.Paragraph; //導入方法依賴的package包/類
/**
* Demonstrates some Anchor functionality.
*
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Document document = new Document();
// step 2:
PdfWriter.getInstance(document, PdfTestBase.getOutputStream("AHref.pdf"));
HtmlWriter.getInstance(document, PdfTestBase.getOutputStream("AHref.html"));
// step 3: we open the document
document.open();
// step 4:
Paragraph paragraph = new Paragraph("Please visit my ");
Anchor anchor1 = new Anchor("website (external reference)", FontFactory.getFont(FontFactory.HELVETICA, 12,
Font.UNDERLINE, new Color(0, 0, 255)));
anchor1.setReference("http://www.lowagie.com/iText/");
anchor1.setName("top");
paragraph.add(anchor1);
paragraph.add(new Chunk(".\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"));
document.add(paragraph);
Anchor anchor2 = new Anchor("please jump to a local destination", FontFactory.getFont(FontFactory.HELVETICA,
12, Font.NORMAL, new Color(0, 0, 255)));
anchor2.setReference("#top");
document.add(anchor2);
// step 5: we close the document
document.close();
}