2017-12-14 8 views
2

pdf를 생성 할 때 y 좌표를 추적하고 싶습니다. 이것은 현재 어떻게 수행하고 있는지입니다.pdfBox의 apache에서 newLine()이 차지하는 높이는 어느 정도입니까?

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 

감사합니다.

답변

1

newLine() 의해 생성 연산자는 현재 라인의 시작을 취하고, 당신 setLeading을 사용하여 설정할 수있는 값을 y 좌표 에서 선도 을 뺀 새로운 줄을 시작한다.

관련 문제