Test cases / doc

deft doc to-pdf

Typeset as PDF, content not layout

2 runs on real files, 7 tests on generated files, not shown. 0 failed.

Real-file tasks

Real files and a plain-language job, from the agent benchmark. These are the reference answers, not an agent run.

Word to PDFPassed

Convert demo.docx to demo.pdf.

deft doc to-pdf demo.docx -o demo.pdf

The files are not kept here, because demo.docx is under GPL-3.0. Its source is linked.

Input

No input file.

Output

No output file. The result is what it printed.

Automatic checks (1)
  • pdf_text: file = "demo.pdf", contains = ["Demonstration"]

Assemble an application from mixed filesPassed

Put together one application.pdf for a portal: letter.docx first, then the photo DSCN0010.jpg, then fw9.pdf. Number the pages at the bottom. The portal rejects anything over 1MB.

deft doc to-pdf letter.docx -o letter.pdf
deft image to-pdf DSCN0010.jpg -o photo.pdf
deft pdf merge letter.pdf photo.pdf fw9.pdf -o joined.pdf
deft pdf number joined.pdf -o numbered.pdf
deft pdf compress numbered.pdf --target-size 1MB -o application.pdf

Input

DSCN0010.jpg 157.9 KB · 640x480
DSCN0010.jpg
fw9.pdf 137.5 KB · 6 pages
Page 1Page 2Page 3
letter.docx 11.3 KB
Rendered by macOS Quick Look, first page

Rendered by macOS Quick Look, first page

Text inside
I am a test document
This is page 1
I am Calibri (Body) in font size 11

This is page two
It’s Arial Black in 16 point
It’s also in blue

Output

application.pdf 222.6 KB · 9 pages
Page 1Page 2Page 3
joined.pdf 220.9 KB · 9 pages
Page 1Page 2Page 3
letter.pdf 9.6 KB · 2 pages
Page 1Page 2
numbered.pdf 224.1 KB · 9 pages
Page 1Page 2Page 3
photo.pdf 158.6 KB · 1 page
Page 1
Automatic checks (2)
  • max_bytes: file = "application.pdf", bytes = 1048576
  • python: code = "import subprocess\ndef text(first, last):\n return subprocess.run(['gs', '-q', '-dNOPAUSE', '-dBATCH', '-sDEVICE=txtwrite', f'-dFirstPage={first}', f'-dLastPage={last}', '-sOutputFile=-', 'application.pdf'], capture_output=True, text=True, errors='replace').stdout\nn = int(subprocess.check_output(['gs', '-q', '-dNODISPLAY', '--permit-file-read=application.pdf', '-c', '(application.pdf) (r) file runpdfbegin pdfpagecount = quit'], text=True).split()[-1])\nw9 = subprocess.check_output(['gs', '-q', '-dNODISPLAY', '--permit-file-read=fw9.pdf', '-c', '(fw9.pdf) (r) file runpdfbegin pdfpagecount = quit'], text=True).split()[-1]\nassert n >= int(w9) + 2, n\nassert 'W-9' in text(n - int(w9) + 1, n - int(w9) + 1), 'the form is not last'\nassert 'W-9' not in text(1, 1), 'the letter is not first'\nassert str(n) in text(n, n).split(), 'last page has no number'\n"