-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Return table start PDPage from drawer #115
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor things should be changed before merging.
Thanks for your PR! 👍
pageToDrawOn = pageSupplier.get(); | ||
document.addPage(pageToDrawOn); | ||
} else | ||
pageToDrawOn = document.getPage(document.getNumberOfPages() - 1); | ||
pageToDrawOn = document.getPage(document.getNumberOfPages() - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add brackets around the bodies of if
s and else
s. This is a general recommendation. It's very easy to make mistakes on refactorings and it's pretty simple to prevent 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do.
@@ -139,11 +155,15 @@ public void draw(Supplier<PDDocument> documentSupplier, Supplier<PDPage> pageSup | |||
|
|||
protected PDPage determinePageToDraw(int index, PDDocument document, Supplier<PDPage> pageSupplier) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the returned value used at all? So either return the value and assign it where it is called (preferably) or just make the method void
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The returned PDPage is used by the draw(Supplier documentSupplier, Supplier pageSupplier, float yOffset) method. Not sure I got your suggestion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my bad. You are right. Still, there is a thing which I don't like about this method and which should be easy to fix: There is a side effect, namely setting the member variable tableStartPage
within the method. At the same time this value is returned. Since it is called only once one could argue that it would make more sense to set the member variable after the method is called using its returned value.
(There is a 2nd side effect nonetheless though which is setting the member variable startTableInNewPage
– but the fewer side effects the better in my opinion.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Point taken. Have moved both the if conditions into the parent draw method.
Attempt to solve issue 114. - #114.