@@ -637,8 +637,8 @@ else if (valign == PDFReportPDFBox.VerticalAlign.BOTTOM.value())
637
637
638
638
loadSupportedHTMLTags ();
639
639
640
- Document document = Jsoup .parse (sTxt );
641
- Elements allElements = document .getAllElements ();
640
+ Document htmlDocument = Jsoup .parse (sTxt );
641
+ Elements allElements = htmlDocument .getAllElements ();
642
642
for (Element element : allElements ){
643
643
if (pageHeightExceeded (bottomMargin , spaceHandler .getCurrentYPosition ())) {
644
644
llx = leftAux + leftMargin ;
@@ -652,7 +652,7 @@ else if (valign == PDFReportPDFBox.VerticalAlign.BOTTOM.value())
652
652
GxStartPage ();
653
653
654
654
cb .close ();
655
- cb = new PDPageContentStream (this . document , this . document .getPage (page - 1 ),PDPageContentStream .AppendMode .APPEND ,false );
655
+ cb = new PDPageContentStream (document , document .getPage (page - 1 ),PDPageContentStream .AppendMode .APPEND ,false );
656
656
}
657
657
if (this .supportedHTMLTags .contains (element .normalName ()))
658
658
processHTMLElement (cb , htmlRectangle , spaceHandler , element );
@@ -870,7 +870,12 @@ else if (valign == PDFReportPDFBox.VerticalAlign.BOTTOM.value())
870
870
} catch (Exception ioe ){
871
871
log .error ("GxDrawText failed: " , ioe );
872
872
} finally {
873
- try {if (cb != null ) cb .close ();} catch (IOException ioe ) {}
873
+ try {
874
+ if (cb != null ) cb .close ();
875
+ }
876
+ catch (IOException ioe ) {
877
+ log .error ("GxDrawText failed to close a content stream to one of it's pages: " , ioe );
878
+ }
874
879
}
875
880
}
876
881
@@ -1324,8 +1329,8 @@ public void GxEndDocument() {
1324
1329
try {
1325
1330
document .save (outputStream );
1326
1331
document .close ();
1327
- } catch (IOException ioe ) {
1328
- log .error ("GxEndDocument: failed to save document to the output stream" , ioe );
1332
+ } catch (IOException | IllegalStateException e ) {
1333
+ log .error ("GxEndDocument: failed to save document to the output stream" , e );
1329
1334
}
1330
1335
1331
1336
log .debug ("GxEndDocument!" );
0 commit comments