Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除表iText java的左右边距_Itext - Fatal编程技术网

删除表iText java的左右边距

删除表iText java的左右边距,itext,Itext,我对表格左右两侧的固定的边距有问题 我想删除该页边距,并使用所有没有边距或填充的纸张。我该怎么办 我刚刚尝试过这一点,但不适用于我: cell.setPaddingLeft(0); cell.setBorderWidthLeft(0); cell.setLeft(0); 这对我来说很有用,但是单元格的边框不跟随文本 (看下面的表格) 这是我代码的一部分: Font fontStandard = FontFactory.getFont("Arial", 8); int w[

我对表格左右两侧的固定的边距有问题

我想删除该页边距,并使用所有没有边距或填充的纸张。我该怎么办

我刚刚尝试过这一点,但不适用于我:

cell.setPaddingLeft(0);
cell.setBorderWidthLeft(0);
cell.setLeft(0);
这对我来说很有用,但是单元格的边框不跟随文本 (看下面的表格)

这是我代码的一部分:

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);
这就是我想要的。

默认情况下,由
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)
为了避免这些额外的利润

此外,添加到
文档的
PdfPTable
实例尊重文档边距值。要使用(几乎)整个页面作为要填充表的页面内容区域,必须使用带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)
还是二传手

/**
 * 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)

您是否已使用
PdfPTable
方法
setWidthPercentage
设置了表格在页面中所占的宽度百分比?否,我可以试试。好的,我已经试过了,但它不起作用。差距仍然存在@mklYou不显示如何创建文档。您是否相应地减少了文档边距?默认情况下,边距为36磅,即半英寸。您可以使用
文档(矩形pageSize、float-marginLeft、float-marginRight、float-marginTop、float-marginBottom)
构造函数显式选择它们,并且可以使用
文档.setMargins(float-marginLeft、float-marginRight、float-marginTop、float-marginBottom)方法更改它们。
/**
 * 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)