attachment
attachment

Please create a colorful pdf handbook copy in similar way and more HD clear text with exactly same information .

analyse_media
Reading File
Browsing Directory

~/

Browsing Directory

~/attachments/4ef1df73-dca4-4953-9635-3918b7d6127b/

Reading File
Running Command

mkdir -p "/tmp/workspace/conditionals-handbook/src" "/tmp/workspace/conditionals-handbook/output" && python - <<'PY' from PIL import Image p='/tmp/workspace/attachments/4ef1df73-dca4-4953-9635-3918b7d6127b/1000307855.jpg' im=Image.open(p) print(im.size, im.mode) PY

Running Command

python - <<'PY' from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import letter from reportlab.lib.colors import HexColor, white, black from reportlab.pdfbase.pdfmetrics import stringWidth from reportlab.lib.utils import simpleSplit from reportlab.pdfbase import pdfmetrics from reportlab.pdfbase.ttfonts import TTFont from pathlib import Path out=Path('/tmp/workspace/conditionals-handbook/output/Conditionals_Handbook.pdf') W,H=letter c=canvas.Canvas(str(out), pagesize=letter, pageCompression=1) c.setTitle('Conditionals - Grammar Handbook') c.setAuthor('Orris') # Palette based on reference DARK=HexColor('#10235d') GREEN=HexColor('#2fb526') MID_GREEN=HexColor('#77d542') PALE_GREEN=HexColor('#a6e761') CYAN=HexColor('#4ecfdd') LINE=HexColor('#1f9d25') SOFT=HexColor('#f9fff7') GREY=HexColor('#28313d') # background c.setFillColor(SOFT); c.rect(0,0,W,H,stroke=0,fill=1) # title strip c.setFillColor(GREEN); c.rect(0,H-62,W,62,stroke=0,fill=1) c.setFont('Helvetica-Bold',34); c.setFillColor(HexColor('#10214d')) t='CONDITIONALS'; c.drawCentredString(W/2,H-47,t) # header row left=14; right=14; usable=W-left-right col=[140, 215, usable-140-215] y_top=H-72; head_h=44 headers=[('TYPE', left, col[0]),('CONDITION',left+col[0],col[1]),('RESULT',left+col[0]+col[1],col[2])] for label,x,w in headers: c.setFillColor(CYAN); c.roundRect(x+5,y_top-head_h+4,w-10,head_h-8,9,stroke=0,fill=1) c.setFillColor(DARK); c.setFont('Helvetica-Bold',18); c.drawCentredString(x+w/2,y_top-28,label) # arrow arrow_y=y_top-27; ax=left+col[0]+col[1] c.setFillColor(HexColor('#14126f')) c.rect(ax-15,arrow_y-4,25,8,stroke=0,fill=1) c.wedge(ax+1,arrow_y-14,ax+29,arrow_y+14,330,30,stroke=0,fill=1) rows=[ ('ZERO','Facts','If this happens,','IF + PRESENT SIMPLE','then this happens','PRESENT SIMPLE','If you heat ice,','it melts'), ('ONE','Present or\nfuture fact','If this happens,','IF + PRESENT SIMPLE','this will happen','SIMPLE FUTURE','If you work hard,','you will succeed'), ('TWO','Hypothetical\nsituations','If this happened,','IF + PAST SIMPLE','this would happen','PRESENT CONDITIONAL','If I earned more money,','I would buy a new car'), ('THREE','Past\nhypothetical','If this had happened,','IF + PAST PERFECT','this would have happened','PERFECT CONDITIONAL','If we had won,','I would have been happy'), ('MIXED 1','Unreal past,\npresent result','If this had happened,','IF + PAST PERFECT','this would happen','PRESENT CONDITIONAL','If we had checked the map,','we would not be lost'), ('MIXED 2','Present\ncondition,\nresult','If this happened,','IF + PAST PRESENT','this would have happened','PERFECT CONDITIONAL',"If I wasn't afraid of planes,",'I would have flown'), ] # Fit rows into remainder down to 20 start=y_top-head_h-3; bottom=18; row_h=(start-bottom)/6 def draw_center_lines(lines, xcenter, ycenter, font, size, leading, color=DARK): c.setFillColor(color); c.setFont(font,size) total=(len(lines)-1)*leading yy=ycenter+total/2-size*.32 for s in lines: c.drawCentredString(xcenter,yy,s); yy-=leading def fit_font(text, font, maxw, size): while stringWidth(text,font,size)>maxw and size>7: size-=.25 return size for i,r in enumerate(rows): y=start-(i+1)*row_h # separator stripe and bottom green rule c.setFillColor(white); c.rect(0,y,W,row_h,stroke=0,fill=1) c.setFillColor(LINE); c.rect(0,y, W,4,stroke=0,fill=1) # type column type_label, descriptor, cond_intro, cond_formula, result_intro, result_formula, cond_ex, result_ex=r cx=left+col[0]/2; cy=y+row_h*.61 c.setFillColor(DARK); c.setFont('Helvetica-Bold',17); c.drawCentredString(cx,cy+8,type_label) # descriptor lines=descriptor.split('\n') draw_center_lines(lines,cx,cy-13,'Helvetica-Bold',13.2,14,DARK) # example label c.setFont('Helvetica-Bold',13); c.drawString(left+10,y+11,'Example:') # condition column x2=left+col[0]; cx2=x2+col[1]/2 intro_size=fit_font(cond_intro,'Helvetica',col[1]-16,15) c.setFillColor(GREY); c.setFont('Helvetica',intro_size); c.drawCentredString(cx2,y+row_h-21,cond_intro) # formula chip chipw=col[1]-28; chipx=x2+14; chipy=y+row_h*.42-11 c.setFillColor(PALE_GREEN); c.roundRect(chipx,chipy,chipw,31,10,stroke=0,fill=1) fs=fit_font(cond_formula,'Helvetica-Bold',chipw-14,14) c.setFillColor(HexColor('#132922')); c.setFont('Helvetica-Bold',fs); c.drawCentredString(cx2,chipy+10,cond_formula) # condition example, italic key exact whole clause exsize=fit_font(cond_ex,'Helvetica-Oblique',col[1]-18,13.5) c.setFillColor(black); c.setFont('Helvetica-Oblique',exsize); c.drawCentredString(cx2,y+12,cond_ex) # result col x3=x2+col[1]; cx3=x3+col[2]/2 resintro=fit_font(result_intro,'Helvetica',col[2]-14,15) c.setFillColor(GREY); c.setFont('Helvetica',resintro); c.drawCentredString(cx3,y+row_h-21,result_intro) chipw=col[2]-25; chipx=x3+12; chipy=y+row_h*.42-11 c.setFillColor(PALE_GREEN); c.roundRect(chipx,chipy,chipw,31,10,stroke=0,fill=1) fs=fit_font(result_formula,'Helvetica-Bold',chipw-12,13.5) c.setFillColor(HexColor('#132922')); c.setFont('Helvetica-Bold',fs); c.drawCentredString(cx3,chipy+10,result_formula) exsize=fit_font(result_ex,'Helvetica-Oblique',col[2]-12,13.5) c.setFillColor(black); c.setFont('Helvetica-Oblique',exsize); c.drawCentredString(cx3,y+12,result_ex) # Thin outer margin accent c.setStrokeColor(HexColor('#d4efd3')); c.setLineWidth(1); c.rect(5,5,W-10,H-10,stroke=1,fill=0) c.showPage(); c.save() print(out, out.stat().st_size) PY

Running Command

python - <<'PY' import fitz from pathlib import Path p=Path('/tmp/workspace/conditionals-handbook/output/Conditionals_Handbook.pdf') doc=fitz.open(p) print('pages',doc.page_count) page=doc[0] print('text:\n',page.get_text()) pix=page.get_pixmap(matrix=fitz.Matrix(1.5,1.5), alpha=False) out=Path('/tmp/workspace/conditionals-handbook/output/Conditionals_Handbook_preview.png') pix.save(out) print(out, out.stat().st_size) PY

Running Command

python - <<'PY' from pypdf import PdfReader from pathlib import Path p=Path('/tmp/workspace/conditionals-handbook/output/Conditionals_Handbook.pdf') r=PdfReader(str(p)) print('pages:',len(r.pages)) text=r.pages[0].extract_text() print(text) required=['CONDITIONALS','ZERO','IF + PRESENT SIMPLE','PRESENT SIMPLE','If you heat ice,','it melts','ONE','SIMPLE FUTURE','TWO','IF + PAST SIMPLE','PRESENT CONDITIONAL','THREE','IF + PAST PERFECT','PERFECT CONDITIONAL','MIXED 1','MIXED 2',"If I wasn't afraid of planes,",'I would have flown'] missing=[s for s in required if s not in text] print('MISSING:', missing) print('file bytes:',p.stat().st_size) PY

Created a colorful, high-resolution, editable-text PDF version with the same information and a clearer handbook-style layout.

Conditionals Handbook

PDF Document · PDF

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