本文整理汇总了Java中com.lowagie.text.pdf.ColumnText.setSimpleColumn方法的典型用法代码示例。如果您正苦于以下问题:Java ColumnText.setSimpleColumn方法的具体用法?Java ColumnText.setSimpleColumn怎么用?Java ColumnText.setSimpleColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.pdf.ColumnText
的用法示例。
在下文中一共展示了ColumnText.setSimpleColumn方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writePageAnchor
import com.lowagie.text.pdf.ColumnText; //导入方法依赖的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();
}
示例2: render
import com.lowagie.text.pdf.ColumnText; //导入方法依赖的package包/类
@Override
public void render()
{
ColumnText colText = new ColumnText(pdfContentByte);
colText.setSimpleColumn(
getPhrase(styledText, text),
x + leftPadding,
pdfExporter.getCurrentPageFormat().getPageHeight()
- y
- topPadding
- verticalAlignOffset
- text.getLeadingOffset(),
//+ text.getLineSpacingFactor() * text.getFont().getSize(),
x + width - rightPadding,
pdfExporter.getCurrentPageFormat().getPageHeight()
- y
- height
+ bottomPadding,
0,//text.getLineSpacingFactor(),// * text.getFont().getSize(),
horizontalAlignment == Element.ALIGN_JUSTIFIED_ALL ? Element.ALIGN_JUSTIFIED : horizontalAlignment
);
colText.setLeading(0, text.getLineSpacingFactor());// * text.getFont().getSize());
colText.setRunDirection(
text.getRunDirectionValue() == RunDirectionEnum.LTR
? PdfWriter.RUN_DIRECTION_LTR : PdfWriter.RUN_DIRECTION_RTL
);
try
{
colText.go();
}
catch (DocumentException e)
{
throw new JRRuntimeException(e);
}
}
示例3: main
import com.lowagie.text.pdf.ColumnText; //导入方法依赖的package包/类
/**
* Demonstrating the use of ColumnText
*/
@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
// and directs a PDF-stream to a file
PdfWriter writer = PdfWriter.getInstance(document, PdfTestBase.getOutputStream("columnsimple.pdf"));
// step 3: we open the document
document.open();
// step 4:
// we grab the ContentByte and do some stuff with it
PdfContentByte cb = writer.getDirectContent();
BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
Font font = new Font(bf, 11, Font.NORMAL);
ColumnText ct = new ColumnText(cb);
ct.setSimpleColumn(60, 300, 100, 300 + 28 * 15, 15, Element.ALIGN_CENTER);
ct.addText(new Phrase(15, "UNI\n", font));
for (int i = 0; i < 27; i++) {
ct.addText(new Phrase(15, uni[i] + "\n", font));
}
ct.go();
cb.rectangle(103, 295, 52, 8 + 28 * 15);
cb.stroke();
ct.setSimpleColumn(105, 300, 150, 300 + 28 * 15, 15, Element.ALIGN_RIGHT);
ct.addText(new Phrase(15, "char\n", font));
for (int i = 0; i < 27; i++) {
ct.addText(new Phrase(15, code[i] + "\n", font));
}
ct.go();
ct.setSimpleColumn(160, 300, 500, 300 + 28 * 15, 15, Element.ALIGN_LEFT);
ct.addText(new Phrase(15, "NAME" + "\n", font));
for (int i = 0; i < 27; i++) {
ct.addText(new Phrase(15, name[i] + "\n", font));
}
ct.go();
// step 5: we close the document
document.close();
}
示例4: main
import com.lowagie.text.pdf.ColumnText; //导入方法依赖的package包/类
/**
* Demonstrating the use of ColumnText
*/
@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("column.pdf"));
// step 3: we open the document
document.open();
// step 4:
// we create some content
BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
Font font = new Font(bf, 11, Font.NORMAL);
Phrase unicodes = new Phrase(15, "UNI\n", font);
Phrase characters = new Phrase(15, "\n", font);
Phrase names = new Phrase(15, "NAME\n", font);
for (int i = 0; i < 27; i++) {
unicodes.add(uni[i] + "\n");
characters.add(code[i] + "\n");
names.add(name[i] + "\n");
}
// we grab the ContentByte and do some stuff with it
PdfContentByte cb = writer.getDirectContent();
ColumnText ct = new ColumnText(cb);
ct.setSimpleColumn(unicodes, 60, 300, 100, 300 + 28 * 15, 15, Element.ALIGN_CENTER);
ct.go();
cb.rectangle(103, 295, 52, 8 + 28 * 15);
cb.stroke();
ct.setSimpleColumn(characters, 105, 300, 150, 300 + 28 * 15, 15, Element.ALIGN_RIGHT);
ct.go();
ct.setSimpleColumn(names, 160, 300, 500, 300 + 28 * 15, 15, Element.ALIGN_LEFT);
ct.go();
// step 5: we close the document
document.close();
}
示例5: draw
import com.lowagie.text.pdf.ColumnText; //导入方法依赖的package包/类
@Override
public void draw()
{
TabSegment segment = segments.get(segmentIndex);
float advance = segment.layout.getAdvance();
ColumnText colText = new ColumnText(pdfContentByte);
colText.setSimpleColumn(
pdfExporter.getPhrase(segment.as, segment.text, text),
x + drawPosX + leftOffsetFactor * advance,// + leftPadding
pdfExporter.getCurrentPageFormat().getPageHeight()
- y
- topPadding
- verticalAlignOffset
//- text.getLeadingOffset()
+ lineHeight
- drawPosY,
x + drawPosX + segment.layout.getAdvance() + rightOffsetFactor * advance,// + leftPadding
pdfExporter.getCurrentPageFormat().getPageHeight()
- y
- topPadding
- verticalAlignOffset
//- text.getLeadingOffset()
-400//+ lineHeight//FIXMETAB
- drawPosY,
0,//text.getLineSpacingFactor(),// * text.getFont().getSize(),
horizontalAlignment
);
//colText.setLeading(0, text.getLineSpacingFactor());// * text.getFont().getSize());
colText.setLeading(lineHeight);
colText.setRunDirection(
text.getRunDirectionValue() == RunDirectionEnum.LTR
? PdfWriter.RUN_DIRECTION_LTR : PdfWriter.RUN_DIRECTION_RTL
);
try
{
colText.go();
}
catch (DocumentException e)
{
throw new JRRuntimeException(e);
}
}
示例6: addTitlePage
import com.lowagie.text.pdf.ColumnText; //导入方法依赖的package包/类
public void addTitlePage(String evaltitle, String groupNames, String startDate, String endDate,
String responseInformation, byte[] bannerImageBytes, String evalSystemTitle, String informationTitle) {
try {
float pagefooter = paragraphFont.getSize();
PdfContentByte cb = pdfWriter.getDirectContent();
float docMiddle = (document.right() - document.left()) / 2 + document.leftMargin();
Paragraph emptyPara = new Paragraph(" ");
emptyPara.setSpacingAfter(100.0f);
// Title
Paragraph titlePara = new Paragraph("\n\n\n" + evaltitle, frontTitleFont);
titlePara.setAlignment(Element.ALIGN_CENTER);
document.add(titlePara);
// Groups
Paragraph groupPara = new Paragraph(groupNames, frontAuthorFont);
groupPara.setSpacingBefore(25.0f);
groupPara.setAlignment(Element.ALIGN_CENTER);
document.add(groupPara);
// Little info area? I don't know, it was on the mockup though
Paragraph infoPara = new Paragraph(informationTitle, frontInfoFont);
infoPara.setAlignment(Element.ALIGN_CENTER);
infoPara.setSpacingBefore(90.0f);
document.add(infoPara);
// Started on
Paragraph startedPara = new Paragraph(startDate, frontInfoFont);
startedPara.setAlignment(Element.ALIGN_CENTER);
startedPara.setSpacingBefore(25.0f);
document.add(startedPara);
// Ended on
Paragraph endedPara = new Paragraph(endDate, frontInfoFont);
endedPara.setAlignment(Element.ALIGN_CENTER);
endedPara.setSpacingBefore(25.0f);
document.add(endedPara);
// Reply Rate
Paragraph replyRatePara = new Paragraph(responseInformation, frontInfoFont);
replyRatePara.setAlignment(Element.ALIGN_CENTER);
replyRatePara.setSpacingBefore(25.0f);
document.add(replyRatePara);
// Logo and Tagline
cb.beginText();
cb.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.CP1252,
BaseFont.EMBEDDED), 12);
cb.showTextAligned(PdfContentByte.ALIGN_CENTER, evalSystemTitle, docMiddle, document
.bottom() + 20, 0);
cb.endText();
if (bannerImageBytes != null) {
Image banner = Image.getInstance(bannerImageBytes);
cb.addImage(banner, banner.getWidth(), 0, 0, banner.getHeight(), docMiddle
- (banner.getWidth() / 2), document.bottom() + 35);
}
document.newPage();
responseArea = new ColumnText(cb);
responseArea.setSimpleColumn(document.left(),document.top(),document.right()/2, document.bottom()+pagefooter);
responseArea.go();
} catch (DocumentException | IOException de) {
throw UniversalRuntimeException.accumulate(de, "Unable to create title page");
}
}
示例7: main
import com.lowagie.text.pdf.ColumnText; //导入方法依赖的package包/类
/**
* Demonstrating the use of ColumnText
*
* @param args
* no arguments needed
*/
public static void main(String[] args) {
System.out.println("Simple Column");
// step 1: creation of a document-object
Document document = new Document();
try {
// step 2:
// we create a writer that listens to the document
// and directs a PDF-stream to a file
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "columnsimple.pdf"));
// step 3: we open the document
document.open();
// step 4:
// we grab the ContentByte and do some stuff with it
PdfContentByte cb = writer.getDirectContent();
BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
Font font = new Font(bf, 11, Font.NORMAL);
ColumnText ct = new ColumnText(cb);
ct.setSimpleColumn(60, 300, 100, 300 + 28 * 15, 15, Element.ALIGN_CENTER);
ct.addText(new Phrase(15, "UNI\n", font));
for (int i = 0; i < 27; i++) {
ct.addText(new Phrase(15, uni[i] + "\n", font));
}
ct.go();
cb.rectangle(103, 295, 52, 8 + 28 * 15);
cb.stroke();
ct.setSimpleColumn(105, 300, 150, 300 + 28 * 15, 15, Element.ALIGN_RIGHT);
ct.addText(new Phrase(15, "char\n", font));
for (int i = 0; i < 27; i++) {
ct.addText(new Phrase(15, code[i] + "\n", font));
}
ct.go();
ct.setSimpleColumn(160, 300, 500, 300 + 28 * 15, 15, Element.ALIGN_LEFT);
ct.addText(new Phrase(15, "NAME" + "\n", font));
for (int i = 0; i < 27; i++) {
ct.addText(new Phrase(15, name[i] + "\n", font));
}
ct.go();
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}
示例8: main
import com.lowagie.text.pdf.ColumnText; //导入方法依赖的package包/类
/**
* Demonstrating the use of ColumnText
*
* @param args
* no arguments needed
*/
public static void main(String[] args) {
System.out.println("Simple single object columns");
// step 1: creation of a document-object
Document document = new Document();
try {
// step 2: creation of the writer
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(android.os.Environment.getExternalStorageDirectory() + java.io.File.separator + "droidtext" + java.io.File.separator + "column.pdf"));
// step 3: we open the document
document.open();
// step 4:
// we create some content
BaseFont bf = BaseFont.createFont(BaseFont.COURIER, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
Font font = new Font(bf, 11, Font.NORMAL);
Phrase unicodes = new Phrase(15, "UNI\n", font);
Phrase characters = new Phrase(15, "\n", font);
Phrase names = new Phrase(15, "NAME\n", font);
for (int i = 0; i < 27; i++) {
unicodes.add(uni[i] + "\n");
characters.add(code[i] + "\n");
names.add(name[i] + "\n");
}
// we grab the ContentByte and do some stuff with it
PdfContentByte cb = writer.getDirectContent();
ColumnText ct = new ColumnText(cb);
ct.setSimpleColumn(unicodes, 60, 300, 100, 300 + 28 * 15, 15, Element.ALIGN_CENTER);
ct.go();
cb.rectangle(103, 295, 52, 8 + 28 * 15);
cb.stroke();
ct.setSimpleColumn(characters, 105, 300, 150, 300 + 28 * 15, 15, Element.ALIGN_RIGHT);
ct.go();
ct.setSimpleColumn(names, 160, 300, 500, 300 + 28 * 15, 15, Element.ALIGN_LEFT);
ct.go();
} catch (DocumentException de) {
System.err.println(de.getMessage());
} catch (IOException ioe) {
System.err.println(ioe.getMessage());
}
// step 5: we close the document
document.close();
}