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

Make page layout look better #21

Open
misaki-web opened this issue Jul 31, 2021 · 3 comments
Open

Make page layout look better #21

misaki-web opened this issue Jul 31, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@misaki-web
Copy link

misaki-web commented Jul 31, 2021

Currently, the argument --page allows to set the width and the height (--page 500 600), but the page margins can't be specified. For example, cover instructions basically don't have any margin:

default margin

It would be useful to be able to set horizontal and vertical margins like this:

--page WIDTH_POINTS+HOR_MARGIN_POINTS HEIGHT_POINTS+VER_MARGIN_POINTS

Example:

--page 500+15 600+15

more margin

It would also allow to center the QR codes on the page.

@za3k za3k added the enhancement New feature or request label Jul 31, 2021
@za3k
Copy link
Owner

za3k commented Jul 31, 2021

Can you say a little more about why you'd want this? I want to get a feel for the current problems you're hitting (you're basically the first actual user who's contacted me, so I'd like to learn more).

Do you actually want to be able to set margins? Or is zero-margin just too ugly? If a sane default would work I should do that too. For example, maybe equal margins on all sides should be the default, or I maybe the rectangular box is drawing attention to the margins.

On my printer, even the zero margin settings result in a lot of margin on actual paper, but that may not be universal.

@misaki-web
Copy link
Author

Do you actually want to be able to set margins?

Actually, I may not if there's enough margin by default and if QR codes are centered. Let's split the discussion in a few parts:

QR Code Alignment

Let's say I must use QR codes version 15 on A4 sheets. With default scale (8), it'll look like this:

Page 1 of 2:

QR code version 15 on A4 sheets, page 1 of 2

Page 2 of 2:

QR code version 15 on A4 sheets, page 2 of 2

Having QR codes centered on the page would have some advantages:

  • It would look a lot better.
  • Having QR codes centered would facilitate folding sheets in two (when there's an even number of columns/rows of course).
  • It would be less vulnerable to torn paper corners.
  • It would reduce risks to have a scanner skip some parts of the page very close to the edges, particularly if the sheets don't meet the exact scanner format, for example scanning a A4 sheet on a Letter scanner (the top or the bottom may be skipped since A4 sheets are longer than Letter sheets) or a Letter sheet on a A4 scanner (Letter sheets are wider than A4). Since I plan to use qr-backup with people in different countries, it's something I have in mind.

The same example with QR codes centered looks like this:

Page 1 of 2:

QR code version 15 centered on A4 sheets, page 1

Page 2 of 2:

QR code version 15 centered on A4 sheets, page 2

It could be argued either the last page should have the QR codes start at the same top-left coordinates than other pages, like the example above, or if codes should also be centered vertically like this:

QR code version 15 centered on A4 sheets, page 2 centered vertically

I prefer the first option (starting at the same top-left coordinates) because IMO it looks more consistent and it would allow to fold the sheet the same way as other sheets without folding in the middle of QR codes.

Instructions

Instructions on the cover don't have any left margin:

Instructions on the cover

IMO it would look better with some margin, something between 1.5 cm (43 points) and 2.5 cm (71 points), or 1 inch (72 points).

While I'm at it, I think that it would be even better if instructions would be a little bit bigger (right now, it's so small, it looks like font 7 pt) and if it was added as text instead of as an image, so copy/paste would be possible if we have access directly to the digital file.

Page Borders

On my printer, even the zero margin settings result in a lot of margin on actual paper, but that may not be universal.

Yeah, printer models vary a lot about the printing area. Some can do borderless printing. A quick way to test a printer is to open LibreOffice, change the top, right, bottom and left margins to 0 and validate. Usually a popup warning will be displayed if the printer can't handle borderless printing and it'll adjust margins to the minimum supported by the printer driver. For example, the printer I have access to right now can print with 1 mm margin from the top and 3 mm from the left.

It also depends on the printer configuration or the software used to print the PDF document. In case the content is outside the printing area (like the instructions that don't have any margin), it may or may not automatically add margin, scale content, center the scaled content, etc.

So, IMO it means that if you want to keep page borders in PDF generated by qr-backup, I think that it may be a good idea to make it optional. Personally, I would prefer no borders:

  • It would make it easier to extract images automatically from the PDF generated and create another one with a different page size without resizing anything.

  • If borders don't have margin, they may force the printer to scale the complete page content (so, QR codes included) in order to add some default margin before printing the page (like when you wrote "On my printer, even the zero margin settings result in a lot of margin on actual paper"), while without borders, the QR codes may have been printed directly without being resized at all.

    We can visually check this scale factor by printing a ruler at 100% size to see if the printer resized the document or not, then adding borders to the PDF document without any margin and print the edited document to see how much 1 inch in the ruler printed is now actually smaller than 1 inch.

    If we need to maximize data per page and use --scale 4 or even less than 4, any unnecessary QR code resizing must be avoided, so it's better if the PDF generated can be printed directly at 100% without resizing the content.

Page Numbers

It doesn't solve the page number margins. Like instructions, I think some default margin would be better, but it greatly depends on the position of the page numbers. Some printers can't print easily near the bottom, like the printer I have access to right now must have a minimum margin of 14 mm at the bottom while only 1 mm is needed at the top.

I see in the code this comment:

# Add page numbers after. Currently page-numbering is perfectly reliable, but we're about to add more complicated layout options.

Would it be about an option to choose the position of the page numbers (top left, top right, bottom left, bottom right, none, label)? The option "label" may add the page number in the label text. For example, labels are like this by default:

code 18/30 lorem-restored.txt

Removing the word "code" would add some space (even when page numbers are not added in labels, it would add more space to the file name) and the page number could be added like this:

P2/2 18/30 lorem-restored.txt

If there were such an option (--page-layout), I would choose "label" and it would solve the page numbers too close to the edge.

@za3k za3k changed the title Allow to set page margins Make page layout look better Sep 21, 2022
@anarcat
Copy link
Contributor

anarcat commented Mar 3, 2023

While I'm at it, I think that it would be even better if instructions would be a little bit bigger (right now, it's so small, it looks like font 7 pt) and if it was added as text instead of as an image, so copy/paste would be possible if we have access directly to the digital file.

in #51 i suggest shifting to a monospace font. DejaVu Sans Mono is slightly bigger and more readable, IMHO.

there's also a discussion specifically about margins in #49 that you might be interested in.

i agree the page layout could look nicer. in comparison, paperbackup is gorgeous, but that comes at a hefty dependency cost (they use Python PyX, which uses LaTeX to generate the layout).

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

No branches or pull requests

3 participants