本文整理汇总了Java中com.itextpdf.text.ExceptionConverter类的典型用法代码示例。如果您正苦于以下问题:Java ExceptionConverter类的具体用法?Java ExceptionConverter怎么用?Java ExceptionConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExceptionConverter类属于com.itextpdf.text包,在下文中一共展示了ExceptionConverter类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: onEndPage
import com.itextpdf.text.ExceptionConverter; //导入依赖的package包/类
/**
* Adds a header to every page
* @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(
* com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
*/
public void onEndPage(PdfWriter writer, Document document) {
PdfPTable table = new PdfPTable(3);
try {
table.setWidths(new int[]{40,5,10});
table.setTotalWidth(100);
table.getDefaultCell().setBorder(Rectangle.NO_BORDER);
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
Font font=new Font(chineseFont,8);
font.setColor(new BaseColor(55,55,55));
Paragraph paragraph=new Paragraph("第 "+writer.getPageNumber()+" 页 共",font);
paragraph.setAlignment(Element.ALIGN_RIGHT);
table.addCell(paragraph);
Image img=Image.getInstance(total);
img.scaleAbsolute(28, 28);
PdfPCell cell = new PdfPCell(img);
cell.setBorder(Rectangle.NO_BORDER);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell);
PdfPCell c = new PdfPCell(new Paragraph("页",font));
c.setHorizontalAlignment(Element.ALIGN_LEFT);
c.setBorder(Rectangle.NO_BORDER);
table.addCell(c);
float center=(document.getPageSize().getWidth())/2-120/2;
table.writeSelectedRows(0, -1,center,30, writer.getDirectContent());
}
catch(DocumentException de) {
throw new ExceptionConverter(de);
}
}
开发者ID:bsteker,项目名称:bdf2,代码行数:35,代码来源:PdfReportPageNumber.java
示例2: cellLayout
import com.itextpdf.text.ExceptionConverter; //导入依赖的package包/类
public void cellLayout(PdfPCell cell, Rectangle position,
PdfContentByte[] canvases) {
PdfWriter writer = canvases[0].getPdfWriter();
float x = position.getLeft();
float y = position.getBottom();
Rectangle rect = new Rectangle(x-5, y-5, x+5, y+5);
RadioCheckField checkbox = new RadioCheckField(
writer, rect, name, "Yes");
checkbox.setCheckType(RadioCheckField.TYPE_CROSS);
checkbox.setChecked(check);
// change: set border color
checkbox.setBorderColor(BaseColor.BLACK);
try {
pdfStamper.addAnnotation(checkbox.getCheckField(), page);
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:20,代码来源:AddField.java
示例3: testStockQuotes_03232015_Incomplete
import com.itextpdf.text.ExceptionConverter; //导入依赖的package包/类
/**
* <a href="http://stackoverflow.com/questions/29209553/itextsharp-pdftextextractor-gettextfrompage-throwing-nullreferenceexception">
* iTextSharp PdfTextExtractor GetTextFromPage Throwing NullReferenceException
* </a>
*
* Test using an incomplete, invalid copy of stockQuotes_03232015.pdf from
* http://www.pse.com.ph/stockMarket/marketInfo-marketActivity.html?tab=4
*/
@Test
public void testStockQuotes_03232015_Incomplete() throws Exception
{
InputStream resourceStream = getClass().getResourceAsStream("stockQuotes_03232015-incomplete.pdf");
try
{
PdfReader reader = new PdfReader(resourceStream);
String content = extractAndStore(reader, new File(RESULT_FOLDER, "stockQuotes_03232015-incomplete.%s.txt").toString());
System.out.println("\nText stockQuotes_03232015-incomplete.pdf\n************************");
System.out.println(content);
System.out.println("************************");
}
catch (ExceptionConverter e)
{
System.err.println("\nException for stockQuotes_03232015-incomplete.pdf\n************************");
e.printStackTrace();
System.err.println("************************");
}
finally
{
if (resourceStream != null)
resourceStream.close();
}
}
开发者ID:mkl-public,项目名称:testarea-itext5,代码行数:34,代码来源:TextExtraction.java
示例4: onEndPage
import com.itextpdf.text.ExceptionConverter; //导入依赖的package包/类
/**
* @see com.itextpdf.text.pdf.PdfPageEventHelper#onEndPage(com.itextpdf.text.pdf.PdfWriter, com.itextpdf.text.Document)
*/
public void onEndPage(PdfWriter writer, Document document) {
PdfContentByte cb = writer.getDirectContent();
cb.saveState();
// write the headertable
table.setTotalWidth(document.right() - document.left());
table.writeSelectedRows(0, -1, document.left(), document.getPageSize().getHeight() - 50, cb);
// compose the footer
String text = "Page " + writer.getPageNumber() + " of ";
float textSize = helv.getWidthPoint(text, 12);
float textBase = document.bottom() - 20;
cb.beginText();
cb.setFontAndSize(helv, 12);
// for odd pagenumbers, show the footer at the left
if ((writer.getPageNumber() & 1) == 1) {
cb.setTextMatrix(document.left(), textBase);
cb.showText(text);
cb.endText();
cb.addTemplate(tpl, document.left() + textSize, textBase);
}
// for even numbers, show the footer at the right
else {
float adjust = helv.getWidthPoint("0", 12);
cb.setTextMatrix(document.right() - textSize - adjust, textBase);
cb.showText(text);
cb.endText();
cb.addTemplate(tpl, document.right() - adjust, textBase);
}
cb.saveState();
// draw a Rectangle around the page
cb.setColorStroke(BaseColor.ORANGE);
cb.setLineWidth(2);
cb.rectangle(20, 20, document.getPageSize().getWidth() - 40, document.getPageSize().getHeight() - 40);
cb.stroke();
cb.restoreState();
// starting on page 3, a watermark with an Image that is made transparent
if (writer.getPageNumber() >= 3) {
cb.setGState(gstate);
cb.setColorFill(BaseColor.RED);
cb.beginText();
cb.setFontAndSize(helv, 48);
cb.showTextAligned(Element.ALIGN_CENTER, "Watermark Opacity " + writer.getPageNumber(), document.getPageSize().getWidth() / 2, document.getPageSize().getHeight() / 2, 45);
cb.endText();
try {
cb.addImage(headerImage, headerImage.getWidth(), 0, 0, headerImage.getHeight(), 440, 80);
}
catch(Exception e) {
throw new ExceptionConverter(e);
}
cb.restoreState();
}
cb.sanityCheck();
}
开发者ID:ltrr-arizona-edu,项目名称:tellervo,代码行数:56,代码来源:PageNumbersWatermark.java
示例5: cellLayout
import com.itextpdf.text.ExceptionConverter; //导入依赖的package包/类
public void cellLayout(final PdfPCell cell,
final Rectangle position,
final PdfContentByte[] canvases) {
try {
final BaseFont bf = font.getCalculatedBaseFont(false);
float availableWidth = position.getWidth();
float contentWidth = bf.getWidthPoint(content, font.getSize());
final String newContent;
if (contentWidth > availableWidth) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Need to truncate '"
+ content
+ "'");
}
final int contentLength = content.length();
int leftChar = 0;
availableWidth -= bf.getWidthPoint("...", font.getSize());
while (leftChar < contentLength) {
availableWidth -= bf.getWidthPoint(content.charAt(leftChar), font.getSize());
if (availableWidth > 0) {
leftChar++;
} else {
break;
}
}
newContent = content.substring(0, leftChar)
+ "...";
} else {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Not truncating '"
+ content
+ "'");
}
newContent = content;
}
final PdfContentByte canvas = canvases[PdfPTable.TEXTCANVAS];
final ColumnText ct = new ColumnText(canvas);
ct.setSimpleColumn(position);
ct.addElement(new Paragraph(newContent, font));
ct.go();
} catch (final DocumentException e) {
throw new ExceptionConverter(e);
}
}
开发者ID:jpschewe,项目名称:fll-sw,代码行数:48,代码来源:PdfUtils.java
注:本文中的com.itextpdf.text.ExceptionConverter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论