0% found this document useful (0 votes)
13 views1 page

Rectangle C++ Program

This method creates a PDF document with a page containing a transformed rectangle and text. It draws a filled and outlined rectangle on the page using transformations including translation, scaling, and rotation. Text is then drawn inside the rectangle explaining the transformations applied. The completed PDF document is saved to the provided stream.

Uploaded by

Kishan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Rectangle C++ Program

This method creates a PDF document with a page containing a transformed rectangle and text. It draws a filled and outlined rectangle on the page using transformations including translation, scaling, and rotation. Text is then drawn inside the rectangle explaining the transformations applied. The completed PDF document is saved to the provided stream.

Uploaded by

Kishan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

public void CreatePDF(Stream stream)

{
// Create a PDF document
var doc = new GcPdfDocument();
var page = doc.NewPage();
var g = page.Graphics;

// Translation Values
var translate0 = Matrix3x2.CreateTranslation(72 * 3, 72 * 5);
var scale0 = Matrix3x2.CreateScale(0.7F);
var rotate0 = Matrix3x2.CreateRotation((float)(-70 * Math.PI) / 180F);

//Draw Rectangle and Apply Transformations


var box = new RectangleF(0, 0, 72 * 4, 72 * 2);
g.Transform = rotate0 * translate0 * scale0;
g.FillRectangle(box, Color.FromArgb(100, Color.DarkSeaGreen));
g.DrawRectangle(box, Color.DarkOrange, 1);
g.DrawString("Sample Box: Text drawn at (0,0) in a 4\"x2\" box"+
", scaled by 0.7, translated by (3\",5\"), " +
"and rotated 70 degrees counterclockwise.",
new TextFormat() { Font = StandardFonts.Times, FontSize = 14, }, box);
// Save document
doc.Save(stream);
}

You might also like