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

Support printing page with different rotation #6103

Closed
wants to merge 1 commit into from

Conversation

xlc
Copy link
Contributor

@xlc xlc commented Jun 10, 2015

This PR fixed a printing issue on document that contains page with different orientation.

Some page may print upside down, but rotate a printed paper sheet shouldn't be a problem.

@Rob--W This is the PR you and @Hengjie discussed in #5857

Some test pdfs:

https://drive.google.com/a/notable.ac/file/d/0B6YhVF9p-y2AbUJlcEI5ZGZ5Z2c/view?usp=sharing
https://drive.google.com/a/notable.ac/file/d/0B6YhVF9p-y2AQTNxMVVOekJYeFE/view?usp=sharing

@Rob--W
Copy link
Member

Rob--W commented Jun 10, 2015

Thanks for the PR. I'll put reviewing it on my to-do list.

@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

From: Bot.io (Linux)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://107.21.233.14:8877/60608bee397dc6f/output.txt

@yurydelendik
Copy link
Contributor

Looks okay. I'm still not sure about isFirstPagePortrait-parameter-logic usage. Shall we make that decision before printing and use it e.g. aspageOrientationMode parameter instead?

@Rob--W
Copy link
Member

Rob--W commented Jun 30, 2015

@yurydelendik The purpose of this patch is to allow pages with varying orientation levels to be printed correctly.

For that specific purpose and the given test cases, the patch looks OK to me, but I'm not completely certain whether this special case is always warranted in its current form. For instance, if a PDF is approximately a square (e.g. presentation slides), then flipping the pages because e.g. 501 > 500 doesn't make a lot of sense to me. I'd like to see a stricter logic to address this issue (e.g. changing pageHeight > pageWidth to something like pageHeight > SOME_MINIMUM_ASPECT_RATIO * pageWidth || pageHeight > pageWidth + SOME_MINIMAL_DIFFERENCE).

@yurydelendik
Copy link
Contributor

The purpose of this patch is to allow pages with varying orientation levels to be printed correctly.

I see -- I was confused about the parameter name, ignore my concern :)

@Hengjie
Copy link
Contributor

Hengjie commented Jul 24, 2015

Anything preventing this from being merged?

@Rob--W
Copy link
Member

Rob--W commented Jul 24, 2015

@Hengjie Yes, the question whether unconditionally rotating a page makes sense. I can obviously see that the patch has the desired effect for the provided test PDF files, but I'm not convinced whether it makes sense to unconditionally rotate all pages whose orientation is slightly different (see my previous comment, 6103#issuecomment-117242076).

Another example is a set of pictures that are so small that it doesn't matter whether the page is rotated when printed. Well, after applying your logic, the images will always be rotated, unconditionally.

Do you have any data on distribution of page sizes/orientations for PDF files?

@Rob--W
Copy link
Member

Rob--W commented Dec 24, 2015

@Hengjie Ping for an answer to my last question (July, 24th) and implementation of my suggestion from 30th of June.

@xlc
Copy link
Contributor Author

xlc commented Jan 4, 2016

I don't have any data about PDF file page sizes but I am unable to see the disadvantage of rotate page with size of 500x501? The result won't be much different and I can't think any case when user doesn't want the auto rotate behaviour. Even there are some edge cases, this PR still fixes more than it breaks so I think the trade-off is worth it.

@Rob--W
Copy link
Member

Rob--W commented Jan 6, 2016

@xlc With my given example, if I print the slides of a presentation that perfectly fit on a page, it would be odd to have them rotated.

It might be a good idea to add a new preference to disable auto-rotating, to allow users / embedders to choose whether to rotate a page.

@xlc
Copy link
Contributor Author

xlc commented Jan 12, 2016

@Rob--W Sorry I still can't see why auto-rotate is bad.
If all pages are same size, only different orientation, we definitely want auto-rotate.
If some pages have non-standard size, those pages can't be print perfectly fit, rotate will reduce the aspect-ratio difference.
In some edge case, given pages with sizes of 500 * 501, 501* 500, rotate may not improve the print quality but I don't think such kind of pdf exists. Why you need to rotate almost square presentation slides?

But if you insist the change is necessary, I can still do it. Just give me the value of SOME_MINIMUM_ASPECT_RATIO and SOME_MINIMAL_DIFFERENCE.

@Rob--W
Copy link
Member

Rob--W commented Jan 19, 2016

Why you need to rotate almost square presentation slides?

I do not want to rotate the slides when not needed (e.g. when PDFs with irregular pages are printed with a printer that automatically puts a staple on the result). But maybe I'm worrying about nothing, so let's not use those magic numbers for now and see how it goes.

The patch looks good to me.
Are you going to add a preference to allow users to disable auto rotate?

@xlc
Copy link
Contributor Author

xlc commented Jan 19, 2016

@Rob--W Updated

@timvandermeij
Copy link
Contributor

@xlc Could you squash the commits into one commit? See https://github.com/mozilla/pdf.js/wiki/Squashing-Commits if you're not familiar with that.

@2Owy
Copy link

2Owy commented Feb 6, 2017

Hi guys ! So when is this going to be live ?

@Rob--W
Copy link
Member

Rob--W commented Feb 6, 2017

I don't know why this patch was not merged. @timvandermeij After your comment this PR was updated but not merged, why?

(the PR needs to be rebased now due to bit rot)

@2Owy
Copy link

2Owy commented Feb 6, 2017

Did someone forget to confirm a merge request ?
I kinda need this fix.
Thank you guys for your hard work.

@timvandermeij
Copy link
Contributor

timvandermeij commented Feb 6, 2017

I think I just forgot about this after asking about squashing since it was assigned to @Rob--W. Sorry for that. Now that I look at this again, I'm not entirely sure if we need to make this a preference, i.e., why would one want to disable this? If we do keep this a preference, we should be able to remove the hash parameter change as we don't use them anymore.

I think this patch is good to go after a rebase, simplification and testing to ensure it still works as intended after the rebase (since the printing code changed quite a bit after this patch).

@Rob--W
Copy link
Member

Rob--W commented Feb 6, 2017

I'm not entirely sure if we need to make this a preference, i.e., why would one want to disable this?

If pages are irregularly shaped, then it does not make sense to rotate pages. PDFs are supposed to closely match the printed result, so I believe that a change as significant as rotating a page should be customizable.

@timvandermeij
Copy link
Contributor

Good point. Let's keep the preference, but only remove https://github.com/mozilla/pdf.js/pull/6103/files#diff-dd42e9b2d2a652b8e312efa567698aa6R1454 since we don't really use the hash parameters anymore.

@xlc
Copy link
Contributor Author

xlc commented Feb 6, 2017

Sorry guys I won't be able to maintain this PR anymore. I haven't worked with pdf.js for long time and a quick rebase shows that there too many changes in the code structure and I don't have time to deal with it. Feel free to take whatever code you need from this PR to make a new one.
@timvandermeij @Rob--W

@xlc xlc closed this Feb 6, 2017
@2Owy
Copy link

2Owy commented Feb 7, 2017

So, as a conclusion, is PDF.js going to support printing a PDF with different orientations ?

@timvandermeij
Copy link
Contributor

It will if someone has time to redo this patch. Until then, the issue is tracked in #6696.

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

Successfully merging this pull request may close these issues.

7 participants