-
-
Notifications
You must be signed in to change notification settings - Fork 240
add new feature for PDF Manipulation, HTML to PDF Conversion, and Enhanced Digital Signatures #134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
galihlasahido
wants to merge
30
commits into
tecnickcom:main
Choose a base branch
from
galihlasahido:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implement support for multiple digital signatures in PDF documents using incremental updates. This addresses the limitation of openssl_pkcs7_sign() which can only sign once. New features: - SignatureManager: Main class for managing multiple signatures - CmsBuilder: Builds CMS/PKCS#7 SignedData structures using phpseclib - PdfParser: Parses existing PDFs for incremental updates - PhpseclibSigner: Implements SignatureInterface using phpseclib - Support for signing existing empty signature fields - Support for adding new signature fields and signing them - Incremental PDF updates to preserve existing signatures 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add signer1, signer2, signer3 certificates for testing multiple signatures - Add multiple_signatures.php example demonstrating: - Creating a PDF document - Applying first signature - Applying second signature (incremental update) - Applying third signature (another incremental update) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Fix CmsBuilder to use ASN1::encodeDER() instead of non-existent saveDN() - Add proper AcroForm, SigFlags, and Fields to document catalog - Add Annots array to page for signature widget annotations - Accumulate signature fields across multiple incremental updates - Add appearance stream reference to signature widgets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add pdfaConformance property to support A, B, U conformance levels - Fix PDF version: use 1.7 for PDF/A-2 and PDF/A-3 (was only 1.4) - Update XMP metadata to use dynamic conformance level - Fix OutputIntents return for PDF-X mode - Support modes: pdfa1a/b, pdfa2a/b/u, pdfa3a/b/u - Add comprehensive PDF/A example 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add TimestampClient class for RFC 3161 Time-Stamp Protocol - Integrate timestamp tokens into CMS signature unsigned attributes - Support configurable TSA URL, authentication, and timeout - Increase signature buffer size to accommodate timestamp tokens - Add example demonstrating timestamped signatures Timestamps provide proof that documents were signed at a specific time, enabling long-term validation (LTV) of digital signatures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Extend TEmbeddedFile type with mimeType, afRelationship, description, dates - Add configurable MIME type and AFRelationship to addEmbeddedFile methods - Add addXmlEmbeddedFile() convenience method for ZUGFeRD/Factur-X invoices - Update getOutEmbeddedFiles() to use dynamic MIME types and relationships - Add creation/modification dates to embedded file parameters - Add example demonstrating PDF/A-3 with embedded invoice XML Supports e-invoicing standards like ZUGFeRD, Factur-X, and XRechnung by allowing arbitrary file embedding with proper PDF/A-3 metadata. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Implement LTV infrastructure for PDF signatures that remain verifiable even after certificates expire or revocation services become unavailable. New classes: - OcspClient: OCSP protocol client for certificate status checking - CrlFetcher: Downloads CRLs from distribution points - DssBuilder: Creates Document Security Store (DSS) with VRI entries SignatureManager additions: - enableLtv() method to add validation data to signed PDFs - Certificate chain extraction from existing CMS signatures - DSS dictionary building with incremental PDF updates Features: - Embeds certificates, OCSP responses, and CRLs in PDF - Creates per-signature VRI (Validation-Related Information) - Compliant with PAdES-LTV specification - Graceful fallback when validation data unavailable 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add FieldCalculation class for automatic field calculations (sum, product, average, min, max, custom) - Add FieldValidator class for JavaScript-based field validation (required, email, number, range, length, regex) - Add ConditionalVisibility class for dynamic show/hide based on field values - Add Tcpdf helper methods: createFieldCalculation, createFieldValidator, createConditionalVisibility - Add addCalculatedField and addValidatedField convenience methods - Add advanced_acroforms.php example demonstrating all features
- Fix PdfMerger to properly copy content streams from source PDFs - Fix PdfSplitter to properly copy content streams when splitting - Fix SignatureManager regex too large error (use strpos instead) - Fix SVG and image paths in examples/index.php to use __DIR__ - Fix index.php to save PDF to file instead of echoing to stdout - Add HtmlRenderer class for HTML to PDF conversion - Add html_to_pdf.php example demonstrating HTML features 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add src/Manipulate/PdfMetadataEditor.php with full metadata editing support - Add examples/pdf_metadata.php demonstrating all features Features: - Load PDF from file or content - Get/set Title, Author, Subject, Keywords, Creator, Producer - Set/update creation and modification dates - Bulk metadata updates via setMetadata() - Remove individual fields or clear all metadata
- Add src/Manipulate/PdfBookmarkManager.php with full bookmark support - Add examples/pdf_bookmarks.php demonstrating all features Features: - Load PDF from file or content - Add bookmarks with title, page, level, and Y position - Create hierarchical bookmark structures - Bulk bookmark addition - Read existing bookmarks - Remove bookmarks by page or level - Clear all bookmarks
- Add src/Manipulate/PdfBarcodeStamper.php with full barcode support - Add examples/pdf_barcode.php demonstrating all features - Integrate all 3 new classes with Tcpdf.php factory methods Features: - Add QR codes to documents - Add Code 128, Code 39, EAN, UPC barcodes - Add DataMatrix 2D codes - Apply to all pages or specific pages - Custom positioning and sizing - Color support for barcodes - Multiple barcodes per document
- Add src/Manipulate/PdfPageRotator.php with full rotation support - Add examples/pdf_rotate.php demonstrating all features - Integrate with Tcpdf.php via createPageRotator() factory method Features: - Rotate single or multiple pages - Clockwise/counter-clockwise/upside-down shortcuts - Rotate odd/even pages separately - Multiple different rotations per document - Reset page or all rotations - Valid rotations: 0, 90, 180, 270 degrees
- Add src/Manipulate/PdfPageBoxEditor.php for page box manipulation - Add examples/pdf_crop_resize.php demonstrating all features - Integrate createPageBoxEditor() and cropPdfPages() methods in Tcpdf.php Features: - Set individual page boxes (MediaBox, CropBox, BleedBox, TrimBox, ArtBox) - Crop pages to standard sizes (A0-A6, Letter, Legal, Tabloid) - Crop to custom dimensions with positioning options - Resize pages to standard or custom sizes - Add uniform or individual margins - Get current page box values - Reset modifications per page or all at once
- Add src/Manipulate/PdfFormFiller.php for PDF form field manipulation - Add examples/pdf_form_fill.php demonstrating all features - Integrate createFormFiller() and fillPdfForm() methods in Tcpdf.php Features: - Load PDFs with AcroForm fields - Inspect form fields (names, types, values, positions) - Set individual or multiple field values - Flatten fields to make them read-only - Check field properties (required, read-only, options) - Support for text, button, choice, and signature fields
- Add src/Manipulate/PdfEncryptor.php for PDF password protection - Add examples/pdf_encrypt.php demonstrating all features - Integrate createEncryptor() and encryptPdf() methods in Tcpdf.php Features: - User password (required to open document) - Owner password (for full access) - Multiple encryption modes: RC4_40, RC4_128, AES_128, AES_256 - Granular permission control (print, copy, modify, etc.) - Convenience methods: allowPrinting, allowCopying, etc. - Check if document is already encrypted
- Add src/Manipulate/PdfOptimizer.php for PDF file size reduction - Add examples/pdf_optimize.php demonstrating all features - Integrate createOptimizer() and optimizePdf() methods in Tcpdf.php Features: - Multiple optimization levels: MINIMAL, STANDARD, MAXIMUM - Stream compression with configurable levels (1-9) - Removal of unused PDF objects - Detection and removal of duplicate objects - Detailed statistics: originalSize, optimizedSize, compressionRatio - Human-readable file size formatting
- Add src/Manipulate/PdfToImage.php for PDF to image conversion - Add examples/pdf_to_image.php demonstrating all features - Integrate createImageConverter() and pdfPageToImage() methods in Tcpdf.php Features: - Multiple format support: PNG, JPEG, WebP, GIF - Configurable resolution (72-600 DPI) - Quality settings for JPEG/WebP - Imagick and Ghostscript backend support - Backend auto-detection with graceful fallback - Convert single page or all pages
- Add src/Manipulate/PdfLinearizer.php for fast web view optimization - Add examples/pdf_linearize.php demonstrating all features - Integrate createLinearizer(), linearizePdf(), isPdfLinearized() in Tcpdf.php Features: - Check if PDF is already linearized - Linearize PDFs for progressive download/display - Generate proper linearization dictionary - Object reordering for first page priority - Hint stream generation for quick page location - Statistics tracking (original/linearized size, first page offset)
- PdfBookmarkManager: Fixed xref offset calculation by tracking current offset position and calculating offsets BEFORE appending object content. This fixes bookmarks not appearing in PDF viewers like Adobe Acrobat. - PdfBarcodeStamper: Fixed barcode rendering by using getArray() method which returns bar coordinates [x, y, width, height] instead of getGrid() which returns a string. This fixes barcodes not appearing in output PDFs. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Extract shared Resources dictionary from source PDF during parsing - Preserve ColorSpace objects (like /CS1 Separation color) when rebuilding - Include ColorSpace references in page Resources dictionary This fixes the issue where PDF content was not visible in Adobe Acrobat because the ColorSpace referenced in content streams was missing from the page Resources. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Add extractNestedDict() helper to properly parse nested << >> structures - Handle both reference (/Resources N 0 R) and inline (/Resources <<...>>) formats when extracting Resources - Fixes issue where PDFs processed multiple times lost ColorSpace This ensures content is visible when loading and re-processing PDFs that were previously created by the bookmark manager. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
Add ColorSpace (CS1) resource preservation to ensure text content renders properly in manipulated PDFs. Without this fix, PDFs with Separation colorspace would show no content after processing. Classes fixed: - PdfEncryptor: encrypted PDFs now preserve ColorSpace - PdfBarcodeStamper: barcode-stamped PDFs preserve ColorSpace - PdfSplitter: split PDFs preserve ColorSpace - PdfPageBoxEditor: cropped/resized PDFs preserve ColorSpace - PdfMetadataEditor: metadata-edited PDFs preserve ColorSpace - PdfMerger: merged PDFs preserve ColorSpace - PdfPageRotator: rotated PDFs preserve ColorSpace Each class now: - Extracts Resources dictionary from source PDF - Allocates and writes ColorSpace object when present - Includes ColorSpace reference in page Resources 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
The modifyPdfWithStamps() method was a stub that returned the original PDF without applying stamps. This commit adds proper implementation: - Add extractObjects() to parse all PDF objects from content - Add extractResources() to extract Resources from page objects - Add extractNestedDict() for proper nested dictionary parsing - Add findPageObjects() to locate page objects - Add buildModifiedPageObject() to inject stamp content references - Implement modifyPdfWithStamps() to rebuild PDF with stamps: - Creates new content stream objects for stamp content - Appends stamp references to page Contents arrays - Adds Helvetica font resources for text rendering - Preserves ColorSpace for proper text rendering - Rebuilds xref table and trailer All stamp types now work: text stamps, watermarks, page numbers, headers, footers, and date stamps. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
- Implement correct Algorithm 2.B (ISO 32000-2) with iterative hashing - Use SHA-256/384/512 selection based on SUM of first 16 bytes mod 3 - Fix round counting to start at 1 and increment at loop start - Correct termination condition: roundNumber >= 64 AND lastByte <= (roundNumber - 32) - Fix encrypt dictionary structure: add /Length 256 and /AuthEvent /DocOpen - Fix permission value calculation using -4 (0xFFFFFFFC) as base - Use PDF 1.7 with Adobe Extension Level 8 for Acrobat compatibility - Passwords now work correctly in Preview, Adobe Acrobat, and Chrome 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
|
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
...
Add new features of
📄 PDF Manipulation Suite
🌐 HTML to PDF Conversion
🔐 Enhanced Digital Signatures
...
Type of change: