



Collapse All
Syntax| HRESULT PDFPAGE_GStateRestore () |
RemarksA 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 PDFPAGE_GStateSave method allows you to use the memory stack for saving the graphical state.
Equivalent in new interface: IPDFDocument4::RestoreGraphicsState.
Example{ PDF object is supposed to be created }
PDF.BeginDoc;
PDF.PDFPAGE_GStateSave;
{ create clip region as circle }
PDF.PDFPAGE_Circle(80, 95, 70);
PDF.PDFPAGE_Clip;
{ now region is clipped, draw a text }
PDF.PDFPAGE_SetActiveFont('Verdana', false, false, false, false, 12.0, 0);
for i := 1 to 10 do
begin
PDF.PDFPAGE_TextOut(10, 15*i, 0.0, 'text text text text text');
end;
{ now restore previous state, without clipping }
PDF.PDFPAGE_GStateRestore;
PDF.PDFPAGE_TextOut(10, 11, -45.0, 'Another text. Another text.');
PDF.EndDoc;
// PDF object is supposed to be created
PDF->BeginDoc();
PDF->PDFPAGE_GStateSave();
// create clip region as circle
PDF->PDFPAGE_Circle(80, 95, 70);
PDF->PDFPAGE_Clip();
// now region is clipped, draw a text
PDF->PDFPAGE_SetActiveFont("Verdana", FALSE, FALSE, FALSE, FALSE, 12.0, 0);
for (int i = 0; i < 10; i++)
PDF->PDFPAGE_TextOut(10, 15*(i+1), 0.0, "text text text text text");
// now restore previous state, without clipping
PDF->PDFPAGE_GStateRestore();
PDF->PDFPAGE_TextOut(10, 11, -45.0, "Another text. Another text.");
PDF->EndDoc();
// PDF object is supposed to be created
PDF.BeginDoc();
PDF.PDFPAGE_GStateSave();
// create clip region as circle
PDF.PDFPAGE_Circle(80, 95, 70);
PDF.PDFPAGE_Clip();
// now region is clipped, draw a text
PDF.PDFPAGE_SetActiveFont("Verdana", false, false, false, false, 12.0, 0);
for (int i = 0; i < 10; i++)
PDF.PDFPAGE_TextOut(10, 15*(i+1), 0.0, "text text text text text");
// now restore previous state, without clipping
PDF.PDFPAGE_GStateRestore();
PDF.PDFPAGE_TextOut(10, 11, -45.0, "Another text. Another text.");
PDF.EndDoc();
' PDF object is supposed to be created
PDF.BeginDoc
PDF.PDFPAGE_GStateSave
' create clip region as circle
PDF.PDFPAGE_Circle 80, 95, 70
PDF.PDFPAGE_Clip
' now region is clipped, draw a text
PDF.PDFPAGE_SetActiveFont "Verdana", False, False, False, False, 12.0, 0
For i = 1 To 10
PDF.PDFPAGE_TextOut 10, 15*i, 0.0, "text text text text text"
Next
' now restore previous state, without clipping
PDF.PDFPAGE_GStateRestore
PDF.PDFPAGE_TextOut 10, 11, -45.0, "Another text. Another text."
PDF.EndDoc
See Also