//////////////////////////////////////////////////////////////////// // Draw heading //////////////////////////////////////////////////////////////////// private void DrawTwoLinesOfHeading( PdfContents Contents ) { // page heading // Arguments: Font: ArialBold, size: 36 points, Position: X = 4.25", Y = 9.5" // Text Justify: Center (text center will be at X position) // Stoking color: R=128, G=0, B=255 (text outline) // Nonstroking color: R=255, G=0, B=128 (text body) Contents.DrawText(Comic, 40.0, 4.25, 9.25, TextJustify.Center, 0.02, Color.FromArgb(128, 0, 255), Color.FromArgb(255, 0, 128), "PDF FILE WRITER"); // save graphics state Contents.SaveGraphicsState(); // change nonstroking (fill) color to purple Contents.SetColorNonStroking(Color.Purple); // Draw second line of heading text // arguments: Handwriting font, Font size 30 point, Position X=4.25", Y=9.0" // Text Justify: Center (text center will be at X position) Contents.DrawText(Comic, 30.0, 4.25, 8.75, TextJustify.Center, "Example"); // Contents.TranslateScaleRotate(4.25, 8.75, 1.5, Math.PI / 6); // Contents.DrawText(Comic, 30.0, 0, 0, TextJustify.Center, "Example"); // restore graphics sate (non stroking color will be restored to default) Contents.RestoreGraphicsState(); return; }
//////////////////////////////////////////////////////////////////// // Draw heart //////////////////////////////////////////////////////////////////// private void DrawHeart( PdfContents Contents ) { // save graphics state Contents.SaveGraphicsState(); // draw heart // The first argument are the coordinates of the centerline of the heart shape. // The DrawHeart is a special case of DrawDoubleBezierPath method. Contents.SetColorNonStroking(Color.HotPink); Contents.DrawHeart(new LineD(new PointD(5.14, 5.1), new PointD(5.14, 6.0)), PaintOp.CloseFillStroke); // restore graphics state Contents.RestoreGraphicsState(); return; }
//////////////////////////////////////////////////////////////////// // Draw six sided regular polygon //////////////////////////////////////////////////////////////////// private void DrawStar( PdfContents Contents ) { // save graphics state Contents.SaveGraphicsState(); // Regular polygon // Coordinate of center point is PosX=6.67" PosY=5.7" // Radius of end points is 0.7" // First drawing point is at 30 degrees (in radians PI / 6). // Number of sides is 6 Contents.SetColorNonStroking(Color.Turquoise); Contents.DrawStar(6.67, 5.7, 0.7, Math.PI / 6, 6, PaintOp.CloseFillStroke); // restore graphics state Contents.RestoreGraphicsState(); return; }
//////////////////////////////////////////////////////////////////// // Draw Happy Face //////////////////////////////////////////////////////////////////// private void DrawHappyFace( PdfContents Contents ) { // save graphics state Contents.SaveGraphicsState(); // translate coordinate origin to the center of the happy face Contents.Translate(4.25, 7.5); // change nonstroking (fill) color to yellow Contents.SetColorNonStroking(Color.Yellow); // draw happy face yellow oval Contents.DrawOval(-1.5, -1.0, 3.0, 2.0, PaintOp.Fill); // set line width to 0.2" this is the black circle around the eye Contents.SetLineWidth(0.2); // eye color is white with black outline circle Contents.SetColorNonStroking(Color.White); Contents.SetColorStroking(Color.Black); // draw eyes Contents.DrawOval(-0.75, 0.0, 0.5, 0.5, PaintOp.CloseFillStroke); Contents.DrawOval(0.25, 0.0, 0.5, 0.5, PaintOp.CloseFillStroke); // mouth color is black Contents.SetColorNonStroking(Color.Black); // draw mouth by creating a path made of one line and one Bezier curve Contents.MoveTo(-0.6, -0.4); Contents.LineTo(0.6, -0.4); Contents.DrawBezier(0.0, -0.8, 0, -0.8, -0.6, -0.4); // fill the path with black color Contents.SetPaintOp(PaintOp.Fill); // restore graphics sate Contents.RestoreGraphicsState(); return; }