logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

New Topic Post Reply
Options
Go to last post Go to first unread
Sugarloafer  
#1 Posted : Friday, July 25, 2025 1:04:54 PM(UTC)
Quote
Sugarloafer

Rank: Newbie

Groups: Registered
Joined: 7/19/2025(UTC)
Posts: 6
United States
Location: New Mexico

Thanks: 1 times
I need to know some information on PageObjects and OCG's for each page.

1) Which, if any, OCG controls the page object?
2) Which OCG's do not contain any PageObjects.

I can scan through the page objects, but where do I go from there. Or is this the wrong approach?

Sugarloafer  
#2 Posted : Friday, July 25, 2025 7:32:04 PM(UTC)
Quote
Sugarloafer

Rank: Newbie

Groups: Registered
Joined: 7/19/2025(UTC)
Posts: 6
United States
Location: New Mexico

Thanks: 1 times
I've gotten a little further.

PageOject.MarkedContent is a PdfMarkedContentCollection.
That colection has 1 entry. The entry is a PdfMarkedContent.
The parameters property of that is a dictionary.
The dictionary has two entries.
One key is "Name" and contains the name of the OCG.
Does anyone know what the other key is? (I have run out of guesses.)


Sugarloafer  
#3 Posted : Monday, August 4, 2025 2:43:21 PM(UTC)
Quote
Sugarloafer

Rank: Newbie

Groups: Registered
Joined: 7/19/2025(UTC)
Posts: 6
United States
Location: New Mexico

Thanks: 1 times
I got it to work. Then I tried a drawing with 80,000 page objects. The processing time was measured in 10's of minutes.

Some clarification. I'm using CrossTalk to access the NET assembly from Delphi.

I narrowed it down to getting a page object from the collection.

Putting some timers in, I found that this step took about 2 sec for the first 1000 iterations. The time kept increasing for successive 1000's.

I tried iterating both ways, from 0 to count-1 and from count-1 downto 0. Same thing. The time kept increasing.

I think I will explore another approach.

Here is my code.

procedure TfrmOCGList.LoadUseage;
var
vPageObjects: PdfPageObjectsCollection;
vPageObject: PdfPageObject;
iPageObj: integer;
vMC: PdfMarkedContentCollection;
vOCGName: string;
vGroup: PdfOCGroup;
vDict: PdfTypeDictionary;
vType: PageObjectTypes;
vOC: PdfMarkedContent;
vDictType: IndirectObjectTypes;
vItem: PdfTypeBase;
vName, vLastName, vMarkName:string;
vCount, vMarkCount: integer;
vMCID: integer;
vMarkLen, vMarkIdx: integer;
vbuffer: TBytes;
vMarkType: IndirectObjectType;

procedure addToSnap(AObj: PdfPageObject);
begin
with FDocArray[FDocIdx].SnapArray do
begin
setlength(SnapArray, length(SnapArray) + 1);
SnapArray[length(SnapArray) - 1] := AObj;
end;
end;

begin
if not FDocArray[FDocIdx].IsVector then
exit;
with FDocArray[FDocIdx].SnapArray do
begin
setlength(SnapArray, 0);
IsValid := False;
end;
vPageObjects := FPage.PageObjects;
vCount := vPageObjects.Count;
for iPageObj := vCount - 1 Downto 0 do
begin
vPageObject := vPageObjects.Item[iPageObj];
if assigned(vMC) then
FreeAndNil(vMC);
vMC := vPageObject.MarkedContent;
if assigned(vMC) then
begin
if vMC.Count > 0 then
begin
vOC := vMC.Item[0];
if assigned(vOC) then
begin
vDict := PdfTypeDictionary(vOC.Parameters);
if vDict.ObjectType = IndirectObjectTypes.Reference then
begin
vGroup := PDFOCGroup(PdfTypeIndirect(vDict).Direct);
vOCGName := vGroup.Name;
end
else if vDict.ObjectType = IndirectObjectTypes.Dictionary then
begin
if vDict.ContainsKey('Name') then
begin
vName := PdfTypeString(vDict.Item['Name']).ANSIStringNet;
if vName <> vLastName then
with FDocArray[FDocIdx].OCGUseage do
begin
SetEntry(FPageIdx, vName, True, True);
vLastName := vName;
end;
end;
end;
end;
end;
end;
if vPageObject.ObjectType = PageObjectTypes.PDFPage_PATH then
if PDFium.FPDFOCG_CheckObjectVisible(FDocArray[FDocIdx].Document.Handle,
OCGEvent.View, vPageObject.Handle) then
addToSnap(vPageObject);
end;
with FDocArray[FDocIdx].SnapArray do
IsValid := True;
end;

Quick Reply Show Quick Reply
Users browsing this topic
New Topic Post Reply
Forum Jump  
You can post new topics in this forum.
You can reply to topics in this forum.
You can delete your posts in this forum.
You can edit your posts in this forum.
You cannot create polls in this forum.
You can vote in polls in this forum.