addKid($page); $catalog = new DocumentCatalog($pages); // 5. Add a document title in /Info. TextString explicitly encodes this Unicode // value; this string does not represent the glyphs displayed by Tj. $information = new DocumentInformation(new Title(new TextString('Un PDF entièrement objet'))); $file = new FileStructure( new FileHeader('1.7'), new FileBody($catalog), new IndirectReference($catalog), new DictionaryType(new Entry(new NameType('Info'), new IndirectReference($information))), ); // 6. Write the file. The writer traverses references, assigns numbers, // measures stream bytes and produces the xref table and trailer. // The first argument selects the destination from the CLI command. $path = $argv[1] ?? __DIR__ . '/hello-world.pdf'; $file->writeTo($path); echo $path . PHP_EOL;