|
|
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;
|
|
|
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.)
|
|
|
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?
|
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close