newLine() 在 apache pdfBox 中占据多少高度?
How much height does a newLine() occupy in apache pdfBox?
我想在生成 pdf 时跟踪 y 坐标。
这就是我目前的做法。
PDRectangle mediabox = page.findMediaBox();
float margin = 15;
float y = mediabox.getUpperRightY() - margin;
float fontSize = 10f;
PDType1Font font = PDType1Font.HELVETICA;
contentStream.showText("Hello");
y = y - fontSize; //decrease y-coordinate
contentStream.newLine(); //go to new line
contentStream.showText("World!");
y = y - fontSize; //decrease y-coordinate
新行的高度是多少,以便我可以精确跟踪 y 坐标?
我需要这样的东西。
contentStream.showText("Hello");
y = y - fontSize; //decrease y-coordinate
contentStream.newLine(); //go to new line
y = y - newLineSize; <---- require the height of new line.
contentStream.showText("World!");
y = y - fontSize; //decrease y-coordinate
谢谢。
由 newLine()
创建的运算符开始一个新行,从当前行开始并从 y[=17 中减去 leading =] 坐标,您可以使用 setLeading
.
设置的值
我想在生成 pdf 时跟踪 y 坐标。 这就是我目前的做法。
PDRectangle mediabox = page.findMediaBox();
float margin = 15;
float y = mediabox.getUpperRightY() - margin;
float fontSize = 10f;
PDType1Font font = PDType1Font.HELVETICA;
contentStream.showText("Hello");
y = y - fontSize; //decrease y-coordinate
contentStream.newLine(); //go to new line
contentStream.showText("World!");
y = y - fontSize; //decrease y-coordinate
新行的高度是多少,以便我可以精确跟踪 y 坐标?
我需要这样的东西。
contentStream.showText("Hello");
y = y - fontSize; //decrease y-coordinate
contentStream.newLine(); //go to new line
y = y - newLineSize; <---- require the height of new line.
contentStream.showText("World!");
y = y - fontSize; //decrease y-coordinate
谢谢。
由 newLine()
创建的运算符开始一个新行,从当前行开始并从 y[=17 中减去 leading =] 坐标,您可以使用 setLeading
.