本文整理汇总了Java中com.lowagie.text.Phrase类的典型用法代码示例。如果您正苦于以下问题:Java Phrase类的具体用法?Java Phrase怎么用?Java Phrase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Phrase类属于com.lowagie.text包,在下文中一共展示了Phrase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: write
import com.lowagie.text.Phrase; //导入依赖的package包/类
public void write(PDFDocument document, PdfPTable tabla) throws DocumentException {
com.lowagie.text.List list = new com.lowagie.text.List(false,10f);
list.setListSymbol(new Chunk("\u2022"));
PdfPCell cell = new PdfPCell();
if(!titulo.equals(""))
{
cell.addElement(new Phrase(titulo,document.getContext().getDefaultFont()));
}
for(int i=0; i<campos.size(); i++)
{
list.add(new ListItem((String)campos.get(i),document.getContext().getDefaultFont()));
}
cell.addElement(list);
cell.setPaddingLeft(30f);
cell.setBorder(Rectangle.LEFT | Rectangle.RIGHT);
cell.setColspan(2);
tabla.addCell(cell);
}
示例2: onEndPage
import com.lowagie.text.Phrase; //导入依赖的package包/类
@Override
public void onEndPage(PdfWriter writer, Document document) {
Phrase[] headers = new Phrase[3];
PdfContentByte cb = writer.getDirectContent();
headers[0] = new Phrase("CuacFM");
ColumnText.showTextAligned(cb, Element.ALIGN_RIGHT, headers[0], document.left() + 80, document.bottom() - 20, 0);
Date day = new Date();
headers[1] = new Phrase(DateUtils.format(day, DateUtils.FORMAT_LOCAL));
ColumnText.showTextAligned(cb, Element.ALIGN_RIGHT, headers[1], (document.right() - document.left()) / 2 + document.leftMargin(),
document.bottom() - 20, 0);
headers[2] = new Phrase(String.format("Página %d", writer.getCurrentPageNumber()));
ColumnText.showTextAligned(cb, Element.ALIGN_RIGHT, headers[2], document.right() - 80, document.bottom() - 20, 0);
}
示例3: PdfPCell
import com.lowagie.text.Phrase; //导入依赖的package包/类
/**
* Constructs a <CODE>PdfPCell</CODE> with an <CODE>Image</CODE>.
* The default padding is 0.25 for a border width of 0.5.
*
* @param image the <CODE>Image</CODE>
* @param fit <CODE>true</CODE> to fit the image to the cell
*/
public PdfPCell(Image image, boolean fit) {
super(0, 0, 0, 0);
borderWidth = 0.5f;
border = BOX;
if (fit) {
this.image = image;
column.setLeading(0, 1);
setPadding(borderWidth / 2);
}
else {
column.addText(this.phrase = new Phrase(new Chunk(image, 0, 0)));
column.setLeading(0, 1);
setPadding(0);
}
}
示例4: RtfHeaderFooterGroup
import com.lowagie.text.Phrase; //导入依赖的package包/类
/**
* Constructs a RtfHeaderFooterGroup by copying the content of the original
* RtfHeaderFooterGroup
*
* @param doc The RtfDocument this RtfHeaderFooter belongs to
* @param headerFooter The RtfHeaderFooterGroup to copy
* @param type The type of RtfHeaderFooterGroup to create
*/
public RtfHeaderFooterGroup(RtfDocument doc, RtfHeaderFooterGroup headerFooter, int type) {
super(new Phrase(""), false);
this.document = doc;
this.mode = headerFooter.getMode();
this.type = type;
if(headerFooter.getHeaderAll() != null) {
this.headerAll = new RtfHeaderFooter(this.document, headerFooter.getHeaderAll(), RtfHeaderFooter.DISPLAY_ALL_PAGES);
}
if(headerFooter.getHeaderFirst() != null) {
this.headerFirst = new RtfHeaderFooter(this.document, headerFooter.getHeaderFirst(), RtfHeaderFooter.DISPLAY_FIRST_PAGE);
}
if(headerFooter.getHeaderLeft() != null) {
this.headerLeft = new RtfHeaderFooter(this.document, headerFooter.getHeaderLeft(), RtfHeaderFooter.DISPLAY_LEFT_PAGES);
}
if(headerFooter.getHeaderRight() != null) {
this.headerRight = new RtfHeaderFooter(this.document, headerFooter.getHeaderRight(), RtfHeaderFooter.DISPLAY_RIGHT_PAGES);
}
setType(this.type);
}
示例5: RtfHeaderFooter
import com.lowagie.text.Phrase; //导入依赖的package包/类
/**
* Constructs a RtfHeaderFooter as a copy of an existing RtfHeaderFooter.
* For internal use only.
*
* @param doc The RtfDocument this RtfHeaderFooter belongs to
* @param headerFooter The RtfHeaderFooter to copy
* @param displayAt The display location of this RtfHeaderFooter
*/
protected RtfHeaderFooter(RtfDocument doc, RtfHeaderFooter headerFooter, int displayAt) {
super(new Phrase(""), false);
this.document = doc;
this.content = headerFooter.getContent();
this.displayAt = displayAt;
for(int i = 0; i < this.content.length; i++) {
if(this.content[i] instanceof Element) {
try {
this.content[i] = this.document.getMapper().mapElement((Element) this.content[i])[0];
} catch(DocumentException de) {
de.printStackTrace();
}
}
if(this.content[i] instanceof RtfBasicElement) {
((RtfBasicElement) this.content[i]).setInHeader(true);
}
}
}
示例6: getPhrase
import com.lowagie.text.Phrase; //导入依赖的package包/类
/**
* Creates a Phrase object based on a list of properties.
* @param attributes
* @return a Phrase
*/
public static Phrase getPhrase(Properties attributes) {
Phrase phrase = new Phrase();
phrase.setFont(FontFactory.getFont(attributes));
String value;
value = attributes.getProperty(ElementTags.LEADING);
if (value != null) {
phrase.setLeading(Float.parseFloat(value + "f"));
}
value = attributes.getProperty(Markup.CSS_KEY_LINEHEIGHT);
if (value != null) {
phrase.setLeading(Markup.parseLength(value,
Markup.DEFAULT_FONT_SIZE));
}
value = attributes.getProperty(ElementTags.ITEXT);
if (value != null) {
Chunk chunk = new Chunk(value);
if ((value = attributes.getProperty(ElementTags.GENERICTAG)) != null) {
chunk.setGenericTag(value);
}
phrase.add(chunk);
}
return phrase;
}
示例7: main
import com.lowagie.text.Phrase; //导入依赖的package包/类
/**
* How to substiture special characters with Phrase.getInstance.
*/
@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("SymbolSubstitution.pdf"));
// step 3: we open the document
document.open();
// step 4:
document.add(Phrase.getInstance("What is the " + (char) 945 + "-coefficient of the " + (char) 946
+ "-factor in the " + (char) 947 + "-equation?\n"));
for (int i = 913; i < 970; i++) {
document.add(Phrase.getInstance(" " + i + ": " + (char) i));
}
// step 5: we close the document
document.close();
}
示例8: main
import com.lowagie.text.Phrase; //导入依赖的package包/类
/**
* Using FontSelector.
*/
@Test
public void main() throws Exception {
// step 1
Document document = new Document();
// step 2
PdfWriter.getInstance(document, PdfTestBase.getOutputStream("fontselection.pdf"));
// step 3
document.open();
// step 4
String text = "This text is the first verse of \u275dThe Iliad\u275e. It's not polytonic as it should be "
+ "with \u2798 and \u279a entoation variants but that's all we have for now.\n\n"
+ "\u2766\u00a0\u00a0\u039c\u03b7\u03bd\u03b9\u03bd \u03b1\u03b5\u03b9\u03b4\u03b5, \u03b8\u03b5\u03b1, \u03a0\u03b7\u03bb\u03b7\u03b9\u03b1\u03b4\u03b5\u03c9 \u0391\u03c7\u03b9\u03bb\u03b7\u03bf\u03c2";
FontSelector sel = new FontSelector();
sel.addFont(new Font(Font.TIMES_ROMAN, 12));
sel.addFont(new Font(Font.ZAPFDINGBATS, 12));
sel.addFont(new Font(Font.SYMBOL, 12));
Phrase ph = sel.process(text);
document.add(new Paragraph(ph));
// step 5
document.close();
}
示例9: main
import com.lowagie.text.Phrase; //导入依赖的package包/类
/**
* Demonstrates what happens if you choose a negative leading.
*
*/
@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("NegativeLeading.pdf"));
// step 3: we open the document
document.open();
// step 4:
document.add(new Phrase(16, "\n\n\n"));
document.add(new Phrase(
-16,
"Hello, this is a very long phrase to show you the somewhat odd effect of a negative leading. You can write from bottom to top. This is not fully supported. It's something between a feature and a bug."));
// step 5: we close the document
document.close();
}
示例10: testTableSpacingPercentage
import com.lowagie.text.Phrase; //导入依赖的package包/类
@Test
public void testTableSpacingPercentage() throws FileNotFoundException,
DocumentException {
Document document = PdfTestBase
.createPdf("testTableSpacingPercentage.pdf");
document.setMargins(72, 72, 72, 72);
document.open();
PdfPTable table = new PdfPTable(1);
table.setSpacingBefore(20);
table.setWidthPercentage(100);
PdfPCell cell;
cell = new PdfPCell();
Phrase phase = new Phrase("John Doe");
cell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER); // This has no
// effect
cell.setVerticalAlignment(PdfPCell.ALIGN_MIDDLE); // This has no effect
cell.addElement(phase);
table.addCell(cell);
document.add(table);
document.close();
}
示例11: anadirTextoTabla
import com.lowagie.text.Phrase; //导入依赖的package包/类
private static void anadirTextoTabla(PdfPTable tabla, String titulo, String desc) {
PdfPCell cell = new PdfPCell();
disableBorders(cell);
cell.setVerticalAlignment(Element.ALIGN_TOP);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
cell.addElement(new Phrase(titulo,fuente10));
tabla.addCell(cell);
cell = new PdfPCell();
disableBorders(cell);
cell.setVerticalAlignment(Element.ALIGN_TOP);
cell.addElement(new Phrase(defaultString(desc),fuente10));
tabla.addCell(cell);
}
示例12: printDocHeaderFooter
import com.lowagie.text.Phrase; //导入依赖的package包/类
public void printDocHeaderFooter() throws DocumentException {
document.resetHeader();
document.resetFooter();
String headerTitle = "Tickler re: " + tickler.getDemographic().getFormattedName() + " DOB:" + tickler.getDemographic().getFormattedDob();
if (newPage) {
document.newPage();
newPage = false;
}
//Header will be printed at top of every page beginning with p2
Phrase headerPhrase = new Phrase(LEADING, headerTitle, boldFont);
getDocument().add(headerPhrase);
getDocument().add(new Phrase("\n"));
}
示例13: createNeedHeader
import com.lowagie.text.Phrase; //导入依赖的package包/类
private PdfPTable createNeedHeader(String name) throws DocumentException {
Font whiteFont = new Font(Font.HELVETICA,14,Font.BOLD,Color.WHITE);
PdfPTable table = new PdfPTable(3);
table.setWidthPercentage(100);
table.setWidths(new float[]{0.10f,0.20f,0.70f});
PdfPCell emptyCell = new PdfPCell();
emptyCell.setBorder(0);
table.addCell(emptyCell);
PdfPCell headerCell = new PdfPCell();
headerCell.setColspan(2);
headerCell.setPhrase(new Phrase(name,whiteFont));
headerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
headerCell.setBackgroundColor(Color.LIGHT_GRAY);
table.addCell(headerCell);
return table;
}
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:18,代码来源:SummaryOfActionsAndCommentsReportGenerator.java
示例14: addDynamicPositionedText
import com.lowagie.text.Phrase; //导入依赖的package包/类
private float addDynamicPositionedText(String name, String text, float dynamicHeight, EctConsultationFormRequestUtil reqForm) throws DocumentException {
if (text != null && text.length() > 0){
Font boldFont = new Font(bf, FONTSIZE, Font.BOLD);
Font font = new Font(bf, FONTSIZE, Font.NORMAL);
float lineCount = (name.length() + text.length()) / 100;
// if there is not enough room on the page for the text start on the next page
if ( (height - 264 - dynamicHeight - lineCount*LINEHEIGHT) < LINEHEIGHT*3 ){
nextPage(reqForm);
dynamicHeight = LINEHEIGHT - 152;
}
ct.setSimpleColumn(new Float(85), height - 264 - dynamicHeight - lineCount*LINEHEIGHT, new Float(526), height - 250 - dynamicHeight, LINEHEIGHT, Element.ALIGN_LEFT);
ct.addText(new Phrase(name, boldFont));
ct.addText(new Phrase(text, font));
ct.go();
dynamicHeight += lineCount*LINEHEIGHT + LINEHEIGHT*2;
}
return dynamicHeight;
}
示例15: writePageAnchor
import com.lowagie.text.Phrase; //导入依赖的package包/类
protected void writePageAnchor(int pageIndex) throws DocumentException
{
Map<Attribute,Object> attributes = new HashMap<Attribute,Object>();
fontUtil.getAttributesWithoutAwtFont(attributes, new JRBasePrintText(jasperPrint.getDefaultStyleProvider()));
Font pdfFont = getFont(attributes, getLocale(), false);
Chunk chunk = new Chunk(" ", pdfFont);
chunk.setLocalDestination(JR_PAGE_ANCHOR_PREFIX + reportIndex + "_" + (pageIndex + 1));
tagHelper.startPageAnchor();
ColumnText colText = new ColumnText(pdfContentByte);
colText.setSimpleColumn(
new Phrase(chunk),
0,
pageFormat.getPageHeight(),
1,
1,
0,
Element.ALIGN_LEFT
);
colText.go();
tagHelper.endPageAnchor();
}