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!
![]() |
Deleting indirect objects |
Post Reply ![]() |
Author | |
cycle ![]() Beginner ![]() Joined: 31 Jan 06 Status: Offline Points: 2 |
![]() ![]() ![]() ![]() ![]() 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. |
|
![]() |
|
swb1 ![]() Debenu Quick PDF Library Expert ![]() Joined: 05 Dec 05 Location: United States Status: Offline Points: 102 |
![]() ![]() ![]() ![]() ![]() |
This looks like it will work well for Delphi programmers but what about ActiveX and DLL users?
Edited by swb1 |
|
![]() |
|
cycle ![]() Beginner ![]() Joined: 31 Jan 06 Status: Offline Points: 2 |
![]() ![]() ![]() ![]() ![]() |
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.
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store