本文整理汇总了Java中com.lowagie.text.pdf.PdfPTable.setWidthPercentage方法的典型用法代码示例。如果您正苦于以下问题:Java PdfPTable.setWidthPercentage方法的具体用法?Java PdfPTable.setWidthPercentage怎么用?Java PdfPTable.setWidthPercentage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lowagie.text.pdf.PdfPTable
的用法示例。
在下文中一共展示了PdfPTable.setWidthPercentage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeColumns
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void writeColumns(PDFDocument document, PdfPTable tb)
{
PdfPTable tabla = new PdfPTable(anchoColumnas);
tabla.setWidthPercentage(100);
// this.tabla.setSplitRows(true);
Font font = document.getContext().getDefaultFont();
PdfPCell cell;
cell = createCell("",Rectangle.LEFT | Rectangle.RIGHT);
tabla.addCell(cell);
for(int i=0; i<columnas.size(); i++)
{
cell = createCell((String)columnas.get(i),document.getContext().getColor(204,204,204),
Rectangle.ALIGN_CENTER,font);
tabla.addCell(cell);
}
cell = createCell("",Rectangle.LEFT | Rectangle.RIGHT);
tabla.addCell(cell);
addTabla(tb,tabla);
}
示例2: writeCampos
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void writeCampos(PDFDocument document, PdfPTable tb)
{
PdfPTable tabla = new PdfPTable(anchoColumnas);
PdfPCell cell;
tabla.setWidthPercentage(100);
Font font = document.getContext().getDefaultFont();
for(int i=0; i<campos.size();i++)
{
cell = createCell("",Rectangle.LEFT | Rectangle.RIGHT);
tabla.addCell(cell);
Vector cp = (Vector)campos.get(i);
for(int j=0; j<cp.size(); j++)
{
cell = createCell((String)cp.get(j),font);
tabla.addCell(cell);
}
cell = createCell("",Rectangle.LEFT | Rectangle.RIGHT);
tabla.addCell(cell);
}
addTabla(tb,tabla);
}
示例3: createNeedHeader
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private PdfPTable createNeedHeader(String name) throws DocumentException {
Font whiteFont = new Font(Font.HELVETICA,14,Font.BOLD,Color.WHITE);
PdfPTable table = new PdfPTable(3);
table.setWidthPercentage(100);
table.setWidths(new float[]{0.10f,0.20f,0.70f});
PdfPCell emptyCell = new PdfPCell();
emptyCell.setBorder(0);
table.addCell(emptyCell);
PdfPCell headerCell = new PdfPCell();
headerCell.setColspan(2);
headerCell.setPhrase(new Phrase(name,whiteFont));
headerCell.setHorizontalAlignment(Element.ALIGN_CENTER);
headerCell.setBackgroundColor(Color.LIGHT_GRAY);
table.addCell(headerCell);
return table;
}
开发者ID:williamgrosset,项目名称:OSCAR-ConCert,代码行数:18,代码来源:SummaryOfActionsAndCommentsReportGenerator.java
示例4: writeGraph
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void writeGraph() throws IOException, DocumentException {
final JRobin jrobin = collector.getJRobin(graphName);
if (jrobin != null) {
final byte[] img = jrobin.graph(range, 960, 400);
final Image image = Image.getInstance(img);
image.scalePercent(50);
final PdfPTable table = new PdfPTable(1);
table.setHorizontalAlignment(Element.ALIGN_CENTER);
table.setWidthPercentage(100);
table.getDefaultCell().setBorder(0);
table.addCell("\n");
table.addCell(image);
table.getDefaultCell().setHorizontalAlignment(Element.ALIGN_RIGHT);
table.addCell(new Phrase(getString("graph_units"), cellFont));
addToDocument(table);
} else {
// just in case request is null and collector.getJRobin(graphName) is null, we must write something in the document
addToDocument(new Phrase("\n", cellFont));
}
}
示例5: addResultExample
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void addResultExample(Section section, ApiDoc apiDoc) throws Exception {
Paragraph result = new Paragraph(itemFont.process("★返回示例"));
// result.setLeading(6f);
result.setSpacingBefore(6f);
result.setSpacingAfter(8f);
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(95f);
table.setHorizontalAlignment(Element.ALIGN_LEFT);
PdfPCell pdfPCell = table.getDefaultCell();
pdfPCell.setHorizontalAlignment(Element.ALIGN_LEFT);
pdfPCell.setBackgroundColor(Color.LIGHT_GRAY);
if (apiDoc.getResultDoc() != null && apiDoc.getResultExample() != null) {
pdfPCell.setPhrase(DefaultPdfTable.tableBSelector.process(apiDoc.getResultExample()));
}
table.addCell(pdfPCell);
Paragraph wrapperTable = new Paragraph();
wrapperTable.setSpacingAfter(8f);
wrapperTable.setIndentationLeft(12f);
wrapperTable.add(table);
section.add(result);
section.add(wrapperTable);
}
示例6: onEndPage
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
@Override
public void onEndPage(PdfWriter writer, Document document) {
try {
Rectangle page = document.getPageSize();
PdfPTable footer = new PdfPTable(1);
footer.setWidthPercentage(100);
footer.setSpacingBefore(20);
PdfPCell footerPageNocell = new PdfPCell(new Paragraph(fontFamilySelector.process(messageSource.getMessage("hrms.payroll.computer.generated.payslip.not.require.signature", null, RequestContextUtils.getLocale(request)), FontContext.SMALL_NORMAL_TIMES_NEW_ROMAN)));
footerPageNocell.setBorder(0);
footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
footer.addCell(footerPageNocell);
footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin()+2 , writer.getDirectContent());
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例7: onEndPage
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
@Override
public void onEndPage(PdfWriter writer, Document document) {
try {
Rectangle page = document.getPageSize();
PdfPTable footer = new PdfPTable(1);
footer.setWidthPercentage(100);
footer.setSpacingBefore(20);
String FootPager = String.valueOf(document.getPageNumber());//current page no
PdfPCell footerPageNocell = new PdfPCell(new Phrase(fontFamilySelector.process(FootPager, FontContext.SMALL_BOLD_HELVETICA)));
footerPageNocell.setBorder(0);
footerPageNocell.setPaddingBottom(5);
footerPageNocell.setHorizontalAlignment(PdfPCell.ALIGN_CENTER);
footer.addCell(footerPageNocell);
footer.setTotalWidth(page.getWidth() - document.leftMargin() - document.rightMargin());
footer.writeSelectedRows(0, -1, document.leftMargin(), document.bottomMargin() - 5, writer.getDirectContent());
} catch (Exception e) {
throw new ExceptionConverter(e);
}
}
示例8: addComponyLogo
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private static void addComponyLogo(Document d, HttpServletRequest req) throws ConfigurationException, DocumentException {
PdfPTable table = new PdfPTable(1);
imgPath = StorageHandler.GetProfileImgStorePath() + "logo.gif";
table.setHorizontalAlignment(Element.ALIGN_LEFT);
table.setWidthPercentage(50);
PdfPCell cell = null;
try {
if(StringUtil.isStandAlone()){
imgPath = URLUtil.getPageURL(req, "").concat(defaultCompanyImgPath);
}
Image img = Image.getInstance(imgPath);
cell = new PdfPCell(img);
} catch (Exception e) {
cell = new PdfPCell(new Paragraph(companyName, fontBig));
}
cell.setBorder(0);
cell.setHorizontalAlignment(Element.ALIGN_LEFT);
table.addCell(cell);
d.add(table);
}
示例9: createTable
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void createTable() {
iPdfTable = new PdfPTable(getNrColumns());
iPdfTable.setWidthPercentage(100);
iPdfTable.getDefaultCell().setPadding(3);
iPdfTable.getDefaultCell().setBorderWidth(1);
iPdfTable.setSplitRows(false);
iPdfTable.setSpacingBefore(10);
if (iTable.isDispModePerWeek()) {
iPdfTable.setKeepTogether(true);
}
}
示例10: createTable
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void createTable(boolean keepTogether) {
iPdfTable = new PdfPTable(getNrColumns());
iPdfTable.setWidthPercentage(100);
iPdfTable.getDefaultCell().setPadding(3);
iPdfTable.getDefaultCell().setBorderWidth(1);
iPdfTable.setSplitRows(false);
iPdfTable.setSpacingBefore(10);
iPdfTable.setKeepTogether(keepTogether);
}
示例11: buildTable
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
public PdfPTable buildTable() {
if (rows.isEmpty())
return new PdfPTable(1);
int ncol = 0;
ArrayList c0 = (ArrayList)rows.get(0);
for (int k = 0; k < c0.size(); ++k) {
ncol += ((PdfPCell)c0.get(k)).getColspan();
}
PdfPTable table = new PdfPTable(ncol);
String width = (String)props.get("width");
if (width == null)
table.setWidthPercentage(100);
else {
if (width.endsWith("%"))
table.setWidthPercentage(Float.parseFloat(width.substring(0, width.length() - 1)));
else {
table.setTotalWidth(Float.parseFloat(width));
table.setLockedWidth(true);
}
}
for (int row = 0; row < rows.size(); ++row) {
ArrayList col = (ArrayList)rows.get(row);
for (int k = 0; k < col.size(); ++k) {
table.addCell((PdfPCell)col.get(k));
}
}
return table;
}
示例12: main
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
/**
* Width manipulations of cells.
*
*/
@Test
public void main() throws Exception {
// step1
Document document = new Document(PageSize.A4, 36, 36, 36, 36);
// step2
PdfWriter.getInstance(document, PdfTestBase.getOutputStream("CellWidths.pdf"));
// step3
document.open();
// step4
float[] widths = { 0.1f, 0.1f, 0.05f, 0.75f };
PdfPTable table = new PdfPTable(widths);
table.addCell("10%");
table.addCell("10%");
table.addCell("5%");
table.addCell("75%");
table.addCell("aa");
table.addCell("aa");
table.addCell("a");
table.addCell("aaaaaaaaaaaaaaa");
table.addCell("bb");
table.addCell("bb");
table.addCell("b");
table.addCell("bbbbbbbbbbbbbbb");
table.addCell("cc");
table.addCell("cc");
table.addCell("c");
table.addCell("ccccccccccccccc");
document.add(table);
document.add(new Paragraph("We change the percentages:\n\n"));
widths[0] = 20f;
widths[1] = 20f;
widths[2] = 10f;
widths[3] = 50f;
table.setWidths(widths);
document.add(table);
widths[0] = 40f;
widths[1] = 40f;
widths[2] = 20f;
widths[3] = 300f;
Rectangle r = new Rectangle(PageSize.A4.getRight(72), PageSize.A4.getTop(72));
table.setWidthPercentage(widths, r);
document.add(new Paragraph("We change the percentage using absolute widths:\n\n"));
document.add(table);
document.add(new Paragraph("We use a locked width:\n\n"));
table.setTotalWidth(300);
table.setLockedWidth(true);
document.add(table);
// step5
document.close();
}
示例13: printAppointmentHistory
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
public void printAppointmentHistory() throws DocumentException {
if( newPage ) {
document.newPage();
newPage=false;
}
List<Appointment> appts = appointmentDao.getAppointmentHistory(demographic.getDemographicNo());
PdfPTable table = new PdfPTable(6);
table.setWidthPercentage(100f);
table.getDefaultCell().setBorder(PdfPCell.NO_BORDER);
table.addCell("Date");
table.addCell("From");
table.addCell("To");
table.addCell("Reason");
table.addCell("Provider");
table.addCell("Notes");
for(Appointment appt:appts) {
table.addCell(generalCellForApptHistory(formatter.format(appt.getAppointmentDate())));
table.addCell(generalCellForApptHistory(timeFormatter.format(appt.getStartTime())));
table.addCell(generalCellForApptHistory(timeFormatter.format(appt.getEndTime())));
table.addCell(generalCellForApptHistory(appt.getReason()));
table.addCell(generalCellForApptHistory(providerDao.getProvider(appt.getProviderNo()).getFormattedName()));
table.addCell(generalCellForApptHistory(appt.getNotes()));
}
getDocument().add(table);
}
示例14: printPdf
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
public void printPdf() throws IOException, DocumentException{
// check that we have data to print
if (handler == null)
throw new DocumentException();
//response.setContentType("application/pdf"); //octet-stream
//response.setHeader("Content-Disposition", "attachment; filename=\""+handler.getPatientName().replaceAll("\\s", "_")+"_LabReport.pdf\"");
//Create the document we are going to write to
document = new Document();
//PdfWriter writer = PdfWriter.getInstance(document, response.getOutputStream());
// PdfWriter writer = PdfWriter.getInstance(document, os);
PdfWriter writer = PdfWriterFactory.newInstance(document, os, FontSettings.HELVETICA_10PT);
//Set page event, function onEndPage will execute each time a page is finished being created
writer.setPageEvent(this);
document.setPageSize(PageSize.LETTER);
document.addTitle("Title of the Document");
document.addCreator("OSCAR");
document.open();
//Create the fonts that we are going to use
bf = BaseFont.createFont(BaseFont.TIMES_ROMAN, BaseFont.CP1252, BaseFont.NOT_EMBEDDED);
font = new Font(bf, 9, Font.NORMAL);
boldFont = new Font(bf, 10, Font.BOLD);
// redFont = new Font(bf, 9, Font.NORMAL, Color.RED);
// add the header table containing the patient and lab info to the document
createInfoTable();
// add the tests and test info for each header
ArrayList<String> headers = handler.getHeaders();
for (int i=0; i < headers.size(); i++)
addLabCategory( headers.get(i) ,null);
for(MessageHandler extraHandler:handlers) {
ArrayList<String> extraHeaders = extraHandler.getHeaders();
for (int i=0; i < extraHeaders.size(); i++)
addLabCategory( extraHeaders.get(i) , extraHandler);
}
// add end of report table
PdfPTable table = new PdfPTable(1);
table.setWidthPercentage(100);
PdfPCell cell = new PdfPCell();
cell.setBorder(0);
cell.setPhrase(new Phrase(" "));
table.addCell(cell);
cell.setBorder(15);
cell.setBackgroundColor(new Color(210, 212, 255));
cell.setPhrase(new Phrase("END OF REPORT", boldFont));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setVerticalAlignment(Element.ALIGN_MIDDLE);
table.addCell(cell);
document.add(table);
document.close();
os.flush();
}
示例15: insertSaveAsButton
import com.lowagie.text.pdf.PdfPTable; //导入方法依赖的package包/类
private void insertSaveAsButton( Document document, PdfWriter writer, String name, String dataSetName )
throws DocumentException
{
boolean hasBorder = false;
// Button Table
PdfPTable tableButton = new PdfPTable( 1 );
tableButton.setWidthPercentage( 20.0f );
float buttonHeight = PdfDataEntryFormUtil.UNITSIZE_DEFAULT + 5;
tableButton.setHorizontalAlignment( Element.ALIGN_CENTER );
//FIXME
String jsAction = "var newFileName = this.getField(\"" + PdfDataEntryFormUtil.LABELCODE_PERIODID + "\").value + ' ' + "
+ " this.getField(\"" + PdfDataEntryFormUtil.LABELCODE_ORGID + "\").value + ' ' + "
+ " \"" + dataSetName + ".pdf\";"
+ "var returnVal = app.alert('This will save this PDF file as ' + newFileName + '. Do you want to Continue?', 1, 2);"
+ "if(returnVal == 4) { "
+ " var aMyPath = this.path.split(\"/\");"
+ " aMyPath.pop();"
+ " aMyPath.push(newFileName);"
+ " this.saveAs(aMyPath.join(\"/\"));"
+ " this.saveAs({cPath:cMyPath, bPromptToOverwrite:true});"
+ " app.alert('File Saved.', 1);"
+ "} ";
addCell_WithPushButtonField( tableButton, writer, PdfDataEntryFormUtil.getPdfPCell( buttonHeight, PdfDataEntryFormUtil.CELL_COLUMN_TYPE_ENTRYFIELD, hasBorder ), name, jsAction );
document.add( tableButton );
}