Repository navigation
Implement predefined and custom paper sizes - #87
Merged
Merged
Conversation
aura-lsprog-86
force-pushed
the
feature-papersize2
branch
from
April 11, 2026 06:12
5687fa7 to
231c4e9
Compare
Owner
|
Please use |
aura-lsprog-86
force-pushed
the
feature-papersize2
branch
2 times, most recently
from
April 12, 2026 18:57
7e3b3e8 to
7061cd9
Compare
aura-lsprog-86
force-pushed
the
feature-papersize2
branch
2 times, most recently
from
April 12, 2026 19:06
ea4e8cb to
9afe348
Compare
jubalh
requested changes
Apr 12, 2026
aura-lsprog-86
force-pushed
the
feature-papersize2
branch
from
April 13, 2026 02:14
158cda1 to
1f77536
Compare
Includes sizes "a4", "a5", "letter", "legal", "invoice", and "oficio".
* Add page header in every page. * Calculate number of sudokus that fit inside a given page size. * Do not allow PDF generation if no sudokus can fit in a page. * Ensure Cairo objects are destroyed upon PDF failure
Include "outp.c" in list of translatable files.
aura-lsprog-86
force-pushed
the
feature-papersize2
branch
from
April 13, 2026 02:20
1f77536 to
525ae11
Compare
jubalh
approved these changes
Apr 13, 2026
Owner
|
Thanks for the feature! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
From the discussion in #86, I went ahead and implemented scaffolding to detect predefined and custom page sizes, especially taking into account #86 (comment). 😄
Now, option
-Saccepts any of the following options:a4(default),a5,letter,legal,invoice, andoficio.WIDTHxHEIGHT[unit].unitis optional, and defaults tocmif not given.unitaccepts one ofin,cm, orpt.Then, when parsing the options, the program basically follows this parsing path:
sscanfto aid with this.)EXIT_FAILUREis returned).Even though implementing predefined and custom page sizes was not a too difficult task, the behavior of PDF rendering when multiple sudokus are requested is another matter. 😬
The previous implementation hardcoded 4 sudokus per page, and used
cairo_scaleandcairo_translateto reuse the grid drawing function.Now, it was necessary to get the current transformation matrix and map user units to device units, or points (each sudoku is composed of squares that measure 50 user units, and so each sudoku is
450x450user units). To determine how many sudokus fit per axis, the following calculations were done.The code above basically means:
Then, each sudoku is printed in its right place, by calculating the user unit coordinates where Cairo should start drawing each of them, as seen in the code below:
Overall, I'm quite satisfied by the results achieved. 😌
However, I know my code can be improved. For example, right now there is no upper-limit capping in either
-nor-S, so a user can issue something like:Therefore, any comments or suggestions are welcome to make this better. 👍🏻
Thanks! 🚀