本文整理汇总了C#中iTextSharp.SetPageSize方法的典型用法代码示例。如果您正苦于以下问题:C# iTextSharp.SetPageSize方法的具体用法?C# iTextSharp.SetPageSize怎么用?C# iTextSharp.SetPageSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类iTextSharp
的用法示例。
在下文中一共展示了iTextSharp.SetPageSize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPageWithImage
/// <summary>
/// Add a page containing a single image. Set the page size to match the image size.
/// </summary>
/// <param name="doc"></param>
/// <param name="imagePath"></param>
private void AddPageWithImage(iTextSharp.text.Document doc, String imagePath)
{
// Read the image file
iTextSharp.text.Image image = iTextSharp.text.Image.GetInstance(new Uri(imagePath));
// Set the page size to the dimensions of the image BEFORE adding a new page to the document.
// Pad the height a bit to leave room for the page header.
float imageWidth = image.Width;
float imageHeight = image.Height;
doc.SetMargins(0, 0, 0, 0);
doc.SetPageSize(new iTextSharp.text.Rectangle(imageWidth, imageHeight + 100));
// Add a new page
doc.NewPage();
// The header at the top of the page is an anchor linked to by the table of contents.
iTextSharp.text.Anchor contentsAnchor = new iTextSharp.text.Anchor("\nGRAPH\n\n", _largeFont);
contentsAnchor.Name = "graph";
// Add the anchor and image to the page
this.AddParagraph(doc, iTextSharp.text.Element.ALIGN_CENTER, _largeFont, contentsAnchor);
doc.Add(image);
image = null;
}
示例2: SetStandardPageSize
/// <summary>
/// Set margins and page size for the document
/// </summary>
/// <param name="doc"></param>
private void SetStandardPageSize(iTextSharp.text.Document doc)
{
// Set margins and page size for the document
doc.SetMargins(50, 50, 50, 50);
// There are a huge number of possible page sizes, including such sizes as
// EXECUTIVE, POSTCARD, LEDGER, LEGAL, LETTER_LANDSCAPE, and NOTE
doc.SetPageSize(new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.LETTER.Width,
iTextSharp.text.PageSize.LETTER.Height));
}
示例3: Settings
/// <summary>
/// This method consist settings of pdf file
/// </summary>
/// <param name="ms"></param>
/// <param name="doc"></param>
public void Settings(MemoryStream ms, iTextSharp.text.Document doc)
{
PdfWriter.GetInstance(doc, ms);
iTextSharp.text.Rectangle rec = new iTextSharp.text.Rectangle(iTextSharp.text.PageSize.A4);
doc.SetPageSize(rec);
doc.SetMargins(0, 0, 0, 0);
doc.Open();
doc.NewPage();
}