PDF Creator Pilot documentation |
Download CHM version of this manual. |
|
![]() ![]() Collapse AllPulls the graphical state from the stack.
|
| HRESULT PDFPAGE_GStateRestore () |
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 PDFPAGE_GStateSave method allow you to use the memory stack for saving the graphical state.
Analogue in new interface: IPDFDocument4::RestoreGraphicsState.
Example
Graphical state save and restore example
Delphi
[copy to clipboard]
{ 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 previuose state, without clipping }
PDF.PDFPAGE_GStateRestore;
PDF.PDFPAGE_TextOut(10, 11, -45.0, 'Another text. Another text.');
PDF.EndDoc;
C/C++
[copy to clipboard]
// 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 previuose state, without clipping
PDF->PDFPAGE_GStateRestore();
PDF->PDFPAGE_TextOut(10, 11, -45.0, "Another text. Another text.");
PDF->EndDoc();
C#
[copy to clipboard]
// 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 previuose state, without clipping
PDF.PDFPAGE_GStateRestore();
PDF.PDFPAGE_TextOut(10, 11, -45.0, "Another text. Another text.");
PDF.EndDoc();
Visual Basic
[copy to clipboard]
' 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 previuose state, without clipping
PDF.PDFPAGE_GStateRestore
PDF.PDFPAGE_TextOut 10, 11, -45.0, "Another text. Another text."
PDF.EndDoc
See Also
Reference


