attachment
attachment

I will make a PDF of this image.

Reading File
Running Command

mkdir -p /home/daytona/workspace/pan-card-pdf && curl -s -o /home/daytona/workspace/pan-card-pdf/IMG_0021.jpeg "https://d361swluvexzqs.cloudfront.net/chats-attachments/IMG_0021-1779359616551-8u8www.jpeg" && echo "Downloaded"

Running Command

python3 -c " from PIL import Image from reportlab.lib.pagesizes import A4 from reportlab.pdfgen import canvas img_path = '/home/daytona/workspace/pan-card-pdf/IMG_0021.jpeg' out_path = '/home/daytona/workspace/pan-card-pdf/IMG_0021.pdf' img = Image.open(img_path) img_w, img_h = img.size page_w, page_h = A4 margin = 40 max_w = page_w - 2 * margin max_h = page_h - 2 * margin ratio = min(max_w / img_w, max_h / img_h) draw_w = img_w * ratio draw_h = img_h * ratio x = (page_w - draw_w) / 2 y = (page_h - draw_h) / 2 c = canvas.Canvas(out_path, pagesize=A4) c.drawImage(img_path, x, y, width=draw_w, height=draw_h) c.save() print('Done:', out_path) "

Your PDF is ready. The image has been centered on an A4 page with margins:

IMG 0021

PDF Document · PDF

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