ios - I have inserted an image into pdf digital signature layer n2 using mupdf, but it not showed up -
i using mupdf(git clone @ commit 2014/3/5 4:05) sign pdf.
, i've succeeded sign digital signature in pdf function 'pdf_sign_signature'.
i'm trying insert image layer n2 of signature when i'm signing it.
there's function called 'pdf_set_signature_appearance' in '/source/pdf/pdf-appearance.c'.
try add codes below insert image:
image_doc = (image_document *)fz_open_document(ctx, jpgfilepathandname); fz_fill_image(dev, image_doc->image, page_ctm, 1.0f); these codes inserted between:
rect = annot->rect; rect.x0 = (rect.x0 + rect.x1)/2.0f; text = fit_text(ctx, &font_rec, (char *)bufstr, &rect); fz_fill_text(dev, text, page_ctm, cs, font_rec.da_rec.col, 1.0f); and
rect = annot->rect; fz_transform_rect(&rect, page_ctm); pdf_set_annot_appearance(doc, annot, &rect, dlist); after executing, got pdf file this:
%pdf-1.4 %μῦ 1 0 obj << /type /font /basefont /helvetica /subtype /type1 /encoding /winansiencoding >> endobj 2 0 obj << /length 63 >> stream q bt 36 806 td 0 -18 td /f1 12 tf (hello world!)tj 0 0 td et q endstream endobj 3 0 obj << /count 1 /type /pages /itxt (5.3.0) /kids [ 4 0 r ] >> endobj 4 0 obj << /annots 10 0 r /contents 2 0 r /mediabox [ 0 0 595 842 ] /parent 3 0 r /resources << /font << /f1 1 0 r >> /procset [ /pdf /text /imageb /imagec /imagei ] >> /type /page >> endobj 5 0 obj << /acroform 8 0 r /metadata 9 0 r /pages 3 0 r /type /catalog >> endobj 6 0 obj << /creationdate (d:20120620091727+02'00') /moddate (d:20120804153425+02'00') /producer (itext\256 5.3.0 \2512000-2012 1t3xt bvba) >> endobj 7 0 obj << /ap << /n 17 0 r >> /da (/helv 0 tf 0 g) /f 4 /ft /sig /mk << >> /p 4 0 r /rect [ 41.3670998 713.710022 237.352997 781.257996 ] /subtype /widget /t (signature1) /type /annot /v 15 0 r >> endobj 8 0 obj << /da (/helv 0 tf 0 g ) /dr << /encoding << /pdfdocencoding 14 0 r >> /font << /helv 12 0 r /zadb 13 0 r >> /xobject << /dsz 11 0 r >> >> /fields [ 7 0 r ] /sigflags 1 >> endobj 9 0 obj << /length 3304 /subtype /xml /type /metadata >> stream <?xpacket begin="" id="w5m0mpcehihzreszntczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="adobe xmp core 4.2.1-c043 52.372728, 2009/01/18-15:08:04 "> <rdf:rdf xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/"> <xmp:createdate>2012-06-20t09:17:27+02:00</xmp:createdate> <xmp:modifydate>2012-08-04t15:34:25+02:00</xmp:modifydate> <xmp:metadatadate>2012-08-04t15:34:25+02:00</xmp:metadatadate> </rdf:description> <rdf:description rdf:about="" xmlns:pdf="http://ns.adobe.com/pdf/1.3/"> <pdf:producer>itext® 5.3.0 ©2000-2012 1t3xt bvba</pdf:producer> </rdf:description> <rdf:description rdf:about="" xmlns:dc="http://purl.org/dc/elements/1.1/"> <dc:format>application/pdf</dc:format> </rdf:description> <rdf:description rdf:about="" xmlns:xmpmm="http://ns.adobe.com/xap/1.0/mm/"> <xmpmm:documentid>uuid:547fb234-f327-4f3d-8dd1-7b7ea87df336</xmpmm:documentid> <xmpmm:instanceid>uuid:72437fbf-7b45-4062-98f1-2b53d3ad86d0</xmpmm:instanceid> </rdf:description> </rdf:rdf> </x:xmpmeta> <?xpacket end="w"?>endstream endobj 10 0 obj [ 7 0 r ] endobj 11 0 obj << /bbox [ 41.3670998 713.710022 237.352997 781.257996 ] /length 67 /resources << /xobject << /img0 16 0 r >> >> /subtype /form /type /xobject /matrix [ 1 0 0 1 0 0 ] >> stream 1.000000 0.000000 0.000000 -1.000000 0.000000 1.000000 cm /img0 endstream endobj 12 0 obj << /basefont /helvetica /encoding 14 0 r /name /helv /subtype /type1 /type /font >> endobj 13 0 obj << /basefont /zapfdingbats /name /zadb /subtype /type1 /type /font >> endobj 14 0 obj << /differences [ 24 /breve /caron /circumflex /dotaccent /hungarumlaut /ogonek /ring /tilde 39 /quotesingle 96 /grave 128 /bullet /dagger /daggerdbl /ellipsis /emdash /endash /florin /fraction /guilsinglleft /guilsinglright /minus /perthousand /quotedblbase /quotedblleft /quotedblright /quoteleft /quoteright /quotesinglbase /trademark /fi /fl /lslash /oe /scaron /ydieresis /zcaron /dotlessi /lslash /oe /scaron /zcaron 160 /euro 164 /currency 166 /brokenbar 168 /dieresis /copyright /ordfeminine 172 /logicalnot /.notdef /registered /macron /degree /plusminus /twosuperior /threesuperior /acute /mu 183 /periodcentered /cedilla /onesuperior /ordmasculine 188 /onequarter /onehalf /threequarters 192 /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /multiply /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring /ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave /iacute /icircumflex /idieresis /eth /ntilde /ograve /oacute /ocircumflex /otilde /odieresis /divide /oslash /ugrave /uacute /ucircumflex /udieresis /yacute /thorn /ydieresis ] /type /encoding >> endobj 15 0 obj << /byterange[0 6712 10814 12756] /contents ... /filter /adobe.ppklite /subfilter /adbe.pkcs7.detached >> endobj 16 0 obj << /type /xobject /subtype /image /width 400 /height 332 /colorspace /devicergb /bitspercomponent 8 /length 11097 >> stream ... endstream endobj 17 0 obj << /bbox [ 41.3670998 713.710022 237.352997 781.257996 ] /formtype 1 /length 7 /matrix [ 1 0 0 1 0 0 ] /resources << /procset [ /pdf /text ] /xobject << /frm 18 0 r >> >> /subtype /form /type /xobject >> stream /frm doendstream endobj 18 0 obj << /bbox [ 41.3670998 713.710022 237.352997 781.257996 ] /formtype 1 /length 51 /matrix [ 1 0 0 1 0 0 ] /resources << /procset [ /pdf /text ] /xobject << /n0 19 0 r /n2 11 0 r >> >> /subtype /form /type /xobject >> stream q 1 0 0 1 0 0 cm /n0 q q 1 0 0 1 0 0 cm /n2 qendstream endobj 19 0 obj << /bbox [ 41.3670998 713.710022 237.352997 781.257996 ] /formtype 1 /length 9 /matrix [ 1 0 0 1 0 0 ] /resources << /procset [ /pdf /text ] >> /subtype /form /type /xobject >> stream % dsblankendstream endobj xref 0 20 0000000000 65536 f 0000000017 00000 n 0000000123 00000 n 0000000238 00000 n 0000000320 00000 n 0000000544 00000 n 0000000634 00000 n 0000000790 00000 n 0000001026 00000 n 0000001272 00000 n 0000004664 00000 n 0000004691 00000 n 0000004990 00000 n 0000005101 00000 n 0000005196 00000 n 0000006628 00000 n 0000010882 00000 n 0000022144 00000 n 0000022423 00000 n 0000022763 00000 n trailer << /size 20 /info 6 0 r /root 5 0 r /id [ <d0151a7adf2410cf3e72a04b9cb83452> <fa2030fcc5a66742887f23e51dec5875> ] >> startxref 23003 %%eof it seems correct, since there's /n2 11 0 r in 18 0 obj , /img0 16 0 r in 11 0 obj , 16 0 obj looks well-formed image xobject.
image doesn't show when using pdf reader open pdf.
please give me clue what's wrong pdf file, , how insert image correctly.
lot.
ps.
signed_with_image_only.pdf
signed_with_text_and_image.pdf
signed_with_image_only.pdf pdf i've added '\n' before 'endstream'. can see image doesn't show in form below 'hello world!'.
signed_with_text_and_image.pdf pretty same signed_with_image_only.pdf, put text in layer n2 show text insertion ok. same image inserted, , not showed up.
the transformation matrix not right.
you can use other pdf utility, pdfbox, add image digital signature appearance, analyze transformation matrix on image painting, pay attention on bbox.
Comments
Post a Comment