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

add paper size to document information #6990

Closed
ousia opened this issue Feb 14, 2016 · 29 comments
Closed

add paper size to document information #6990

ousia opened this issue Feb 14, 2016 · 29 comments

Comments

@ousia
Copy link

ousia commented Feb 14, 2016

Would it be possible that you add paper size to document information?

This is important to know whether the document uses letter or A4 paper size (among others).

@berenddeschouwer
Copy link

And can it include portrait/landscape?

@timvandermeij
Copy link
Contributor

timvandermeij commented May 26, 2017

What is the expected behavior if multiple page sizes/orientations are used, i.e., some pages are A4 portrait, but some are A3 landscape for example? How do other viewers do that?

@yurydelendik
Copy link
Contributor

and also we need to deal with internationalization and localization, e.g.

  • "A4" or "Letter" needs to be translated
  • 10cm×15cm shall be in inches for US

@berenddeschouwer
Copy link

berenddeschouwer commented May 26, 2017

Re: rotation. I'm going to check what PR 8043 does for me. That may fix my problem. It looks like I really need to read PR 8043 and #6103 properly, and make sure I'm on a late release with those fixes applied.

Re: multi-size. Dunno if any print backends support that without splitting the printout into multiple print jobs. If you don't split the print job, you have "print on biggest" or "scale to smallest" as sane options.

Cups includes an media size header with every print job, so Linux and MacOS are limited to one-size per print-job, as far as I know.

Re: localisation.
The printer has a list of possible and available paper sizes.
The OS print dialog knows the locale of the user, and a list of printers.
The OS print dialog doesn't know the original size.
The pdf viewer knows the locale, but not a list of printers, so not a list of available paper.
The pdf viewer knows the original PDF size.
The pdf generator knows the server and client locales.
The user hates "pc load letter"

@yurydelendik
Copy link
Contributor

yurydelendik commented May 26, 2017

Re: rotation. I'm going to check what PR 8043 does for me.
Re: multi-size. Dunno if any print backends support that without splitting the printout i..
Re: localisation... The printer has a list of possible and available paper sizes...

@berenddeschouwer I don't think any of the above related to the OP

@ousia
Copy link
Author

ousia commented Aug 27, 2017

What is the expected behavior if multiple page sizes/orientations are used, i.e., some pages are A4 portrait, but some are A3 landscape for example? How do other viewers do that?

@timvandermeij, SumatraPDF displays the size of the browsed page (the one that has the number in the toolbar).

and also we need to deal with internationalization and localization, e.g.

  • "A4" or "Letter" needs to be translated
  • 10cm×15cm shall be in inches for US

@yurydelendik, I don’t think A4 should be translated.

And as far as i know, page dimensions are specified in points inside the PDF document. So PDF.js should use the default dimension unit from OS.

@yurydelendik
Copy link
Contributor

@ousia what is the expected page size for document at https://github.com/mozilla/pdf.js/blob/master/test/pdfs/sizes.pdf ?

@ousia
Copy link
Author

ousia commented Aug 28, 2017

@ousia what is the expected page size for document at https://github.com/mozilla/pdf.js/blob/master/test/pdfs/sizes.pdf?

@yurydelendik, I don’t understand your question.

Size is a property related to the actual page, not to the document.

in PDF terms, /MediaBox is an entry in the /Page dictionary, not in the /Catalog (/Pages is the entry there).

Which should be the page size in the document you mention?

Acrobat Reader displays the dimensions of the displayed page. Here you have it.

pageone

pagetwo

pagethree

@timvandermeij
Copy link
Contributor

Thank you for providing this information! Now that this is clear, I think this should be good to implement. I'm marking this as a good beginner bug since it should not be too hard.

@loganhuskins
Copy link

I can knock this out if nobody is working on it.

@timvandermeij
Copy link
Contributor

@loganhuskins It's yours!

@sudheesh001
Copy link

sudheesh001 commented Nov 20, 2017

I think I am pretty close, I want to use getPagesOverview() from base_viewer.

Should I import import { BaseViewer } from './base_viewer'; in pdf_document_properties and then do BaseViewer.getPagesOverview()[0] as the value for pageSize value that I am planning to display? This somehow doesn't seem to be working, is there any other util method that I can reuse for getting this information. Sorry for hijacking this from Logan.

@loganhuskins
Copy link

I've been wrapped up with work, so if you're taking this over I'm good.

@linton-Portman
Copy link

Hi,
Is this what you are looking to do ?

compressed tracemonkey pldi 09 pdf

@ousia
Copy link
Author

ousia commented Dec 3, 2017

@linton-Portman, in that case adding Letter, portrait would be great.

I mean, with standard paper sizes it is useful to provide the standard paper name.

See what Evince does:

evince-properties

And SumatraPDF:

sumatrapdf-properties

@yurydelendik
Copy link
Contributor

I mean, with standard paper sizes it is useful to provide the standard paper name.

That means we need to properly localize all of these name. Is there a short list of popular paper sizes?

@linton-Portman
Copy link

Hi,
From what i have read so far the differences are in paper size ( US letter = 8.50 x 11.00 inch & UK A4 = 8.26 x 11.69 inch )... The way i was going to approach it was using a series of if/else statements checking for these sizes. Then this will determine what text is displayed .... By also using these sizes you can also determine if portrait or landscape....

This will be a lot of if/else statements depending on how many paper sizes are catered for....
I am a beginner/novice so maybe there is a better way :)

a4 portrait pdf
letter portrait pdf

@yurydelendik
Copy link
Contributor

Notice that A4 size is better to be expressed in mm, e.g. 210mm x 297mm

@linton-Portman
Copy link

@yurydelendik Oh yes i can do that also.

@ousia
Copy link
Author

ousia commented Dec 6, 2017

Here you have a list (that I adapted from ConTeXt).

Standard European paper sizes:

[A0] [width=841mm, height=1189mm]
[A1] [width=594mm, height=841mm]
[A2] [width=420mm, height=594mm]
[A3] [width=297mm, height=420mm]
[A4] [width=210mm, height=297mm]
[A5] [width=148mm, height=210mm]
[A6] [width=105mm, height=148mm]
[A7] [width=74mm, height=105mm]
[A8] [width=52mm, height=74mm]
[A9] [width=37mm, height=52mm]
[A10] [width=26mm, height=37mm]

Standard European less common paper sizes:

[B0] [width=1000mm, height=1414mm]
[B1] [width=707mm, height=1000mm]
[B2] [width=500mm, height=707mm]
[B3] [width=353mm, height=500mm]
[B4] [width=250mm, height=353mm]
[B5] [width=176mm, height=250mm]
[B6] [width=125mm, height=176mm]
[B7] [width=88mm, height=125mm]
[B8] [width=62mm, height=88mm]
[B9] [width=44mm, height=62mm]
[B10] [width=31mm, height=44mm]

Standard European envelope sizes:

[C0] [width=917mm, height=1297mm]
[C1] [width=648mm, height=917mm]
[C2] [width=458mm, height=648mm]
[C3] [width=324mm, height=458mm]
[C4] [width=229mm, height=324mm]
[C5] [width=162mm, height=229mm]
[C6] [width=114mm, height=162mm]
[C7] [width=81mm, height=114mm]
[C8] [width=57mm, height=81mm]
[C9] [width=40mm, height=57mm]
[C10] [width=28mm, height=40mm]

CD cover paper size:

[CD] [width=120mm, height=120mm]

American standard paper sizes:

[letter] [width=8.5in, height=11in]
[ledger] [width=11in, height=17in]
[tabloid] [width=17in, height=11in]

[legal] [width=8.5in, height=14in]
[folio] [width=8.5in, height=13in]
[executive] [width=7.25in, height=10.5in]

Different sets of envelopes:

[envelope 9] [width=8.88in, height=3.88in]
[envelope 10] [width=9.5in, height=4.13in]
[envelope 11] [width=10.38in, height=4.5in]
[envelope 12] [width=11.0in, height=4.75in]
[envelope 14] [width=11.5in, height=5.0in]
[monarch] [width=7.5in, height=3.88in]
[check] [width=8.58in, height=3.88in]
[DL] [width=110mm, height=220mm]
[E4] [width=280mm, height=400mm]

I think it is useful to add whether the orientation is portrait or landscape.

@ousia
Copy link
Author

ousia commented Dec 6, 2017

@linton-Portman, from what I see in your screenshots, I have a question:

Wouldn’t the following info be better?

Letter, portrait (8.5  × 11 in)

I mean, these following adaptations:

  • Use paper name first.

  • Followed by portrait or landscape.

    BTW, if the separation before is a comma, I think the word should begin with a lowercase letter.

  • Write the dimensions inside the parentheses.

    • It”s better to use the proper Unicode sign × (instead of x).

    • Which paper size requires which dimensions is specified in the previous list.

    • I think it’s better to use abbreviations for length units (in or mm in this case).

If that weren’t possible, portrait or landscape should go inside the parentheses.

Many thanks for your contribution.

@ousia
Copy link
Author

ousia commented Dec 6, 2017

@linton-Portman, using switch might be a better alternative to if... else statements.

I cannot code, so experienced coders may give better advice. (I simply replied to your question, since it remained unanswered).

@yurydelendik
Copy link
Contributor

Here you have a list (that I adapted from ConTeXt).

All of that needs to be translated. Personally I prefer find 5-10 top most used page sizes and give them names.

Letter, portrait (8.5 × 11 in)

Due to that: "8.5 in × 11 in, Letter/Portrait" or just "100mm x 200mm" might look a better choice here

@yurydelendik
Copy link
Contributor

It”s better to use the proper Unicode sign × (instead of x).

Yes, but it's also up to localizers for specific culture

@yurydelendik
Copy link
Contributor

I cannot code, so experienced coders may give better advice.

I'm sure core contributors will have open mind about the way this problem will be addressed. Main concern here is that a solution must not be complex and not add burden in future maintenance of the project.

Personally, as a first step, I would just add page size information without "nice" names (to avoid their localization), maybe (auto) detect units. The second step would be discussion of the page size name and orientation.

@pal03377
Copy link
Contributor

I tried it, since there has not been communication here since 2 months or so. Apologizes if I should have asked before.
The PR adds the Page Size view in pt, which is a start. Next steps (like described here) would be converting these to cm/mm/inch/... and trying to find a matching standard document size. Both of these are not implemented in this PR.

@timvandermeij
Copy link
Contributor

The pull request above implemented most of this feature. What remains to be done is showing the page size of the currently visible page instead of only from the first one. Optionally letter/portrait and default page sizes (such as A4) can be added, but I don't see that as mandatory for resolving this issue.

@timvandermeij
Copy link
Contributor

More improvements have been made in #9577, which also implemented showing the page size of the currently visible page. For this issue, only letter/portrait and default page sizes remain.

@timvandermeij
Copy link
Contributor

The final part is implemented by the pull request above (page orientation and page size names). Closing as fixed.

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

No branches or pull requests

8 participants