In this example we show how to use the String property to implement a graphics state stack with Push and Pop operators.
[C#]
Doc doc = new Doc();
doc.FontSize = 64;
doc.Rect.Inset(20, 20);
doc.Font = doc.AddFont("Helvetica");
Stack<string> state = new Stack<string>();
state.Push(doc.String);
doc.AddText("Black Helvetica\r\n\r\n");
doc.Color.SetRgb(255, 0, 0);
doc.Font = doc.AddFont("Helvetica-Oblique");
doc.AddText("Red Helvetica-Oblique\r\n\r\n");
doc.String = state.Pop();
doc.AddText("Black Helvetica again\r\n\r\n");
doc.Save("savestate.pdf");
[Visual Basic]
Dim doc As New Doc()
doc.FontSize = 64
doc.Rect.Inset(20, 20)
doc.Font = doc.AddFont("Helvetica")
Dim state As New Stack(Of String)()
state.Push(doc.[String])
doc.AddText("Black Helvetica" & vbCr & vbLf & vbCr & vbLf)
doc.Color.SetRgb(255, 0, 0)
doc.Font = doc.AddFont("Helvetica-Oblique")
doc.AddText("Red Helvetica-Oblique" & vbCr & vbLf & vbCr & vbLf)
doc.[String] = state.Pop()
doc.AddText("Black Helvetica again" & vbCr & vbLf & vbCr & vbLf)
doc.Save("savestate.pdf")
savestate.pdf
|
|
|