vandeseer / easytable

Small table drawing library built upon Apache PDFBox
MIT License
246 stars 94 forks source link

DrawingUtil#drawRectangle calls closePath() when path already got closed by preceding fill() #85

Closed msww closed 4 years ago

msww commented 4 years ago

Hi - I'm trying out easytable for a project, and am finding that some PDF processors (e.g. pdftotext from Poppler 0.48.0) spit out large numbers of messages like Syntax Error: No current point in closepath on documents I create using easytable.

It looks like the cause is that DrawingUtil#drawRectangle calls closePath() (which maps to PDF content stream operator h) as part of drawing the rectangle. However, this happens after it has already called fill(), which is implemented as PDF's operator f. According to the PDF Specification PDF 32000-1:2008 section 8.5.3.3.1, the f operator already closes any open subpaths, leaving no open path that could be closed.

I think the call to closePath() is redundant. Removing the line results in a PDF file that does not cause those error messages without any obvious change to the rendering of the table.

vandeseer commented 4 years ago

Hey @msww , thanks a lot for your thorough analysis!

I never experienced any issue like the one you are mentioning but your comment makes perfect sense. I will hence remove the respective line (as soon as I find time and if there are no other issues popping up due to removing the line).

Thanks again!

Best, Stefan

vandeseer commented 4 years ago

Removed the respective line in version 0.6.5. If you find anything else, let me know!