Components for Developers
© 2000-2008, Two Pilots

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF Add-on History In the Lab

PDF Creator Pilot documentation

Download CHM version of this manual.
Common
Collapse All

This method pushes the graphical state onto the stack.

Syntax

HRESULT SaveGraphicsState ()
Return value
If successful, this method returns S_OK. If it fails, this method should return one of the error values.

Remarks

A well-structured PDF document usually contains many graphical elements that are independent of each other and sometimes nested to multiple levels. The graphics state stack allows these elements to make local changes to the graphics state without disturbing the graphics state of the surrounding environment. The RestoreGraphicsState method allows you to use the memory stack for restoring the graphical state.

Example

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);
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);
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

See Also

PDF Library Download Features Manual Tutorials FAQ Pricing HTML2PDF Add-on History In the Lab

 

 

PDF Library | Virtual Printer | Converters to PDF

Support | Blog | Forum | Contacts

© 2000-2008, Two Pilots