Please create a colorful handbook pdf and create a worksheet as heading for fill in the blanks for following vocabulary words used in attached file.
~/
~/attachments/481f76d2-369f-479e-9f90-e384661e3260
mkdir -p "/tmp/workspace/vocabulary_handbook/src" "/tmp/workspace/vocabulary_handbook/output" && python -c "from pypdf import PdfReader; p='/tmp/workspace/attachments/481f76d2-369f-479e-9f90-e384661e3260/DOC-20261008-WA0009.pdf'; r=PdfReader(p); print('PAGES',len(r.pages)); [print('---PAGE',i+1,'---\n',page.extract_text() or '') for i,page in enumerate(r.pages)]"
python - <<'PY' from pathlib import Path p=Path('/tmp/workspace/vocabulary_handbook/src/create_handbook.py') p.write_text(r'''from reportlab.lib.pagesizes import A4 from reportlab.pdfgen import canvas from reportlab.lib import colors from reportlab.lib.units import mm from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.pdfmetrics import stringWidth from reportlab.lib.colors import HexColor from textwrap import wrap OUT='/tmp/workspace/vocabulary_handbook/output/Everyday_English_Vocabulary_Handbook_and_Worksheet.pdf' W,H=A4 FONT='/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf' BOLD='/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf' pdfmetrics.registerFont(TTFont('DejaVu',FONT)); pdfmetrics.registerFont(TTFont('DejaVuBold',BOLD)) vocab=[ ('Petulant','adjective','PET-yuh-luhnt','Childishly sulky or easily annoyed.','Раздражительный, капризный; обиженный по-детски.','The ______ child crossed his arms when it was time to leave the park.'), ('Perfidious','adjective','per-FID-ee-us','Deceitful and untrustworthy; betraying loyalty.','Вероломный, предательский, коварный.','A ______ friend breaks trust instead of keeping a promise.'), ('Intriguing','adjective','in-TREE-ging','Very interesting because it is unusual or mysterious.','Интригующий, вызывающий интерес.','I found an ______ note inside the old book.'), ('Fastidious','adjective','fa-STID-ee-us','Very careful about small details and standards.','Придирчивый к деталям; очень аккуратный.','She is ______ about keeping her desk clean.'), ('Meticulous','adjective','muh-TIK-yuh-lus','Extremely careful and precise.','Скрупулёзный, очень тщательный.','The mechanic gave the bicycle a ______ inspection.'), ('Micturate','formal/medical verb','MIK-chuh-rayt','To urinate; to pass urine.','Мочиться, испускать мочу. Формальное медицинское слово.','The doctor recorded how often the patient needed to ______.'), ('Too frivolous','phrase','too FRIV-uh-lus','Not serious or sensible enough for the situation.','Слишком легкомысленный, несерьёзный.','His jokes were ______ during the serious meeting.'), ('Quagmire','noun','KWAG-myre','A difficult, confusing situation that is hard to escape.','Трясина; запутанная ситуация, из которой трудно выбраться.','Choosing a phone plan became a ______ of hidden fees.'), ('Abstruse','adjective','ab-STROOSS','Difficult to understand because it is complicated.','Сложный для понимания, заумный.','The instructions for the new router were ______.'), ('Illusion','noun','ih-LOO-zhun','A false appearance or misleading impression.','Иллюзия, обманчивое впечатление.','The mirror created the ______ that the room was bigger.'), ('Delusion','noun','dih-LOO-zhun','A false belief that someone continues to hold despite evidence.','Заблуждение, ложное убеждение.','It is a ______ to think that a password never needs changing.'), ('Douchebag','informal/offensive noun','DOOSH-bag','A rude, selfish, or unpleasant man. Avoid in polite settings.','Грубый и неприятный человек. Грубое разговорное слово.','Calling your neighbor a ______ will only make the argument worse.'), ('Acrimonious','adjective','ak-rih-MOH-nee-us','Full of anger, bitterness, and harsh words.','Ожесточённый, язвительный, полный горечи.','Their ______ argument about chores ruined dinner.'), ('Touch wood / knock on wood','idiom','tuch wood; nok on wood','Said to hope that good luck will continue and a bad thing will not happen.','Постучать по дереву; говорят, чтобы не сглазить.','______, my laptop has not crashed this week.'), ('Eyeing','verb form','EYE-ing','Looking at someone or something with interest, desire, or suspicion.','Поглядывающий, присматривающийся; разглядывающий.','I saw you ______ the last slice of pizza.'), ('Evil eye','noun','EE-vul EYE','A look believed in some cultures to bring bad luck or harm.','Сглаз; взгляд, которому приписывают способность приносить несчастье.','The blue bead is often used as a symbol against the ______.'), ('Casting the evil eye','phrase','KAS-ting thee EE-vul EYE','Giving a look thought to bring bad luck or harm.','Сглазить; бросать взгляд, который, как считают, приносит несчастье.','In the story, the jealous neighbor was accused of ______.'), ('Apple of my eye','idiom','AP-ul uv my EYE','A person who is loved more than anyone else.','Зеница ока; самый любимый человек.','My youngest niece is the ______.'), ('See eye to eye','idiom','see EYE tuh EYE','To agree fully about something.','Полностью соглашаться, сходиться во взглядах.','The team finally ______ on the holiday schedule.'), ('Pernickety','adjective','per-NIK-uh-tee','Too concerned with small details; fussy.','Привередливый, придирчивый к мелочам.','Do not be so ______ about one tiny spelling mistake.'), ('Alacrity','noun','uh-LAK-rih-tee','Cheerful willingness and quickness to act.','Готовность и живость, с которой что-то делают.','He accepted the invitation with ______.'), ('Quintessential','adjective','kwin-tuh-SEN-shul','The most typical or perfect example of something.','Типичный, самый характерный; воплощающий суть.','A cup of tea is a ______ part of his morning routine.'), ('Plausible','adjective','PLAW-zuh-bul','Seeming reasonable or likely to be true.','Правдоподобный, разумный на вид.','Traffic is a ______ reason for being ten minutes late.'), ('Pernicious','adjective','per-NISH-us','Having a harmful effect, often gradually.','Пагубный, вредный, часто с постепенным эффектом.','A ______ rumor can damage a friendship over time.'), ] pal=[HexColor('#7457F5'),HexColor('#F04D8A'),HexColor('#11A9A0'),HexColor('#F49B32'),HexColor('#3478D1'),HexColor('#9A59B5')] ink=HexColor('#203047'); soft=HexColor('#F4F6FB'); mint=HexColor('#EAF8F5') def text(c, s, x,y, size=10, color=ink, font='DejaVu', maxw=None, leading=None): c.setFont(font,size); c.setFillColor(color) if maxw: # basic word wrap measured words=s.split(); lines=[]; line='' for word in words: test=(line+' '+word).strip() if stringWidth(test,font,size)<=maxw: line=test else: lines.append(line); line=word if line: lines.append(line) lead=leading or size*1.35 for i,line in enumerate(lines): c.drawString(x,y-i*lead,line) return y-len(lines)*lead c.drawString(x,y,s); return y-size def header(c, title, subtitle, page): c.setFillColor(HexColor('#18243D')); c.rect(0,H-25*mm,W,25*mm,fill=1,stroke=0) c.setFillColor(HexColor('#F6C347')); c.circle(W-18*mm,H-12*mm,8*mm,fill=1,stroke=0) text(c,title,17*mm,H-13*mm,17,colors.white,'DejaVuBold') text(c,subtitle,17*mm,H-20*mm,8.3,HexColor('#CFD9F5')) text(c,str(page),W-19*mm,10*mm,8,HexColor('#8B97B2'),'DejaVuBold') def footer(c): c.setStrokeColor(HexColor('#D9E0ED')); c.line(17*mm,16*mm,W-17*mm,16*mm) text(c,'Everyday English Vocabulary • English-Russian',17*mm,10*mm,7.5,HexColor('#68758B')) c=canvas.Canvas(OUT,pagesize=A4); c.setTitle('Everyday English Vocabulary Handbook and Worksheet') # cover c.setFillColor(HexColor('#16243D'));c.rect(0,0,W,H,fill=1,stroke=0) for x,y,r,col in [(25,250,36,'#F5B64A'),(520,700,55,'#F04D8A'),(510,150,25,'#10B3A9'),(85,85,23,'#7457F5')]: c.setFillColor(HexColor(col));c.circle(x,y,r,fill=1,stroke=0) text(c,'EVERYDAY ENGLISH',22*mm,H-65*mm,15,HexColor('#F6C347'),'DejaVuBold') text(c,'Vocabulary\nHandbook',22*mm,H-92*mm,31,colors.white,'DejaVuBold',maxw=140*mm,leading=12*mm) text(c,'24 useful words, idioms & phrases',22*mm,H-128*mm,13,HexColor('#C9D4EE')) text(c,'Definitions • pronunciation • Russian translations\n+ a fill-in-the-blanks worksheet',22*mm,H-148*mm,10,HexColor('#E9EFFB'),maxw=132*mm) c.setFillColor(HexColor('#FFFFFF'));c.roundRect(22*mm,35*mm,110*mm,22*mm,6*mm,fill=1,stroke=0) text(c,'LEARN • PRACTISE • REMEMBER',29*mm,46*mm,11,HexColor('#18243D'),'DejaVuBold') text(c,'Name: ____________________________',22*mm,24*mm,10,HexColor('#C9D4EE')) c.showPage() # handbook 12 pages, 2 cards each pageno=2 for i in range(0,len(vocab),2): header(c,'VOCABULARY HANDBOOK','Read each card, say the word aloud, then use it in your own sentence.',pageno) for k,item in enumerate(vocab[i:i+2]): word,pos,pron,meaning,ru,sent=item; y=H-(45+k*112)*mm; col=pal[(i+k)%len(pal)] c.setFillColor(soft);c.roundRect(15*mm,y-88*mm,W-30*mm,78*mm,5*mm,fill=1,stroke=0) c.setFillColor(col);c.roundRect(15*mm,y-25*mm,W-30*mm,15*mm,5*mm,fill=1,stroke=0) text(c,word,22*mm,y-19*mm,17,colors.white,'DejaVuBold') text(c,pos.upper(),W-66*mm,y-19*mm,7.5,colors.white,'DejaVuBold') text(c,'PRONUNCIATION',22*mm,y-34*mm,7.5,col,'DejaVuBold');text(c,pron,22*mm,y-41*mm,10,ink,'DejaVuBold') text(c,'MEANING',22*mm,y-51*mm,7.5,col,'DejaVuBold'); text(c,meaning,22*mm,y-58*mm,9.5,ink,maxw=W-44*mm) text(c,'ПО-РУССКИ',22*mm,y-70*mm,7.5,col,'DejaVuBold');text(c,ru,22*mm,y-77*mm,8.7,HexColor('#3F4C61'),maxw=W-44*mm) footer(c);c.showPage();pageno+=1 # worksheet title page header(c,'WORKSHEET','Fill in the blanks using the word bank. One word or phrase per sentence.',pageno) text(c,'Fill in the Blanks',17*mm,H-45*mm,25,ink,'DejaVuBold') text(c,'Name: ____________________________________ Date: __________________',17*mm,H-58*mm,10,HexColor('#526078')) c.setFillColor(mint);c.roundRect(17*mm,H-160*mm,W-34*mm,84*mm,6*mm,fill=1,stroke=0) text(c,'How to use this worksheet',25*mm,H-91*mm,13,HexColor('#087B74'),'DejaVuBold') steps=['1. Read every sentence carefully.','2. Choose a word or phrase from the word bank.','3. Write the answer on the line.','4. Check your work using the answer key at the end.'] for j,s in enumerate(steps): text(c,s,27*mm,H-(104+j*12)*mm,10,ink) text(c,'Tip: Pay attention to the part of speech and the meaning in the sentence.',25*mm,H-151*mm,9,HexColor('#087B74'),'DejaVuBold',maxw=W-50*mm) footer(c);c.showPage();pageno+=1 # 6 worksheet pages x 4 for group in range(6): items=vocab[group*4:group*4+4]; header(c,'FILL IN THE BLANKS',f'Worksheet {group+1} of 6 • Write the best answer from the word bank.',pageno) c.setFillColor(HexColor('#FFF4D6'));c.roundRect(17*mm,H-72*mm,W-34*mm,25*mm,5*mm,fill=1,stroke=0) text(c,'WORD BANK',23*mm,H-57*mm,8,pal[group%len(pal)],'DejaVuBold') bank=' • '.join(x[0] for x in items); text(c,bank,23*mm,H-66*mm,10,ink,'DejaVuBold',maxw=W-46*mm) y=H-90*mm for n,item in enumerate(items,group*4+1): c.setFillColor(soft); c.roundRect(17*mm,y-30*mm,W-34*mm,25*mm,4*mm,fill=1,stroke=0) text(c,f'{n}.',23*mm,y-15*mm,11,pal[group%len(pal)],'DejaVuBold') text(c,item[5],34*mm,y-14*mm,10,ink,maxw=W-58*mm,leading=5.2*mm) c.setStrokeColor(HexColor('#9AA7B8'));c.line(34*mm,y-27*mm,W-26*mm,y-27*mm) y-=37*mm footer(c);c.showPage();pageno+=1 # answer key header(c,'ANSWER KEY','Use this page after you have completed the worksheet.',pageno) text(c,'Answers',17*mm,H-45*mm,25,ink,'DejaVuBold') for coln in range(2): x=20*mm+coln*90*mm; y=H-62*mm for idx in range(coln*12,(coln+1)*12): c.setFillColor(pal[idx%len(pal)]);c.circle(x,y+2*mm,2.6*mm,fill=1,stroke=0) text(c,f'{idx+1}. {vocab[idx][0]}',x+7*mm,y,10,ink,'DejaVuBold',maxw=78*mm) y-=15*mm c.setFillColor(HexColor('#FFF4D6'));c.roundRect(17*mm,28*mm,W-34*mm,20*mm,5*mm,fill=1,stroke=0) text(c,'Reflection: Which three words will you try to use this week?',23*mm,40*mm,9,HexColor('#7B5A10'),'DejaVuBold') c.setStrokeColor(HexColor('#B79339'));c.line(23*mm,34*mm,W-23*mm,34*mm) footer(c);c.showPage() c.save() print(OUT) ''') PY python "/tmp/workspace/vocabulary_handbook/src/create_handbook.py" python -c "from pypdf import PdfReader; p='/tmp/workspace/vocabulary_handbook/output/Everyday_English_Vocabulary_Handbook_and_Worksheet.pdf'; r=PdfReader(p); print('pages=',len(r.pages),'bytes=',__import__('os').path.getsize(p)); print(r.pages[1].extract_text()[:300])"
/usr/share/fonts
/usr/share/fonts/truetype
/usr/share/fonts/google-noto-vf
/usr/share/fonts/google-droid-sans-fonts
~/vocabulary_handbook/src/create_handbook.py
Successfully replaced 1 instance(s) of the string in '/tmp/workspace/vocabulary_handbook/src/create_handbook.py'
python "/tmp/workspace/vocabulary_handbook/src/create_handbook.py" && python -c "from pypdf import PdfReader; import os; p='/tmp/workspace/vocabulary_handbook/output/Everyday_English_Vocabulary_Handbook_and_Worksheet.pdf'; r=PdfReader(p); print('pages=',len(r.pages),'bytes=',os.path.getsize(p)); print(r.pages[1].extract_text()[:500])"
python -c "import fitz; p='/tmp/workspace/vocabulary_handbook/output/Everyday_English_Vocabulary_Handbook_and_Worksheet.pdf'; d=fitz.open(p); pix=d[1].get_pixmap(matrix=fitz.Matrix(1.3,1.3),alpha=False); pix.save('/tmp/workspace/vocabulary_handbook/output/preview_page_2.png'); pix2=d[15].get_pixmap(matrix=fitz.Matrix(1.3,1.3),alpha=False); pix2.save('/tmp/workspace/vocabulary_handbook/output/preview_worksheet.png'); print(d.page_count)"
python -c "from pypdf import PdfReader; p='/tmp/workspace/vocabulary_handbook/output/Everyday_English_Vocabulary_Handbook_and_Worksheet.pdf'; r=PdfReader(p); assert len(r.pages)==21; txt='\n'.join((pg.extract_text() or '') for pg in r.pages); required=['Petulant','Pernicious','Fill in the Blanks','ANSWER KEY','Worksheet 6 of 6']; missing=[x for x in required if x not in txt]; print('Verification:', 'PASS' if not missing else 'MISSING '+str(missing)); print('pages',len(r.pages))"
Everyday English Vocabulary Handbook and Worksheet
PDF Document · PDF