AppendPage and add Shape

<< Click to Display Table of Contents >>

Navigation:  Tasks > Draw Shapes / Text objects on PDF >

AppendPage and add Shape

The command COMPDF_AppendPage can be used to append a page.

 

Example:

 

var

  Param: Cardinal;

  StrParam: String;

begin

  // size of page expressed as - hi(8.5*72) + 11*72 

  Param := (612 shl 16)+792; 

  StrParam := '1 0 0 rg 0 G 0 0 612 792 re f'; // RED PAGE

  WPViewPDF1.CommandStrEx(COMPDF_AppendPage, StrParam, Param);

  StrParam := '0 0 1 rg 0 G 0 0 612 792 re f'; // BLUE PAGE

  WPViewPDF1.CommandStrEx(COMPDF_AppendPage, StrParam, Param);

end;

 

It is also possible to append a page and draw a shape. Make sure to use some PS code to draw to the page at the start.

 

var

  Param: Cardinal;

  t: TPDFDrawObjectRec;

begin

  Param := (612 shl 16)+792; 

  WPViewPDF1.CommandStrEx(COMPDF_AppendPage,

        '1 0 0 1 0 0 cm 1 1 1 rg 0 G 0 0 0 0 re f', Param); 

 

  FillChar(t, SizeOf(t), 0);

  t.ColorBrush := clRed;

  t.Alpha := 0; // transparent

  t.grtyp := 1; // Rectangle

  t.PageNo := 1;

  t.x := 20; t.y := 20; t.w := 200; t.h := 50;

  t.structsize := SizeOf(t);

 

  WPViewPDF1.CommandStrEx(COMPDF_AddHighlightRect, 

                  'REDRECT', Cardinal(@t));

End;