Skip to content

Commit b8b3a8a

Browse files
PDFBox brokens (#949)
* Add missing font name Issue:203719 * Fix HTML positioning
1 parent f476368 commit b8b3a8a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Diff for: java/src/main/java/com/genexus/reports/PDFReportPDFBox.java

+9-6
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,9 @@ public void GxAttris(String fontName, int fontSize, boolean fontBold, boolean fo
482482
}
483483
}
484484
baseFont = createPDType1FontFromName(fontName);
485+
baseFontName = fontName;
485486
if (baseFont == null){
486487
baseFont = getOrLoadFont(fontName, document);
487-
baseFontName = fontName;
488488
}
489489

490490
}
@@ -652,11 +652,14 @@ public void GxDrawText(String sTxt, int left, int top, int right, int bottom, in
652652
log.debug("WARNING: HTML rendering is not natively supported by PDFBOX 2.0.27. Handcrafted support is provided but it is not intended to cover all possible use cases");
653653

654654
try {
655+
float htmlBottomAux = (float)convertScale(bottom);
656+
float htmlTopAux = (float)convertScale(top);
657+
655658
float drawingPageHeight = this.pageSize.getUpperRightY() - topMargin - bottomMargin;
656659
float llx = leftAux + leftMargin;
657-
float lly = drawingPageHeight - bottomAux;
660+
float lly = drawingPageHeight - htmlBottomAux;
658661
float urx = rightAux + leftMargin;
659-
float ury = drawingPageHeight - topAux;
662+
float ury = drawingPageHeight - htmlTopAux;
660663

661664
PDRectangle htmlRectangle = new PDRectangle(llx, lly, urx - llx, ury - lly);
662665
SpaceHandler spaceHandler = new SpaceHandler(htmlRectangle.getUpperRightY(), htmlRectangle.getHeight());
@@ -668,13 +671,13 @@ public void GxDrawText(String sTxt, int left, int top, int right, int bottom, in
668671
for (Element element : allElements) {
669672
if (pageHeightExceeded(bottomMargin, spaceHandler.getCurrentYPosition())) {
670673
llx = leftAux + leftMargin;
671-
lly = drawingPageHeight - bottomAux;
674+
lly = drawingPageHeight - htmlBottomAux;
672675
urx = rightAux + leftMargin;
673-
ury = drawingPageHeight - topAux;
676+
ury = drawingPageHeight - htmlTopAux;
674677
htmlRectangle = new PDRectangle(llx, lly, urx - llx, ury - lly);
675678
spaceHandler = new SpaceHandler(htmlRectangle.getUpperRightY(), htmlRectangle.getHeight());
676679

677-
bottomAux -= drawingPageHeight;
680+
htmlBottomAux -= drawingPageHeight;
678681
GxEndPage();
679682
GxStartPage();
680683

0 commit comments

Comments
 (0)