I have downloading PDF's and PDF downloading with the opening of a new tab using _blank in the link
both download fine
However
I am trying to get "Attachment"=>0) so that is opens in the tab
this now leads to a page of text that has not rendered as a PDF
Using SLIM and TWIG I have the following
$html = $twig->render('reportPdfView.html', array(
'pageTitle' => 'Report Detail',
'report' => $reportShowResult,
'users' => $userList
));
$dompdf->load_html($html);
$dompdf->render();
$dompdf->stream("sample.pdf",array("Attachment"=>0));
in response to question what do I see -
%PDF-1.3 1 0 obj << /Type /Catalog /Outlines 2 0 R /Pages 3 0 R >> endobj 2 0 obj << /Type /Outlines /Count 0 >> endobj 3 0 obj << /Type /Pages /Kids [6 0 R 13 0 R 17 0 R 21 0 R 23 0 R ] /Count 5 /Resources << /ProcSet 4 0 R /Font << /F1 8 0 R /F2 9 0 R /F3 10 0 R >> /XObject << /I1 11 0 R /I2 12 0 R /I3 15 0 R /I4 16 0 R /I5 19 0 R /I6 20 0 R >> >> /MediaBox [0.000 0.000 612.000 792.000] >> endobj 4 0 obj [/PDF /Text /ImageC ] endobj 5 0 obj << /Creator (DOMPDF) /CreationDate (D:20140208210105+00'00') /ModDate (D:20140208210105+00'00') /Title (Trainers Report) >> endobj 6 0 obj << /Type /Page /Parent 3 0 R /Contents 7 0 R >> endobj 7 0 obj << /Length 1534 >> stream 1.000 1.000 1.000 rg 34.016 34.016 543.969 723.969 re f 0.200 0.200 0.200 rg BT 34.766 713.165 Td /F1 28.5 Tf [(Attendance List)] TJ ET q 180.000 0 0 61.500 397.234 695.734 cm /I2 Do Q BT 34.016 682.774 Td /F1 10.5 Tf [(ID: 26 - )] TJ ET BT 71.364 682.774 Td /F2 10.5 Tf [(Sun 29th September 2013)] TJ ET BT 193.941 682.774 Td /F1 10.5 Tf [( - Trainer: des cooke )] TJ ET 0.957 0.957 0.957 rg 34.016 652.459 222.028 27.263 re f 0.200 0.200 0.200 rg BT 40.016 661.512 Td /F3 10.5 Tf [(Name)] TJ ET 0.957 0.957 0.957 rg 256.044 652.459 166.521 27.263 re f 0.200 0.200 0.200 rg BT 262.044 661.512 Td /F3 10.5 Tf [(House)] TJ ET 0.957 0.957 0.957 rg 422.565 652.459 38.855 27.263 re f 0.200 0.200 0.200 rg BT 428.565 661.512 Td /F3 10.5 Tf [(Day1)] TJ ET 0.957 0.957 0.957 rg 461.420 652.459 38.855 27.263 re f 0.200 0.200 0.200 rg BT 467.420 661.512 Td /F3 10.5 Tf [(Day2)] TJ ET 0.957 0.957 0.957 rg 500.274 652.459 38.855 27.263 re f 0.200 0.200 0.200 rg BT 506.274 661.512 Td /F3 10.5 Tf [(Day3)] TJ ET 0.957 0.957 0.957 rg 539.129 652.459 38.855 27.263 re f 0.200 0.200 0.200 rg BT 545.129 661.512 Td /F3 10.5 Tf [(Cert)] TJ ET BT 34.016 625.249 Td /F1 10.5 Tf [(Key:)] TJ ET 0.933 0.933 0.933 rg 0.933 0.933 0.933 RG 34.016 607.197 m 577.984 607.197 l 577.984 606.447 l 34.016 606.447 l f 0.200 0.200 0.200 rg BT 34.016 579.237 Td /F1 10.5 Tf [(Days Y -Attended, N -Absent, am -attended am, pm -attended pm )] TJ ET BT 34.016 563.974 Td /F1 10.5 Tf [(Certtificates C -completed, A -attended, N -no certificate)] TJ ET endstream endobj 8 0 obj << /Type /Font /Subtype /Type1 /Name /F1 /BaseFont /Helvetica /Encoding /WinAnsiEncoding >> endobj 9 0 obj << /Type /Font /Subtype /Type1 /Name /F2 /BaseFont /Helvetica-Oblique /Encoding /WinAnsiEncoding >> endobj 10 0 obj << /Type /Font /Subtype /Type1 /Name /F3 /BaseFont /Helvetica-Bold /Encoding /WinAnsiEncoding >> endobj 11 0 obj << /Type /XObject /Subtype /Image /Width 240 /Height 82 /Filter /FlateDecode /DecodeParms << /Predictor 15 /Colors 1 /Columns 240 /BitsPerComponent 8>> /ColorSpace /DeviceGray /BitsPerComponent 8 /Length 5494>> stream xœí\dríÿŸãH’$I’$I’$É$I’ÌL&3If&33“ÉÌd233™™™I2333“™ÉÌÌ$3ÉL2I’Iff’$ù\çW?Î9ÝÏžÏó}¾÷ãyýqßw缯¯ëÇû×u{hè_ü‹ñ/þ#·|•É—+ŸïÅìÝ’ðïîÍ_ŒñÈk»¥mÖßÝ©¿ "ï}›Á¿»gئz¶ª|èïîßÿŒÓÁl´xðßÝÅÿ%ÅÖ¯ùþ³ksÄÁÕü×/kÅ_Û†èú'tl¬Á=`ø×ExÀ$PKÀL¨ŠÉ€ÕÕ©å×£õú/¸;Žs?¤Ûn?°™´hBSv¥˜Ãb!¥mŸÇãD"1<³[‚i¾B·NrIÍã°™”ª˜Ó7ëÑi”2>‹*ÐC(U*å¤;07Ídž‘_ì'Õlþb3«8ôÛø}{,òØL]7m™ ŸCÐõ<¯;%N?#æy_Ém±€CÛÔ,¿ÅD, ;a§„ù H=øúúú®ÕH‡E´‹ráï?WD"P+E² |0¬’p1yÒBûrÊìžáM‘JFŒj¢d?¦?q‰‚Q'²á5ügÖ~rÉ|«•÷÷Jõã»Ö¤ë_JÆ¥›bXÞ‘¨.KÁ:%w¢®Ý¾ð8´"”yäÛ‹f¥E´¦ù"¿¾šÑ‰Ù”ÞÈÞ:×3ã&9ÅÇ'oüT¬’jù,åÒO©§L¶ðþY£é_Y#¤ÛÅ° G&mWˆ¸ÌþžÀ” ‘ÍØ<ÉÞ$–=&—•·PK>mÎÚ•<©'‰‹E§VÈæ×±ŸÑÍ…±%R%õüÓÍY,;ß=¿½SµÝþ6I©ƒ øpû¤–u2>»oÿAð=áÜÑê„VƒÜÒõTÍÇ–Š”¦dá$4©–ÒY¯ÄÃéºÇ âð±™k$ŽBäõÜÊ=œî¬.Î/Ö÷NéÂg›ŒúˆŠ2¨N¿Ø¹E-êÓ(|N©EéjkÊV äÃ4k5d ¶²Ç«ã¶žª4%ßov¦‡Eý땼¢lF¸–¾Ü"ï«êÃqhÆi5[®™•½‹Ç,eã}MPåÃ&ɽÙtnOg 'ܨ}||T>¿Áïòuí6t„½ÿ®‚€4*ÈÜF–ÑEêˆtêý®”K…|’ÊížÏØGzëïDánwÚ dq1Âõ—8%.Jž®y,j™D*טœ³GwE²D‰2¨ô„Ûï£Ã2^W²Cøû£üö’~Æ~m.6½ÈÃxg¾*o©Äe<¸:Z÷%èþa&£V)^Ÿnoo“Ÿíb}6:ÂÅ)K‡ñ ±½·QÊ “xv·=ã0†‡Q§)K¨èjùåfÙm7ê´z£mÌårè¥=Ž>·B¶DÞv÷¦ÆúóÖn K¨$’û$=A"ܨ^òé°ûØ \;Ùõi% sðgƒY›F.y,Ô²A&üEåí.²ä–‹H¦ÒêԲĥò…×{œZ>ÑK¸Q 4Ÿöôî ˜+³øûJ7Û½àW„‹Ï7g]‹{á1J1ïoáz|ó`Ž¾ótk\/pYL<¸Á…zéù4èÒK¸,ƒÁdsB Ó1öF¼ì{áõî螎pýÚüˆºÇÈB,‘>Ô?™ó SE— ׳‰Èfh§³¬7'btÍ ÜHÌ[eˆhm·óøpD+æv"‡(öð#·ë3K1ó´ƒÙšU0¡¯Bîáh휎p£Bm?¨èÙS Jö¾mîæ-´žA¸–>ߘõL/>ڧߩAµB‡p³ ñ'ŽÒõî¬YÊF|u·µK»VÜq\ðÌÓûëeh\ÝÕR}i‚y¼`1Ÿ: y#´„ËTÂï¢~Â#}³Q~>¿ƒÎ—î~:Œ›ÍΘ·+‘>v³Ï©ä#‚‡û«ØšÛ€`0Gfíšý;‡NBlœp9}¼d—ч§„Æ{/¤ã[ÓÖ0-aŠSŒlÏôA,NŸ^k5*[f m´Ô!œŠ-ÚÔ ƒJZÛSfD„[ÕÂÓÍiìÅÁ~xut|5£Ým–vê‰à·¥T„Þ ðà³wvõ:=aº€m¿»‡aÖ.#DC×`—ptÞ,ˆT¶=\þmuBu‡p)ß.ÎÍø|3^—UC„x0[lp•: e]TáA>_åÇ›ŠâeÊ…ÔÉê¸V¤%\¦ †€j52¦éÞkÍÿ5a“„謄Y´Ë‘Žã„ßî—&íf#ŠaƒF!⦚Á•™=ÝE•s #Œ!xïÙ`ÂfL¢U|ž¹QÊ[¥%\¢ÙÄ &¬–5ú×_³,¡zNocÌN8{³å5)%"B>·›˜<àÝÝušIŽ£ŒVìgãñ`–Ö J`ïùd,0¢ä±Wh óõ„j¥—øÁÓ#¾íöý9¡ÑO‚Ù"mŽùÈã„U«°™8pOØ1ù ³§ëâ_L$&Sƒÿ|ŠÒ»yCx0Þ*½^oy "6s™žðÚúžIŒû £Ž“ĈëˆûM7²‹qÂ/Á1%²R!ˆš€Œåfw7rÞréÅl‘MÉ/Ùdl¯g {ÿ]H-9\ƒžpá5K ðŠ«þ ˜LlHžâ{Vˆ, k—ð¨b#ê]Õr“ûhåË?¦r8iìWå+š¢¸Å+çá©a#ø-Îu=ý?o‡LqÅq_±~¾æþÂùO#Œ¥ÃÛD+÷ó6…€7‰ÿJl¹u|šô6oÍbúl8‚L˜A»‡ë¹ÔÃsñ¿g,ïËàPGB‚o™Û)ƒˆù£Fs¥†qbÿ7·¦Œ2¡ß¹Ã9³„º¦ùxÛ…dtÁ¦à±˜lZ-]}¸¾Í”)1âOëMÅÒ†˜B\yf¢ˆCú³F“D?†gÒÛ÷+NDLDî«cxÒ§·îu4kÅ—äíÍõõuŽ–ðKâô4ñRþ”soÕ¾B îóÊ(„A´El¥³•÷§„cŽDOµæžÏ¢”â;°²”T4i‰p&~¸½N?¾ëÍf‹Jíë9h_!gð»=ìÏx<Ÿ†|ÓÑøc&W¤œ2|U ÙL:ÉæKÕ/zE/ìæèhÁ"ìáçÝî”Aø'#FMŽç¥ŠG1”8k·6ÜÀé/>Ð >Y™°xü›‡gײìwéå!~z||z™HfòZ·{CÞ“¢#Œ{û3â?C1j¸¢þº\wë%’ÎÁbku\'êßÆ4=>XdÂQ½fØáž[= ‹6‹ÏW‡+KKËkÛ‘ó»Lღ¾{m7)IKx'¼~ãŸ#Œ®ñj‰ðŒI*”wIš«£Èé[W}àf¸Õj6êµÚ7"/M"âi¥X¬Ð[”1*=]„'Gm6‡Ó3Ü;ÈÑÌñ›©ãÙÒ^ÀVÿ4aˆµ…®ßï£ÆªŽ‰f[Û#€q7äÂOR¾ªÅlæù)•zz¢ÏZÂ69Ã+ƒ” ÎÄÃócµ\®PlóÇ÷Y*á’½³¦i ê³üø“%ÝïXC<W{Œ,Úd\®Äؽ,wl׊;š‹ ü]yKÝœŸ§öÛ¤“+¡d ‰ýÅQ„Ïåpù"¹Î>ŒÝQõ»SÍûa¼'íÂýÞô*õe‰º3Œ7ò™Œúm2‹¯°uÓ!on½Oâv’g»k?ÀÒÕ`ÂÀÓæPN¢ÛÉز,&ÃW¨4¹ƒGÔ4vÙ0†¢Ø³æÛmØ£üš°¬Ýv ÜŽ÷©‰QM‚–²A„éɳn›”BìFAøãå*YÃ=”f²c |5~ÜîxÁþçýá5áv;Î#fSÌðëåÚxÇñ"ß÷ÂzüQÊÞÇ‚zà š7–ºÜíS=¹Ú{áù2ì³v¯ ŒÙÀ+p-lœâýÉ]unæ<-ZñÅn„iz!“|7‹‹Œþ=¼BxOÅí2"lQPkh֪ŷt"ºê1;5T¢JxºØ] „bé>uT¯³çÛsv•€Õ£?WÀ“jmž¥ØC PÍÆ;û¡.Ú¡Žc‘B®-QÍ.=ãÞ †äUQ{CS¢ÄسyJ‡ÿ0‘Éåóù7Ùìk&u{¶˜#o}cöíÄŸ^Á«\^ŸÑ5Ÿgfi+Ï”¿jõz£‚ñükê:¶îs¨…¤nÀ å‡×¿9»Ï?oÎygCÇ÷éçÄðÐÕÏÜgéd|ô‘'PÚöož³hÓo ¾§ßÓg=GH•Ô,#º·{G æHÍÓëÑ‹ë×W—g± oÌ€Ü^‚ –È0¹²zyEFüì0ä5[F½þƒ“øíCê „<·—±í%·E%¤G;Ë)v÷|0¼¿¿éw{üÛGçÑuDŸÃh:_3æß9¹8Ý_vé„®Ôä];<‹#]ßÜ¥²Î˜Ú+¼¡¶YÍ^÷åÓ`–H;:³ÚØì`}myaÊiV‹ÑûiÈéºÍ³¸Z'#´ºèµëär•Á>9…÷£±££èA8ä÷Žä|]`_®³8½³s3.»Õ19¿ZÌ€#Gò%æÉ…ÕPÐï±*ùlŽHã˜Z ¢MolíÝdj±ú¡Ì3EA7?óÿˆ²Ïû”é¬c®‰‰I.çˆÅ –ò±È,D±Úäwõc||ÌnTÀŒ'’kM—Ç7·è_œ÷yÇí¥ˆ;à8BY UéÍV³A£Ö™ìN×ø(ðA°Ë0[¤2:œãΓxçÈ®78±–Ý3+7í =_ÅÔ ¢{»Þ'¢KD2¥ZÁ¡V«”r)r]ï1Ää¤ ¥Š ¥¹ Î`°8|±\6[¬³Q¯–‰¨·{¶2Ìdó„©T,Š¤ •Z°;¼`tðH¥"!ð jÙˆ>ü©ó‡Ægñé|sª{µßX,—×.—Ãî½u1Xl·O¤+‡~zÆá Db‰T" xœÁtqÎ&¨DXË\¤Ôi‹x„^³CšÆšHB»üÑ'-ZuÀ÷bÛgSL5åû òWø·Œ>ôÉ!€ˆwXL&üÇÐ`Ÿ{ 0 ê :‘–ˆGݦ“Û#IºýôÖªùÔùÖ,bÿ°Cÿ hQÿ—õ3…z÷æÕëûךõ¯÷ìýɆϮҩÏß0WáðGrŒØl|Wé›èÚ”õ÷å‹Ü€3x6ã/•?)šÍFí³œK^ì/»-Jûÿൿ QØç÷osÕGHØÜ6êݧëØÆÜØ0âü®|ÑS s9vÿV¥ÿp§ÕjÔëµï#÷æ8¼ä±iăÜß0G2<<ºÏU¾©g£-0¹µïÏJá5y}^žÞž€æ;¬ß hvÌŒ&2Åêw½Ñ9*nµ¶¥\úøòéQã`oï7â›&—÷._‹ä¼Þ#€œL}Vß¹ôãõÉþú¢gĨ¢ùæìwÂØàœ[ÄÒ¹Bé½Zý¨V+ïåb>—IÝÅO6—}.›^)¦ûªð·ÄäJ4ÖÉÅõ}>>¥3//™ôSò>?î®|“#&LÈe1~WãKÄ`äzÛ„/°>ˆŸœžžÇ÷¶CËóS.‡I«ó‘“œÆô¢#ÒBz}þÀòrÀ??;í1F.æsYƒ¿Øþ](£©Þh±Ù»Õb4èT ¦åsþlQ©D*“Ëe (òyXLûOd‹‰•™ ªFÁÂ.÷þcÉÀþGø§1鮂Ö~ endstream endobj 12 0 obj << /Type /XObject /Subtype /Image /Width 240 /Height 82 /SMask 11 0 R /Filter /FlateDecode /DecodeParms << /Predictor 15 /Colors 3 /Columns 240 /BitsPerComponent 8>> /ColorSpace /DeviceRGB /BitsPerComponent 8 /Length 6214>> stream xœíy˜ÅùÇ¿U}ÌtÏìÁî²,Dz°ÜQTLx*D#ü¢B¨`ÂåÊ%ñ<¸5b~êÅpŠþ!Š–ÕeÙåX`wçè£~Œ;OÏÝÓÓƒ˜ôç™ÇGz«»ª«ßzë·ÞªÎOAÈv$Û8ü—À󼪪¡ÿoSZÚµk×òöå-JJŠŠŠšåçË^/G)cŒâóûÏœ>]Ss¬âpÅ®]»vìø¥T×õÌ‹á´CFBcJZ¶ìÒ¹Ëå?¾ü¢‹.¦”*Š¢iZÊÛA ”nxíµÍ›6ž:u*?¿Y]Ý©ŒÊ“ÉÍ………?ýiÿ›‡ “$)Z~ŽÇãY·î™×7lj!ÖpÚÁ Ç]s͵cùË°†¶…ÚÚÚ)“'eòG Ò£¤¤åÔiÓZ·nÍ󼢦®®î×wO„U=í´ƒÀz_ØgôèQ¥¥mu]φ(‡ùlçÎ'Ÿ|ÂÚ½¼½Eqø#ä|èÞ£û˜1cËËËMõ2äâ¾}ËÚµ«8|ؽŽ†vHFAAÁ„‰/ºèâ# ( c¬¢¢`„P¯×[XX(‚ªª™hñššš©S&[¸ñ¿KCË #PFd±ßü ÿ¿™4IQ”$Ò¬(Ê3¦=zÔx±¬¬lØðáÝ»÷eÙšX·iÓ¦]»v‡ÓWÒñ5ô H•Ð?…º ºY1—#3{‚³òHá&BŒj¾°Ú2+¡gòŽh z5¸2Ð ðu`*p¬ ú·`Ðë²Ó~À=Áµá€ÍÐÔxÑx;‘õÀóüSO/*..Nž5clܯn÷ûý‰Ü0dèÈ‘# ±blØðÚË/½”î]ñs ~:\¡ÿ÷Õ‚-FðÓ„¯o…Ÿ€{îL¦†þu1jŽ0m#×Ar'þÐûŸ[à_¡šÏ½äXkÐ…pµu5=Ÿkä¨óL”6-®ÿ9 î¦+UÐo/nâ'ᾜ±À¡1*!¤°¨pÉ’e”¦P8ª¢ÜqÇø$Ê;„ËåZ¼di~~~òd±TUUÝwï=éÞ¿ÐAc#èç)]÷kÇBL7ƒDì….€è€å_JuGö †äJœ8ôŽ9 ³áöšQPàØ"¸_ÔTh*O8ïg#c l†ü\EMm)ôû UÄIdÎŽ×ÀºvíºhñÒ”ÒL)>ýþ”Ò Ü=qÂÁÿ;eÊ(:tèî-H$ÐJÌ(¹ÂfÈWÚay×e¨’RútàQ¸ÌH¦ÂWoNêàÙùbpæUº]£ïb?Aš1$ê3qÀ¡ÄýUÌŸöÇ\)-m;ã™f¤ùoo¼Q]]m¾Øóæ=ä7!ýQäxsÒ½%~ÑÕŠä€Ì‡kÜ9£ÚH"&~iÑ´38ã €þ ´ÐªÁø¦‹ÿ€¶ÝœAEÈK bŠC |\HýÁ½ Oh܆Däfº±0 ™ØårMŸ1$u±}>߳Ϯ3WäïPUõÉ…9ŽKÔ/¤:èÚ ÐÜ›GÃw0±JH‰±:9à3#3/"¹&¤åz~C&0¾#†_îa¸O€=ˆ„Ú(t`5ÜžÈÜ)жúËPöBÓ ¤'¸kÁõ—’¡½AŒƒx„³†7 ™Æ¢¤¥‚òÀƒ3yžOY„×^{5|¾cÿþ}õõõ’$™LO9u*í#%ëƃ <é)^Og,•7ÈTøÌ?¨-è T…o)I롉l~Û¡ FC^:št\e ƧP`=”•ˆˆËiÛ u+TùÀRH™hkÜñçŒypÀZ(¹À0ØdܧOI–(G MѺ\î|ðµ\V¯^5uê4“‰«ªª,daJ Cï«fp?\]Á-´{üž’#Ð× ElW”Û™„Ä|¯ƒä"…ëò˜ û$jÞäzðˬ3Y7‰lØ"\šÆ<—‚ef ìƒ~gßœ5:vìŽr„Дínÿ¾/,gLFç¹ÝîwÞyÛB¦Zv#Û_gÐ)û‚3 ¯ ô·î2é°×á1™X.E}ÊÌB¿Ðày½\7ÐØ¡½Ix w¤÷ØV;Ì$4YÉ×Ô(°ÚÄÌtG,Ý{t§G(!„¤ÖÖ·œ‘ù5)Û·o¯¬¬´Ez³u_Aÿ5ü3í€Q+À…çb,#˜É_£¹ÉËW ¸ ÿôË`zHC.ˆ±õS`’Ý‚e$ÀóipºíÒìõz§IsjdëUˆ”Á„•¿_a1÷¼ õ:4œˆTu0üÐó)8ä[°÷"íð"dkOûYäØë$Xuž”ÔÝ—qÀ€1¶Z!¼^/Ó ¥õ¢CÇŽ–óE—{cúý÷544XËÂb<… ÜßèQ50®^HÏטUž# j4V²É’L÷¬«ãYlºÜ/ÚA¦Áw\ž!n·;ø¡Î;›T´±”—·Ož€ã¸5øƒ5c#„õ!Œƒïÿ åW~waú#z T#?lúgòÔ‚ÝTirAþÙüDwˆ®†ºâ€Ïll‰e&\F»n”YÎÑ$~ _¿~ÖfÆ¿#É_].×êU«¶n}×jÑ€ÌÃGg!°¤¯a´¤OÀ=.ÍÎQ¹-ý)€P_ ÑØd-ï€ïKÓfƒ$,a¨È¦†ž¡$<Þ€u©|”– ©\Jèºvë#¶mÛ–V.„6mÚ‡·:ˆBÅyóÚ³{wZ%ÃN¸þŠH±øèè4½ý,›¡Ù+¡¼Ù“„XéÇV ¤¬jËaŸ}|±Ñ5vÑØØHiz궸¤Åˆ#Óº…1vç]Is0œ÷ÐÜÇI’;nóØ E˜ÿ_!‡U–Üñ…81Nß" ‚ …`ÄF`)¤¹ðo1á}‹J‘½æ7 ¢ÛNslw6GŸ§OŸ654 ©ÚÍÆ}ñÅÞÝ»w›ô+8¨K—.‰Úår=üÈ£¤‰ŠŠŠ;w~òñÇG**ÎÖŸM«l6hhœ»>cˆÀRdÚÚìe‚ëŒzáF°¹p 7ÑŸ}h™…Õká†i˜o,h/‡J÷EQfΚ=èºëÌHsiié]ªgŒ1¿ßïóùŠŠŠ8{ÎœuÏ=÷øüyyiÄRÛ Ð!öAÿÂÐ3à‚óÉÝb-”yD)× 0â]©æÿe0šu »}U†‚36”J至©žCìß·Ï¢]×ÇŽ»îÙ犚7O’¬eËVó,49c,¶k×nåªU¿[þ{·Û”~´ó«L‚ßhdðÀì¦Z²ÄÛPï†/ªX¸ ÂMIõôg‘͵$ à1C·&Ïfm,häøñã'OYÏp¹\Ë—¯øÝòƤëßÀÓ‹Yvó…),,XûÇg®¾úš”)ã·Ë<gíWÐÇ›sAÜñÆÈój4ú8Þ‚'üõ< —¢>»óȺ‚®ƒe㻀Iðœ`¼Wòª¡N|ñÖ/eZ¼9\ À`¤˜_¸b¸ Àt>H<xžð÷fÀ4„?Œ×ë¿`¡Ç둤;HpÇq|]Ý©S§N5Ôׂ·Kêö£nI,taó¦MÉC±mV3O"hìZ4 ýy¹S¿ ßÓÒÀï µHàÄ:f”t/H[k}Á?þ{Y1R__ÿÂÏg¢J5M²,·nݺs—.={^Щs'¥€¢(72jÔh‰l$ûûÍÐŒYÝnß2D{9 v#OGË4{ ¹ÄC´Û nð¸3¾ù蟽ü¿/Y[¡}ÎPeèÏ~Ö«W¯DƒQûz=£_s>EwDánEcTù:€ÞϘfÀ&¨ÔðÏî Öãtbð€üÈ0ŒÖ€Ýç|jpË–ÍS§LN²-Áù€®ëÎœåñÄÍ´_ wA3zƒ`m³3~²…`<|FùU F‡Ë4ª ü«EBt5öo[õ¦¶¶vü¯nŸ1}zmm Çq*lBÈ'üÏ?Ü»gϱc5¢(fþLº®O¼ûî¸ÊŠúÜí’&e£-AŽd#›Ø}-”±Ñô€Üqu<Ãaèe†ö9âëPOÛ1 Þ43G¥TWWßß½IvvaàÀAãÆ·lálÙ²å…?=u1+ÆÀ7Ðs*mÎKG‡X‹ ±”HÜÓ]Ð÷DêÎA௰c ɨøд¸ð¯g‚_ìn ÙcÀ€+gÍžmFškjjî½gZò}JEÙ¼yÓˆ[o9RQaÍ»rà ×Ç^ÌŠ#3~aÏy/ÐÖA1V?âγ`)‚Fï†xîLÖÀ†ÈÆ\ºüäŠ+&Lœhf/]BÈÜ9³MÚ#àf|±w¯™±k·nQ³"ÐQ+IÓÚ'à{äld?0ÞƒŸCÛÓ?LEçñйwïÞ“'O1c7BæÌžuæÌ™´žÿÈ#8p ÝRƒÁz^uñ\Tâ©È®µQ†pÇÄ•ó$Q.è /Y]Ü…˜±9¸ÍýÎA¸L³fÍfÏ™krŠ¤²²ò믿¶ËsÆLíÚG/ÉŠ—£ÄØ–(Û0k¹7 I0S[à{Rø#3 ÈzÈ£,͇K‘ù®Fð9sÁ·Ó þÜ>×a\fÎœeòx+ÆØÿg5öÌ33flZ~ââ踨¬hè¶ FS«ê"ÐÍÒñ‚†>?2•¥ ‚äJ}’7R ÍëÝl÷°7«ÑØØ`yq+€wÞ~ÇüFa!bwsÌJ…ô2<–•Ù€´)RµTò½Ê&(Q}\è_ —œ«aC¶UÅM7Þ¤(¦ú JéÆ39†"|øáö´n¡1»?Ú/ÐèkP1pôÜjh˯ea¢.#ð}hQ•š²òåç_8xº\zée¹yy&SJÿþÖ[æøþ{崙¾±1ÚÀ³_ €Ëè(' çXC뀤Eš:²¨Ñ½H€æ¬Øá32#X÷JHço ‹ ÆoôÓ%ß¿=´ä$몪ҚÝeÏfι¼ñmÏMˆz˜Ð# ¿¹ÄÜjæÐi/«!›üÝt4ÅÃð¯D0J!‡¢—Þ„gôùo˜ABÝ`Œ1Ʀiš®ëº®‡/…Ñí8îMU•´– W‰ª°S %àåH± ÀKçv©,fÁ’ õû¥ê÷)À€ypE©ÒZ°´Êý"”)ðÇŽh`"„M§A<¿–X¦"´äI×4JICCý‚§ž¼mäH¿ÏTEQTUg̸%›-f%ÇqæϨa×®]QMu‰)s ÀhwCT"/î‚~Òô99\Àkmæ"pƒÁ‡þ-‹á~ÚJÌË™×%àŒê…&¥¿IȧЮGãr¸K#wØ×€\aF#øú~è•Ð·Býæûvþ$Ï^ÊÉy}ÓÆÚ“'÷} ١÷BÜCÉÙ³g9žxAEQÀó´ÉDeënø0…EE懕º®ïܹ#ê¢)n2b¬S–… #û€úbNfQÓ‹Ø]tDæ÷å$ ¤hpgÁBMdÜÆb€~஄ôôPÿ ý,X€bkÀßÞ¹Él†ZmIÚjÁnoÄhdáuÀ”–rÀI°oM8¶bÏw6m¾?»ªZé¥Wû‚{œÏYP×ÖŠ¢(ɲ,Ë„J) ½z÷þñk¯Æ9HÀ”#€ŒIê½õ=R`Zª}2掌JßÖ½É+UDì‡þxfÑs«|Á:ƒÆ••ØAUÔ¼c‘%¯Cóï¡NÕdâ#ȳÎØÑꣲ,çææ^àž›¢iÚ¨Q£2èÁƒ¯3|'Â[o¾{=¾ áØ\æ!°#UD¯…-ð’3ä P€ &PK_¦(›?0¾ëјHÓG½yWPãi™M»üŒAQzª*Í|ÅØѪªÚÚÚ3gNû}ª¢ê,âû–%-yÞºìôêÝÛ¤ÏÀsÏ=w¥z|6s$O\ànBãÛ©L⼈ýúíá,Ø(ønFã¿ §«íy`-‚¶H³±<¿#ã4¾Õ“tô~U“ÝâBÓÝÞðu ]âQ~—È£a¬QS[[WW×Pßu]‹²w9žŸ2uªå‡9ÊL4MÓ¶lÞ÷OñÛÓ¯FœHÈíÅ|m‚‰¶ˆ¢¨žñQ…ˆ§hƒÝ _ ȵàÇA”#b«”2ÈPV!X™ÛõØ|– ÐÜ(W€Wb2êÎXèúu*ÿ½èθ ‰WgÿüóD ~‘Êß…….ñ;ÛR*ŠBnnnq‹[·nݺMóâæ99¹.QŒÍw¹\Í»wï3¹PJW®Z““úÐXŽãþ°zuòÄ~ðñÙCSÕòòrÇãÍñæäääååæçå7+((((ÈËËóx=.—Ès|ìdµ¦iW^uUYYÙg»v©IA–,]fòhûÅ‹ŸNyD¢£¡’qíµ×†vÀ „ò<ç–¤œœœfÍ š5kæÍñJn‰çã´‘;v¬X±_#€¢¢¢!C†¦<ý›PòÍ‘Ê9sf›ôOÿ £Á²ÎÁƒ}~YYBÇq¼À‹¢(ÏóÔĶŽ!מ,˲,—””„Õ9c,å"EŽã–.]º}Û?ÌØÑÐ)ÈÏËzÉbMÓHhº›r”RJ)gòhCH’ôî»ï>óÌÚ†úô–À8íš={Ξ5GQ•ïãí†çù,Y¼¨¶¶ÖÂíŽ#;˜¢OŸ>÷MŸ²²!4„MS¿ùæÛÇ{ìÌ™ÓÖŸcc™þ³)++›¿`a6žÌóüë6¼øâúL–$†pÚ! <Ï܇æµoß>óÌ)¥¢(nÛ¶íÏ/®¯©©±kktG Ò¦[·n£FßÖ½{w¿ßŸ–N¥” ‚à÷ùß{oë‡~øõ×lß‹Úh‹””´0`#ž=:vì$Bhax©áwB(ÇiªVUõíáÇ8°g÷î#1mÄhhÑ¢¤c§ŽZ¶*((àrº®îäÉ“ÕÕÕ‡Œ]›íààààààààààààààààààààààààààà`'ÿ|º¢ endstream endobj 13 0 obj << /Type /Page /Parent 3 0 R /Contents 14 0 R >> endobj 14 0 obj << /Length 6472 >> stream 0.200 0.200 0.200 rg 0.933 0.933 0.933 RG 1.000 1.000 1.000 rg 34.016 34.016 543.969 723.969 re f 0.200 0.200 0.200 rg BT 34.766 713.165 Td /F1 28.5 Tf [(Trainers Report )] TJ ET q 180.000 0 0 61.500 397.234 695.734 cm /I4 Do Q BT 34.016 682.774 Td /F1 10.5 Tf [(ID: 26 - )] TJ ET BT 71.364 682.774 Td /F2 10.5 Tf [(Sun 29th September 2013)] TJ ET BT 193.941 682.774 Td /F1 10.5 Tf [( - Trainer: des cooke )] TJ ET 0.957 0.957 0.957 rg 34.016 652.459 242.150 27.263 re f 0.200 0.200 0.200 rg BT 40.016 661.512 Td /F3 10.5 Tf [(Label)] TJ ET 0.957 0.957 0.957 rg 276.166 652.459 301.819 27.263 re f 0.200 0.200 0.200 rg BT 282.166 661.512 Td /F3 10.5 Tf [(Content)] TJ ET 0.867 0.867 0.867 RG 0.75 w 0 J [ ] 0 d 34.016 652.459 m 276.166 652.459 l S BT 40.016 636.372 Td /F1 10.5 Tf [(Course Date)] TJ ET 0.75 w 0 J [ ] 0 d 276.166 652.459 m 376.772 652.459 l S 0.75 w 0 J [ ] 0 d 376.772 652.459 m 477.378 652.459 l S 0.75 w 0 J [ ] 0 d 477.378 652.459 m 577.984 652.459 l S BT 282.166 636.372 Td /F1 10.5 Tf [(Sun 29th 0000027104 00000 n 0000033576 00000 n 0000033641 00000 n 0000034648 00000 n 0000040387 00000 n 0000046859 00000 n 0000046924 00000 n 0000047094 00000 n 0000047159 00000 n trailer << /Size 25 /Root 1 0 R /Info 5 0 R >> startxref 47307 %%EOF
Related
I 'm trying to create a visible signature in a PDF file.
Taking a simple PDF "hello world" file:
%PDF-1.7
1 0 obj % entry point
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/MediaBox [ 0 0 200 200 ]
/Count 1
/Kids [ 3 0 R ]
>>
endobj
3 0 obj
<<
/Type /Page
/Parent 2 0 R
/Resources <<
/Font <<
/F1 4 0 R
>>
>>
/Contents 5 0 R
>>
endobj
4 0 obj
<<
/Type /Font
/Subtype /Type1
/BaseFont /Times-Roman
>>
endobj
5 0 obj % page content
<<
/Length 44
>>
stream
BT
10 05 TD
/F1 12 Tf
(Hello, world!) Tj
ET
endstream
endobj
xref
0 6
0000000000 65535 f
0000000010 00000 n
0000000079 00000 n
0000000173 00000 n
0000000301 00000 n
0000000380 00000 n
trailer
<<
/Size 6
/Root 1 0 R
>>
startxref
492
%%EOF
And signing it with a text to appear "Yolo" at some position at the first page produces this:
%PDF-1.7
1 0 obj % entry point
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/MediaBox [ 0 0 200 200 ]
/Count 1
/Kids [ 3 0 R ]
>>
endobj
3 0 obj
<<
/Type /Page
/Parent 2 0 R
/Resources <<
/Font <<
/F1 4 0 R
>>
>>
/Contents 5 0 R
>>
endobj
4 0 obj
<<
/Type /Font
/Subtype /Type1
/BaseFont /Times-Roman
>>
endobj
5 0 obj % page content
<<
/Length 44
>>
stream
BT
10 05 TD
/F1 12 Tf
(Hello, world!) Tj
ET
endstream
endobj
xref
0 6
0000000000 65535 f
0000000010 00000 n
0000000079 00000 n
0000000173 00000 n
0000000301 00000 n
0000000380 00000 n
trailer
<<
/Size 6
/Root 1 0 R
>>
startxref
492
%%EOF
8 0 obj
<</F 132/Type/Annot/Subtype/Widget/Rect[0 0 0 0]/FT/Sig/DR<<>>/T(Signature1)/V 6 0 R/P 3 0 R/AP<</N 7 0 R>>>>
endobj
6 0 obj
<</Contents <...>/Type/Sig/SubFilter/ETSI.CAdES.detached/M(D:20190626125540+00'00')/ByteRange [0 824 60826 1401]/Filter/Adobe.PPKLite>>
endobj
9 0 obj
<</BaseFont/Helvetica/Type/Font/Subtype/Type1/Encoding/WinAnsiEncoding/Name/Helv>>
endobj
10 0 obj
<</BaseFont/ZapfDingbats/Type/Font/Subtype/Type1/Name/ZaDb>>
endobj
12 0 obj
<</Length 35>>stream
BT
1 15 TD
/Helv 6 Tf
(Yolo) Tj
ET
endstream
endobj
7 0 obj
<</Type/XObject/Resources<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]>>/Subtype/Form/BBox[0 0 0 0]/Matrix [1 0 0 1 0 0]/Length 8/FormType 1/Filter/FlateDecode>>stream
xœ
endstream
endobj
3 0 obj
<</Type/Page/Parent 2 0 R/Resources<</Font<</F1 4 0 R>>>>/Contents [12 0 R 5 0 R]/Annots[8 0 R]>>
endobj
2 0 obj
<</Type/Pages/MediaBox[0 0 200 200]/Count 1/Kids[3 0 R]>>
endobj
1 0 obj
<</AcroForm<</Fields[8 0 R]/DR<</Font<</Helv 9 0 R/ZaDb 10 0 R>>>>/DA(/Helv 0 Tf 0 g )/SigFlags 3>>/Type/Catalog/Pages 2 0 R>>
endobj
11 0 obj
<</Producer(AdES Tools https://www.turboirc.com)/ModDate(D:20190626125540+00'00')>>
endobj
xref
0 4
0000000000 65535 f
0000061604 00000 n
0000061529 00000 n
0000061414 00000 n
6 7
0000000804 00000 n
0000000000 65535 f
0000000679 00000 n
0000060952 00000 n
0000061050 00000 n
0000061746 00000 n
0000061127 00000 n
trailer
<</Root 1 0 R/Prev 492/Info 11 0 R/Size 17/ID[<4BB225C2F629BB21464F66FBF2FED264><8E3C9AD8354C66931EAAC282088455EA>]>>
startxref
61846
%%EOF
So there is an object in the PDF that shows some text in the first page:
12 0 obj
<</Length 35>>stream
BT
1 15 TD
/Helv 6 Tf
(Yolo) Tj
ET
endstream
endobj
My problem is now that this object is treated like a common text object in adobe reader. I want it, when clicked, to go to the digital signature, like how Adobe Acrobat signs the documents.
What do I miss? Is there a parameter in the digital signature (The 6 or 8 number object) or in any of the other objects my app puts in the new PDF that links the text object with the signature?
Thanks a lot.
Your object 8
8 0 obj
<</F 132/Type/Annot/Subtype/Widget/Rect[0 0 0 0]/FT/Sig/DR<<>>/T(Signature1)/V 6 0 R/P 3 0 R/AP<</N 7 0 R>>>>
endobj
is an AcroForm form field for signatures (as the FT entry with value Sig tells us). At the same time, though, this object also is a form field widget annotation (as can be seen in the Type and Subtype entries). Form field widget annotations are the visual representations of form fields, and if a form field has only one representation, the widget can be merged with the form field as in your object.
In your case the annotation has a 0x0 size (/Rect[0 0 0 0]), i.e. invisible. To have a visible representation, you need an annotation rectangle that does not vanish.
The content that is displayed is defined in the normal appearance /AP<</N 7 0 R>> which points to object 7.
7 0 obj
<</Type/XObject/Resources<</ProcSet [/PDF /Text /ImageB /ImageC /ImageI]>>/Subtype/Form/BBox[0 0 0 0]/Matrix [1 0 0 1 0 0]/Length 8/FormType 1/Filter/FlateDecode>>stream
xœ
endstream
endobj
At first glance this looks pretty empty, even after decompression.
Thus, what you have to do is
choose a non-vanishing rectangle for your signature form field annotation,
adapt the BBox of the normal appearance stream to that annotation rectangle, and
create a non-empty content in the normal appearance stream of that annotation instead of adding page content.
Furthermore you should fix obvious errors in your PDF, e.g.
object 7, your signature field normal appearance, is marked as free in your cross references
your trailer claims a size of 17
For details please study the PDF specification ISO 32000. Part 1 is published for download by Adobe at https://www.adobe.com/content/dam/acom/en/devnet/pdf/pdfs/PDF32000_2008.pdf
In particular sections
12.5 "Annotations"
12.7 "Interactive Forms"
12.8 "Digital Signatures"
I am signing PDF programmatically. Every new signature is added in an incremental way where I add the signature dictionnary after the %EOF and I update the AcroForm like this (sorry, I'm at work so I can't upload the PDF) :
... // ORIGINAL FILE
trailer
<<
/Size 11
/Root 1 0 R
/Info 10 0 R
>>
startxref
2714
%%EOF
1 0 obj
<</Type /Catalog /Outlines 2 0 R /Pages 3 0 R /AcroForm <</Fields [11 0 R ] /SigFlags 3 >> /Names 14 0 R >>
endobj
...
11 0 obj
<</Type /Annot /SubType /Widget /Rect [0 0 0 0 ] /P 4 0 R /F 4 /FT /Sig /T (Signature) /Ff 0 /V <</Type /Sig /Filter /Adobe.PPKLite /SubFilter /adbe.pkcs7.detached /ByteRange [0 3729 15473 422 ] /Contents <308209...>
/M (D:20170801165520+02'00') >> >>
endobj
...
trailer
<</Size 15 /Root 1 0 R /Info 10 0 R /Prev 2714 >>
startxref
15609
%%EOF
1 0 obj
<</Type /Catalog /Outlines 2 0 R /Pages 3 0 R /AcroForm <</Fields [15 0 R ] /SigFlags 3 >> /Names 14 0 R >>
endobj
...
15 0 obj
<</Type /Annot /SubType /Widget /Rect [0 0 0 0 ] /P 4 0 R /F 4 /FT /Sig /T (Signature) /Ff 0 /V <</Type /Sig /Filter /Adobe.PPKLite /SubFilter /adbe.pkcs7.detached /ByteRange [0 16632 28376 387 ] /Contents <3082062...>
/M (D:20170802094848+02'00') >> >>
endobj
16 0 obj
...
<</Size 18 /Root 1 0 R /Info 10 0 R /Prev 15609 >>
startxref
28476
%%EOF
Maybe the problem is that I have multiple objects having the same ID and that my last AcroForm only refers to the last signature ? I want to be able to sign one file multiple times but I have an issue. The first signing is okay and displays this banner :
And then I try to sign the same file another time with another certificate and this give me this trash can icon next to the signature and says it was removed as you can see here :
I am using Zend_PDF to parse the file and add the signature.
EDIT : Thanks to #mkl the 2 signatures are now recognized by Adobe Reader. My AcroForms now look like this :
2714
%%EOF
1 0 obj
<</Type /Catalog /Outlines 2 0 R /Pages 3 0 R /AcroForm <</Fields [11 0 R ] /SigFlags 3 >> /Names 14 0 R >>
endobj
...
15610
%%EOF
1 0 obj
<</Type /Catalog /Outlines 2 0 R /Pages 3 0 R /AcroForm <</Fields [11 0 R 15 0 R ] /SigFlags 3 >> /Names 14 0 R >>
endobj
...
And I have this surprising errors since I didn't modify anything about the ByteRange and I verified by hand that they are correct. Is is about my new modifications ?
While adding the first signature you set the AcroForm dictionary to
/AcroForm <</Fields [11 0 R ] /SigFlags 3 >>
For the second one, you set it to
/AcroForm <</Fields [15 0 R ] /SigFlags 3 >>
I.e. you removed 11 0 R from it and added 15 0 R to it. Thus, you indeed deleted the first signature field from the form structure.
You should instead only have added the new signature field:
/AcroForm <</Fields [11 0 R 15 0 R ] /SigFlags 3 >>
Furthermore, both your signature fields have the same name
11 0 obj
<<
...
/T (Signature)
...
>>
endobj
...
15 0 obj
<<
...
/T (Signature)
...
>>
endobj
Obviously, different form fields must have different names.
For reasons tedious to explain, I need to create simple PDFs from a C# application without using any third-party libraries. The PDFs in question need to include text and line drawings, and if possible should include images, radio buttons, and text fields. I've been reading Adobe's documentation, which is for the most part straightforward, but so far have been unable to figure out how to make interactive fields actually appear on the document.
For example, consider the partial test PDF document described below:
1 0 obj
<< /Type /Catalog
/Pages 2 0 R
/AcroForm 6 0 R
>>
endobj
...
6 0 obj
<< /Fields [ 7 0 R ]
/DR 5 0 R
>>
endobj
7 0 obj
<< /FT /Btn
/Ff 65536
/Kids [ 8 0 R 9 0 R ]
>>
endobj
8 0 obj
<< /Parent 7 0 R
/AS /FieldA
/AP 10 0 R
>>
endobj
9 0 obj
<< /Parent 8 0 R
/AS /FieldB
/AP 10 0 R
>>
endobj
10 0 obj
<< /N
<< /FieldA 11 0 R
/FieldB 12 0 R
/Off 13 0 R
>>
>>
endobj
11 0 obj
<< /Length 59 >>
stream
BT
/F1 12 Tf
0 0 Td
(Field A) Tj
ET
endstream
endobj
...
Where 5 0 R references a resource dictionary containing the font /F1 and 12 0 R and 13 0 R reference streams similar to 11 0 R with the string replaced by Field B and Off respectively.
What changes do I need to make to the document to cause the fields thus defined to actually appear on a page?
Edit: Since mkl asked, here's the whole pdf (extra line breaks removed to save space)
%PDF-1.7
%¥±ë
1 0 obj << /Type /Catalog /Pages 2 0 R >> endobj
2 0 obj << /Type /Pages /Kids [3 0 R] /Count 1 /MediaBox [0 0 200 200] >> endobj
3 0 obj << /Type /Page /Parent 2 0 R /Resources 5 0 R /Contents 4 0 R >> endobj
4 0 obj << /Length 39 >>
stream
BT /F1 12 Tf 0 0 Td (Hello World) Tj ET
endstream
endobj
5 0 obj << /Font << /F1 << /Type /Font /Subtype /Type1 /BaseFont /Helvetica >> >> >> endobj
6 0 obj << /Fields [ 7 0 R ] /DR 5 0 R >> endobj
7 0 obj << /FT /Btn /Ff 65536 /Kids [ 8 0 R 9 0 R ] >> endobj
8 0 obj << /Parent 7 0 R /AS /FieldA /AP 10 0 R >> endobj
9 0 obj << /Parent 7 0 R /AS /FieldB /AP 10 0 R >> endobj
10 0 obj << /N << /FieldA 11 0 R /FieldB 12 0 R /Off 13 0 R >> >> endobj
11 0 obj << /Length 59 >>
stream
BT /F1 12 Tf 0 0 Td (Field A) Tj ET
endstream
endobj
12 0 obj << /Length 39 >>
stream
BT /F1 12 Tf 0 0 Td (Field B) Tj ET
endstream
endobj
13 0 obj << /Length 39 >>
stream
BT /F1 12 Tf 0 0 Td (Off... ) Tj ET 94
endstream
endobj
xref
0 14
0000000000 65535 f
0000000018 00000 n
0000000068 00000 n
0000000150 00000 n
0000000233 00000 n
0000000327 00000 n
0000000420 00000 n
0000000470 00000 n
0000000533 00000 n
0000000592 00000 n
0000000651 00000 n
0000000727 00000 n
0000000821 00000 n
0000000917 00000 n
trailer << /Root 1 0 R /Size 5 >>
startxref
1013
%%EOF
Based on the full file you posted I see several issues (there might be more):
The document catalog does not include an /AcroForm entry
The page does not include an /Annots entry with links to field widgets
Field definitions 8 and 9 are incomplete, they do not include the widget annotation entries. These entries specify the field location on the page
Your field is a pushbutton, it does not have different appearance states, the /N appearance should be a reference to an appearance stream (11, 12 or 13)
Field appearances 11, 12, 13 are invalid, entries such as /Type, /Subtype, /BBox, /Resources are missing
Update: below you can find a minimum file structure for a radio button.
1 0 obj
<< /Type /Catalog /Version /1.4 /Pages 8 0 R /AcroForm <</Fields [2 0 R ]>> >>
endobj
2 0 obj
<< /FT /Btn /T (Radio) /V /Off /Kids [5 0 R 3 0 R ] /Ff 32768 >>
endobj
3 0 obj
<< /Type /Annot /F 4 /Rect [250 667 270 687 ] /Subtype /Widget /AS /Off /AP << /N << /Two 7 0 R /Off 6 0 R >> >> /Parent 2 0 R /P 4 0 R >>
endobj
4 0 obj
<< /Type /Page /Contents null /MediaBox [0 0 612 792 ] /Parent 8 0 R /Annots [5 0 R 3 0 R ] >>
endobj
5 0 obj
<< /Type /Annot /F 4 /Rect [150 667 170 687 ] /Subtype /Widget /AS /Off /AP << /N << /One 7 0 R /Off 6 0 R >> >> /Parent 2 0 R /P 4 0 R >>
endobj
6 0 obj
<< /Type /XObject /Subtype /Form /BBox [0 0 20 20 ] /Length 74 >>
stream
/DeviceRGB CS 0 0 0 SC 1 w 0.5 0.5 m 19.5 0.5 l 19.5 19.5 l 0.5 19.5 l h S
endstream
endobj
7 0 obj
<< /Type /XObject /Subtype /Form /BBox [0 0 20 20 ] /Length 55 >>
stream
/DeviceRGB cs 0 0 0 sc 0 0 m 20 0 l 20 20 l 0 20 l h f
endstream
endobj
8 0 obj
<< /Type /Pages /Count 1 /Kids [4 0 R ] >>
endobj
You can download minimum radio button sample and a more detailed radio button sample.
Using our XFINIUM.PDF Inspector you can visualize the PDF file structure.
Your fields will need to include what are known as "appearances" which are XObjects that contain the drawing instructions used to create the visual appearance of the field. See section 12.5.5 of the PDF Specification. Alternatively, you can set the NeedAppearances property of the AcroForm entry in the document catalog to true. See section 12.7.2 of the PDF specification. Setting this to true will cause a conforming viewer to create the appearances of the fields based on their properties. However, you can't count on most viewers to do this.
I wrote a program that creates a pdf file from scratch. The output is this:
%PDF-1.3
1 0 obj
<< /Type /Catalog
/Pages 2 0 R
/Outlines 20 0 R
>>
endobj
3 0 obj
<< /Type /Font
/Subtype /Type1
/Name /Fn1
/BaseFont /Arial.BoldItalic
/Encoding /UTF8
>>
endobj
2 0 obj
<< /Type /Pages
/Count 2
/Kids [4 0 R 5 0 R ]>>
endobj
4 0 obj
<< /Type /Page
/Parent 2 0 R
/Resources << /ProcSet [/PDF /Text] /Font <</Fn1 3 0 R>> >>
/MediaBox [0 0 595.2 842]
/Contents 5 0
BT
/Fn1 24 Tf
100 400 Td
(Test) Tj
ET
>>
endobj
5 0 obj
<< /Type /Page
/Parent 2 0 R
/Resources << /ProcSet [/PDF /Text] /Font <</Fn1 3 0 R>> >>
/MediaBox [0 0 595.2 842]
/Contents 5 0
BT
/Fn1 24 Tf
100 400 Td
(Test2) Tj
ET
>>
endobjtrailer
<< /Size 5
/Root 1 0 R
/Info 2 0 R
>>
startxref
1000
%%EOF
Now my problem is that when i write texy in the 4th and 5th objects the the pdf reader see only two blank pages. Can anyone tell to me which are my mistakes and how to fix it in the pdf format structure?
In the below example (from gnupdf.org/Introduction_to_PDF; also related: How to generate plain-text source-code PDF examples that work in a document viewer?), text is written verbatim using:
(Hello, world!) Tj
Is there a way I could store this "Hello, world!" in a variable (dictionary?), say /MyStringVar, and then output it multiple places using something like:
(/MyStringVar) Tj
(I've tried the above, couldn't get it to work; /MyStringVar is interpreted verbatim)
Here is the code, hello.pdf:
%PDF-1.4
1 0 obj % entry point
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/MediaBox [ 0 0 200 200 ]
/Count 1
/Kids [ 3 0 R ]
>>
endobj
3 0 obj
<<
/Type /Page
/Parent 2 0 R
/Resources <<
/Font <<
/F1 4 0 R
>>
>>
/Contents 5 0 R
>>
endobj
4 0 obj
<<
/Type /Font
/Subtype /Type1
/BaseFont /Times-Roman
>>
endobj
5 0 obj % page content
<<
/Length 44
>>
stream
BT
70 50 TD
/F1 12 Tf
(Hello, world!) Tj
ET
endstream
endobj
xref
0 6
0000000000 65535 f
0000000010 00000 n
0000000079 00000 n
0000000173 00000 n
0000000301 00000 n
0000000380 00000 n
trailer
<<
/Size 6
/Root 1 0 R
>>
startxref
492
%%EOF
The PDF does not have something like a variable like PostScript does. What may come close to what you are trying to achieve (output the same text multiple places) is a form XObject. Just like a page it has a content stream with graphics objects such as (Hello, world!) Tj, and it can be be drawn on a page (or another XObject) through the graphics Do operator. Its operand corresponds to a key in the XObject dictionary in the Resources dictionary of the page. The PDF would look something like this. (Note that stream lengths, the cross references table and the trailer or no longer valid so consider this pseudo-PDF.)
%PDF-1.4
1 0 obj % entry point
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/MediaBox [ 0 0 200 200 ]
/Count 1
/Kids [ 3 0 R ]
>>
endobj
3 0 obj
<<
/Type /Page
/Parent 2 0 R
/Resources <<
/Font <<
/F1 4 0 R
>>
/XObject <<
/A 6 0 R % XObject /A is obj 6 0
>>
>> % /Resources must close here
/Contents 5 0 R
>>
endobj
4 0 obj
<<
/Type /Font
/Subtype /Type1
/BaseFont /Times-Roman
>>
endobj
5 0 obj % page content
<<
/Length 44
>>
stream
BT
70 50 TD % this has no effect on `/A Do` - only on the "manual" `Tj`
/A Do % do the drawing of XObject A
/F1 12 Tf % without this line: "Error: No font in show;"
% if without TD, then the next text is just appended
%-10 50 TD
0 0 TD % "Td/TD move to the start of next line"; but here like \r
(Hello, world - manual!) Tj
ET
endstream
endobj
6 0 obj
<< /Type /XObject
/Subtype /Form
/FormType 1
/BBox [ 0 0 1000 1000 ]
/Matrix [ 1 0 0 1 0 0 ]
/Resources << /ProcSet [ /PDF ] >>
/Length 58
>>
stream
%70 50 TD % without this `TD` setting, `/A Do` places this in 0,0 - bottom left corner
/F1 12 Tf
(Hello, world!) Tj
endstream
endobj
xref
0 7
0000000000 65535 f
0000000010 00000 n
0000000079 00000 n
0000000173 00000 n
0000000301 00000 n
0000000380 00000 n
0000000450 00000 n
trailer
<<
/Size 7
/Root 1 0 R
>>
startxref
600
%%EOF
Output in evince:
EDIT The text in the form XObject appears at the lower left corner because the current transformation matrix equals the identity matrix at the time of the show string operation. The initial CTM of the form XObject equals the concatenation of [the CTM in the parent stream when Do is invoked] and [the Matrix entry in the form XObject dictionary]. Which is identity in this case. The text matrix is not propagated from the parent stream to the form XObject.
As an addendum to #Frank's answer:
Deviations
There are some deviations from the PDF specification in the PDF in the answer.
in the page content stream (object 5) the XObject A is drawn from within a text object:
BT
70 50 TD % this has no effect on `/A Do` - only on the "manual" `Tj`
/A Do % do the drawing of XObject A
This is not allowed, cf. section 8.2, especially figure 9 at its end: XObjects may only be inserted at the page description level of the content of a page or XObject.
in the XObject content stream (object 6) a font is referenced
/F1 12 Tf
but no font resources are defined:
/Resources << /ProcSet [ /PDF ] >>
This is not allowed, The Tf operator shall specify the name of a font resource—that is, an entry in the Font subdictionary of the current resource dictionary (section 9.2.2 of the specification) which here is the resource dictionary of the XObject, not the page.
In very early versions of the PDF format a XObject could inherit resources of the page if it omitted the Resources entry... This construct is obsolete and should not be used by conforming writers (section 7.8.3 of the PDF specification) and in the example at hand, the Resources entry is not even omitted after all.
in the XObject content stream (object 6) the text showing operator Tj is used outside a text object:
stream
%70 50 TD % without this `TD` setting, `/A Do` places this in 0,0 - bottom left corner
/F1 12 Tf
(Hello, world!) Tj
endstream
This is not allowed, cf. section 8.2, especially figure 9 at its end: Text showing operators are only allowed in text objects, and as XObject shall not be used inside text objects, this stream cannot be considered to reside in one.
As it displays the XObject nonetheless, evince seems to be quite forgiving concerning PDF validity issues, even more forgiving than the Adobe Reader which already is very forgiving but shows that PDF as:
i.e. it does not display the XObject at all.
Adapted sample
This section contains an adapted sample which is nearer to the specification.
Furthermore the wish of the OP to position the XObject more freely is taken into account:
%PDF-1.4
1 0 obj % entry point
<<
/Type /Catalog
/Pages 2 0 R
>>
endobj
2 0 obj
<<
/Type /Pages
/MediaBox [ 0 0 200 200 ]
/Count 1
/Kids [ 3 0 R ]
>>
endobj
3 0 obj
<<
/Type /Page
/Parent 2 0 R
/Resources <<
/XObject <<
/A 6 0 R
>>
>>
/Contents 5 0 R
>>
endobj
4 0 obj
<<
/Type /Font
/Subtype /Type1
/BaseFont /Times-Roman
>>
endobj
5 0 obj % page content
<<
/Length 588
>>
stream
% draw xobject at 0, 0
/A Do
% draw xobject at 20, 180
q
1 0 0 1 20 180 cm
/A Do
Q
% draw xobject at 100, 100, with different scales and rotations applied
q
1 0 0 1 100 100 cm
/A Do
0.7 0.5 -0.5 0.7 0 0 cm
/A Do
0.7 0.5 -0.5 0.7 0 0 cm
/A Do
0.7 0.5 -0.5 0.7 0 0 cm
/A Do
0.7 0.5 -0.5 0.7 0 0 cm
/A Do
0.7 0.5 -0.5 0.7 0 0 cm
/A Do
0.7 0.5 -0.5 0.7 0 0 cm
/A Do
0.7 0.5 -0.5 0.7 0 0 cm
/A Do
0.7 0.5 -0.5 0.7 0 0 cm
/A Do
0.7 0.5 -0.5 0.7 0 0 cm
/A Do
Q
% draw xobject at 120, 180, skewed somewhat
q
1 0 0.3 1 120 180 cm
/A Do
Q
endstream
endobj
6 0 obj
<< /Type /XObject
/Subtype /Form
/FormType 1
/BBox [ 0 0 1000 1000 ]
/Matrix [ 1 0 0 1 0 0 ]
/Resources <<
/ProcSet [ /PDF ]
/Font <<
/F1 4 0 R
>>
>>
/Length 130
>>
stream
BT
/F1 12 Tf
% To not cut off stuff below the base line, namely parts of the comma
1 0 0 1 0 3 Tm
(Hello, world!) Tj
ET
endstream
endobj
xref
0 7
0000000000 65535 f
0000000010 00000 n
0000000079 00000 n
0000000173 00000 n
0000000301 00000 n
0000000380 00000 n
0000000450 00000 n
trailer
<<
/Size 7
/Root 1 0 R
>>
startxref
600
%%EOF
(Cross reference entries and stream lengths surely are wrong.)
This results (as seen in Adobe Reader):
All the "Hello, world!" instances are generated using the single XObject of the PDF.