Skip to content

Commit 5557ad7

Browse files
authored
Fix PDF generation: handle index.pdf in _exports and configure proper PDF filename
1 parent 74a9283 commit 5557ad7

File tree

3 files changed

+106
-16
lines changed

3 files changed

+106
-16
lines changed

.github/workflows/build-and-deploy-tutorial.yml

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ jobs:
7272
if [ -d "./build/site" ]; then
7373
echo "✅ Site generated successfully"
7474
ls -la ./build/site
75-
# Check if PDF was generated and would be available for UI bundle
76-
if [ -f "./build/assembler/microprofile-tutorial/6.1/microprofile-tutorial.pdf" ]; then
77-
echo "✅ PDF generated successfully for UI bundle"
78-
ls -la ./build/assembler/microprofile-tutorial/6.1/
75+
# Check if PDF was generated (it's actually generated as index.pdf in _exports)
76+
echo "🔍 Looking for generated PDF files..."
77+
find . -name "*.pdf" -type f
78+
79+
if [ -f "./build/assembler/microprofile-tutorial/6.1/_exports/index.pdf" ] || [ -f "./build/site/microprofile-tutorial/6.1/_exports/index.pdf" ]; then
80+
echo "✅ PDF generated successfully (found as index.pdf in _exports)"
7981
else
8082
echo "⚠️ PDF not generated in expected location"
8183
find . -name "*.pdf" -type f
@@ -176,17 +178,33 @@ jobs:
176178
# Verify PDF generation and copy to correct location for download
177179
- name: Verify PDF generation and copy to correct location for download
178180
run: |
179-
if [ -f "./build/assembler/microprofile-tutorial/6.1/microprofile-tutorial.pdf" ]; then
180-
echo "✅ PDF generated in assembler location"
181-
PDF_SIZE=$(stat -f%z "./build/assembler/microprofile-tutorial/6.1/microprofile-tutorial.pdf" 2>/dev/null || stat -c%s "./build/assembler/microprofile-tutorial/6.1/microprofile-tutorial.pdf")
181+
echo "🔍 Looking for generated PDF files..."
182+
find . -name "*.pdf" -type f
183+
184+
# The PDF is actually generated as index.pdf in _exports subdirectory
185+
PDF_SOURCE=""
186+
if [ -f "./build/assembler/microprofile-tutorial/6.1/_exports/index.pdf" ]; then
187+
PDF_SOURCE="./build/assembler/microprofile-tutorial/6.1/_exports/index.pdf"
188+
echo "✅ PDF found in assembler/_exports location"
189+
elif [ -f "./build/site/microprofile-tutorial/6.1/_exports/index.pdf" ]; then
190+
PDF_SOURCE="./build/site/microprofile-tutorial/6.1/_exports/index.pdf"
191+
echo "✅ PDF found in site/_exports location"
192+
else
193+
echo "❌ PDF not found in expected locations"
194+
echo "Available PDF files:"
195+
find . -name "*.pdf" -type f
196+
exit 1
197+
fi
198+
199+
if [ -n "$PDF_SOURCE" ]; then
200+
PDF_SIZE=$(stat -f%z "$PDF_SOURCE" 2>/dev/null || stat -c%s "$PDF_SOURCE")
182201
echo "PDF Size: ${PDF_SIZE} bytes"
183202
184203
# Copy PDF to the exact location the download link expects
185204
# The download link is ../../microprofile-tutorial/6.1/microprofile-tutorial.pdf
186205
# From /microprofile-tutorial/6.1/index.html, this resolves to /microprofile-tutorial/6.1/microprofile-tutorial.pdf
187206
mkdir -p "./build/site/microprofile-tutorial/6.1/"
188-
cp "./build/assembler/microprofile-tutorial/6.1/microprofile-tutorial.pdf" \
189-
"./build/site/microprofile-tutorial/6.1/microprofile-tutorial.pdf"
207+
cp "$PDF_SOURCE" "./build/site/microprofile-tutorial/6.1/microprofile-tutorial.pdf"
190208
echo "✅ PDF copied to download location: /microprofile-tutorial/6.1/microprofile-tutorial.pdf"
191209
192210
# Verify the copy was successful
@@ -216,10 +234,6 @@ jobs:
216234
echo "✅ PDF-specific .htaccess created"
217235
218236
echo "✅ PDF download headers configured"
219-
else
220-
echo "❌ PDF not found in assembler location"
221-
find . -name "*.pdf" -type f
222-
exit 1
223237
fi
224238
225239
# Copy assembler directory to site for PDF access via UI bundle

antora-assembler.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ antora:
3838
- require: '@antora/lunr-extension' # Search functionality
3939
index_latest_only: true
4040
- require: '@antora/pdf-extension' # PDF generation
41-
generate_index: true
42-
index_filename: microprofile-tutorial
43-
output_format: pdf
41+
as_attachment: true
42+
filename: microprofile-tutorial.pdf
43+
output_dir: ./build/assembler
4444

4545
output:
4646
dir: ./build/site

test-pdf-download.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
echo "🔍 Testing PDF Download Functionality"
4+
echo "======================================"
5+
6+
# Check if the site was built
7+
if [ ! -d "build/site" ]; then
8+
echo "❌ Site not built. Run the GitHub Actions workflow first."
9+
exit 1
10+
fi
11+
12+
echo "✅ Site directory exists"
13+
14+
# Check if PDF exists in assembler location
15+
if [ -f "build/assembler/microprofile-tutorial/6.1/microprofile-tutorial.pdf" ]; then
16+
echo "✅ PDF found in assembler location"
17+
PDF_SIZE=$(stat -f%z "build/assembler/microprofile-tutorial/6.1/microprofile-tutorial.pdf" 2>/dev/null || stat -c%s "build/assembler/microprofile-tutorial/6.1/microprofile-tutorial.pdf")
18+
echo " Size: ${PDF_SIZE} bytes"
19+
else
20+
echo "❌ PDF not found in assembler location"
21+
fi
22+
23+
# Check if PDF exists in site location (where download link points)
24+
if [ -f "build/site/microprofile-tutorial/6.1/microprofile-tutorial.pdf" ]; then
25+
echo "✅ PDF found in download location: /microprofile-tutorial/6.1/microprofile-tutorial.pdf"
26+
PDF_SIZE=$(stat -f%z "build/site/microprofile-tutorial/6.1/microprofile-tutorial.pdf" 2>/dev/null || stat -c%s "build/site/microprofile-tutorial/6.1/microprofile-tutorial.pdf")
27+
echo " Size: ${PDF_SIZE} bytes"
28+
else
29+
echo "❌ PDF not found in download location: /microprofile-tutorial/6.1/microprofile-tutorial.pdf"
30+
echo " This is where the download link expects to find the PDF"
31+
fi
32+
33+
# Check if .htaccess files exist
34+
if [ -f "build/site/.htaccess" ]; then
35+
echo "✅ Root .htaccess file exists"
36+
else
37+
echo "❌ Root .htaccess file missing"
38+
fi
39+
40+
if [ -f "build/site/microprofile-tutorial/6.1/.htaccess" ]; then
41+
echo "✅ PDF directory .htaccess file exists"
42+
else
43+
echo "❌ PDF directory .htaccess file missing"
44+
fi
45+
46+
# Check the main HTML file for download link
47+
if [ -f "build/site/microprofile-tutorial/6.1/index.html" ]; then
48+
echo "✅ Main HTML file exists"
49+
50+
# Look for PDF download link
51+
if grep -q "microprofile-tutorial.pdf" "build/site/microprofile-tutorial/6.1/index.html"; then
52+
echo "✅ PDF download link found in HTML"
53+
echo " Link details:"
54+
grep -n "microprofile-tutorial.pdf" "build/site/microprofile-tutorial/6.1/index.html" | head -2
55+
else
56+
echo "❌ PDF download link not found in HTML"
57+
fi
58+
59+
# Check if our JavaScript is included
60+
if grep -q "querySelectorAll.*pdf" "build/site/microprofile-tutorial/6.1/index.html"; then
61+
echo "✅ PDF download JavaScript found in HTML"
62+
else
63+
echo "❌ PDF download JavaScript not found in HTML"
64+
fi
65+
else
66+
echo "❌ Main HTML file not found"
67+
fi
68+
69+
echo ""
70+
echo "🎯 Manual Test Instructions:"
71+
echo "1. Open the deployed site in a browser"
72+
echo "2. Navigate to the tutorial page"
73+
echo "3. Click the 'Download PDF' button"
74+
echo "4. The PDF should download as 'microprofile-tutorial.pdf'"
75+
echo ""
76+
echo "🔗 Expected PDF URL: [your-site-url]/microprofile-tutorial/6.1/microprofile-tutorial.pdf"

0 commit comments

Comments
 (0)