prawnpdf / pdf-core

Implements low level PDF features for Prawn (experimental)
Other
23 stars 38 forks source link

Adding US-TRADE and US-TRADE-BLEED to page_geometry.rb #56

Closed krisnova closed 2 years ago

krisnova commented 2 years ago

To be clear, I personally despise the United States customary units.

However the printers in my country unfortunately seem to be fond of it.

I am adding two sizes here.

US-TRADE which is the default 6" X 9" size for US Trade sized publications. US-TRADE-BLEED which is the default size, with an additional .25" bleed margin (6.25" x 9.25" total)

Signed-off-by: Kris Nóva kris@nivenly.com

krisnova commented 2 years ago

For reference on why I need these specific sizes see the LULU Book Creation Guide where it mentions

US Trade 

Without Bleed Margins
6 in x 9 in (152 mm x 229 mm)

With Bleed Margins
6.25 in x 9.25 in (159 mm x 235 mm)
krisnova commented 2 years ago

Happy to rename the values if that would be appropriate. I have tested this on X86 Linux with Ruby 3.0.3

ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-linux]
petergoldstein commented 2 years ago

@pointlessone These changes look good to me. And the rationale behind them makes sense.

gettalong commented 2 years ago

@kris-nova @petergoldstein I'm not sure US-TRADE is a single paper size, see https://www.blurb.com/book-dimensions. There is also no mention of it on https://en.wikipedia.org/wiki/Paper_size. I would therefore not include it.

krisnova commented 2 years ago

So I am unsure how much more validation you need other than a US tape measure, and a trip to any book store in any country. There are quite literally millions of books in this size.

6" x 9" and 6.25" x 9.25" are valid book sizes, and therefor valid page sizes.

If this is in question I will close my pull request as clearly you are living in a reality that conflicts with my own and I wish you good luck on your journey.

The link you provided validates my argument even further. The link you provided conflicts with your argument.

In the link you provided the corresponding size is labelled as TRADE BOOK 6 × 9 IN. (15 × 23 CM)

image

I am unsure if you are challenging if the sizes in my pull request are invalid page sizes? Or if you are challenging the names I selected in my pull request?

Would there be better names for the following sizes?

Inches PDF Points (1/72) My value Better Value
6" x 9" 450 x 666 US-TRADE ?
6.25" x 9.25" 432 x 648 US-TRADE-BLEED ?

Happy to update to whatever values you suggest in favor of US-TRADE and US-TRADE-BLEED.

If you are not convinced that these are legitimate page sizes please do let us know.

References to the 6" x 9" page size

My own private collection

Below are photographs I took today, of book sizes (and subsequent page sizes that match) of the 6" x 9" page size that is not represented in your library without this change.

image

image

gettalong commented 2 years ago

@kris-nova I never doubted that there are books in size 6x9", as can be seen in the link I posted before. However, there it also says: image

So it seemed to me that the name "US-TRADE" doesn't refer to a single size but multiple. And that was what I was referring to.

In the second of your reference links (https://authority.pub/standard-books-sizes/#5-trade-paperbacks) it says:

Trade Paperbacks

These are the most common book sizes for most fiction and nonfiction books. The two most popular sizes in the U.S. are 5.5” by 8.5” (“digest”) and 6” by 9”.

In your other two reference links it mentions: "Trade paperback sizes will range anywhere from 5.5” x 8.5” (a size that’s called digest) to 6” x 9” (also known as US trade)."

So if indeed "US trade" is the unique name for a certain paper size, then adding it to the list is fine.

As for US-TRADE-BLEED: Is 0.25 inches the standard amount of bleed? Or is it just something that Lulu does?

krisnova commented 2 years ago

When in doubt, we should be verbose. Here are some suggested labels that clearly denote what is being suggested here. The .025 margins are a common printing convention. Multiple sources (including the ones above) reference them.

This suggestion would allow for future TRADE-* style labels in the future.

Will this work?

How are these suggested names for the sizes?

Inches PDF Points (1/72) New Suggestion
6" x 9" 450 x 666 TRADE-6x9
6.25" x 9.25" 432 x 648 TRADE-6.25x9.25

Directly inline it would look like:

        'TRADE-6x9' => [450.00, 666.00],
        'TRADE-6.25x9.25' => [432.00, 648.00]

If these suggested labels are acceptable to you I can update my PR, and include a small section in the documentation to capture this illustrious conversation as well as the convention for trade sizes moving forward.

gettalong commented 2 years ago

So, as I have said: US-TRADE would be fine me due to the discussion and the various given references.

As for the version with bleed, after thinking about it a bit more: I'm not sure it would be right to include that in the list as US-TRADE-BLEED as no other format has a version with bleed margins in there.

Therefore I think your new suggestion would be more appropriate, i.e. the 'TRADE' prefix with the sizes afterwards. And probably US-TRADE as an alias for TRADE-6x9.

The final decision lies with @pointlessone and, just so that you know, may take some time, given the current circumstances.

fidothe commented 2 years ago

I'm very sympathetic to the idea of having constants for page sizes to make generating correctly sized documents very simple, but I have a couple of problems with this specific approach to making that happen.

My general problem is that while 6x9" is a standard size, so are the 20 or 30 other sizes you can find documented in the links being shared above, and many of those are more common in use than 6x9.

A vast list of 'standard' sizes is less useful, especially when there are disagreements over the names (British and American paper sizes had some commonly used sizes with the same name but different dimensions, for example).

InDesign and other page layout apps list the same basic set of standard sizes as Prawn, and omit the profusion of other common sizes too. Those standard sizes we're using are the ones defined by either actual international standards (DIN A4 and friends) or de facto national ones (US Letter), and probably most important they're the sizes of paper you buy and print on, not the size of a page after it's been printed and trimmed as in book printing.

The bleed case is, for me, much more clear cut. A quarter-inch bleed is not an industry standard, although I imagine it's probably quite common in POD services with large tolerances. 3mm (a little under 1/8") was common in professional work when I was involved in book design and printing, but it's going to vary a lot and I don't see value in bloating the list in a way that is going to add multiple values for each new size.

I think what @kris-nova has identified is a clear need for a better way of specifying page sizes - if you're doing any work with generating PDFs for press in book publishing you're going to have to move out of the standard A sizes immediately. Generating a specific value for the page size is straightforward – Prawn::Document.generate(page_size: [450, 666]) (or even page_size: [6.in, 9.in] if you have prawn/measurement_extensions required) – but it's not drop-dead-simple the way page_size: "A4" is because you need to calculate the point size and handle bleed.

I wonder if some kind of convenience function for generating the right point values would allow both keeping a minimal list of standard sizes and making it easy to generate other sizes.

Off the top of my head, something like this, perhaps?

LULU_US_TRADE = Prawn.page_size_generator do
  size 6.in, 9.in
  bleed 0.25.in
end

Prawn::Document.generate('output.pdf', page_size: LULU_US_TRADE)

If there's interest in that approach, I volunteer to have a crack at it.

krisnova commented 2 years ago

My immediate use case will require the sizes I have identified, and ideally comes as a constant.

For context I am using the asciidoctor-pdf project to generate my book.

The specific documentation for page.size is here.

I interface with this library via a YAML abstraction that is parsed by asciidoctor-pdf.

extends: base
page:
  layout: portrait
  margin: [1in, 1in, 1in, 1in]
  size: TRADE-6X9

Adding a dynamic function to calculate custom sizes seems like the correct functionality for this library to expose, however I believe that it would break the dependency chain for asciidoctor-pdf as the YAML values would no longer render correctly. CC @mojavelinux to be sure.


For now can we merge this PR with the sizes I suggested and figure out a more long term solution in another issue please?

fidothe commented 2 years ago

Sorry, I think I'm missing something. Can you not specify the size directly in your config?

extends: base
page:
  layout: portrait
  margin: [1in, 1in, 1in, 1in]
  size: [6in, 9in]

This works for me in 1.6, anyway.

mojavelinux commented 2 years ago

@fidothe Exactly. You can specify any page size you want in Asciidoctor PDF using either the theme configuration or an AsciiDoc attribute. See https://github.com/asciidoctor/asciidoctor-pdf/blob/v1.6.x/docs/theming-guide.adoc#keys-page and https://github.com/asciidoctor/asciidoctor-pdf/blob/v1.6.x/docs/theming-guide.adoc#theme-related-document-attributes. For Asciidoctor PDF users, this change isn't mandatory and I question how much time this change saves users who need these additional sizes.

Having said that, if pdf-core provides these keys, Asciidoctor PDF will recognize them automatically.

gettalong commented 2 years ago

@kris-nova A change like the one suggested by @fidothe shouldn't break asciidoctor-pdf and even if it does, it would not be Prawn's fault (because this would be a feature addition without an API change).

@fidothe Thanks for your thoughtful comment and additional input! As for your suggestion, wouldn't that only save two plus operations (e.g. 6+0.25, 9+0.25)? And, personally, I would expect such a generator to not only set the media box with such a generator, but also the bleed box since we specify a bleed size.

For reference from the PDF spec: image

The bleed box has a definite meaning in the context of PDF and can already be set by Prawn. That should be taken into account.

@kris-nova As for "For now can we merge this PR with the sizes I suggested and figure out a more long term solution in another issue please?" - I'm against doing it this way because there is no need to rush it. As @mojavelinux said, you can already specify the paper size you need without this change.

Summing up all the information from this PR my impression is:

@petergoldstein What do you think?

pointlessone commented 2 years ago

@kris-nova Thank you for your contribution but I don't think I will accept this patch.

There are a few reasons for that.

  1. As @fidothe mentioned, this is not a widely used standard (and not so much a standard as A sizes).
  2. There's a workaround (thanks @fidothe and @mojavelinux). You can manually specify exact size of the page. Prawn also provides a way to specify margins and bleeds but I'm not sure if those are supported by asciidoctor-pdf.

I'm closing this PR but feel free to continue the discussion regarding the ergonomics of canned page layouts.

mojavelinux commented 2 years ago

Prawn also provides a way to specify margins and bleeds but I'm not sure if those are supported by asciidoctor-pdf.

margins are also fully supported. The running header and footer are defined separately and can thus overlap the margin, which I think is what the bleed is about. Anyway, that's a discussion for Asciidoctor PDF.