Please create a handbook colorful pdf with all the required vocabulary words list from the pdf I have attached for my ESL 3rd grade student.
~/
python - <<'PY' import pdfplumber p='/tmp/workspace/attachments/a90ee2a8-4eba-4278-befb-18a6f2136f2c/DOC-20260831-WA0003 (1).pdf' with pdfplumber.open(p) as pdf: print('PAGES',len(pdf.pages)) for i,page in enumerate(pdf.pages): t=page.extract_text(x_tolerance=1,y_tolerance=3) or '' print('\n--- PAGE',i+1,'---\n',t[:12000]) PY
mkdir -p "/tmp/workspace/esl-vocabulary-handbook/assets" "/tmp/workspace/esl-vocabulary-handbook/output" "/tmp/workspace/esl-vocabulary-handbook/src" && python - <<'PY' import fitz p='/tmp/workspace/attachments/a90ee2a8-4eba-4278-befb-18a6f2136f2c/DOC-20260831-WA0003 (1).pdf' doc=fitz.open(p) for i,page in enumerate(doc): pix=page.get_pixmap(matrix=fitz.Matrix(2,2), alpha=False) pix.save(f'/tmp/workspace/esl-vocabulary-handbook/assets/source_page_{i+1}.png') print(i+1, page.rect, len(page.get_images(full=True))) PY
python - <<'PY' from pypdf import PdfReader from PIL import Image from io import BytesIO p='/tmp/workspace/attachments/a90ee2a8-4eba-4278-befb-18a6f2136f2c/DOC-20260831-WA0003 (1).pdf' r=PdfReader(p) for n,page in enumerate(r.pages,1): print('page',n,'images',len(page.images)) for j,img in enumerate(page.images): print(' ',j,img.name,len(img.data)) open(f'/tmp/workspace/esl-vocabulary-handbook/assets/p{n}_{j}_{img.name.replace("/", "_")}', 'wb').write(img.data) PY ls -lh "/tmp/workspace/esl-vocabulary-handbook/assets"
python - <<'PY' from PIL import Image import os for f in os.listdir('/tmp/workspace/esl-vocabulary-handbook/assets'): p='/tmp/workspace/esl-vocabulary-handbook/assets/'+f im=Image.open(p) print(f, im.size, im.mode) try: import pytesseract print('pytesseract import yes') for f in sorted(os.listdir('/tmp/workspace/esl-vocabulary-handbook/assets')): print('\n',f, '\n',pytesseract.image_to_string(Image.open('/tmp/workspace/esl-vocabulary-handbook/assets/'+f))) except Exception as e: print('OCR ERR',repr(e)) PY
command -v tesseract || true; python - <<'PY' try: import cv2; print('cv2 yes') except Exception as e: print('cv2 no') try: import easyocr; print('easyocr yes') except Exception as e: print('easyocr no') PY
pip install --user rapidocr_onnxruntime -q
pip install rapidocr_onnxruntime -q
python - <<'PY' from rapidocr_onnxruntime import RapidOCR from PIL import Image import os ocr=RapidOCR() base='/tmp/workspace/esl-vocabulary-handbook/assets' for f in sorted(os.listdir(base)): if not f.endswith('.jpg'): continue r,elapse=ocr(os.path.join(base,f)) print('\n-----',f,'-----') if r: for x in r: print(x[1],round(x[2],2)) PY
~/esl-vocabulary-handbook/
~/esl-vocabulary-handbook/src/create_handbook.py
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter
from reportlab.lib import colors
from reportlab.pdfbase.pdfmetrics import stringWidth
from reportlab.lib.utils import simpleSplit
from reportlab.pdfbase.ttfonts import TTFont
from reportlab.pdfbase import pdfmetrics
from reportlab.lib.colors import HexColor
import os, random
OUT='/tmp/workspace/esl-vocabulary-handbook/output/Animal_Vocabulary_Handbook_Grade3_ESL.pdf'
W,H=letter
random.seed(4)
# Palette
NAVY=HexColor('#173F5F'); BLUE=HexColor('#20639B'); AQUA=HexColor('#3CAEA3')
YELLOW=HexColor('#F6D55C'); ORANGE=HexColor('#ED553B'); PINK=HexColor('#F28DA3')
PURPLE=HexColor('#7E57C2'); CREAM=HexColor('#FFF9ED'); DARK=HexColor('#263238')
PALE=HexColor('#EAF7F5'); GREEN=HexColor('#65B97A')
c=canvas.Canvas(OUT,pagesize=letter)
c.setTitle('Animal Vocabulary Handbook - Grade 3 ESL')
def font(size=12,bold=False):
c.setFont('Helvetica-Bold' if bold else 'Helvetica',size)
def rect(x,y,w,h,fill,stroke=None,r=0):
c.setFillColor(fill); c.setStrokeColor(stroke or fill)
if r: c.roundRect(x,y,w,h,r,fill=1,stroke=bool(stroke))
else:c.rect(x,y,w,h,fill=1,stroke=bool(stroke))
def text(x,y,s,size=12,col=DARK,bold=False):
c.setFillColor(col); font(size,bold); c.drawString(x,y,s)
def center(y,s,size=12,col=DARK,bold=False):
c.setFillColor(col);font(size,bold);c.drawCentredString(W/2,y,s)
def wrap(x,y,s,width,size=12,leading=16,col=DARK,bold=False):
c.setFillColor(col);font(size,bold)
for line in simpleSplit(s,'Helvetica-Bold' if bold else 'Helvetica',size,width):
c.drawString(x,y,line);y-=leading
return y
def dots():
for _ in range(25):
x=random.randint(18,int(W-18)); y=random.randint(18,int(H-18)); r=random.choice([2,3,4])
c.setFillColor(random.choice([YELLOW,PINK,AQUA,HexColor('#C9E9EE')]));c.circle(x,y,r,fill=1,stroke=0)
def footer(n):
c.setStrokeColor(HexColor('#B8D8D8'));c.line(42,34,W-42,34)
text(42,20,'Animal Vocabulary Handbook',8,BLUE,True);text(W-58,20,str(n),8,BLUE,True)
def page(title,subtitle,n):
rect(0,0,W,H,CREAM);dots();rect(0,H-100,W,100,NAVY)
text(42,H-55,title,25,colors.white,True)
if subtitle:text(42,H-78,subtitle,11,HexColor('#D5F3F0'))
footer(n)
def badge(x,y,num,color):
c.setFillColor(color);c.circle(x,y,22,fill=1,stroke=0);centerold=c._currentPageHasImages
c.setFillColor(colors.white);font(18,True);c.drawCentredString(x,y-6,str(num))
def draw_animal(x,y,kind,scale=1):
# friendly simple animal marker
c.saveState();c.translate(x,y);c.scale(scale,scale)
if kind=='bird':
c.setFillColor(YELLOW);c.circle(0,0,25,fill=1,stroke=0);c.circle(-8,24,15,fill=1,stroke=0)
c.setFillColor(ORANGE);c.wedge(8,22,32,42,330,30,fill=1,stroke=0)
c.setFillColor(BLUE);c.circle(-12,27,2,fill=1,stroke=0)
c.setFillColor(PINK);c.ellipse(-32,-7,-3,16,fill=1,stroke=0);c.ellipse(4,-7,32,16,fill=1,stroke=0)
c.setStrokeColor(ORANGE);c.setLineWidth(2);c.line(-5,-27,-7,-40);c.line(8,-27,10,-40)
elif kind=='fish':
c.setFillColor(AQUA);c.ellipse(-35,-20,30,20,fill=1,stroke=0);c.setFillColor(PURPLE);c.wedge(22,-20,54,20,130,230,fill=1,stroke=0)
c.setFillColor(colors.white);c.circle(10,8,4,fill=1,stroke=0);c.setFillColor(DARK);c.circle(11,8,1.5,fill=1,stroke=0)
c.setStrokeColor(HexColor('#168F8A'));c.setLineWidth(1);c.arc(-18,-12,5,8,230,100);c.arc(-3,-12,20,8,230,100)
elif kind=='frog':
c.setFillColor(GREEN);c.circle(0,0,27,fill=1,stroke=0);c.circle(-17,22,12,fill=1,stroke=0);c.circle(17,22,12,fill=1,stroke=0)
for xx in (-17,17): c.setFillColor(colors.white);c.circle(xx,24,5,fill=1,stroke=0);c.setFillColor(DARK);c.circle(xx,24,2,fill=1,stroke=0)
c.setStrokeColor(DARK);c.setLineWidth(1.5);c.arc(-12,-7,12,10,200,140)
elif kind=='mammal':
c.setFillColor(ORANGE);c.circle(0,0,28,fill=1,stroke=0);c.circle(-20,26,12,fill=1,stroke=0);c.circle(20,26,12,fill=1,stroke=0)
c.setFillColor(CREAM);c.ellipse(-16,-17,16,6,fill=1,stroke=0)
for xx in (-10,10):c.setFillColor(DARK);c.circle(xx,8,2.5,fill=1,stroke=0)
c.setFillColor(DARK);c.circle(0,-2,3,fill=1,stroke=0)
c.restoreState()
def vocab_card(x,y,w,h,num,word,meaning,sentence,color,animal):
rect(x,y,w,h,colors.white,HexColor('#D1E8E4'),14)
c.setFillColor(color);c.circle(x+32,y+h-31,19,fill=1,stroke=0);c.setFillColor(colors.white);font(15,True);c.drawCentredString(x+32,y+h-36,str(num))
text(x+60,y+h-39,word.upper(),19,NAVY,True)
draw_animal(x+w-45,y+h-48,animal,.48)
wrap(x+22,y+h-77,meaning,w-44,10,13,DARK)
c.setStrokeColor(HexColor('#D5E5E4'));c.line(x+22,y+52,x+w-22,y+52)
wrap(x+22,y+35,'Say it: '+sentence,w-44,9,12,BLUE,False)
# Cover
rect(0,0,W,H,HexColor('#EAF7F5'));dots();rect(0,H-180,W,180,NAVY)
center(H-68,'ANIMAL',34,colors.white,True);center(H-110,'VOCABULARY HANDBOOK',23,YELLOW,True)
center(H-140,'Grade 3 ESL',15,HexColor('#D5F3F0'),False)
draw_animal(120,430,'bird',1.35);draw_animal(310,398,'fish',1.35);draw_animal(490,430,'frog',1.35);draw_animal(230,265,'mammal',1.35)
rect(105,140,402,66,colors.white,HexColor('#BFE1DF'),18)
center(180,'Learn • Say • Draw • Practice',17,BLUE,True)
center(155,'Unit 1: Animals and Animal Body Parts',11,DARK,False)
text(72,70,'Name: ________________________________',13,NAVY,True)
c.showPage()
words=[
('skin','the outside covering of an animal’s body','The frog has smooth skin.','frog',AQUA),
('mammals','animals that have hair or fur and drink milk when they are babies','Dogs and elephants are mammals.','mammal',ORANGE),
('eggs','round objects that some animals lay. A baby animal can grow inside.','Birds lay eggs.','bird',YELLOW),
('amphibians','animals that can live in water and on land','Frogs are amphibians.','frog',GREEN),
('scales','small, hard plates that cover some animals','Fish have scales.','fish',PURPLE),
('gills','body parts fish use to breathe underwater','Fish breathe with gills.','fish',BLUE),
('feathers','soft, light coverings on birds','A bird has colorful feathers.','bird',PINK),
('wings','body parts that help birds and insects fly','The bird spreads its wings.','bird',ORANGE),
('fur','soft hair that covers many mammals','The cat has soft fur.','mammal',YELLOW),
]
for p in range(3):
page('Words to Know',f'Listen, repeat, and use each word. • Set {p+1} of 3',p+2)
for j in range(3):
i=p*3+j; word,meaning,sent,animal,col=words[i]
y=H-250-j*176
vocab_card(48,y,516,145,i+1,word,meaning,sent,col,animal)
c.showPage()
# picture / words match page
page('Practice 1: Match It!', 'Draw a line from each word to the correct clue.',5)
left=[('1','fur'),('2','gills'),('3','eggs'),('4','wings'),('5','scales')]
right=['a. Fish use these to breathe underwater.','b. Birds use these to fly.','c. Soft hair on a mammal.','d. A baby bird can grow inside one.','e. Hard plates on a fish.']
for i,(num,wrd) in enumerate(left):
y=H-180-i*75;rect(55,y-20,205,48,HexColor('#FFFFFF'),HexColor('#D1E8E4'),10);text(72,y-3,num+'.',15,ORANGE,True);text(103,y-3,wrd,17,NAVY,True)
for i,clue in enumerate(right):
y=H-180-i*75;rect(302,y-20,250,48,HexColor('#FFFFFF'),HexColor('#D1E8E4'),10);wrap(316,y+7,clue,222,10,12,DARK)
text(56,105,'My score: ____ / 5',15,BLUE,True);text(56,75,'Great work! Read the answers out loud.',12,DARK,False)
c.showPage()
# sort page
page('Practice 2: Sort the Words', 'Write each word in the best group.',6)
rect(54,415,240,205,HexColor('#E4F5EF'),GREEN,18);rect(318,415,240,205,HexColor('#EAE4F7'),PURPLE,18)
center(585,'ANIMAL GROUPS',17,NAVY,True);center(560,'BODY PARTS / COVERINGS',17,NAVY,True)
# manual headings centered respective
c.setFillColor(NAVY);font(17,True);c.drawCentredString(174,585,'ANIMAL GROUPS');c.drawCentredString(438,585,'BODY PARTS / COVERINGS')
for y in [540,505,470]:c.setStrokeColor(GREEN);c.line(76,y,273,y);c.setStrokeColor(PURPLE);c.line(340,y,537,y)
text(60,365,'Word bank:',14,BLUE,True)
rect(60,250,490,85,colors.white,HexColor('#D1E8E4'),14)
wrap(82,306,'mammals amphibians skin scales gills feathers wings fur eggs',445,15,23,NAVY,True)
text(60,190,'Challenge: Circle the words that you can find on a bird.',14,ORANGE,True)
c.showPage()
# sentence builder
page('Practice 3: Make Sentences', 'Choose a word from the box. Then write a complete sentence.',7)
rect(54,594,504,55,HexColor('#FFF0C9'),YELLOW,14)
center(616,'skin • mammals • eggs • amphibians • scales • gills • feathers • wings • fur',12,NAVY,True)
for i in range(4):
y=535-i*95;text(58,y,'My sentence:',13,BLUE,True);c.setStrokeColor(HexColor('#8DBFC0'));c.setLineWidth(1.3);c.line(58,y-26,550,y-26);c.line(58,y-51,550,y-51)
text(58,116,'Speak it! Read your best sentence to a partner or adult.',13,ORANGE,True)
c.showPage()
# review
page('Word Review', 'Use this checklist to show what you know.',8)
text(59,640,'I can...',17,NAVY,True)
for i,(word,*_) in enumerate(words):
y=592-i*54
rect(60,y-9,22,22,colors.white,BLUE,4);text(95,y,word,17,NAVY,True)
text(250,y,'I can say it',12,DARK);rect(350,y-8,18,18,colors.white,BLUE,3)
text(389,y,'I know it',12,DARK);rect(480,y-8,18,18,colors.white,BLUE,3)
text(60,75,'Teacher / Parent note: _________________________________________________',12,BLUE,True)
c.save()
print(OUT)
python "/tmp/workspace/esl-vocabulary-handbook/src/create_handbook.py" && ls -lh "/tmp/workspace/esl-vocabulary-handbook/output/Animal_Vocabulary_Handbook_Grade3_ESL.pdf"
python - <<'PY' from pypdf import PdfReader p='/tmp/workspace/esl-vocabulary-handbook/output/Animal_Vocabulary_Handbook_Grade3_ESL.pdf' r=PdfReader(p) print('pages:',len(r.pages)) for i,page in enumerate(r.pages,1): t=page.extract_text() or '' print(i, len(t), t[:80].replace('\n',' | ')) PY
Animal Vocabulary Handbook Grade3 ESL
PDF Document · PDF