Delete object problem

If you are a Delphi developer and have any questions about using our products from Delphi here is the place to post them.
Post Reply
systweakamol
Posts: 16
Joined: Fri Sep 09 2005
Contact:

Delete object problem

Post by systweakamol »

I have two pages in a pdf document and created three text objects on each page named FirstText.

Now i want to delete the objects created. I am using delphi 7 and wrote this code. I looped through the controls on the page and tried to delete the object.

THIS IS MY CODE:

var
i : Integer;
Tab : OleVariant;
Objet : OleVariant;
Begin
PDFCreator.ReportState:=acReportStateDesign;
Tab:=PDFCreator.ObjectAttribute['Pages[1]','Objects'];
for i := VarArrayLowBound(Tab,1) to VarArrayHighBound(Tab,1) do
begin

Objet:=Tab;
showmessage(Objet.Attribute['Name']);
if Objet.Attribute['Name'])='FirstText' then PDFCreator.DeleteObject('FirstText',0);
end;

//For second page
PDFCreator.ReportState:=acReportStateDesign;
Tab:=PDFCreator.ObjectAttribute['Pages[2]','Objects'];
for i := VarArrayLowBound(Tab,1) to VarArrayHighBound(Tab,1) do
begin

Objet:=Tab;

showmessage(Objet.Attribute['Name']);
if Objet.Attribute['Name'])='FirstText' then
PDFCreator.DeleteObject('FirstText',0);
end;


It delete the text object of the last page first but gives error when the line PDFCreator.DeleteObject('FirstText',0); on the second line of code..

---------------------------
Debugger Exception Notification
---------------------------
Project PDFEditor.exe raised exception class EOleException with message 'The parameter is incorrect'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------



Please help
Joan
Amyuni Team
Posts: 2799
Joined: Wed Sep 11 2002
Contact:

Post by Joan »

Hello,

Which version of the PDF Creator are you using?

You can not create different objects and give them the same name, each object in the PDF Document should have a unique name.

You can delete all text object by example by checking
Object.Attribute("Type") = 5 (Text Object).

If you want to delete objects having specific names you may be able to increment the names of the object by example Text1, Text2, Text3, ...
and check for: Object.Attribute("Name") = Text1 Or Text2 (I am not sure you can use OR in Delphi, you may replace it by the right syntax).

Hope this helps.
Post Reply