List of usage examples for com.itextpdf.text.pdf PdfPTable setWidths
public void setWidths(final int relativeWidths[]) throws DocumentException
From source file:org.techytax.report.helper.PdfReportHelper.java
License:Open Source License
private void addTotalsOut(VatReportData vatReportData, PdfPTable table) throws DocumentException { PdfPCell cell;/* w w w. j a v a2 s. c o m*/ Paragraph chunk; PdfPTable subTable = new PdfPTable(2); subTable.setWidths(new int[] { 8, 2 }); chunk = new Paragraph("btw uit overzicht", headerFont); cell = new PdfPCell(chunk); cell.setBorder(PdfPCell.NO_BORDER); cell.setColspan(2); subTable.addCell(cell); Paragraph headerChunk = new Paragraph("Omschrijving", headerFont); cell = new PdfPCell(headerChunk); subTable.addCell(cell); headerChunk = new Paragraph("Subtotaal", headerFont); cell = new PdfPCell(headerChunk); subTable.addCell(cell); PdfPCell tableCell = new PdfPCell(subTable); for (VatJournal vatJournal : vatReportData.getVatJournalsOut().getVatJournals()) { cell = new PdfPCell(new Paragraph(vatJournal.getCostType(), font)); subTable.addCell(cell); Paragraph chunkMoney = new Paragraph(AmountHelper.formatDecimal(vatJournal.getTotalAmount()), font); cell = new PdfPCell(chunkMoney); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); subTable.addCell(cell); } cell = new PdfPCell(new Paragraph("Totaal uit", headerFont)); subTable.addCell(cell); Paragraph chunkMoney = new Paragraph( AmountHelper.formatDecimal(vatReportData.getVatDeclarationData().getValueAddedTaxOnInput()), totalAmountFont); cell = new PdfPCell(chunkMoney); cell.setHorizontalAlignment(PdfPCell.ALIGN_RIGHT); cell.setBorder(PdfPCell.NO_BORDER); subTable.addCell(cell); tableCell = new PdfPCell(subTable); table.addCell(tableCell); }
From source file:org.totschnig.myexpenses.model.Account.java
License:Open Source License
private void addTransactionList(Document document, Cursor transactionCursor, PdfHelper helper, WhereFilter filter) throws DocumentException, IOException { String selection;//from w ww. j a v a 2 s .c o m String[] selectionArgs; if (!filter.isEmpty()) { selection = filter.getSelectionForParts(DatabaseConstants.VIEW_EXTENDED);//GROUP query uses extended view selectionArgs = filter.getSelectionArgs(true); } else { selection = null; selectionArgs = null; } Builder builder = Transaction.CONTENT_URI.buildUpon(); builder.appendPath(TransactionProvider.URI_SEGMENT_GROUPS).appendPath(grouping.name()); if (getId() < 0) { builder.appendQueryParameter(KEY_CURRENCY, currency.getCurrencyCode()); } else { builder.appendQueryParameter(KEY_ACCOUNTID, String.valueOf(getId())); } Cursor groupCursor = cr().query(builder.build(), null, selection, selectionArgs, KEY_YEAR + " ASC," + KEY_SECOND_GROUP + " ASC"); MyApplication ctx = MyApplication.getInstance(); int columnIndexGroupSumIncome = groupCursor.getColumnIndex(KEY_SUM_INCOME); int columnIndexGroupSumExpense = groupCursor.getColumnIndex(KEY_SUM_EXPENSES); int columnIndexGroupSumTransfer = groupCursor.getColumnIndex(KEY_SUM_TRANSFERS); int columIndexGroupSumInterim = groupCursor.getColumnIndex(KEY_INTERIM_BALANCE); int columnIndexRowId = transactionCursor.getColumnIndex(KEY_ROWID); int columnIndexYear = transactionCursor.getColumnIndex(KEY_YEAR); int columnIndexYearOfWeekStart = transactionCursor.getColumnIndex(KEY_YEAR_OF_WEEK_START); int columnIndexMonth = transactionCursor.getColumnIndex(KEY_MONTH); int columnIndexWeek = transactionCursor.getColumnIndex(KEY_WEEK); int columnIndexDay = transactionCursor.getColumnIndex(KEY_DAY); int columnIndexAmount = transactionCursor.getColumnIndex(KEY_AMOUNT); int columnIndexLabelSub = transactionCursor.getColumnIndex(KEY_LABEL_SUB); int columnIndexLabelMain = transactionCursor.getColumnIndex(KEY_LABEL_MAIN); int columnIndexComment = transactionCursor.getColumnIndex(KEY_COMMENT); int columnIndexReferenceNumber = transactionCursor.getColumnIndex(KEY_REFERENCE_NUMBER); int columnIndexPayee = transactionCursor.getColumnIndex(KEY_PAYEE_NAME); int columnIndexTransferPeer = transactionCursor.getColumnIndex(KEY_TRANSFER_PEER); int columnIndexDate = transactionCursor.getColumnIndex(KEY_DATE); DateFormat itemDateFormat; switch (grouping) { case DAY: itemDateFormat = android.text.format.DateFormat.getTimeFormat(ctx); break; case MONTH: itemDateFormat = new SimpleDateFormat("dd"); break; case WEEK: itemDateFormat = new SimpleDateFormat("EEE"); break; default: itemDateFormat = Utils.localizedYearlessDateFormat(); } PdfPTable table = null; int prevHeaderId = 0, currentHeaderId; transactionCursor.moveToFirst(); groupCursor.moveToFirst(); while (transactionCursor.getPosition() < transactionCursor.getCount()) { int year = transactionCursor .getInt(grouping.equals(Grouping.WEEK) ? columnIndexYearOfWeekStart : columnIndexYear); int month = transactionCursor.getInt(columnIndexMonth); int week = transactionCursor.getInt(columnIndexWeek); int day = transactionCursor.getInt(columnIndexDay); int second = -1; switch (grouping) { case DAY: currentHeaderId = year * 1000 + day; break; case WEEK: currentHeaderId = year * 1000 + week; break; case MONTH: currentHeaderId = year * 1000 + month; break; case YEAR: currentHeaderId = year * 1000; break; default: currentHeaderId = 1; } if (currentHeaderId != prevHeaderId) { if (table != null) { document.add(table); } switch (grouping) { case DAY: second = transactionCursor.getInt(columnIndexDay); break; case MONTH: second = transactionCursor.getInt(columnIndexMonth); break; case WEEK: second = transactionCursor.getInt(columnIndexWeek); break; } table = helper.newTable(2); table.setWidthPercentage(100f); PdfPCell cell = helper.printToCell(grouping.getDisplayTitle(ctx, year, second, transactionCursor), FontType.HEADER); table.addCell(cell); Long sumExpense = DbUtils.getLongOr0L(groupCursor, columnIndexGroupSumExpense); Long sumIncome = DbUtils.getLongOr0L(groupCursor, columnIndexGroupSumIncome); Long sumTransfer = DbUtils.getLongOr0L(groupCursor, columnIndexGroupSumTransfer); Long delta = sumIncome - sumExpense + sumTransfer; Long interimBalance = DbUtils.getLongOr0L(groupCursor, columIndexGroupSumInterim); Long previousBalance = interimBalance - delta; cell = helper.printToCell(String.format("%s %s %s = %s", Utils.convAmount(previousBalance, currency), Long.signum(delta) > -1 ? "+" : "-", Utils.convAmount(Math.abs(delta), currency), Utils.convAmount(interimBalance, currency)), FontType.HEADER); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell); document.add(table); table = helper.newTable(3); table.setWidthPercentage(100f); cell = helper.printToCell("+ " + Utils.convAmount(sumIncome, currency), FontType.NORMAL); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = helper.printToCell("- " + Utils.convAmount(sumExpense, currency), FontType.NORMAL); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = helper.printToCell("<-> " + Utils.convAmount(DbUtils.getLongOr0L(groupCursor, columnIndexGroupSumTransfer), currency), FontType.NORMAL); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); table.setSpacingAfter(2f); document.add(table); LineSeparator sep = new LineSeparator(); document.add(sep); table = helper.newTable(4); table.setWidths(new int[] { 1, 5, 3, 2 }); table.setSpacingBefore(2f); table.setSpacingAfter(2f); table.setWidthPercentage(100f); prevHeaderId = currentHeaderId; groupCursor.moveToNext(); } long amount = transactionCursor.getLong(columnIndexAmount); String catText = transactionCursor.getString(columnIndexLabelMain); PdfPCell cell = helper.printToCell( Utils.convDateTime(transactionCursor.getString(columnIndexDate), itemDateFormat), FontType.NORMAL); table.addCell(cell); if (DbUtils.getLongOrNull(transactionCursor, columnIndexTransferPeer) != null) { catText = ((amount < 0) ? "=> " : "<= ") + catText; } else { Long catId = DbUtils.getLongOrNull(transactionCursor, KEY_CATID); if (SPLIT_CATID.equals(catId)) { Cursor splits = cr().query(Transaction.CONTENT_URI, null, KEY_PARENTID + " = " + transactionCursor.getLong(columnIndexRowId), null, null); splits.moveToFirst(); catText = ""; while (splits.getPosition() < splits.getCount()) { String splitText = DbUtils.getString(splits, KEY_LABEL_MAIN); if (splitText.length() > 0) { if (DbUtils.getLongOrNull(splits, KEY_TRANSFER_PEER) != null) { splitText = "[" + splitText + "]"; } else { String label_sub = DbUtils.getString(splits, KEY_LABEL_SUB); if (label_sub.length() > 0) splitText += TransactionList.CATEGORY_SEPARATOR + label_sub; } } else { splitText = ctx.getString(R.string.no_category_assigned); } splitText += " " + Utils .convAmount(splits.getLong(splits.getColumnIndexOrThrow(KEY_AMOUNT)), currency); String splitComment = DbUtils.getString(splits, KEY_COMMENT); if (splitComment != null && splitComment.length() > 0) { splitText += " (" + splitComment + ")"; } catText += splitText; if (splits.getPosition() != splits.getCount() - 1) { catText += "; "; } splits.moveToNext(); } splits.close(); } else if (catId == null) { catText = ctx.getString(R.string.no_category_assigned); } else { String label_sub = transactionCursor.getString(columnIndexLabelSub); if (label_sub != null && label_sub.length() > 0) { catText = catText + TransactionList.CATEGORY_SEPARATOR + label_sub; } } } String referenceNumber = transactionCursor.getString(columnIndexReferenceNumber); if (referenceNumber != null && referenceNumber.length() > 0) catText = "(" + referenceNumber + ") " + catText; cell = helper.printToCell(catText, FontType.NORMAL); String payee = transactionCursor.getString(columnIndexPayee); if (payee == null || payee.length() == 0) { cell.setColspan(2); } table.addCell(cell); if (payee != null && payee.length() > 0) { table.addCell(helper.printToCell(payee, FontType.UNDERLINE)); } FontType t = amount < 0 ? FontType.EXPENSE : FontType.INCOME; cell = helper.printToCell(Utils.convAmount(amount, currency), t); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(cell); String comment = transactionCursor.getString(columnIndexComment); if (comment != null && comment.length() > 0) { cell = helper.printToCell(comment, FontType.ITALIC); cell.setColspan(2); table.addCell(helper.emptyCell()); table.addCell(cell); table.addCell(helper.emptyCell()); } transactionCursor.moveToNext(); } // now add all this to the document document.add(table); groupCursor.close(); }
From source file:Output.QuotePDf.java
private PdfPTable shipperInformationTable(String personnelInformation) throws DocumentException { PdfPTable table = new PdfPTable(4); table.setHorizontalAlignment(Element.ALIGN_LEFT); float[] columnWidths = new float[] { 30f, 70f, 20f, 80f }; table.setWidths(columnWidths); cell = new PdfPCell(new Phrase("Quote ID:", labelFont)); cell.setColspan(1);/* ww w . ja v a 2s. c om*/ cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(quoteID, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Date:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(date, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Company:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(company, textFont)); cell.setColspan(3); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Customer:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(customerName, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Email:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(customerEmail, emailTextFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Quote Type:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(status, textFont)); cell.setColspan(3); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Quoted By:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(personnelInformation, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Email:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(groupEmail, emailTextFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); return table; }
From source file:Output.QuotePDf.java
private PdfPTable commodityTable() throws DocumentException { PdfPTable table = new PdfPTable(4); table.setHorizontalAlignment(Element.ALIGN_LEFT); float[] columnWidths = new float[] { 55f, 70f, 55f, 65f }; table.setWidths(columnWidths); cell = new PdfPCell(new Phrase("Port(s) of Load:", labelFont)); cell.setColspan(1);/*from w w w . j av a 2s . co m*/ cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(pol, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("via:", labelFont)); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(tship, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Port(s) of Discharge:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(pod, textFont)); cell.setColspan(3); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Commodity:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(commodityClass, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Handling:", labelFont)); cell.setColspan(1); cell.setHorizontalAlignment(Element.ALIGN_RIGHT); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(cargoHandling, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Accompanying:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); if (accessories) { cell = new PdfPCell(new Phrase(accessories_accompanying, textFont)); cell.setColspan(3); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); } else { cell = new PdfPCell(new Phrase("N/A", textFont)); cell.setColspan(3); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); } cell = new PdfPCell(new Phrase("Description", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(description, textFont)); cell.setColspan(3); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); return table; }
From source file:Output.QuotePDf.java
private PdfPTable rateTable() throws DocumentException { PdfPTable table = new PdfPTable(2); table.setHorizontalAlignment(Element.ALIGN_LEFT); float[] columnWidths = new float[] { 35f, 75f }; table.setWidths(columnWidths); table.setSpacingAfter(10f);// w w w . j a va 2s . c o m cell = new PdfPCell(new Phrase("Base Ocean Freight:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(oft, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("MAFI Minimum Charge:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); if (includeMafiMinimum) { cell = new PdfPCell(new Phrase("$" + mafiMinimum + " per MAFI unit.", textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); } else { cell = new PdfPCell(new Phrase("N/A", textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); } cell = new PdfPCell(new Phrase("Subject To:", subjectToFont)); cell.setColspan(2); cell.setBorder(Rectangle.NO_BORDER); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Bunker Adjustment Factor:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(baf, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("ECA Surcharge:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(eca, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Terminal Handling (Origin):", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(thc, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Wharfage (Origin):", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(wfg, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("Documentation Fee:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase(doc, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); cell = new PdfPCell(new Phrase("War Risk Surcharge:", labelFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); if (includeWarRisk) { cell = new PdfPCell(new Phrase(wRsk, textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); } else { cell = new PdfPCell(new Phrase("N/A", textFont)); cell.setColspan(1); cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell); } return table; }
From source file:Output.QuotePDf.java
private PdfPTable packingListTable(JTable packingListTable) throws DocumentException { PdfPTable table = new PdfPTable(11); table.setHorizontalAlignment(Element.ALIGN_LEFT); table.setWidthPercentage(100f);/*from w w w.j av a 2s. com*/ table.setWidths(new int[] { 5, 2, 2, 2, 2, 3, 2, 2, 2, 3, 3 }); table.setSpacingAfter(10f); cell = new PdfPCell(new Phrase("Packing List", tableHeadingFont)); cell.setBackgroundColor(BaseColor.BLACK); cell.setColspan(11); cell.setPaddingBottom(5); cell.setHorizontalAlignment(Element.ALIGN_CENTER); table.addCell(cell); cell = new PdfPCell(new Phrase("Commodity", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("Qty", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("L(cm)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("W(cm)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("H(cm)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("Kgs", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("L(in)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("W(in)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("H(in)", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("M3", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); cell = new PdfPCell(new Phrase("Lbs", plLabelFont)); cell.setBackgroundColor(BaseColor.LIGHT_GRAY); cell.setPaddingBottom(5); table.addCell(cell); for (int row = 0; row < packingListTable.getRowCount(); row++) { for (int col = 0; col < 11; col++) { String packingListData = String.valueOf(packingListTable.getValueAt(row, col)); if (packingListData.equals("null")) { packingListData = " "; cell = new PdfPCell(new Phrase(packingListData, textFont)); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); } else { cell = new PdfPCell(new Phrase(packingListData, textFont)); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_LEFT); table.addCell(cell); } } } return table; }
From source file:pdf.FooterHeader.java
License:Open Source License
@Override public void onEndPage(PdfWriter writer, Document document) { PdfPTable table = new PdfPTable(3); try {// w w w. j a v a 2s . c o m if (document.getPageNumber() > 1) { table.setWidths(new int[] { 24, 24, 2 }); table.setTotalWidth(527); table.setLockedWidth(true); table.getDefaultCell().setFixedHeight(20); table.getDefaultCell().setBorder(Rectangle.BOTTOM); table.addCell(header); table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT); table.addCell(String.format("Seite %d von", writer.getPageNumber())); PdfPCell cell = new PdfPCell(Image.getInstance(total)); cell.setBorder(Rectangle.BOTTOM); table.addCell(cell); table.writeSelectedRows(0, -1, 34, 803, writer.getDirectContent()); } } catch (DocumentException de) { throw new ExceptionConverter(de); } PdfContentByte cb = writer.getDirectContent(); if (document.getPageNumber() > 1) { footer = new Phrase(document.getPageNumber() - 2); ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, footer, (document.right() - document.left() - 30) / 2 + document.leftMargin(), document.bottom() + 10, 0); } }
From source file:PDF.GenerateReportActivities.java
private PdfPTable TablaDatos() throws Exception { PdfPTable Datos_prof = new PdfPTable(5); Datos_prof.setWidths(new int[] { 2, 3, 2, 2, 2 }); PdfPCell Titulo_tabla = new PdfPCell(new Phrase("Datos generales del Profesor", encabezadost)); PdfPCell Nombre = new PdfPCell(new Phrase("Nombre del Profesor")); PdfPCell Matricula = new PdfPCell(new Phrase("No. de Empleado")); PdfPCell UA = new PdfPCell(new Phrase("Unidad Acadmica")); PdfPCell Puntos = new PdfPCell(new Phrase("Puntos obtenidos")); PdfPCell Nivel = new PdfPCell(new Phrase("Nivel de Beca")); Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER); Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE); Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76)); Titulo_tabla.setColspan(5);//w w w . j a v a 2s . co m Titulo_tabla.setExtraParagraphSpace(15f); Datos_prof.addCell(Titulo_tabla); Nombre.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(Nombre); Matricula.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(Matricula); UA.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(UA); Puntos.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(Puntos); Nivel.setHorizontalAlignment(Element.ALIGN_CENTER); Datos_prof.addCell(Nivel); /*Aqui van las consultas de los datos del profesor*/ ResultSet rn, rt; String nom_usuario = null, id_usuario = null, u_a = null, puntaje_final = null, nivel = null; //Datos_prof.addCell("Hola"); ResultSet rp = lb.executeQuery("SELECT * FROM usuario WHERE id_usuario = " + username); while (rp.next()) { nom_usuario = rp.getString("nom_usuario"); id_usuario = rp.getString("id_usuario"); u_a = rp.getString("u_a"); } System.out.println(getUsername()); rn = lb.executeQuery( "SELECT * FROM evaluador_evalua_profesor WHERE id_usuario_prof = '" + getUsername() + "'"); while (rn.next()) { puntaje_final = rn.getString("puntaje_final"); //Datos_prof.addCell(rn.getString("puntaje_final")); } rt = lb.executeQuery("SELECT * FROM profesor WHERE id_usuario = '" + getUsername() + "'"); while (rt.next()) { nivel = rt.getString("nivel"); } Datos_prof.addCell(nom_usuario); Datos_prof.addCell(id_usuario); Datos_prof.addCell(u_a); Datos_prof.addCell(puntaje_final); Datos_prof.addCell(nivel); return Datos_prof; }
From source file:PDF.GenerateReportActivities.java
private PdfPTable dospuntouno() throws Exception { PdfPTable Dos_uno = new PdfPTable(6); Dos_uno.setWidths(new int[] { 2, 2, 3, 2, 2, 2 }); PdfPCell Titulo_tabla = new PdfPCell(new Phrase( "Actividad 2.1" + " - Formacin de Recursos Humanos para la Investigacin", encabezadost)); PdfPCell Nom_Proyecto = new PdfPCell(new Phrase("Nmero de proyecto SIP")); PdfPCell Num_Actividad = new PdfPCell(new Phrase("Nmero de Actividad")); PdfPCell Tipo_Actividad = new PdfPCell(new Phrase("Tipo de Actividad")); PdfPCell Ruta_alm = new PdfPCell(new Phrase("Evidencia")); PdfPCell Puntos = new PdfPCell(new Phrase("Puntos obtenidos")); PdfPCell Observaciones = new PdfPCell(new Phrase("Observaciones")); //PdfPCell celda=new PdfPCell(); Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER); Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE); Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76)); Titulo_tabla.setColspan(6);//from www . jav a 2s .co m Titulo_tabla.setExtraParagraphSpace(15f); Dos_uno.addCell(Titulo_tabla); Nom_Proyecto.setHorizontalAlignment(Element.ALIGN_CENTER); Nom_Proyecto.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Nom_Proyecto); Num_Actividad.setHorizontalAlignment(Element.ALIGN_CENTER); Num_Actividad.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Num_Actividad); Tipo_Actividad.setHorizontalAlignment(Element.ALIGN_CENTER); Tipo_Actividad.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Tipo_Actividad); Ruta_alm.setHorizontalAlignment(Element.ALIGN_CENTER); Ruta_alm.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Ruta_alm); Puntos.setHorizontalAlignment(Element.ALIGN_CENTER); Puntos.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Puntos); Observaciones.setHorizontalAlignment(Element.ALIGN_CENTER); Observaciones.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_uno.addCell(Observaciones); /*Aqui van las consultas de las Actividades del profesor*/ /**Get actual period***/ int periodo = 0; ResultSet rperiodo = lb.executeQuery("SELECT * FROM profesor WHERE id_usuario = " + getUsername()); if (rperiodo.next()) periodo = rperiodo.getInt("periodo"); /**Get actual period***/ String id_al = null, tipo_alumno = null, puntaje = null, comen = null, nom_proyecto = null; ResultSet rb = lb .executeQuery("SELECT * FROM profesor_tiene_proyecto WHERE " + "id_usuario = " + getUsername() + " AND (validado_alumno = 1 OR validado_alumno = 0) AND " + "periodo = " + periodo); while (rb.next()) { nom_proyecto = rb.getString("id_proyecto"); Dos_uno.addCell(nom_proyecto); id_al = rb.getString("id_alumno"); Dos_uno.addCell(id_al); tipo_alumno = rb.getString("tipo_alumno"); Dos_uno.addCell(tipo_alumno); Anchor anchor = new Anchor("Constancia"); //anchor.setReference("file:///"+rb.getString("ruta_alm")); anchor.setReference(rb.getString("ruta_alumno")); Dos_uno.addCell(anchor); puntaje = rb.getString("puntaje_alumno"); Dos_uno.addCell(puntaje); comen = rb.getString("comentarios"); Dos_uno.addCell(comen); } return Dos_uno; }
From source file:PDF.GenerateReportActivities.java
private PdfPTable dospuntodos() throws Exception { PdfPTable Dos_dos = new PdfPTable(5); Dos_dos.setWidths(new int[] { 2, 2, 3, 2, 3 }); PdfPCell Titulo_tabla = new PdfPCell( new Phrase("Actividad 2.2" + " - Publicaciones Cientficas y/o de Divulgacin", encabezadost)); PdfPCell Num_Actividad = new PdfPCell(new Phrase("Nmero de Actividad")); PdfPCell Tipo_Actividad = new PdfPCell(new Phrase("Tipo de Actividad* (Consultar parte de abajo)")); PdfPCell Ruta_alm = new PdfPCell(new Phrase("Evidencia")); PdfPCell Puntos = new PdfPCell(new Phrase("Puntos obtenidos")); PdfPCell Observaciones = new PdfPCell(new Phrase("Observaciones")); PdfPCell celda = new PdfPCell(); Titulo_tabla.setHorizontalAlignment(Element.ALIGN_CENTER); Titulo_tabla.setVerticalAlignment(Element.ALIGN_MIDDLE); Titulo_tabla.setBackgroundColor(new BaseColor(153, 0, 76)); Titulo_tabla.setColspan(5);/*w w w. j av a2 s . c o m*/ Titulo_tabla.setExtraParagraphSpace(15f); Dos_dos.addCell(Titulo_tabla); Num_Actividad.setHorizontalAlignment(Element.ALIGN_CENTER); Num_Actividad.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_dos.addCell(Num_Actividad); Tipo_Actividad.setHorizontalAlignment(Element.ALIGN_CENTER); Tipo_Actividad.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_dos.addCell(Tipo_Actividad); Ruta_alm.setHorizontalAlignment(Element.ALIGN_CENTER); Ruta_alm.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_dos.addCell(Ruta_alm); Puntos.setHorizontalAlignment(Element.ALIGN_CENTER); Puntos.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_dos.addCell(Puntos); Observaciones.setHorizontalAlignment(Element.ALIGN_CENTER); Observaciones.setVerticalAlignment(Element.ALIGN_MIDDLE); Dos_dos.addCell(Observaciones); /*Aqui van las consultas de las Actividades del profesor*/ int periodo = 0; ResultSet rperiodo = lb.executeQuery("SELECT * FROM profesor WHERE id_usuario = " + getUsername()); if (rperiodo.next()) periodo = rperiodo.getInt("periodo"); /**Get actual period***/ String id_pub = null, id_tipo = null, puntaje = null, coment = null; ResultSet rb = lb.executeQuery("SELECT * FROM profesor_tiene_pub WHERE " + "id_usuario = '" + getUsername() + "' AND (validado = 1 OR validado = 0) AND (id_tipo_pub = 1 " + "OR id_tipo_pub = 2 OR id_tipo_pub = 3 OR id_tipo_pub = 4 OR id_tipo_pub = 5) AND " + "periodo = " + periodo); while (rb.next()) { id_pub = rb.getString("id_publicacion"); Dos_dos.addCell(id_pub); id_tipo = rb.getString("id_tipo_pub"); Dos_dos.addCell(id_tipo);//Add the type of every type pub Anchor anchor = new Anchor("Constancia"); anchor.setReference(rb.getString("ruta_alm")); //anchor.setReference("file:///"+rb.getString("ruta_alm")); Dos_dos.addCell(anchor); puntaje = rb.getString("puntaje"); Dos_dos.addCell(puntaje); coment = rb.getString("comentarios"); Dos_dos.addCell(coment); } return Dos_dos; }