本文整理汇总了Java中com.lowagie.text.BadElementException类的典型用法代码示例。如果您正苦于以下问题:Java BadElementException类的具体用法?Java BadElementException怎么用?Java BadElementException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BadElementException类属于com.lowagie.text包,在下文中一共展示了BadElementException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPersonalInfo
import com.lowagie.text.BadElementException; //导入依赖的package包/类
/**
* Get the PDF Table with personal information about the initiator and traveler
*
* @returns {@link Table} used for a PDF
*/
protected Table getPersonalInfo() throws BadElementException {
final Table retval = new Table(2);
retval.setWidth(100f);
retval.setBorder(NO_BORDER);
retval.addCell(getHeaderCell("Traveler"));
final Cell initiatorHeaderCell = getHeaderCell("Request Submitted By");
retval.addCell(initiatorHeaderCell);
retval.endHeaders();
retval.addCell(getTravelerInfo());
final Cell initiatorCell = getInitiatorInfo();
retval.addCell(initiatorCell);
return retval;
}
示例2: createBarcodeImage
import com.lowagie.text.BadElementException; //导入依赖的package包/类
/**
* Generate a Code128C barcode
*
* @param rrn
* unique Rijksregister number
* @param cardNumber
* number of the card
* @return Image containing barcode
* @throws IOException
* @throws BadElementException
*/
private Image createBarcodeImage(String rrn, String cardNumber) throws IOException, BadElementException {
if (null == rrn || rrn.length() != 11 || null == cardNumber || cardNumber.length() < 9) {
throw new IllegalArgumentException("Missing or invalid length for RRN or Card Number");
}
String lastDigits = cardNumber.substring(cardNumber.length() - 9);
String code = rrn + lastDigits;
Barcode128 barcode = new Barcode128();
barcode.setCodeType(Barcode128.CODE_C);
barcode.setCode(code);
barcode.setFont(null);
return Image.getInstance(barcode.createAwtImage(Color.BLACK, Color.WHITE), null, true);
}
示例3: writeJndiBinding
import com.lowagie.text.BadElementException; //导入依赖的package包/类
private void writeJndiBinding(JndiBinding jndiBinding) throws BadElementException, IOException {
final PdfPCell defaultCell = getDefaultCell();
defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
final String name = jndiBinding.getName();
final String className = jndiBinding.getClassName();
final String contextPath = jndiBinding.getContextPath();
final String value = jndiBinding.getValue();
if (contextPath != null) {
final Image image = getFolderImage();
final Phrase phrase = new Phrase("", cellFont);
phrase.add(new Chunk(image, 0, 0));
phrase.add(" ");
phrase.add(name);
addCell(phrase);
} else {
addCell(name);
}
addCell(className != null ? className : "");
addCell(value != null ? value : "");
}
示例4: writeMemoryInformations
import com.lowagie.text.BadElementException; //导入依赖的package包/类
private void writeMemoryInformations(MemoryInformations memoryInformations)
throws BadElementException, IOException {
addCell(memoryInformations.getMemoryDetails().replace(" Mo", ' ' + getString("Mo")));
final long usedPermGen = memoryInformations.getUsedPermGen();
if (usedPermGen > 0) {
// perm gen est à 0 sous jrockit
final long maxPermGen = memoryInformations.getMaxPermGen();
addCell(getString("Memoire_Perm_Gen") + ':');
if (maxPermGen > 0) {
final Phrase permGenPhrase = new Phrase(
integerFormat.format(usedPermGen / 1024 / 1024) + ' ' + getString("Mo")
+ DIVIDE + integerFormat.format(maxPermGen / 1024 / 1024) + ' '
+ getString("Mo") + BAR_SEPARATOR,
cellFont);
final Image permGenImage = Image.getInstance(
Bar.toBarWithAlert(memoryInformations.getUsedPermGenPercentage()), null);
permGenImage.scalePercent(50);
permGenPhrase.add(new Chunk(permGenImage, 0, 0));
currentTable.addCell(permGenPhrase);
} else {
addCell(integerFormat.format(usedPermGen / 1024 / 1024) + ' ' + getString("Mo"));
}
}
}
示例5: writeJobInformations
import com.lowagie.text.BadElementException; //导入依赖的package包/类
private void writeJobInformations(JobInformations jobInformations)
throws BadElementException, IOException {
final PdfPCell defaultCell = getDefaultCell();
defaultCell.setHorizontalAlignment(Element.ALIGN_LEFT);
addCell(jobInformations.getGroup());
addCell(jobInformations.getName());
addCell(jobInformations.getJobClassName());
defaultCell.setHorizontalAlignment(Element.ALIGN_RIGHT);
final CounterRequest counterRequest = getCounterRequest(jobInformations);
// counterRequest ne peut pas être null ici
if (counterRequest.getMean() >= 0) {
addCell(formatDuration(counterRequest.getMean()));
} else {
addCell("");
}
// rq: on n'affiche pas ici le nb d'exécutions, le maximum, l'écart-type
// ou le pourcentage d'erreurs, uniquement car cela ferait trop de colonnes dans la page
writeJobTimes(jobInformations, counterRequest);
defaultCell.setHorizontalAlignment(Element.ALIGN_CENTER);
if (jobInformations.isPaused()) {
addCell(getString("oui"));
} else {
addCell(getString("non"));
}
}
示例6: initTable
import com.lowagie.text.BadElementException; //导入依赖的package包/类
/**
* Initialize the main info holder table.
*
* @throws BadElementException
* for errors during table initialization
*/
protected void initTable() throws BadElementException {
tablePDF = new Table(this.model.getNumberOfColumns());
tablePDF.setDefaultVerticalAlignment(Element.ALIGN_TOP);
tablePDF.setCellsFitPage(true);
tablePDF.setWidth(100);
tablePDF.setPadding(2);
tablePDF.setSpacing(0);
// smallFont = FontFactory.getFont(FontFactory.HELVETICA, 7,
// Font.NORMAL, new Color(0, 0, 0));
smallFont = FontFactory.getFont("STSong-Light", "UniGB-UCS2-H", Font.DEFAULTSIZE);
}
示例7: generateHeaders
import com.lowagie.text.BadElementException; //导入依赖的package包/类
/**
* Generates the header cells, which persist on every page of the PDF
* document.
*
* @throws BadElementException
* IText exception
*/
protected void generateHeaders() throws BadElementException {
Iterator iterator = this.model.getHeaderCellList().iterator();
while (iterator.hasNext()) {
HeaderCell headerCell = (HeaderCell) iterator.next();
String columnHeader = headerCell.getTitle();
if (columnHeader == null) {
columnHeader = StringUtils.capitalize(headerCell.getBeanPropertyName());
}
Cell hdrCell = getCell(columnHeader);
hdrCell.setGrayFill(0.9f);
hdrCell.setHeader(true);
tablePDF.addCell(hdrCell);
}
}
示例8: generateRows
import com.lowagie.text.BadElementException; //导入依赖的package包/类
/**
* Generates all the row cells.
*
* @throws JspException
* for errors during value retrieving from the table model
* @throws BadElementException
* errors while generating content
*/
protected void generateRows() throws JspException, BadElementException {
// get the correct iterator (full or partial list according to the
// exportFull field)
RowIterator rowIterator = this.model.getRowIterator(this.exportFull);
// iterator on rows
while (rowIterator.hasNext()) {
Row row = rowIterator.next();
// iterator on columns
ColumnIterator columnIterator = row.getColumnIterator(this.model.getHeaderCellList());
while (columnIterator.hasNext()) {
Column column = columnIterator.nextColumn();
// Get the value to be displayed for the column
Object value = column.getValue(this.decorated);
Cell cell = getCell(ObjectUtils.toString(value));
tablePDF.addCell(cell);
}
}
}
示例9: getTripInfo
import com.lowagie.text.BadElementException; //导入依赖的package包/类
/**
* Get the PDF Table containing trip information like trip id, date, and destination
*
* @returns {@link Table} used for a PDF
*/
protected Table getTripInfo() throws BadElementException {
final Table retval = new Table(3);
retval.setWidth(100f);
retval.setBorder(NO_BORDER);
retval.addCell(getHeaderCell("Trip/Event ID"));
final Cell dateHeaderCell = getHeaderCell("Date");
retval.addCell(dateHeaderCell);
retval.addCell(getHeaderCell("Destination/Event Name"));
retval.endHeaders();
retval.addCell(getBorderlessCell(getTripId()));
final Cell dateCell = getBorderlessCell(getDate());
retval.addCell(dateCell);
retval.addCell(getBorderlessCell(getDestination()));
return retval;
}
示例10: getExpenses
import com.lowagie.text.BadElementException; //导入依赖的package包/类
public Table getExpenses() throws BadElementException {
final Table retval = new Table(3);
retval.setWidth(100f);
retval.setBorder(NO_BORDER);
retval.addCell(getHeaderCell("Expenses"));
retval.addCell(getHeaderCell("Amount"));
retval.addCell(getHeaderCell("Receipt Required?"));
retval.endHeaders();
for (final Map<String, String> expense : expenses) {
retval.addCell(getBorderlessCell(expense.get("expenseType")));
retval.addCell(getBorderlessCell(expense.get("amount")));
retval.addCell(getBorderlessCell(expense.get("receipt")));
}
return retval;
}
示例11: preProcessPDF
import com.lowagie.text.BadElementException; //导入依赖的package包/类
public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException {
Document pdf = (Document) document;
pdf.setPageSize(PageSize.A3);
pdf.open();
ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
String logo = servletContext.getRealPath("") + File.separator +"resources" + File.separator + "images" + File.separator +"logo" + File.separator + "logo.png";
Image image=Image.getInstance(logo);
image.scaleAbsolute(100f, 50f);
pdf.add(image);
// add a couple of blank lines
pdf.add( Chunk.NEWLINE );
pdf.add( Chunk.NEWLINE );
Font fontbold = FontFactory.getFont("Times-Roman", 16, Font.BOLD);
fontbold.setColor(55, 55, 55);;
pdf.add(new Paragraph("Investment Summary",fontbold));
// add a couple of blank lines
pdf.add( Chunk.NEWLINE );
pdf.add( Chunk.NEWLINE );
}
示例12: preProcessPDF
import com.lowagie.text.BadElementException; //导入依赖的package包/类
public void preProcessPDF(Object document) throws IOException, BadElementException, DocumentException {
Document pdf = (Document) document;
pdf.setPageSize(PageSize.A3);
pdf.open();
ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
String logo = servletContext.getRealPath("") + File.separator +"resources" + File.separator + "images" + File.separator +"logo" + File.separator + "logo.png";
Image image=Image.getInstance(logo);
image.scaleAbsolute(100f, 50f);
pdf.add(image);
// add a couple of blank lines
pdf.add( Chunk.NEWLINE );
pdf.add( Chunk.NEWLINE );
Font fontbold = FontFactory.getFont("Times-Roman", 16, Font.BOLD);
fontbold.setColor(55, 55, 55);;
pdf.add(new Paragraph("Account Summary",fontbold));
// add a couple of blank lines
pdf.add( Chunk.NEWLINE );
pdf.add( Chunk.NEWLINE );
}
示例13: preProcessPDF
import com.lowagie.text.BadElementException; //导入依赖的package包/类
public void preProcessPDF(Object document) throws IOException,
BadElementException, DocumentException {
Document pdf = (Document) document;
pdf.setPageSize(PageSize.A4);
pdf.open();
ServletContext servletContext = (ServletContext) FacesContext
.getCurrentInstance().getExternalContext().getContext();
String logo = servletContext.getRealPath("") + File.separator
+ "resources" + File.separator + "images" + File.separator
+ "logo" + File.separator + "logo.png";
Image image = Image.getInstance(logo);
image.scaleAbsolute(100f, 50f);
pdf.add(image);
// add a couple of blank lines
pdf.add(Chunk.NEWLINE);
pdf.add(Chunk.NEWLINE);
Font fontbold = FontFactory.getFont("Times-Roman", 16, Font.BOLD);
fontbold.setColor(55, 55, 55);
;
pdf.add(new Paragraph("Transaction Summary", fontbold));
// add a couple of blank lines
pdf.add(Chunk.NEWLINE);
pdf.add(Chunk.NEWLINE);
}
示例14: generateHeaders
import com.lowagie.text.BadElementException; //导入依赖的package包/类
/**
* Generates the header cells, which persist on every page of the PDF document.
*
* @throws BadElementException
* IText exception
* @throws NetxiliaBusinessException
* @throws NetxiliaResourceException
*/
protected void generateHeaders(ISheet sheet, Table tablePDF, Font font, int columnCount)
throws BadElementException, NetxiliaResourceException, NetxiliaBusinessException {
Cell hdrCell = getCell("", font, Element.ALIGN_CENTER, 50);
hdrCell.setGrayFill(0.9f);
hdrCell.setHeader(true);
tablePDF.addCell(hdrCell);
List<ColumnData> columnData = sheet.receiveColumns(Range.ALL).getNonBlocking();
for (int i = 0; i < columnCount; ++i) {
ColumnData column = i < columnData.size() ? columnData.get(i) : null;
hdrCell = getCell(CellReference.columnLabel(i), font, Element.ALIGN_CENTER, column != null ? column
.getWidth() : 120);
hdrCell.setGrayFill(0.9f);
hdrCell.setHeader(true);
tablePDF.addCell(hdrCell);
}
}
示例15: convertToIText
import com.lowagie.text.BadElementException; //导入依赖的package包/类
/**
* Crea un com.lowagie.text.Image a partir de un org.eclipse.swt.graphics.ImageData
* @param data
* @return
*/
public static Image convertToIText(ImageData data){
try {
PaletteData palette = data.palette;
int width = data.width;
int height = data.height;
byte bytes[] = new byte[(width * height * 3)];
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
RGB rgb = palette.getRGB(data.getPixel(x, y));
bytes[y * (width * 3) + (x * 3)] = (byte)rgb.red;
bytes[y * (width * 3) + (x * 3) + 1] = (byte)rgb.green;
bytes[y * (width * 3) + (x * 3) + 2] = (byte)rgb.blue;
}
}
return Image.getInstance(width,height,3,8,bytes);
} catch (BadElementException e) {
e.printStackTrace();
}
return null;
}