Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Deleting indirect objects
  FAQ FAQ  Forum Search   Register Register  Login Login

Deleting indirect objects

 Post Reply Post Reply
Author
Message
cycle View Drop Down
Beginner
Beginner


Joined: 31 Jan 06
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote cycle Quote  Post ReplyReply Direct Link To This Post Topic: Deleting indirect objects
    Posted: 04 Feb 06 at 6:55AM
Here is an observation I made while using this library.

Suppose you are editing a pdf file and you want to delete an indirect object that is referenced from a dictionary.
The relevant portions of the file can look like this

1000 0 obj << /StreamKey 2000 0 R /OtherKey whatever>>
endobj

...

2000 0 obj << /Length 34141 >> stream
... stream contents ...
endstream
endobj


How do you delete this stream?

Maybe

doc:TPDFDocument;
dict:TPDFDictionary;
obj:TPDFObject;
ref:TPdfIndRef;

obj:=dict.FindValueByKeyName('StreamKey', true);
obj.Purge;


No, it produces an error during saving. Similarly, the following code will not work either.

obj:=dict.FindValueByKeyName('StreamKey', false);
if obj is TPDFIndRef then begin
ref:=TPDFIndRef(obj);
ref.Obj.Purge;
ref.Purge
end;


Looking closer, one can find procedure TPDFDocument.DeleteObj(ObjNum, GenNum) that does exactly what needed. But alas, it is not public.

Fortunately, there is a way around that does not require modifying the library source. The address of this procedure is assigned to a published property of PageTree field. The final code is

ref:=TPDFIndRef(obj);
doc.PageTree.OnDeleteObj(ref.ObjNum, ref.GenNum);
and
dict.PurgeKey('StreamKey');


It works, but it is not exactly trivial.
Back to Top
swb1 View Drop Down
Debenu Quick PDF Library Expert
Debenu Quick PDF Library Expert
Avatar

Joined: 05 Dec 05
Location: United States
Status: Offline
Points: 100
Post Options Post Options   Thanks (0) Thanks(0)   Quote swb1 Quote  Post ReplyReply Direct Link To This Post Posted: 04 Feb 06 at 5:31PM
This looks like it will work well for Delphi programmers but what about ActiveX and DLL users?

Edited by swb1
Back to Top
cycle View Drop Down
Beginner
Beginner


Joined: 31 Jan 06
Status: Offline
Points: 2
Post Options Post Options   Thanks (0) Thanks(0)   Quote cycle Quote  Post ReplyReply Direct Link To This Post Posted: 05 Feb 06 at 2:24AM
It probably won't work for them. It looks like COM and DLL wrappers only expose the top level interface, TiSedQuickPdf class, not the underlying classes, and pdf objects (Cos layer in Adobe terms) are pretty low level.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store