julianhille / MuhammaraJS

Muhammara a node module with c/cpp bindings to modify PDF with js for node or electron (based/replacement on/of galkhana/hummusjs)
Other
228 stars 46 forks source link

startModifiedIndirectObject always create new object #360

Open ohroy opened 10 months ago

ohroy commented 10 months ago

I try to modify sth in pdf (hidden the secret message in pdf), follow the doc

 const ctx = writer.getObjectsContext();
ctx.startModifiedIndirectObject(i)
// do sth
ctx.endIndirectObject()

It works perfect, but the only things is that startModifiedIndirectObject will always create new object instead replace old one in the real pdf file It will append some new info after the end of pdf file

%%EOF
12 0 obj
endobj
14 0 obj
endobj
16 0 obj
endobj
29 0 obj
endobj
31 0 obj
<<
    /ModDate (D:20231130025534+05'00')
>>
endobj

And if I exec 10 times, it will append 10 times these sections..... so file will big and big. And the secret message I want to changed is still in the real pdf

How can I optimize the real pdf file ?