ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Iterate all the objects of a PDF page (PDFium)

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
xequte Posted - Oct 27 2023 : 02:11:21

// Output details of all objects of the current PDF page to a memo
var
  i: Integer;
  s: string;
  r: TRect;
  objType: TPdfObjectType;
  bmp: TIEBitmap;
  fontName: String;
  fontSize, strokeWidth: Single;
  fontWeight, italicAngle: Integer;
  strokeColor, fillColor, FontColor: TRGBA;
  pointArray: TIEDPointArray;
begin
  Memo1.Lines.Clear();
  for i := 0 to ImageEnView1.PdfViewer.Objects.Count - 1 do
  begin
    Memo1.Lines.Add( 'OBJECT ' + i.ToString );

    // Type
    s := '';
    objType := ImageEnView1.PdfViewer.Objects.Items[i].ObjectType;
    case objType of
      ptUnknown  : s := 'Unknown';
      ptText     : s := 'Text';
      ptPath     : s := 'Path';
      ptImage    : s := 'Image';
      ptShading  : s := 'Shading';
      ptForm     : s := 'Form';
    end;
    Memo1.Lines.Add( '  Type: ' + s );

    // Bounds
    r := ImageEnView1.PdfViewer.Objects.Items[i].Bounds;
    Memo1.Lines.Add( Format( '  Bounds: %d,%d,%d,%d', [ r.Left, r.Top, r.Right, r.Bottom ]));

    // Text properties
    if objType = ptText then
    begin
      Memo1.Lines.Add( '  Text: ' + ImageEnView1.PdfViewer.Objects.Items[i].Text );

      ImageEnView1.PdfViewer.Objects.Items[i].GetTextFont( fontName, fontSize, fontColor, fontWeight, italicAngle );
      Memo1.Lines.Add( '  Font Name: ' + fontName );
      Memo1.Lines.Add( '  Font Size: ' + fontSize.ToString );
      Memo1.Lines.Add( Format( '  Font Color: %d,%d,%d/%d', [ fontColor.r, fontColor.g, fontColor.b, fontColor.a ]));
      Memo1.Lines.Add( '  Font Weight: ' + fontWeight.ToString );
      Memo1.Lines.Add( '  Italic Angle: ' + italicAngle.ToString );
    end
    else
    // Path properties
    if objType = ptPath then
    begin
      strokeColor := ImageEnView1.PdfViewer.Objects.Items[i].StrokeColor;
      strokeWidth := ImageEnView1.PdfViewer.Objects.Items[i].StrokeWidth;
      fillColor := ImageEnView1.PdfViewer.Objects.Items[i].FillColor;

      Memo1.Lines.Add( Format( '  Stroke Color: %d,%d,%d/%d', [ strokeColor.r, strokeColor.g, strokeColor.b, strokeColor.a ]));
      Memo1.Lines.Add( '  Stroke Width: ' + strokeWidth.ToString );
      Memo1.Lines.Add( Format( '  Fill Color: %d,%d,%d/%d', [ fillColor.r, fillColor.g, fillColor.b, fillColor.a ]));

      pointArray := ImageEnView1.PdfViewer.Objects.Items[i].GetPath();
      Memo1.Lines.Add( '  Point Count: ' + Length( pointArray ).ToString );
    end
    else
    // Image properties
    if objType = ptImage then
    begin
      bmp := TIEBitmap.Create();
      if ImageEnView1.PdfViewer.Objects.Items[i].GetImage( bmp ) then
        Memo1.Lines.Add( format( '  Image Size: %d x %d', [ bmp.Width, bmp.height ]));
      // ImageEnMView1.AppendImage( bmp );
      bmp.Free;
    end;
  end;
end;


Nigel
Xequte Software
www.imageen.com