page_print is a Ruby gem with a native C extension that renders HTML strings to PDF files using the plutobook C library.
The public Ruby API is intentionally small. PagePrint.html_to_pdf is the primary entry point.
lib/page_print.rbloads the gem version and native extension.lib/page_print/version.rbdefines the gem version.ext/page_print/page_print.ccontains the native Ruby C extension.ext/page_print/extconf.rbconfigures compilation and locatesplutobook.test/page_print_test.rbcontains the Minitest suite.Rakefiledefines compile, test, and default tasks.page_print.gemspecdefines gem metadata, files, and extension build config.
Install Ruby dependencies:
bundle installThe native extension requires plutobook development headers and library files.
On macOS with Homebrew:
brew install plutobook pkg-configIf pkg-config cannot find plutobook, pass explicit paths when building or installing the gem.
Compile the native extension:
bundle exec rake compileRun tests only:
bundle exec rake testRun the default task, which compiles and tests:
bundle exec rakeUse bin/console for a local development console. It compiles the extension before starting IRB.
- Keep the Ruby-facing API minimal and documented in
README.md. - When changing
PagePrint.html_to_pdf, update tests for both successful output and validation/error behavior. - Prefer inline Ruby calls for readability; only break Ruby argument lists across lines when the line would exceed 120 characters.
- Format Ruby private sections with
privateat the class indentation level and private method definitions indented beneath it, without a blank line betweenprivateand the first private method. - Validate Ruby argument types before passing data into
plutobook. - Ensure native resources are destroyed on failure paths before raising Ruby exceptions.
- Prefer clear Ruby exception messages because tests assert exact messages.
- Do not commit generated native build artifacts such as
.bundle,.o,Makefile,mkmf.log,pkg/, ortmp/.
ext/page_print/extconf.rbusesmkmf,pkg_config('plutobook'), anddir_config('plutobook').- The extension currently supports keyword options for
base_url,page_size,margins,media,resource_fetcher, andmetadata. - Keep accepted option values synchronized across
README.md, tests, andext/page_print/page_print.c.
Before finishing changes, run:
bundle exec rakeIf the environment lacks plutobook, report that compilation or tests could not be completed and include the relevant error.
Issues live in GitHub Issues for dixpac/page_print. See docs/agents/issue-tracker.md.
Default triage roles: needs-triage, needs-info, ready-for-agent, ready-for-human, wontfix. See docs/agents/triage-labels.md.
Single-context: root CONTEXT.md + docs/adr/. See docs/agents/domain.md.