attachment
attachment
attachment
attachment
attachment
attachment

Make PDF of three images.

I'll combine the three images into a single PDF right away.
Reading File
Running Command

mkdir -p /home/daytona/workspace/images-to-pdf && cd /home/daytona/workspace/images-to-pdf && curl -sL "https://d361swluvexzqs.cloudfront.net/chats-attachments/IMG_0077-1779956821172-7jmv7s.jpg" -o img1.jpg && curl -sL "https://d361swluvexzqs.cloudfront.net/chats-attachments/IMG_0076-1779956822336-lkogpy.jpg" -o img2.jpg && curl -sL "https://d361swluvexzqs.cloudfront.net/chats-attachments/photo-1779956852487-1779956852556-m7omsf.jpg" -o img3.jpg && echo "Downloaded" && ls -lh *.jpg

Running Command

cd /home/daytona/workspace/images-to-pdf && python3 - <<'EOF' from PIL import Image from reportlab.lib.pagesizes import A4 from reportlab.pdfgen import canvas import os images = ["img1.jpg", "img2.jpg", "img3.jpg"] output_path = "documents.pdf" c = canvas.Canvas(output_path, pagesize=A4) page_w, page_h = A4 for img_path in images: img = Image.open(img_path) img_w, img_h = img.size # Scale to fit A4 with small margins margin = 20 max_w = page_w - 2 * margin max_h = page_h - 2 * margin scale = min(max_w / img_w, max_h / img_h) draw_w = img_w * scale draw_h = img_h * scale x = (page_w - draw_w) / 2 y = (page_h - draw_h) / 2 c.drawImage(img_path, x, y, width=draw_w, height=draw_h) c.showPage() c.save() print(f"PDF created: {output_path}") print(f"Size: {os.path.getsize(output_path) / 1024:.1f} KB") EOF

Done! Your 3-page PDF is ready - each image on its own A4 page, scaled to fit with margins.

documents

PDF Document · PDF

attachment
attachment
attachment
attachment
attachment
attachment

Make PDF of all three images.

Running Command

mkdir -p /home/daytona/workspace/images-to-pdf2 && cd /home/daytona/workspace/images-to-pdf2 && curl -sL "https://d361swluvexzqs.cloudfront.net/chats-attachments/IMG_0077-1779957082858-1now21.jpg" -o img1.jpg && curl -sL "https://d361swluvexzqs.cloudfront.net/chats-attachments/IMG_0076-1779957083826-kp7hpy.jpg" -o img2.jpg && curl -sL "https://d361swluvexzqs.cloudfront.net/chats-attachments/IMG_0075-1779957085494-8cm74m.jpg" -o img3.jpg && echo "Downloaded" && ls -lh *.jpg

Running Command

cd /home/daytona/workspace/images-to-pdf2 && python3 - <<'EOF' from PIL import Image from reportlab.lib.pagesizes import A4 from reportlab.pdfgen import canvas import os images = ["img1.jpg", "img2.jpg", "img3.jpg"] output_path = "documents.pdf" c = canvas.Canvas(output_path, pagesize=A4) page_w, page_h = A4 for img_path in images: img = Image.open(img_path) img_w, img_h = img.size margin = 20 max_w = page_w - 2 * margin max_h = page_h - 2 * margin scale = min(max_w / img_w, max_h / img_h) draw_w = img_w * scale draw_h = img_h * scale x = (page_w - draw_w) / 2 y = (page_h - draw_h) / 2 c.drawImage(img_path, x, y, width=draw_w, height=draw_h) c.showPage() c.save() print(f"PDF created: {output_path}") print(f"Size: {os.path.getsize(output_path) / 1024:.1f} KB") EOF

Done! Your 3-page PDF is ready - one image per page.

documents

PDF Document · PDF

This is a shared conversation. Sign in to Orris to start your own chat.