本文整理匯總了C#中System.Windows.Forms.Document.RenderToSize方法的典型用法代碼示例。如果您正苦於以下問題:C# Document.RenderToSize方法的具體用法?C# Document.RenderToSize怎麽用?C# Document.RenderToSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Windows.Forms.Document
的用法示例。
在下文中一共展示了Document.RenderToSize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: RenderToSize
public void RenderToSize()
{
//ExStart
//ExFor:Document.RenderToSize
//ExSummary:Render to a bitmap at a specified location and size.
Document doc = new Document(MyDir + "Rendering.doc");
using (Bitmap bmp = new Bitmap(700, 700))
{
// User has some sort of a Graphics object. In this case created from a bitmap.
using (Graphics gr = Graphics.FromImage(bmp))
{
// The user can specify any options on the Graphics object including
// transform, antialiasing, page units, etc.
gr.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
// Let's say we want to fit the page into a 3" x 3" square on the screen so use inches as units.
gr.PageUnit = GraphicsUnit.Inch;
// The output should be offset 0.5" from the edge and rotated.
gr.TranslateTransform(0.5f, 0.5f);
gr.RotateTransform(10);
// This is our test rectangle.
gr.DrawRectangle(new Pen(Color.Black, 3f / 72f), 0f, 0f, 3f, 3f);
// User specifies (in world coordinates) where on the Graphics to render and what size.
float returnedScale = doc.RenderToSize(0, gr, 0f, 0f, 3f, 3f);
// This is the calculated scale factor to fit 297mm into 3".
Console.WriteLine("The image was rendered at {0:P0} zoom.", returnedScale);
// One more example, this time in millimiters.
gr.PageUnit = GraphicsUnit.Millimeter;
gr.ResetTransform();
// Move the origin 10mm
gr.TranslateTransform(10, 10);
// Apply both scale transform and page scale for fun.
gr.ScaleTransform(0.5f, 0.5f);
gr.PageScale = 2f;
// This is our test rectangle.
gr.DrawRectangle(new Pen(Color.Black, 1), 90, 10, 50, 100);
// User specifies (in world coordinates) where on the Graphics to render and what size.
doc.RenderToSize(1, gr, 90, 10, 50, 100);
bmp.Save(MyDir + "Rendering.RenderToSize Out.png");
}
}
//ExEnd
}