addKid($first)->addKid($second); $catalog = new DocumentCatalog($pages, new Entry(new NameType('Metadata'), new IndirectReference(new StreamObject('SECRET-XMP', new DictionaryType(new Entry(new NameType('Type'), new NameType('Metadata')), new Entry(new NameType('Subtype'), new NameType('XML'))))))); // There is no font-program geometry backend in this example: all BT/ET text // objects on the selected page are removed conservatively. Text on untouched // pages remains. A tainted shared image is removed from every reachable use. $result = (new SecureRedaction())->apply($catalog, new RedactionPlan(new RedactionPageRequest($second, new RedactionAnnotation($annotation)))); $path = $argv[1] ?? __DIR__ . '/pdf17-secure-redaction.pdf'; $result->writeTo($path); // Independent validators can retain the original separately; it is never // embedded, copied or incrementally appended to the redacted result. if (isset($argv[2]) && str_starts_with($argv[2], '--source=')) { (new FileStructure(new FileHeader('1.7'), new FileBody($catalog), new IndirectReference($catalog)))->writeTo(substr($argv[2], strlen('--source='))); } echo $path . PHP_EOL;