Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,4 @@ nosetests.xml
/tests/testCalendar/a4l/*.pdf
/tests/testCalendar/a4p/*.pdf
/tests/testIndexLarge/*.mcf.*.idx.*.png
/utilities/fixleftrightchanges/tests
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ more detail for users, contributors, and coding assistants.
| Set up and test Linux using WSL | [Linux/WSL guide](documents/TestingOnWSL.md) |
| Build or install a standalone executable | [Build and Windows integration guide](documents/build_a_compiled_version.md) |
| Work with tests and approved PDFs | [Test workflow and cleanup](tests/README.md), and [compare-pdf interface](tests/compare-pdf/README.md) |
| Center selected album page content | [MCF/MCFX content centering utility](utilities/contenttocenter/README.md) |
| Understand or author clip art and passepartout resources | [CLP file format and authoring notes](clipart/CLP_FILE_FORMAT.md) |
| Consult superseded setups and investigations | [Historical documentation](documents/history/README.md) |

Expand Down Expand Up @@ -222,6 +223,13 @@ shared operating-system font folders (for example ``C:\\Windows\\Fonts``).
This is disabled by default because the available fonts differ between
machines.

**Windows executable exception:** when the executable converts an album from
the Explorer context menu, automatic mode enables shared system-font discovery
even if an album or program ``cewe2pdf.ini`` sets ``loadSystemFonts = False``.
See the [Windows Explorer guide](documents/build_a_compiled_version.md#windows-explorer-installation-and-use).
This setting is separate from per-user fonts: those are still searched unless
the ``IGNORELOCALFONTS`` environment variable is set.

To find a potential ``additional_fonts.txt`` the code searches, in order, the album directory, the current directory and the location of the program itself; it uses only the **first** such file found.

For normal use (i.e. actually creating a pdf album, rather than testing the code) the most reasonable strategy is to place an ``additional_fonts.txt`` file with the album file, out of the way of future updates to the program repository. The repository supplies a commented ``additional_fonts.example.txt`` which you can copy and adapt. It is deliberately not called ``additional_fonts.txt``, so it is never used as implicit configuration.
Expand Down
4 changes: 4 additions & 0 deletions cewe2pdf.pyproj
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@
<Content Include="tests\unittest_fotobook\unittest_fotobook_mcf-Dateien\img4.png" />
<Content Include="tests\unittest_fotobook\unittest_fotobook_mcf-Dateien\img5.png" />
<Content Include="tests\unittest_fotobook\unittest_fotobook_mcf-Dateien\img6.png" />
<Content Include="utilities\contenttocenter\README.md" />
</ItemGroup>
<ItemGroup>
<Compile Include="albumConversionSession.py" />
Expand Down Expand Up @@ -496,6 +497,7 @@
<Compile Include="texts\shadows.py" />
<Compile Include="texts\tabs.py" />
<Compile Include="texts\__init__.py" />
<Compile Include="utilities\contenttocenter\contenttocenter.py" />
</ItemGroup>
<ItemGroup>
<Folder Include=".github\" />
Expand Down Expand Up @@ -662,6 +664,8 @@
<Folder Include="tests\unittest_fotobook\previous_result_pdfs\" />
<Folder Include="tests\unittest_fotobook\unittest_fotobook_mcf-Dateien\" />
<Folder Include="texts\" />
<Folder Include="utilities\" />
<Folder Include="utilities\contenttocenter\" />
</ItemGroup>
<ItemGroup>
<InterpreterReference Include="CondaEnv|CondaEnv|cewe2pdf312" />
Expand Down
7 changes: 5 additions & 2 deletions documents/build_a_compiled_version.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,11 @@ Administrator rights are not required. The editor remains the normal double-clic
application for album files.

Right-click an album and select the command. Automatic mode discovers the CEWE
installation from Windows file associations where possible and enables system fonts.
A valid explicit configuration still wins. The resulting PDF and a diagnostic
installation from Windows file associations where possible and enables shared
Windows system-font discovery. This deliberately overrides
`loadSystemFonts = False` in either INI file. An explicit, valid `cewe_folder`
still takes precedence over automatic CEWE-folder discovery. Per-user fonts are
also searched unless `IGNORELOCALFONTS` is set. The resulting PDF and a diagnostic
`<album>.mcf.log` or `<album>.mcfx.log` are written beside the input.
The log is overwritten each run.

Expand Down
5 changes: 3 additions & 2 deletions pageNumbering.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ def ToEnum(value: str):
class PageNumberingInfo:
def __init__(self, pageNumberElement, pdf, availableFonts, state: ConversionState):
"""

Constructor that initializes the page numbering info from the given lxml element.
"""
# Extract relevant attributes or sub-elements from lxml_element
Expand All @@ -63,8 +64,8 @@ def __init__(self, pageNumberElement, pdf, availableFonts, state: ConversionStat
logging.error(f"Unrecognised pagenumbering position value {self.position}, reset to 1")
self.position = 1
self.format = PageNumberFormat.ToEnum(pageNumberElement.get('format','0'))
self.horizontalMargin = int(pageNumberElement.get('margin','50')) * mcf2rl # * 0.1 mm
self.verticalMargin = int(pageNumberElement.get('verticalMargin','50')) * mcf2rl # * 0.1 mm
self.horizontalMargin = float(pageNumberElement.get('margin','50')) * mcf2rl # * 0.1 mm
self.verticalMargin = float(pageNumberElement.get('verticalMargin','50')) * mcf2rl # * 0.1 mm
fontfamily = pageNumberElement.get('fontfamily','Liberation Sans')
self.fontfamily = getAvailableFont(fontfamily, pdf, availableFonts, state)
self.fontsize = int(pageNumberElement.get('fontsize','12'))
Expand Down
55 changes: 55 additions & 0 deletions utilities/contenttocenter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Centering album page content

`contenttocenter.py` adjusts the horizontal position of page content in a CEWE
album. It reads the edited MCF or MCFX and an explicit list of pages to center;
it does not need the original album or a record of how pages changed.

## Page selection

Page numbers are one-based editor page numbers. Use comma-separated page
numbers or inclusive ranges. Pages cannot repeat. For example:

```text
2-5,8,10-65
```

This selects pages 2 through 5, page 8, and pages 10 through 65 in the edited
album. Only selected pages are adjusted. CEWE album page 1 is on the right;
odd pages are on the right and even pages are on the left.

## Centering rule

For each selected physical page, the tool finds the horizontal bounding box of
all positioned areas, including rotated areas. It shifts every area on that
page by the same amount so the center of that bounding box matches the physical
page center. This preserves relative positions between photos, text, and other
elements. It does not scale, mirror, or move elements vertically. Pages with no
positioned areas are skipped; pages do not need to contain photos.

MCF positions use spread-wide coordinates. Areas are assigned to a physical
page by the center of their rotated horizontal bounds. Page backgrounds stored
separately from page areas are not translated.

## Run

From the repository root:

```text
python utilities/contenttocenter/contenttocenter.py --pages 2-65 --dry-run edited.mcf
```

Review the reported shifts and centered bounds. To write the corrected MCF,
omit `--dry-run`:

```text
python utilities/contenttocenter/contenttocenter.py --pages 2-65 edited.mcf
```

The output has the same format as the input. By default, this creates
`edited.centered.mcf` or `edited.centered.mcfx` beside the input and never
overwrites an existing file. For MCFX input, the tool uses the project's
`unpackMcfx()` reader and replaces only the embedded MCF in a copy of the
archive, preserving its other files. Use `--output corrected.mcf` or
`--output corrected.mcfx` to choose another destination with the matching
extension. Open the result in CEWE and inspect the changed spreads before
continuing to edit the album.
Loading
Loading