Graphical State Save and Restore Example
Delphi
[copy to clipboard]
{ PDF object is supposed to be created }
PDF.SaveGraphicsState;
{ create clip region as circle }
PDF.DrawCircle(60, 95, 50);
PDF.Clip;
{ now region is clipped, draw a text }
for i := 1 to 16 do
PDF.ShowTextAt(10, 10*i, 'text text text text text text text');
{ now restore previous state, without clipping }
PDF.RestoreGraphicsState;
PDF.ShowTextAt(10, 11, 'Another text. Another text.');
PDF.SaveToFile('test.pdf', true);
C/C++
[copy to clipboard]
// PDF object is supposed to be created
PDF->SaveGraphicsState();
// create clip region as circle
PDF->DrawCircle(60, 95, 50);
PDF->Clip();
// now region is clipped, draw a text
for(int i = 1; i < 16; i++)
PDF->ShowTextAt(10, 10*i, "text text text text text text text");
// now restore previous state, without clipping
PDF->RestoreGraphicsState();
PDF->ShowTextAt(10, 11, "Another text. Another text.");
PDF->SaveToFile("test.pdf", true);
// PDF object is supposed to be created
PDF.SaveGraphicsState();
// create clip region as circle
PDF.DrawCircle(60, 95, 50);
PDF.Clip();
// now region is clipped, draw a text
for(int i = 1; i < 16; i++)
PDF.ShowTextAt(10, 10*i, "text text text text text text text");
// now restore previous state, without clipping
PDF.RestoreGraphicsState();
PDF.ShowTextAt(10, 11, "Another text. Another text.");
PDF.SaveToFile("test.pdf", true);
Visual Basic
[copy to clipboard]
' PDF object is supposed to be created
PDF.SaveGraphicsState
' create clip region as circle
PDF.DrawCircle 60, 95, 50
PDF.Clip
' now region is clipped, draw a text
For i = 1 To 16
PDF.ShowTextAt 10, 10*i, "text text text text text text text"
Next
' now restore previous state, without clipping
PDF.RestoreGraphicsState
PDF.ShowTextAt 10, 11, "Another text. Another text."
PDF.SaveToFile "test.pdf", true