attachment
attachment

Iska bdiya pdf bna do

analyse_media
Reading File
Reading File
Browsing Directory

~/

Browsing Directory

~/attachments

Running Command

mkdir -p "/tmp/workspace/biomedical-waste-pdf/src" "/tmp/workspace/biomedical-waste-pdf/output" && python - <<'PY' from PIL import Image p='/tmp/workspace/attachments/55d10f33-7a2d-4759-9109-a45f3bb28ac5/photo-1788265742104.jpg' im=Image.open(p) print(im.size, im.mode) PY

Running Command

fc-list | sed -n '1,20p'; python - <<'PY' import os for root,dirs,files in os.walk('/usr/share/fonts/truetype'): for f in files: if f.endswith('.ttf') and ('DejaVuSans' in f or 'Noto' in f): print(os.path.join(root,f)) PY

Running Command

fc-match 'Noto Sans Devanagari' -f '%{file}\n'; fc-match 'Noto Sans' -f '%{file}\n'

Browsing Directory

~/biomedical-waste-pdf

Writing File

~/biomedical-waste-pdf/src/create_poster.py

from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import A3, landscape
from reportlab.lib.colors import HexColor, white, black
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.lib.utils import simpleSplit
from reportlab.pdfbase.pdfmetrics import stringWidth
import os

OUT = '/tmp/workspace/biomedical-waste-pdf/output/Biomedical_Waste_Segregation_Poster.pdf'
FONT = '/usr/share/fonts/google-noto-vf/NotoSans[wght].ttf'
pdfmetrics.registerFont(TTFont('Noto', FONT))
pdfmetrics.registerFont(TTFont('NotoBold', FONT))

W, H = landscape(A3)
c = canvas.Canvas(OUT, pagesize=(W,H))
c.setTitle('Biomedical Waste Segregation - Quick Reference')
c.setAuthor('Prepared from the supplied biomedical waste poster')

# Palette
NAVY=HexColor('#035C9F'); DEEP=HexColor('#053B67'); BLACK=HexColor('#24272B')
YELLOW=HexColor('#F7D837'); RED=HexColor('#D32D27'); BLUE=HexColor('#2957A4')
GREY=HexColor('#EFF3F7'); DARK=HexColor('#12263A'); WHITEBOX=HexColor('#F5F7F9')

# Background and outer border
c.setFillColor(white); c.rect(0,0,W,H,fill=1,stroke=0)
c.setStrokeColor(NAVY); c.setLineWidth(10); c.rect(18,18,W-36,H-36,stroke=1,fill=0)

# Header
header_h=126
c.setFillColor(NAVY); c.rect(23,H-23-header_h,W-46,header_h,fill=1,stroke=0)
c.setFillColor(white); c.setFont('NotoBold',22)
c.drawCentredString(W/2,H-62,'Dr. Susheela Tiwari Govt. Hospital & Govt. Medical College, Haldwani')
c.setFont('NotoBold',31); c.drawCentredString(W/2,H-98,'बायो मेडिकल वेस्ट  |  BIO-MEDICAL WASTE')
c.setFont('Noto',13); c.drawCentredString(W/2,H-120,'Quick Segregation Reference  •  Biomedical Waste Management Rules, 2016')
# biohazard circles left/right
for x in (63,W-63):
    c.setStrokeColor(white); c.setLineWidth(2.2); c.circle(x,H-83,22,stroke=1,fill=0)
    c.setFont('NotoBold',10); c.drawCentredString(x,H-87,'☣')
    c.setFont('NotoBold',7); c.drawCentredString(x,H-113,'BIOHAZARD')

# content geometry
left=38; bottom=72; top=H-header_h-34; gap=12
available=W-2*left-4*gap
widths=[190,215,360,170,170]
scale=available/sum(widths); widths=[v*scale for v in widths]
colors=[BLACK,WHITEBOX,YELLOW,RED,BLUE]
titles=[('काला थैला','BLACK BAG'),('सफेद डिब्बा','WHITE CONTAINER'),('पीला थैला','YELLOW BAG'),('लाल थैला','RED BAG'),('नीला डिब्बा','BLUE CONTAINER')]
text_colors=[white,DARK,DARK,white,white]
body_top=top-78

items=[
 ['General waste (non-infectious)', 'Paper, tissue, wrappers, dry waste, water bottle'],
 ['Waste sharps including metals', 'Needles, syringes with fixed needles, needles from needle cutter or burner, scalpel blades and other contaminated sharp objects', 'Use a puncture-, tamper- and leak-proof container.'],
 ['Human and animal anatomical waste', 'Tissues, organs, body parts, fetus etc.', 'Soiled waste', 'Dressings, plaster casts, cotton swabs, bags contaminated with blood or body fluids', 'Expired or discarded medicine', 'Chemical waste', 'Discarded linen, mattresses and bedding', 'Pre-treated microbiology / biotechnology and clinical laboratory waste', 'Cytotoxic drug waste'],
 ['Contaminated recyclable waste', 'Plastic tubing, bottles, IV sets, catheters, urine bags, syringes without needles, vacutainers and gloves'],
 ['Glassware', 'Contaminated broken or discarded glass, vials, ampoules, and metallic body implants']
]

def wrapped(text,x,y,maxw,font='Noto',size=10,leading=13, color=DARK, bullet=True):
    c.setFont(font,size); c.setFillColor(color)
    prefix='•  ' if bullet else ''
    lines=simpleSplit(prefix+text,font,size,maxw)
    for line in lines:
        c.drawString(x,y,line); y-=leading
    return y

def draw_icon(x,y,w,h,kind,fg):
    # pale card and simple visual identifier
    c.setFillColor(HexColor('#FFFFFF') if kind!='black' else HexColor('#41454A'))
    c.roundRect(x,y,w,h,8,fill=1,stroke=0)
    c.setFillColor(fg)
    if kind=='black':
        c.roundRect(x+w*.34,y+h*.18,w*.32,h*.50,7,fill=1,stroke=0)
        c.rect(x+w*.39,y+h*.68,w*.22,h*.06,fill=1,stroke=0)
        c.setFillColor(white); c.setFont('NotoBold',18); c.drawCentredString(x+w*.5,y+h*.40,'WASTE')
    elif kind=='white':
        c.setStrokeColor(DEEP); c.setLineWidth(3); c.line(x+w*.27,y+h*.24,x+w*.68,y+h*.72)
        c.setFillColor(HexColor('#59C7DA')); c.circle(x+w*.71,y+h*.74,7,fill=1,stroke=0)
        c.setFillColor(RED); c.setFont('NotoBold',24); c.drawCentredString(x+w*.5,y+h*.26,'☣')
    elif kind=='yellow':
        c.setFillColor(HexColor('#A99F15')); c.roundRect(x+w*.34,y+h*.14,w*.32,h*.63,8,fill=1,stroke=0)
        c.setFillColor(BLACK); c.setFont('NotoBold',32); c.drawCentredString(x+w*.5,y+h*.42,'☣')
    elif kind=='red':
        c.setFillColor(RED); c.roundRect(x+w*.34,y+h*.14,w*.32,h*.63,8,fill=1,stroke=0)
        c.setFillColor(white); c.setFont('NotoBold',28); c.drawCentredString(x+w*.5,y+h*.42,'☣')
    else:
        c.setFillColor(BLUE); c.roundRect(x+w*.34,y+h*.14,w*.32,h*.63,8,fill=1,stroke=0)
        c.setFillColor(white); c.setFont('NotoBold',15); c.drawCentredString(x+w*.5,y+h*.44,'GLASS')

x=left
for i,w in enumerate(widths):
    col=colors[i]; tc=text_colors[i]
    # full panel
    c.setFillColor(col); c.roundRect(x,bottom,w,top-bottom,9,fill=1,stroke=0)
    # panel header
    c.setFillColor(white if i in (0,3,4) else (HexColor('#E1E6EA') if i==1 else HexColor('#FDEB75')))
    c.roundRect(x+5,top-70,w-10,64,6,fill=1,stroke=0)
    c.setFillColor(DARK); c.setFont('NotoBold',16 if i!=2 else 18)
    c.drawCentredString(x+w/2,top-31,titles[i][0])
    c.setFont('NotoBold',16 if i!=2 else 18); c.drawCentredString(x+w/2,top-53,titles[i][1])
    # content text
    y=body_top-4
    maxw=w-28
    for j,t in enumerate(items[i]):
        is_head=(i==2 and j in [0,2,4,5,6,7,8]) or (i in [0,1,3,4] and j==0)
        y=wrapped(t,x+14,y,maxw,'NotoBold' if is_head else 'Noto',10.2 if i==2 else 11,13 if i==2 else 14,tc,bullet=True)
        y-=5
    # illustration
    draw_icon(x+w*.15,bottom+15,w*.70,58,['black','white','yellow','red','blue'][i],white if i in (0,3,4) else DARK)
    x+=w+gap

# bottom strip
c.setFillColor(DEEP); c.rect(23,25,W-46,33,fill=1,stroke=0)
c.setFillColor(white); c.setFont('NotoBold',10)
c.drawCentredString(W/2,38,'SEGREGATE AT THE POINT OF GENERATION  •  DO NOT MIX WASTE STREAMS  •  FOLLOW YOUR FACILITY SOP')

c.save()
print(OUT)
Running Command

python "/tmp/workspace/biomedical-waste-pdf/src/create_poster.py" && python - <<'PY' from pypdf import PdfReader p='/tmp/workspace/biomedical-waste-pdf/output/Biomedical_Waste_Segregation_Poster.pdf' r=PdfReader(p) print('pages:',len(r.pages)) print('size:',r.pages[0].mediabox) print((r.pages[0].extract_text() or '')[:500]) import fitz D=fitz.open(p) pix=D[0].get_pixmap(matrix=fitz.Matrix(1.3,1.3), alpha=False) out='/tmp/workspace/biomedical-waste-pdf/output/preview.png' pix.save(out) print(out) PY

Running Command

fc-list | grep -Ei 'devanagari|hindi|lohit' || true; ls -lh "/tmp/workspace/biomedical-waste-pdf/output/Biomedical_Waste_Segregation_Poster.pdf"; python - <<'PY' from pypdf import PdfReader p='/tmp/workspace/biomedical-waste-pdf/output/Biomedical_Waste_Segregation_Poster.pdf' r=PdfReader(p) assert len(r.pages)==1 assert r.pages[0].mediabox.width > 1000 print('PDF verified:', len(r.pages), 'page, A3 landscape') PY

Reading File
Editing File

~/biomedical-waste-pdf/src/create_poster.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/biomedical-waste-pdf/src/create_poster.py'
Editing File

~/biomedical-waste-pdf/src/create_poster.py

Successfully replaced 1 instance(s) of the string in '/tmp/workspace/biomedical-waste-pdf/src/create_poster.py'
Running Command

python "/tmp/workspace/biomedical-waste-pdf/src/create_poster.py" && python - <<'PY' from pypdf import PdfReader p='/tmp/workspace/biomedical-waste-pdf/output/Biomedical_Waste_Segregation_Poster.pdf' r=PdfReader(p) assert len(r.pages)==1 assert r.pages[0].mediabox.width > 1000 print('Verified:', len(r.pages), 'page; size:', r.pages[0].mediabox.width, 'x', r.pages[0].mediabox.height) PY ls -lh "/tmp/workspace/biomedical-waste-pdf/output/Biomedical_Waste_Segregation_Poster.pdf"

साफ-सुथरा A3 landscape PDF poster तैयार है, जिसमें biomedical waste की 5 रंग-कोडेड categories दी गई हैं।

Biomedical Waste Segregation Poster

PDF Document · PDF

Bnd do same likha hua bas pdf format

Reading File
Browsing Directory

~/

Running Command

mkdir -p "/tmp/workspace/biomedical-waste-photo-pdf/output" && python - <<'PY' from PIL import Image from pypdf import PdfReader src='/tmp/workspace/attachments/55d10f33-7a2d-4759-9109-a45f3bb28ac5/photo-1788265742104.jpg' out='/tmp/workspace/biomedical-waste-photo-pdf/output/Biomedical_Waste_Original_Photo.pdf' im=Image.open(src) # The original photo is placed unchanged as a single PDF page. im.save(out, 'PDF', resolution=150.0, quality=100) r=PdfReader(out) assert len(r.pages)==1 print('created',out, 'source_size',im.size, 'pages',len(r.pages)) PY ls -lh "/tmp/workspace/biomedical-waste-photo-pdf/output/Biomedical_Waste_Original_Photo.pdf"

Same image ko bina kuch change kiye PDF format mein bana diya hai:

Biomedical Waste Original Photo

PDF Document · PDF

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