hi all
At First special thanks to “lrosenth” and “Test Screen Name” for the good answers in the previous threads
Now I have another question
In PDF32000_2008 explained pdf syntax considered as a four part
- 1) Objects
- 2) File structure - - -> use this for encryption
- 3) Document structure
- 4) Content stream
Also mention that: “we have 8 object types “
1) Boolean
2) Numeric
3) String
4) Name
5) Array
6) Stream
7) Null
8) Indirect
This object have a structure like this:
5 0 obj
<< /Type /XObject
/Subtype /Image
/Width 52
/Height 66
/ColorSpace /DeviceGray
/BitsPerComponent 1
/Length 224
/Filter [/ASCIIHexDecode /JBIG2Decode]
/DecodeParms [null << /JBIG2Globals 6 0 R >>]
>>
stream
000000013000010000001300000034000000420000000000
00000040000000000002062000010000001e000000340000
004200000000000000000200100000000231db51ce51ffac>
endstream
endobj
6 0 obj
<< /Length 126
/Filter /ASCIIHexDecode
>>
stream
0000000000010000000032000003fffdff02fefefe000000
01000000012ae225aea9a5a538b4d9999c5c8e56ef0f872
7f2b53d4e37ef795cc5506dffac>
endstream
endobj
In encryption section mention that we can encrypt string, streams, … .
As I think and understand for encryption I must extract encrypt able objects, for this goal I do this steps
ASFileSys fileSys = ASGetDefaultFileSysForPath(pathType, myPath);
ASPathName pathName = ASFileSysCreatePathName(fileSys, pathType, myPath, NULL);
AVDoc myAVDoc=AVDocOpenFromFile(pathName, fileSys, titleText);
PDDoc myPDDoc2 =AVDocGetPDDoc(myAVDoc);
CosDoc cdoc;
cdoc = PDDocGetCosDoc(myPDDoc2);
CosObj cosOBJ=CosDocGetRoot(cdoc);
CosType t = CosObjGetType(cosOBJ);
// traverse pdf file structure tree
CosObj obj2= CosDictGet(cosOBJ,ASAtomFromString("Pages"));
CosType ttt = CosObjGetType(obj2);
CosObj obj3= CosDictGet(obj2,ASAtomFromString("Kids"));
CosType tttt = CosObjGetType(obj3);
CosObj kid1 = CosArrayGet(obj3,0);
CosType tttrtt = CosObjGetType(kid1);
CosObj cosst = CosDictGet(kid1,ASAtomFromString("Contents"));
CosType ttrrrttt = CosObjGetType(cosst);
ASArraySize s = CosStreamLength(cosst);
ASStm stm= CosStreamOpenStm(cosst,2);
char buf[10000];
int aaaaagyg=ASStmRead(buf,1,10000,stm);
ASStmFlush(stm);
ASStmClose(stm);
Now in buf I have content like this
/CS0 cs 1 scn
10 36 591.75 729.75 re
f
BT
0 scn
/TT0 1 Tf
12 0 0 12 16 749.25 Tm
(a b c)Tj
0 -1.125 TD
(d e)Tj
T*
(f)Tj
ET
I thinked with ASStmWrite can write in this and change pdf content but this is not possible ,
Then this is my questions
Are this steps are correct or not ?
If yes how I can extract encrypt able object and after edit save them as pdf file.
else I think I must use Crypt Filter.
how I can get dictionary and change parameters for example set V value to 4
how I can retrieve pdf object (like example I mention before (5 0 obj ….) )
if need to make Crypt Filter how do this ?
for make Crypt Filter need to edit encryption dictionary, how edit encryption dictionary?
I really thankful for your guidance and time you spend for answer my questions
Regard F.Afshari