本文整理汇总了Java中com.lowagie.text.Paragraph.setLeading方法的典型用法代码示例。如果您正苦于以下问题:Java Paragraph.setLeading方法的具体用法?Java Paragraph.setLeading怎么用?Java Paragraph.setLeading使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.Paragraph
的用法示例。
在下文中一共展示了Paragraph.setLeading方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: newPara
import com.lowagie.text.Paragraph; //导入方法依赖的package包/类
private static Element newPara(String text, int alignment, int type) {
Font font = FontFactory.getFont("Helvetica", 10, type, Color.BLACK);
Paragraph p = new Paragraph(text, font);
p.setAlignment(alignment);
p.setLeading(font.getSize() * 1.2f);
return p;
}
示例2: makeCell
import com.lowagie.text.Paragraph; //导入方法依赖的package包/类
private static PdfPCell makeCell(String text, int vAlignment, int hAlignment, Font font, float leading,
float padding, Rectangle borders, boolean ascender, boolean descender) {
Paragraph p = new Paragraph(text, font);
p.setLeading(leading);
PdfPCell cell = new PdfPCell(p);
cell.setLeading(leading, 0);
cell.setVerticalAlignment(vAlignment);
cell.setHorizontalAlignment(hAlignment);
cell.cloneNonPositionParameters(borders);
cell.setUseAscender(ascender);
cell.setUseDescender(descender);
cell.setUseBorderPadding(true);
cell.setPadding(padding);
return cell;
}
示例3: 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;
}
示例4: printFooter
import com.lowagie.text.Paragraph; //导入方法依赖的package包/类
protected void printFooter() throws DocumentException {
iEmpty=false;
out("");
out(renderEnd(renderMiddle((iFooter==null?"":iFooter),"Page "+(iPageNo+1)),(iPageId==null||iPageId.length()==0?"":iPageId)+" "));
if (iPrint!=null) {
iPrint.print(iBuffer);
} else {
//FIXME: For some reason when a line starts with space, the line is shifted by one space in the resulting PDF (when using iText 5.0.2)
Paragraph p = new Paragraph(iBuffer.toString().replace("\n ", "\n "), PdfFont.getFixedFont());
p.setLeading(9.5f); //was 13.5f
iDoc.add(p);
}
iBuffer = new StringBuffer();
iPageNo++;
}
示例5: printFooter
import com.lowagie.text.Paragraph; //导入方法依赖的package包/类
protected void printFooter() throws DocumentException {
out("");
out(renderEnd(renderMiddle("","Page "+(iPageNo+1)),"<"+iCurrentSubjectArea.getSubjectAreaAbbreviation()+(iCourseNumber!=null?" "+iCourseNumber:"")+"> "));
//FIXME: For some reason when a line starts with space, the line is shifted by one space in the resulting PDF (when using iText 5.0.2)
Paragraph p = new Paragraph(iBuffer.toString().replace("\n ", "\n "), PdfFont.getFixedFont());
p.setLeading(9.5f); //was 13.5f
iDoc.add(p);
iBuffer = new StringBuffer();
iPageNo++;
}
示例6: printHeader
import com.lowagie.text.Paragraph; //导入方法依赖的package包/类
@Override
public void printHeader(String... fields) {
iTable = new PdfPTable(fields.length - iHiddenColumns.size());
iMaxWidth = new float[fields.length];
iTable.setHeaderRows(1);
iTable.setWidthPercentage(100);
for (int idx = 0; idx < fields.length; idx++) {
if (iHiddenColumns.contains(idx)) continue;
String f = fields[idx];
PdfPCell cell = new PdfPCell();
cell.setBorder(Rectangle.BOTTOM);
cell.setVerticalAlignment(Element.ALIGN_TOP);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
Font font = PdfFont.getFont(true);
Paragraph ch = new Paragraph(f, font);
ch.setLeading(0f, 1f);
cell.addElement(ch);
iTable.addCell(cell);
float width = 0;
if (f.indexOf('\n')>=0) {
for (StringTokenizer s = new StringTokenizer(f,"\n"); s.hasMoreTokens();)
width = Math.max(width,font.getBaseFont().getWidthPoint(s.nextToken(), font.getSize()));
} else
width = Math.max(width,font.getBaseFont().getWidthPoint(f, font.getSize()));
iMaxWidth[idx] = width;
}
}
示例7: addPTable
import com.lowagie.text.Paragraph; //导入方法依赖的package包/类
/** Adds a <CODE>PdfPTable</CODE> to the document.
* @param ptable the <CODE>PdfPTable</CODE> to be added to the document.
* @throws DocumentException on error
*/
void addPTable(PdfPTable ptable) throws DocumentException {
ColumnText ct = new ColumnText(writer.getDirectContent());
// if the table prefers to be on a single page, and it wouldn't
//fit on the current page, start a new page.
if (ptable.getKeepTogether() && !fitsPage(ptable, 0f) && currentHeight > 0) {
newPage();
}
// add dummy paragraph if we aren't at the top of a page, so that
// spacingBefore will be taken into account by ColumnText
if (currentHeight > 0) {
Paragraph p = new Paragraph();
p.setLeading(0);
ct.addElement(p);
}
ct.addElement(ptable);
boolean he = ptable.isHeadersInEvent();
ptable.setHeadersInEvent(true);
int loop = 0;
while (true) {
ct.setSimpleColumn(indentLeft(), indentBottom(), indentRight(), indentTop() - currentHeight);
int status = ct.go();
if ((status & ColumnText.NO_MORE_TEXT) != 0) {
text.moveText(0, ct.getYLine() - indentTop() + currentHeight);
currentHeight = indentTop() - ct.getYLine();
break;
}
if (indentTop() - currentHeight == ct.getYLine())
++loop;
else
loop = 0;
if (loop == 3) {
add(new Paragraph("ERROR: Infinite table loop"));
break;
}
newPage();
}
ptable.setHeadersInEvent(he);
}
示例8: setParagraphLeading
import com.lowagie.text.Paragraph; //导入方法依赖的package包/类
private static void setParagraphLeading(Paragraph p, String leading) {
if (leading == null) {
p.setLeading(0, 1.5f);
return;
}
try {
StringTokenizer tk = new StringTokenizer(leading, " ,");
String v = tk.nextToken();
float v1 = Float.parseFloat(v);
if (!tk.hasMoreTokens()) {
p.setLeading(v1, 0);
return;
}
v = tk.nextToken();
float v2 = Float.parseFloat(v);
p.setLeading(v1, v2);
} catch (Exception e) {
p.setLeading(0, 1.5f);
}
}
示例9: main
import com.lowagie.text.Paragraph; //导入方法依赖的package包/类
/**
* PdfTemplates can be wrapped in an Image.
*/
@Test
public void main() throws Exception {
// step 1: creation of a document-object
Rectangle rect = new Rectangle(PageSize.A4);
rect.setBackgroundColor(new Color(238, 221, 88));
Document document = new Document(rect, 50, 50, 50, 50);
// step 2: we create a writer that listens to the document
PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("templateImages.pdf"));
// step 3: we open the document
document.open();
// step 4:
PdfTemplate template = writer.getDirectContent().createTemplate(20, 20);
BaseFont bf = BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI,
BaseFont.NOT_EMBEDDED);
String text = "Vertical";
float size = 16;
float width = bf.getWidthPoint(text, size);
template.beginText();
template.setRGBColorFillF(1, 1, 1);
template.setFontAndSize(bf, size);
template.setTextMatrix(0, 2);
template.showText(text);
template.endText();
template.setWidth(width);
template.setHeight(size + 2);
template.sanityCheck();
Image img = Image.getInstance(template);
img.setRotationDegrees(90);
Chunk ck = new Chunk(img, 0, 0);
PdfPTable table = new PdfPTable(3);
table.setWidthPercentage(100);
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_CENTER);
table.getDefaultCell().setVerticalAlignment(Element.ALIGN_MIDDLE);
PdfPCell cell = new PdfPCell(img);
cell.setPadding(4);
cell.setBackgroundColor(new Color(0, 0, 255));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell("I see a template on my right");
table.addCell(cell);
table.addCell("I see a template on my left");
table.addCell(cell);
table.addCell("I see a template everywhere");
table.addCell(cell);
table.addCell("I see a template on my right");
table.addCell(cell);
table.addCell("I see a template on my left");
Paragraph p1 = new Paragraph("This is a template ");
p1.add(ck);
p1.add(" just here.");
p1.setLeading(img.getScaledHeight() * 1.1f);
document.add(p1);
document.add(table);
Paragraph p2 = new Paragraph("More templates ");
p2.setLeading(img.getScaledHeight() * 1.1f);
p2.setAlignment(Element.ALIGN_JUSTIFIED);
img.scalePercent(70);
for (int k = 0; k < 20; ++k)
p2.add(ck);
document.add(p2);
// step 5: we close the document
document.close();
}
示例10: getEnvelopeLabel
import com.lowagie.text.Paragraph; //导入方法依赖的package包/类
Paragraph getEnvelopeLabel(String text){
Paragraph p = new Paragraph(text,FontFactory.getFont(FontFactory.HELVETICA, 18));
p.setLeading(22);
return p;
}
示例11: setParagraphStyle
import com.lowagie.text.Paragraph; //导入方法依赖的package包/类
/**
* 功能说明:设置段落的样式,设置前半截内容填充了浅灰色的背景颜色,后半截内容没有背景颜色的段落样式</BR>
* 修改日期:2011-04-27
* @author myclover
* @param content 前半截有背景颜色的内容
* @param font 字体的样式
* @param firstLineIndent 首行缩进的字符,16f约等于一个字符
* @param leading 行间距12f表示单倍行距
* @param appendStr 后半截内容
* @return
*/
public static Paragraph setParagraphStyle(String content , Font font , float firstLineIndent , float leading , String appendStr){
Phrase phrase = setPhraseStyle(content , appendStr);
Paragraph par = new Paragraph(phrase);
par.setFont(font);
par.setFirstLineIndent(firstLineIndent);
par.setLeading(leading);
//设置对齐方式为两端对齐
par.setAlignment(Paragraph.ALIGN_JUSTIFIED_ALL);
return par;
}