ImageEn, unit iexPdfiumCore |
|
TPdfObject.ObjectType
Declaration
property ObjectType: TPdfObjectType;
Description
Returns the type of a PDF object.
Read-only
case ImageEnView1.PdfViewer.Objects[idx].ObjectType of
ptText : s := 'Text';
ptPath : s := 'Path';
ptImage : s := 'Image';
ptShading : s := 'Shading';
ptForm : s := 'Form';
else s := 'Unknown';
end;
lblType.Caption := 'Type: ' + s;
// Output details of all page objects to a memo
var
i, p, ptCount: Integer;
s: string;
r: TRect;
bmp: TIEBitmap;
objType: TPdfObjectType;
fontName: String;
fontSize, strokeWidth: Single;
fillMode: TPdfFillMode;
fontWeight, italicAngle: Integer;
isStroked: Boolean;
strokeColor, fillColor, FontColor: TRGBA;
pointArray: TIEDPointArray;
pts: string;
begin
Memo1.Lines.BeginUpdate();
Memo1.Lines.Clear();
Memo1.Lines.Add( format( 'Page %d: %d x %d', [ ImageEnView1.PdfViewer.PageIndex, Round( ImageEnView1.PdfViewer.CurrentPage.Width ), Round( ImageEnView1.PdfViewer.CurrentPage.Height )] ));
for i := 0 to ImageEnView1.PdfViewer.Objects.Count - 1 do
begin
Memo1.Lines.Add( 'OBJECT ' + i.ToString );
// Type
s := '';
objType := ImageEnView1.PdfViewer.Objects[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[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[i].Text );
ImageEnView1.PdfViewer.Objects[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[i].StrokeColor;
strokeWidth := ImageEnView1.PdfViewer.Objects[i].PathStrokeWidth;
fillColor := ImageEnView1.PdfViewer.Objects[i].FillColor;
fillMode := ImageEnView1.PdfViewer.Objects[i].FillMode;
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 ]));
Memo1.Lines.Add( Format( ' Fill Mode: %d', [ ord( fillMode )]));
ImageEnView1.PdfViewer.Objects[i].GetPath( pointArray, ptCount );
Memo1.Lines.Add( ' Point Count: ' + ptCount.ToString );
pts := '';
for p := 0 to Length( pointArray ) - 1 do
begin
if pointArray[p].x = IE_PointArray_ClosingBreak then
pts := pts + format( ',CLOSE', [ Round( pointArray[p].X ), Round( pointArray[p]. Y )])
else
if pointArray[p].Y = IE_PointArray_Break then
pts := pts + format( ',BREAK', [ Round( pointArray[p].X ), Round( pointArray[p]. Y )])
else
pts := pts + format( ',(%d,%d)', [ Round( pointArray[p].X ), Round( pointArray[p]. Y )]);
end;
if pts <> '' then
Delete(pts, 1, 1 );
Memo1.Lines.Add( ' Points: ' + pts );
end
else
// Image properties
if objType = ptImage then
begin
bmp := TIEBitmap.Create();
if ImageEnView1.PdfViewer.Objects[i].GetImage( bmp ) then
begin
Memo1.Lines.Add( format( ' Image Size: %d x %d', [ bmp.Width, bmp.height ]));
// Save? bmp.SaveToFile( 'D:\_PDF\Image_'+i.ToString+ '.png');
// Show in MView? ImageEnMView1.AppendImage( bmp );
end;
bmp.Free();
end;
end;
Memo1.Lines.EndUpdate();
end;