Custom-Dimension PDF Printer Bash Script Linux
Budget: €30 – €250 EUR
Develop a Bash script that prints user-provided PDFs at their exact dimensions on laser printers with adjustable trays, using CUPS on a Raspberry Pi 3b+ (Raspbian/Debian 12).
Requirements
Deliverables:
A Bash script (print-pdf.sh) that:
Accepts a PDF file and printer name as arguments.
Dynamically detects the PDF’s dimensions (in mm).
Configures CUPS temporarily (if needed) and prints the PDF 1:1 without scaling.
Example command:
bash
Copy
./print-pdf.sh -p "Printer_Name" -f "document.pdf"
Test PDFs: I will provide 3 PDFs with unique sizes (e.g., 132x96 mm, 340x110 mm, 80x50 mm).
Technical Constraints:
Use only command-line tools (lp, pdfinfo, awk).
No persistent CUPS configuration changes (e.g., avoid lpadmin if possible).
Handle printers with hard-coded margins (content must be centered as much as hardware allows).
Key Focus:
Ensure the printer uses the exact paper size of the PDF (no cropping/stretching).
Graceful error handling for unsupported sizes (e.g., Error: Printer X does not support 80x50mm).
Skills Required
Expertise in CUPS command-line tools and PDF metadata extraction.
Knowledge of printer margin limitations and centering techniques.
Experience with Bash string parsing (e.g., extracting dimensions from pdfinfo).
Testing & Validation
You will:
Test the script with your own laser printer(s) using the client’s test PDFs.
Verify:
Printed dimensions match the PDF’s dimensions (measured manually).
No content distortion or misalignment.
Provide a debugging log for errors (e.g., CUPS job failures).
Sample Script Structure
bash
Copy
#!/bin/bash
# Extract PDF dimensions (in mm)
width=$(pdfinfo "$2" | grep "Page size" | awk '{printf "%.0f", $3*25.4/72}') # Convert points to mm
height=$(pdfinfo "$2" | grep "Page size" | awk '{printf "%.0f", $5*25.4/72}')
# Print with CUPS
lp -d "$1" \
-o media=Custom.${width}x${height}mm \
-o position=center \
-o fit-to-page \
"$2" || echo "Error: Check printer size support."
Budget & Timeline
Budget: Fixed price (state in proposal).
Deadline: 5 days after acceptance.
Submission Guidelines
Proposal Must Include:
Explanation of how you’ll handle printer-specific margins.
A snippet showing PDF dimension extraction logic.
Confirmation that you have access to a laser printer for testing.
Exclude: Proposals without CUPS/Bash examples.
Requirements
Deliverables:
A Bash script (print-pdf.sh) that:
Accepts a PDF file and printer name as arguments.
Dynamically detects the PDF’s dimensions (in mm).
Configures CUPS temporarily (if needed) and prints the PDF 1:1 without scaling.
Example command:
bash
Copy
./print-pdf.sh -p "Printer_Name" -f "document.pdf"
Test PDFs: I will provide 3 PDFs with unique sizes (e.g., 132x96 mm, 340x110 mm, 80x50 mm).
Technical Constraints:
Use only command-line tools (lp, pdfinfo, awk).
No persistent CUPS configuration changes (e.g., avoid lpadmin if possible).
Handle printers with hard-coded margins (content must be centered as much as hardware allows).
Key Focus:
Ensure the printer uses the exact paper size of the PDF (no cropping/stretching).
Graceful error handling for unsupported sizes (e.g., Error: Printer X does not support 80x50mm).
Skills Required
Expertise in CUPS command-line tools and PDF metadata extraction.
Knowledge of printer margin limitations and centering techniques.
Experience with Bash string parsing (e.g., extracting dimensions from pdfinfo).
Testing & Validation
You will:
Test the script with your own laser printer(s) using the client’s test PDFs.
Verify:
Printed dimensions match the PDF’s dimensions (measured manually).
No content distortion or misalignment.
Provide a debugging log for errors (e.g., CUPS job failures).
Sample Script Structure
bash
Copy
#!/bin/bash
# Extract PDF dimensions (in mm)
width=$(pdfinfo "$2" | grep "Page size" | awk '{printf "%.0f", $3*25.4/72}') # Convert points to mm
height=$(pdfinfo "$2" | grep "Page size" | awk '{printf "%.0f", $5*25.4/72}')
# Print with CUPS
lp -d "$1" \
-o media=Custom.${width}x${height}mm \
-o position=center \
-o fit-to-page \
"$2" || echo "Error: Check printer size support."
Budget & Timeline
Budget: Fixed price (state in proposal).
Deadline: 5 days after acceptance.
Submission Guidelines
Proposal Must Include:
Explanation of how you’ll handle printer-specific margins.
A snippet showing PDF dimension extraction logic.
Confirmation that you have access to a laser printer for testing.
Exclude: Proposals without CUPS/Bash examples.