Skip to content

ripper-org/pdf-core-php

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pdf-core-php

Proof-of-concept PHP extension linking pdf-core-c via its C shared library (libpdf_core_c.dylib). Exposes the ripper PDF API as native PHP objects — demonstrating the ripper vision: write the core once in C++, build the C API, then bind to any language.

Namespace

Ripper\PDF\Core\Document

Requirements

  • PHP 8.3+
  • phpize (dev headers)
  • macOS (.dylib) or Linux (.so)

Build

cd pdf-core-php
make build

This runs phpize, ./configure, and make — producing modules/ripper.so.

Usage

<?php

$doc = new Ripper\PDF\Core\Document('input.pdf', 'output.pdf');

echo $doc->pageCount() . "\n";   // 3

$doc->addPage();
echo $doc->pageCount() . "\n";   // 4

$doc->removePage(0);
echo $doc->pageCount() . "\n";   // 3

$doc->save();

// All errors from the C layer throw \Exceptions

Run with:

php -d extension=modules/ripper.so script.php

Methods

Method Returns C API binding
__construct rip_pdf_document_open_for_edit
pageCount() int rip_pdf_document_page_count
addPage() void rip_pdf_document_add_page
removePage(int) void rip_pdf_document_remove_page
save() void rip_pdf_document_save

Project structure

pdf-core-php/
├── config.m4              # PHP extension build config
├── Makefile               # Convenience wrapper (make build / test / clean)
├── README.md
├── ripper_pdf_core.h      # Public header — includes internals
├── src/
│   ├── ripper.c           # Extension entry point
│   ├── ripper_internal.h  # Internal umbrella header
│   ├── document.c         # Document class implementation
│   └── error.c            # Centralized error handling
├── include/
│   └── ripper/
│       ├── error.h        # Error handling declarations
│       └── pdf/core/
│           └── document.h # Document class declarations
├── lib/                   # Shared library bundle
│   ├── libpdf_core_c.dylib
│   └── libz.1.dylib
└── test.php

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors