Skip to content

Commit 2bb3574

Browse files
authored
Refactor PCB export script to combine individual layer PDFs into a single output file (#16)
* Refactor PCB export script to combine individual layer PDFs into a single output file * chore: update kicaddev Docker image to version 1.6.0 across all configurations
1 parent f160511 commit 2bb3574

File tree

13 files changed

+73
-34
lines changed

13 files changed

+73
-34
lines changed

.devcontainer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This DevContainer provides a complete hardware development environment for the K
66

77
1. Open this folder in VS Code
88
2. Click "Reopen in Container" when prompted
9-
3. Container starts in ~30 seconds using `ghcr.io/the78mole/kicaddev:1.5.0`
9+
3. Container starts in ~30 seconds using `ghcr.io/the78mole/kicaddev:1.6.0`
1010

1111
## ✨ Features Included
1212

.devcontainer/STATUS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The DevContainer environment for the KM217 hardware project is fully configured
66

77
### 🚀 What has been implemented:
88

9-
1. **Pre-built Docker Image**: Using `ghcr.io/the78mole/kicaddev:1.5.0`
9+
1. **Pre-built Docker Image**: Using `ghcr.io/the78mole/kicaddev:1.6.0`
1010
2. **Performance**: Startup time of ~30 seconds
1111
3. **Simplified Structure**: Only essential configuration files
1212
4. **Optimized Documentation**: Focus on essential features

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "KM217 Hardware Development Environment",
3-
"image": "ghcr.io/the78mole/kicaddev:1.5.0",
3+
"image": "ghcr.io/the78mole/kicaddev:1.6.0",
44
"features": {
55
"ghcr.io/devcontainers/features/common-utils:2": {
66
"installZsh": true,

.devcontainer/test-devcontainer.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fi
2828
echo ""
2929
echo "🐳 Container Quick Test:"
3030
echo "Testing if container can start and run basic commands..."
31-
docker run --rm ghcr.io/the78mole/kicaddev:1.5.0 bash -c "
31+
docker run --rm ghcr.io/the78mole/kicaddev:1.6.0 bash -c "
3232
echo 'Container startup: ✅'
3333
echo 'KiCad version:' \$(kicad-cli version 2>/dev/null | head -1 || echo 'KiCad CLI not found')
3434
echo 'Python version:' \$(python3 --version)

.github/workflows/pr-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
runs-on: ubuntu-latest
5353
needs: load-config
5454
container:
55-
image: ghcr.io/the78mole/kicaddev:1.5.0
55+
image: ghcr.io/the78mole/kicaddev:1.6.0
5656

5757
strategy:
5858
matrix:
@@ -199,7 +199,7 @@ jobs:
199199
name: 📚 Documentation Build
200200
runs-on: ubuntu-latest
201201
container:
202-
image: ghcr.io/the78mole/kicaddev:1.5.0
202+
image: ghcr.io/the78mole/kicaddev:1.6.0
203203

204204
steps:
205205
- name: 📥 Checkout Repository

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
runs-on: ubuntu-latest
7676
needs: [version, load-config]
7777
container:
78-
image: ghcr.io/the78mole/kicaddev:1.5.0
78+
image: ghcr.io/the78mole/kicaddev:1.6.0
7979

8080
strategy:
8181
matrix:
@@ -176,7 +176,7 @@ jobs:
176176
runs-on: ubuntu-latest
177177
needs: [version]
178178
container:
179-
image: ghcr.io/the78mole/kicaddev:1.5.0
179+
image: ghcr.io/the78mole/kicaddev:1.6.0
180180

181181
steps:
182182
- name: 📥 Checkout Repository

.github/workflows/scripts/export-pcb-pdf.sh

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,69 @@ while [[ $# -gt 0 ]]; do
2323
esac
2424
done
2525

26-
echo "📄 Exporting PCB layout to PDF for ${PROJECT_DESCRIPTION}..."
26+
echo "📄 Exporting PCB layout to combined PDF for ${PROJECT_DESCRIPTION}..."
2727
cd "${PROJECT_PATH}"
2828

29-
# Export PCB top layer
29+
# Create temporary directory for individual pages
30+
TEMP_DIR="Export/PDF/temp"
31+
mkdir -p "${TEMP_DIR}"
32+
33+
# Export individual layer pages
34+
echo "📄 Exporting User.Drawings + Edge.Cuts..."
3035
kicad-cli pcb export pdf \
31-
--output "Export/PDF/${PROJECT_NAME}-PCB-Top.pdf" \
36+
--output "${TEMP_DIR}/01-user-drawings.pdf" \
37+
--layers "User.Drawings,Edge.Cuts" \
38+
${PROJECT_NAME}.kicad_pcb
39+
40+
echo "📄 Exporting F.Cu + Edge.Cuts..."
41+
kicad-cli pcb export pdf \
42+
--output "${TEMP_DIR}/02-front-copper.pdf" \
43+
--layers "F.Cu,Edge.Cuts" \
44+
${PROJECT_NAME}.kicad_pcb
45+
46+
echo "📄 Exporting B.Cu + Edge.Cuts (mirrored)..."
47+
kicad-cli pcb export pdf \
48+
--output "${TEMP_DIR}/03-back-copper.pdf" \
49+
--layers "B.Cu,Edge.Cuts" \
50+
--mirror \
51+
${PROJECT_NAME}.kicad_pcb
52+
53+
echo "📄 Exporting F.Cu + F.Silkscreen + F.Mask + Edge.Cuts..."
54+
kicad-cli pcb export pdf \
55+
--output "${TEMP_DIR}/04-front-assembly.pdf" \
3256
--layers "F.Cu,F.Silkscreen,F.Mask,Edge.Cuts" \
3357
${PROJECT_NAME}.kicad_pcb
34-
35-
# Export PCB bottom layer
58+
59+
echo "📄 Exporting B.Cu + B.Silkscreen + B.Mask + Edge.Cuts (mirrored)..."
3660
kicad-cli pcb export pdf \
37-
--output "Export/PDF/${PROJECT_NAME}-PCB-Bottom.pdf" \
61+
--output "${TEMP_DIR}/05-back-assembly.pdf" \
3862
--layers "B.Cu,B.Silkscreen,B.Mask,Edge.Cuts" \
63+
--mirror \
3964
${PROJECT_NAME}.kicad_pcb
65+
66+
# Combine all PDFs into one using pdftk
67+
echo "📄 Combining all layers into single PDF using pdftk..."
68+
COMBINED_PDF="Export/PDF/${PROJECT_NAME}-PCB-Complete.pdf"
69+
70+
pdftk "${TEMP_DIR}"/01-user-drawings.pdf \
71+
"${TEMP_DIR}"/02-front-copper.pdf \
72+
"${TEMP_DIR}"/03-back-copper.pdf \
73+
"${TEMP_DIR}"/04-front-assembly.pdf \
74+
"${TEMP_DIR}"/05-back-assembly.pdf \
75+
cat output "${COMBINED_PDF}"
76+
77+
# Clean up temporary files
78+
rm -rf "${TEMP_DIR}"
79+
80+
# Verify export
81+
if [ -f "${COMBINED_PDF}" ]; then
82+
echo "${PROJECT_NAME}-PCB-Complete.pdf exported successfully (5 pages)"
83+
ls -lh "${COMBINED_PDF}"
4084

41-
# Verify exports
42-
for pdf in "Export/PDF/${PROJECT_NAME}-PCB-Top.pdf" "Export/PDF/${PROJECT_NAME}-PCB-Bottom.pdf"; do
43-
if [ -f "$pdf" ]; then
44-
echo "$(basename $pdf) exported successfully"
45-
ls -lh "$pdf"
46-
else
47-
echo "❌ Error: $(basename $pdf) export failed!"
48-
exit 1
49-
fi
50-
done
85+
# Show page count using pdftk
86+
PAGE_COUNT=$(pdftk "${COMBINED_PDF}" dump_data 2>/dev/null | grep NumberOfPages | awk '{print $2}' || echo "5")
87+
echo "📄 PDF contains ${PAGE_COUNT} pages"
88+
else
89+
echo "❌ Error: Combined PCB PDF export failed!"
90+
exit 1
91+
fi

.github/workflows/scripts/generate-production-summary-pr.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ $(ls -1 Export/Gerbers/ | sed 's/^/- /')
5050
$(ls -1 Export/Drill/ | sed 's/^/- /')
5151
5252
## 📄 Documentation
53-
- \`${PROJECT_NAME}-PCB-Top.pdf\` - Top layer layout
54-
- \`${PROJECT_NAME}-PCB-Bottom.pdf\` - Bottom layer layout
53+
- \`${PROJECT_NAME}-PCB-Complete.pdf\` - Complete PCB layout (5 pages: User drawings, Front copper, Back copper, Front assembly, Back assembly)
5554
5655
## 🖼️ Assembly Images
5756
$(ls -1 Export/Images/ | sed 's/^/- /')

.github/workflows/scripts/generate-production-summary.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ $(ls -1 Export/Gerbers/ | sed 's/^/- /')
5555
$(ls -1 Export/Drill/ | sed 's/^/- /')
5656
5757
## 📄 Documentation
58-
- \`${PROJECT_NAME}-PCB-Top.pdf\` - Top layer layout
59-
- \`${PROJECT_NAME}-PCB-Bottom.pdf\` - Bottom layer layout
58+
- \`${PROJECT_NAME}-PCB-Complete.pdf\` - Complete PCB layout (5 pages: User drawings, Front copper, Back copper, Front assembly, Back assembly)
6059
6160
## 🖼️ Assembly Images
6261
$(ls -1 Export/Images/ | sed 's/^/- /')

.github/workflows/scripts/validate-export-files.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ echo "🧪 Validating exported files for ${PROJECT_DESCRIPTION}..."
7676
cd "${PROJECT_PATH}/Export"
7777

7878
# Check if critical files exist and have reasonable sizes
79-
critical_files="PDF/${PROJECT_NAME}-Schematics.pdf PDF/${PROJECT_NAME}-PCB-Top.pdf PDF/${PROJECT_NAME}-PCB-Bottom.pdf 3D/${PROJECT_NAME}.step"
79+
critical_files="PDF/${PROJECT_NAME}-Schematics.pdf PDF/${PROJECT_NAME}-PCB-Complete.pdf 3D/${PROJECT_NAME}.step"
8080

8181
for file in $critical_files; do
8282
if [ -f "$file" ]; then

0 commit comments

Comments
 (0)