本文整理汇总了C#中Doc.FillRect方法的典型用法代码示例。如果您正苦于以下问题:C# Doc.FillRect方法的具体用法?C# Doc.FillRect怎么用?C# Doc.FillRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doc
的用法示例。
在下文中一共展示了Doc.FillRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePdf
public byte[] CreatePdf(PDFService.Settings settings)
{
if (settings == null) throw new ArgumentNullException("settings");
if (!settings.Uris.Any()) throw new ArgumentException("No URIs provided to create PDF from");
using (Doc pdf = new Doc())
{
pdf.HtmlOptions.Engine = EngineType.Gecko;
pdf.HtmlOptions.Timeout = (int)settings.Timeout.TotalMilliseconds;
pdf.HtmlOptions.RetryCount = settings.RetryCount;
pdf.HtmlOptions.PageCacheClear();
pdf.HtmlOptions.PageCacheEnabled = false;
pdf.HtmlOptions.AddForms = settings.UseForms;
pdf.HtmlOptions.AddLinks = settings.UseLinks;
pdf.HtmlOptions.UseScript = settings.UseScript;
pdf.Color.Red = 255;
pdf.Color.Green = 255;
pdf.Color.Blue = 255;
pdf.Rect.Inset(10, 10);
pdf.FillRect();
// If selected, make the PDF in landscape format
if (settings.UseLandscapeOrientation)
{
pdf.Transform.Rotate(90, pdf.MediaBox.Left, pdf.MediaBox.Bottom);
pdf.Transform.Translate(pdf.MediaBox.Width, 0);
pdf.Rect.Width = pdf.MediaBox.Height;
pdf.Rect.Height = pdf.MediaBox.Width;
}
int imageId = 0;
// For each URI provided, add the result to the output doc
foreach (String uri in settings.Uris)
{
if (imageId != 0)
{
pdf.Page = pdf.AddPage();
}
// Render the web page by uri and return the image id for chaining
imageId = pdf.AddImageUrl(uri, paged: true, width: 0, disableCache: false);
while (true)
{
// Stop when we reach a page which wasn't truncated, per the examples
if (!pdf.Chainable(imageId)) break;
// Add a page to the pdf and sets the page id
pdf.Page = pdf.AddPage();
// Add the previous image to the chain and set the image id
imageId = pdf.AddImageToChain(imageId);
}
}
// flatten the pages
for (var ii = 1; ii <= pdf.PageCount; ii++)
{
pdf.PageNumber = ii;
pdf.Flatten();
}
// Return the byte array representing the pdf
return pdf.GetData();
}
}