我在表的左右两侧有固定边距的问题.我正在使用Struts2开展一个项目.
我想删除该边距并使用没有边距或填充的所有工作表.我该怎么办?
我刚试过这个,但对我不起作用:
cell.setPaddingLeft(0);
cell.setBorderWidthLeft(0);
cell.setLeft(0);
Run Code Online (Sandbox Code Playgroud)
这适用于我,但单元格的边框,不遵循文本(查看底部的表格)
cell.setPaddingLeft(-50);
Run Code Online (Sandbox Code Playgroud)
这是我的代码的一部分:
Font fontStandard = FontFactory.getFont("Arial", 8);
int w[] = { 50, 50 };
PdfPTable tableInner = new PdfPTable(5);
tableInner.setWidths(w);
cell = new PdfPCell(new Phrase("PADDING -50", fontStandard));
cell.setHorizontalAlignment(PdfPCell.ALIGN_LEFT);
/******/
//cell.setPaddingLeft(0);
//cell.setBorderWidthLeft(0);
//cell.setLeft(0);
cell.setPaddingLeft(-50);
/******/
tableInner.addCell(cell);
document.add(tableInner);
Run Code Online (Sandbox Code Playgroud)
默认情况下,PdfPTable对象绘制的表仅填充页面内容区域宽度的80%.您可以使用该PdfPTable方法更改此比率
/**
* Sets the width percentage that the table will occupy in the page.
*
* @param widthPercentage the width percentage that the table will occupy in
* the page
*/
public void setWidthPercentage(final float widthPercentage)
Run Code Online (Sandbox Code Playgroud)
避免这些额外的利润.
此外,PdfPTable添加到的实例Document尊重文档边距值.要使用(几乎)整个页面作为要填充的表的页面内容区域,必须使用带有5个参数的构造函数将文档边距减少到(接近)0
/**
* Constructs a new <CODE>Document</CODE>-object.
*
* @param pageSize the pageSize
* @param marginLeft the margin on the left
* @param marginRight the margin on the right
* @param marginTop the margin on the top
* @param marginBottom the margin on the bottom
*/
public Document(Rectangle pageSize, float marginLeft, float marginRight, float marginTop, float marginBottom)
Run Code Online (Sandbox Code Playgroud)
或者是二传手
/**
* Sets the margins.
*
* @param marginLeft the margin on the left
* @param marginRight the margin on the right
* @param marginTop the margin on the top
* @param marginBottom the margin on the bottom
* @return a <CODE>boolean</CODE>
*/
public boolean setMargins(float marginLeft, float marginRight, float marginTop, float marginBottom)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7961 次 |
| 最近记录: |