Skip to content

Commit cf84a53

Browse files
Merge pull request #247 from AnEnglishmanInNorway/PR244ParaWrap
PR240 bullets, PR244 paragraph wrapping, vertical alignment, internal text box margins, CEWE 8.0.x format
2 parents 15c1cbd + 1721dd5 commit cf84a53

62 files changed

Lines changed: 1424 additions & 404 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,12 @@ nosetests.xml
6868
/junk*.pdf
6969
/tests/testIndex/test_index.mcf.*S.idx.png
7070
/tests/testIndexLarge/test_indexLarge.mcf.*S.idx.png
71+
.idea/cewe2pdf.iml
72+
.idea/misc.xml
73+
.idea/modules.xml
74+
.idea/vcs.xml
75+
.idea/inspectionProfiles/profiles_settings.xml
76+
.DS_Store
77+
# macOS custom folder icon file is stored as "Icon" plus a hidden control character.
78+
# Match that hidden-character variant anywhere in the repo.
79+
**/Icon?

.idea/.gitignore

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,17 +310,22 @@ Where-Object {
310310
```
311311
and then delete them (via the recycle bin) with
312312
```
313-
$shell = New-Object -ComObject Shell.Application
313+
Add-Type -AssemblyName Microsoft.VisualBasic
314+
314315
Get-ChildItem -Recurse -File -Filter *.pdf |
315316
Where-Object {
316317
$_.FullName -notmatch '\\previous_result_pdfs\\' -and
317-
$_.Name -match '^[^\\]*\d{8}[DS]\.pdf$'
318+
$_.Name -match '^\w*\d{8}[DS]\.pdf$'
318319
} |
319320
ForEach-Object {
320-
$shell.Namespace(0).ParseName($_.FullName).InvokeVerb("delete")
321+
[Microsoft.VisualBasic.FileIO.FileSystem]::DeleteFile(
322+
$_.FullName,
323+
'OnlyErrorDialogs',
324+
'SendToRecycleBin'
325+
)
321326
}
322327
```
323-
If you want a dry run first, just replace the `InvokeVerb("delete")` line with:
328+
If you want a dry run first, just replace the DeleteFile section with:
324329
```
325330
Write-Output "Would delete: $($_.FullName)"
326331
```

cewe2pdf.py

Lines changed: 436 additions & 203 deletions
Large diffs are not rendered by default.

cewe2pdf.pyproj

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,13 @@
174174
<Content Include="tests\testTextArt\test_textart.mcf" />
175175
<Content Include="tests\testTextArt\test_textart.mcf~" />
176176
<Content Include="tests\testTextArt\test_textart_mcf-Dateien\folderid.xml~" />
177+
<Content Include="tests\testTextBox\additional_fonts.txt" />
178+
<Content Include="tests\testTextBox\cewe2pdf.ini" />
179+
<Content Include="tests\testTextWrapVAlignBorder\cewe2pdf.ini" />
180+
<Content Include="tests\testTextWrapVAlignBorder\previous_result_pdfs\test_textwrapvalignborder.mcf.20251216S.pdf" />
181+
<Content Include="tests\testTextWrapVAlignBorder\previous_result_pdfs\test_textwrapvalignborder.mcf.20251217S.pdf" />
182+
<Content Include="tests\testTextWrapVAlignBorder\test_textwrapvalignborder.mcf" />
183+
<Content Include="tests\testTextWrapVAlignBorder\test_textwrapvalignborder_mcf-Dateien\folderid.xml" />
177184
<Content Include="tests\unittest_fotobook\additional_fonts.txt" />
178185
<Content Include="tests\unittest_fotobook\cewe2pdf.ini" />
179186
<Content Include="tests\hps\5026\.gitkeep" />
@@ -252,6 +259,7 @@
252259
<Content Include="tests\unittest_fotobook\previous_result_pdfs\unittest_fotobook.mcf.20250413D.pdf" />
253260
<Content Include="tests\unittest_fotobook\previous_result_pdfs\unittest_fotobook.mcf.20250413S.pdf" />
254261
<Content Include="tests\unittest_fotobook\previous_result_pdfs\unittest_fotobook.mcfx.20250413S.pdf" />
262+
<Content Include="tests\testTextBox\testTextBox.mcf" />
255263
<Content Include="tests\unittest_fotobook\unittest_fotobook.mcf" />
256264
<Content Include="tests\unittest_fotobook\unittest_fotobook.mcf.pdf" />
257265
<Content Include="tests\unittest_fotobook\unittest_fotobook.mcfx" />
@@ -316,6 +324,8 @@
316324
<Compile Include="tests\testMcfxExtraction\test_McfxExtraction.py" />
317325
<Compile Include="tests\testPageNumbers\test_pagenumbers.py" />
318326
<Compile Include="tests\testTextArt\test_textart.py" />
327+
<Compile Include="tests\testTextBox\test_textBox.py" />
328+
<Compile Include="tests\testTextWrapVAlignBorder\test_textwrapvalignborder.py" />
319329
<Compile Include="tests\unittest_fotobook\test_simpleBook.py" />
320330
<Compile Include="tests\test_webp_loading\test_webp_loading.py" />
321331
<Compile Include="testutils.py">
@@ -382,6 +392,11 @@
382392
<Folder Include="tests\testTextArt\" />
383393
<Folder Include="tests\testTextArt\previous_result_pdfs\" />
384394
<Folder Include="tests\testTextArt\test_textart_mcf-Dateien\" />
395+
<Folder Include="tests\testTextBox\" />
396+
<Folder Include="tests\testTextBox\previous_result_pdfs\" />
397+
<Folder Include="tests\testTextWrapVAlignBorder\" />
398+
<Folder Include="tests\testTextWrapVAlignBorder\previous_result_pdfs\" />
399+
<Folder Include="tests\testTextWrapVAlignBorder\test_textwrapvalignborder_mcf-Dateien\" />
385400
<Folder Include="tests\test_webp_loading\" />
386401
<Folder Include="tests\unittest_fotobook\" />
387402
<Folder Include="tests\Resources\" />

configUtils.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,31 @@
11
import logging
22

3+
def getUncommentedConfigItem(configSection, itemName, defaultValue):
4+
return str(configSection.get(itemName, defaultValue)).split('#', 1)[0].rstrip()
5+
36
def getConfigurationInt(configSection, itemName, defaultValue, minimumValue):
47
returnValue = minimumValue
58
if configSection is not None:
69
try:
710
# eg getConfigurationInt(defaultConfigSection, 'pdfImageResolution', '150', 100)
8-
returnValue = int(configSection.get(itemName, defaultValue))
11+
returnValue = int(getUncommentedConfigItem(configSection, itemName, defaultValue))
912
except ValueError:
10-
logging.error(f'Invalid configuration value supplied for {itemName}')
13+
logging.error(f'Invalid int configuration value supplied for {itemName}')
1114
returnValue = int(defaultValue)
1215
if returnValue < minimumValue:
1316
logging.error(f'Configuration value supplied for {itemName} is less than {minimumValue}, using {minimumValue}')
1417
returnValue = minimumValue
1518
return returnValue
1619

20+
1721
def getConfigurationFloat(configSection, itemName, defaultValue, minimumValue):
1822
returnValue = minimumValue
1923
if configSection is not None:
2024
try:
2125
# eg getConfigurationFloat(defaultConfigSection, 'pdfImageResolution', '1.15', 1.0)
22-
returnValue = float(configSection.get(itemName, defaultValue))
26+
returnValue = float(getUncommentedConfigItem(configSection, itemName, defaultValue))
2327
except ValueError:
24-
logging.error(f'Invalid configuration value supplied for {itemName}')
28+
logging.error(f'Invalid float configuration value supplied for {itemName}')
2529
returnValue = float(defaultValue)
2630
if returnValue < minimumValue:
2731
logging.error(f'Configuration value supplied for {itemName} is less than {minimumValue}, using {minimumValue}')
@@ -33,9 +37,9 @@ def getConfigurationBool(configSection, itemName, defaultValue):
3337
if configSection is not None:
3438
try:
3539
# eg getConfigurationBool(defaultConfigSection, 'insideCoverWhite', 'False')
36-
bv = configSection.get(itemName, defaultValue)
40+
bv = getUncommentedConfigItem(configSection, itemName, defaultValue)
3741
returnValue = bv.lower() == "true"
3842
except ValueError:
39-
logging.error(f'Invalid configuration value supplied for {itemName}')
43+
logging.error(f'Invalid bool configuration value supplied for {itemName}')
4044
returnValue = bool(defaultValue)
4145
return returnValue

fontHandling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ def registerFontFamilies(fontFamilies, explicitlyRegisteredFamilyNames):
301301
"Calibri": "Liberation Sans Narrow",
302302
"CalligraphScript": "Dancing Script",
303303
"CEWE Head": "Liberation Sans",
304-
"FranklinGothic": "Liberation Sans Narrow",
304+
"FranklinGothic": "Archivo Narrow",
305305
"Pecita": "Dancing Script",
306306
"Stafford": "Liberation Sans Narrow",
307307
"Balloon Caps": "Liberation Sans Narrow",

index.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import logging
2+
import re
13
import cv2
24
import fitz # PyMuPDF
35
import numpy as np
4-
import logging
5-
import re
66
from reportlab.lib.units import mm
77
from reportlab.pdfgen import canvas
88
from PIL import Image
@@ -128,7 +128,7 @@ def SaveIndexPdf(self, outputFileName, albumTitle, pagesize):
128128

129129
def SaveIndexPng(self, indexPdfFileName):
130130
if not self.indexing:
131-
return
131+
return None
132132
doc = fitz.open(indexPdfFileName)
133133
image = Index._convert_to_opencv(doc.load_page(0), dpi=150)
134134
transparent_image = Index._make_white_transparent(image)
@@ -225,7 +225,7 @@ def MergeAlbumAndIndexPng(self, albumPdfFileName, indexPngFileName):
225225
for line in lines:
226226
if pattern.search(line): # Check regex against each line separately
227227
markerFound = True
228-
markerRect = fitz.Rect(x0, y0, x1, y1)
228+
# markerRect = fitz.Rect(x0, y0, x1, y1)
229229
# full block rect, this needs refining if the marker is to be removed
230230
if not markerFound:
231231
continue

pageNumbering.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,14 @@ def horizontalPageNumberAdjustment(pnp, pageNumberingInfo, sideWidth, frameWidth
188188
if productStyle == ProductStyle.AlbumSingleSide:
189189
if pnp == PageNumberPosition.RIGHT:
190190
return sideWidth - pageNumberingInfo.horizontalMargin - frameWidth
191-
elif pnp == PageNumberPosition.LEFT:
191+
if pnp == PageNumberPosition.LEFT:
192192
return pageNumberingInfo.horizontalMargin
193193

194194
# all other cases drop through here to original outer edge page number position
195195
if oddpage:
196196
return sideWidth - pageNumberingInfo.horizontalMargin - frameWidth
197-
else:
198-
return pageNumberingInfo.horizontalMargin
197+
198+
return pageNumberingInfo.horizontalMargin
199199

200200

201201
def getPageNumberXy(pnp, pageNumberingInfo, pdf, frameWidth, frameHeight, productStyle, oddpage):

runAllTests.py

100644100755
File mode changed.

0 commit comments

Comments
 (0)