Skip to content
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

WIP: add support for orphan and widow page breaking #71

Closed
wants to merge 33 commits into from
Closed

WIP: add support for orphan and widow page breaking #71

wants to merge 33 commits into from

Conversation

thnkloud9
Copy link

To config min lines require before allowing a block orphan / widow update config.php:

$this->minWidowLines = 3;
$this->minOrphanLines = 3;

a value of 0 here should result in current behavior without auto breaks.

I have only so far tested with examples/example02_CSS_styles.php, and this is a bit of a hasty patch, so any help with testing, examples, and feedback (be critical, I can take it ;-) would be very much appreciated. I would be interested in the proper way to regression test and make sure I didn't break anything with these changes as well.

@jakejackson1
Copy link
Contributor

Nice work! I especially liked the clone of the original object to check for overflow onto the next page.

Adding appropriate unit tests will be the main way to ensure there is no regression. Adding tests for the new methods added should be relatively straightforward. But writing appropriate tests for WriteFlowingBlock looks like it will be more challenging – your added code may have to be moved to it's own method to make it easier to test, as that method is huge.

@marclaporte
Copy link
Member

So, what next? :-)

@thnkloud9
Copy link
Author

There are a handful of issues remaining with multi-column processing that need to be addressed in this PR before it can be made ready for merging. Specifically with regards to processing of the test document, amnesty2014-report-english-litho-full.php. At least three specific problems have been identified and documented (via TODO comments only thus far). Unfortunately I will not have the time to dedicate my attention to these issues to make a speedy resolution, but I will focus on these as time permits. In the meantime, I'm available for questions / discussion if anyone else wants to have a go at addressing the remaining issues.

@jakejackson1
Copy link
Contributor

What if for the initial patch you disabled orphan and widow support for multi-columns? From memory mPDF already disabled a couple of features when columns are enabled anyway.

@@ -120,12 +120,16 @@

// DEBUGGING & DEVELOPERS
$this->showStats = false;
$this->debug = false;
$this->debug = true; //false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea to debug by default in the development branch.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not so sure whether committing the changed value is a good idea at all. It may (and eventually will) lead to erroneous merging this to stable branches.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a fair point. One way to handle this is to have a release script which sets reasonable defaults for production users.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather see some sort of overridable local configs in 7.0+

@danielhjames
Copy link
Contributor

Regarding the conflicts shown below, recent commits (since December 2015) to https://github.com/mpdf/mpdf/commits/development can be merged in, except for changing all "else if" to "elseif" but that is easily done.

@thnkloud9
Copy link
Author

merged latest changes from development, and addressed issues with debug in default config. custom_config.php can contain any overrides desired, and has been added to .gitignore

@finwe
Copy link
Member

finwe commented Mar 8, 2016

Thanks for all the work done on this!

A first-sight issue I have with the code are spaces vs. tabs in the codebase, could you please change spaces to tabs? Thanks.

Also, please, rebase your branch to current development.

Custom config is a nice idea for the time being, though I would like to name the file config.local.php.

I will test results of the patch and review the code more thoroughly then.

@thnkloud9
Copy link
Author

@finwe - thanks for your comments! your suggestions have been implemented. Please note, however, that the PR is still WIP and contains many unresolved issues and not at all in review state at the moment. Any help with the issues (see above comments, and TODO comments in mpdf.php) would be much appreciated as I will have very limited time to dedicate to this project.

@finwe
Copy link
Member

finwe commented Mar 8, 2016

Ok, duly noted. I gained an impression from Daniel's comments that this could be somehow merged as a first phase. I won't, then.

Anyway thanks a lot for the changes, although the rebase is still not entirely to my satisfaction, I would like to see a straight Git history line above current development.
I guess you are making a merge, but I would like to have the codebase rebased via rebase upstream/development see this stackoverflow answer.

I'd rather have you make the rebase, because when I try, there are many conflicts that I am not entirely confident to solve properly. This is not a priority, though.

@thnkloud9
Copy link
Author

actually last update was a rebase upstream/development, but usually I merge and squash commits at the end, but whatever you prefer is fine with me.

btw, I'm not seeing any conflicts with latest upstream/development

@danielhjames
Copy link
Contributor

I personally think it would be good to merge this PR in the development branch, as the current lack of widows and orphans handling are a blocker for many potential users. We are already using Mark's version in production for single-column book layouts and it works well for those.

@thnkloud9 thnkloud9 closed this Apr 29, 2016
@thnkloud9
Copy link
Author

closing this to satisfy finwe's rebase policy. will submit another PR with latest changes soon.

@finwe
Copy link
Member

finwe commented Apr 29, 2016

It is entirely sufficient to rebase and/or squash and then force-push, the PR will update itself. Thanks, anyway!

@thnkloud9
Copy link
Author

we still have some issues to resolve with this feature. new PR will be submitted hopefully this weekend.

@marclaporte
Copy link
Member

@thnkloud9 I am really looking forward to your PR. Thanks!

@1manfactory
Copy link

I can't make head or tale out of this thread. I am not a programmer.

So, is Orphan/Widow control added or not?

And if yes, where can I download it? Sources of 6.1 do not include the keywords "minWidowLines" or "minOrphanLines"

@thnkloud9
Copy link
Author

thnkloud9 commented Nov 12, 2016

it has NOT been added and I have stopped work on my fork for this feature, sorry.

@1manfactory
Copy link

Thanks for clarifying this. This is bad news for me as a working Widow/Orphan control is essential for professionell paper printing (I am a book/ebook publisher)

@danielhjames
Copy link
Contributor

If you are publishing in European languages try https://github.com/speedata/publisher instead, it has widow and orphan control and a very good layout engine. If you are publishing in Eastern languages such as Arabic or Chinese, mPDF has great support for these languages but Speedata Publisher does not.

@1manfactory
Copy link

@danielhjames Sorry for reacting late. I wasn't (why ever) not informed by this thread. I will look this up, it sounds very promising, especially because I am German as the developer.

@Klap-in
Copy link
Contributor

Klap-in commented Nov 20, 2017

Page linked to this work: https://dev.tiki.org/Widows-and-Orphans-in-mPDF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants