本文整理汇总了C#中PdfDocument.Close方法的典型用法代码示例。如果您正苦于以下问题:C# PdfDocument.Close方法的具体用法?C# PdfDocument.Close怎么用?C# PdfDocument.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PdfDocument
的用法示例。
在下文中一共展示了PdfDocument.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
// Create one page
PdfPageBase page = doc.Pages.Add();
//Draw the text
page.Canvas.DrawString("Hello, World!",
new PdfFont(PdfFontFamily.Helvetica, 30f),
new PdfSolidBrush(Color.Black),
10, 10);
//Draw the image
PdfImage image = PdfImage.FromFile(@"..\..\..\..\..\..\Data\SalesReportChart.png");
float width = image.Width * 0.75f;
float height = image.Height * 0.75f;
float x = (page.Canvas.ClientSize.Width - width) / 2;
page.Canvas.DrawImage(image, x, 60, width, height);
//Save pdf file.
doc.SaveToFile("Image.pdf");
doc.Close();
//Launching the Pdf file.
PDFDocumentViewer("Image.pdf");
}
示例2: CreateRekenPyramide
public PdfDocument CreateRekenPyramide(string filename)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
// Create one page
PdfPageBase page = doc.Pages.Add();
int basislengte = 8;
int maxbasisgetal = 14;
Random rnd = new Random();
for (int pyramide = 1; pyramide <= 3; pyramide++)
{
GeneratePyramid(basislengte, rnd, maxbasisgetal);
int papierhoogte = ((int)page.Canvas.Size.Height / 3 - 40) * pyramide;
TekenHelePyramideOpPapier(page, pyrArray, basislengte, papierhoogte);
}
//Save pdf file.
doc.SaveToFile(filename);
doc.Close();
return doc;
}
示例3: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
//margin
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
PdfMargins margin = new PdfMargins();
margin.Top = unitCvtr.ConvertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Bottom = margin.Top;
margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Right = margin.Left;
// Create one page
PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, margin);
Image img = Image.FromFile(@"..\..\..\..\..\..\Data\Background.png");
page.BackgroundImage = img;
//Draw table
DrawPage(page);
//Save pdf file.
doc.SaveToFile("ImageWaterMark.pdf");
doc.Close();
//Launching the Pdf file.
PDFDocumentViewer("ImageWaterMark.pdf");
}
示例4: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//load two document
PdfDocument doc1 = new PdfDocument();
doc1.LoadFromFile(@"..\..\..\..\..\..\Data\Sample1.pdf");
PdfDocument doc2 = new PdfDocument();
doc2.LoadFromFile(@"..\..\..\..\..\..\Data\Sample3.pdf");
//Create page template
PdfTemplate template = doc1.Pages[0].CreateTemplate();
foreach (PdfPageBase page in doc2.Pages)
{
page.Canvas.SetTransparency(0.25f, 0.25f, PdfBlendMode.Overlay);
page.Canvas.DrawTemplate(template, PointF.Empty);
}
//Save pdf file.
doc2.SaveToFile("Overlay.pdf");
doc1.Close();
doc2.Close();
//Launching the Pdf file.
PDFDocumentViewer("Overlay.pdf");
}
示例5: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
// Create one page
PdfPageBase page = doc.Pages.Add();
//Draw the page
DrawPage(page);
//set view reference
doc.ViewerPreferences.CenterWindow = true;
doc.ViewerPreferences.DisplayTitle = false;
doc.ViewerPreferences.FitWindow = false;
doc.ViewerPreferences.HideMenubar = true;
doc.ViewerPreferences.HideToolbar = true;
doc.ViewerPreferences.PageLayout = PdfPageLayout.SinglePage;
//Save pdf file.
doc.SaveToFile("ViewerPreference.pdf");
doc.Close();
//Launching the Pdf file.
PDFDocumentViewer("ViewerPreference.pdf");
}
示例6: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
//margin
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
PdfMargins margin = new PdfMargins();
margin.Top = unitCvtr.ConvertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Bottom = margin.Top;
margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Right = margin.Left;
// Create one page
PdfPageBase page = doc.Pages.Add(PdfPageSize.A4, margin);
float y = 10;
//title
PdfBrush brush1 = PdfBrushes.Black;
PdfTrueTypeFont font1 = new PdfTrueTypeFont(new Font("Arial", 16f, FontStyle.Bold), true);
PdfStringFormat format1 = new PdfStringFormat(PdfTextAlignment.Center);
page.Canvas.DrawString("Categories List", font1, brush1, page.Canvas.ClientSize.Width / 2, y, format1);
y = y + font1.MeasureString("Categories List", format1).Height;
y = y + 5;
RectangleF rctg = new RectangleF(new PointF(0, 0), page.Canvas.ClientSize);
PdfLinearGradientBrush brush
= new PdfLinearGradientBrush(rctg, Color.Navy, Color.OrangeRed, PdfLinearGradientMode.Vertical);
PdfFont font = new PdfFont(PdfFontFamily.Helvetica, 12f, PdfFontStyle.Bold);
String formatted
= "Beverages\nCondiments\nConfections\nDairy Products\nGrains/Cereals\nMeat/Poultry\nProduce\nSeafood";
PdfList list = new PdfList(formatted);
list.Font = font;
list.Indent = 8;
list.TextIndent = 5;
list.Brush = brush;
PdfLayoutResult result = list.Draw(page, 0, y);
y = result.Bounds.Bottom;
PdfSortedList sortedList = new PdfSortedList(formatted);
sortedList.Font = font;
sortedList.Indent = 8;
sortedList.TextIndent = 5;
sortedList.Brush = brush;
sortedList.Draw(page, 0, y);
//Save pdf file.
doc.SaveToFile("SimpleList.pdf");
doc.Close();
//Launching the Pdf file.
PDFDocumentViewer("SimpleList.pdf");
}
示例7: SavePDF
protected bool SavePDF(PdfDocument transferDetails)
{
if (File.Exists(Path.Combine(SieradzBankFilesPathHolder.TransferFilesPath, @"..\mBank\Transfers1.pdf")))
{
File.Open(Path.Combine(SieradzBankFilesPathHolder.TransferFilesPath, @"..\mBank\Transfers1.pdf"), FileMode.Open).Close();
File.Delete(Path.Combine(SieradzBankFilesPathHolder.TransferFilesPath, @"..\mBank\Transfers1.pdf"));
}
transferDetails.SaveToFile(SieradzBankFilesPathHolder.TransferFilesPath + @"..\mBank\Transfers1.pdf",FileFormat.PDF);
transferDetails.Close();
return File.Exists(SieradzBankFilesPathHolder.TransferFilesPath + @"..\mBank\Transfers1.pdf");
}
示例8: Main
static void Main(string[] args)
{
PdfDocument document = new PdfDocument(PdfConformanceLevel.Pdf_A1B);
PdfPageBase page = document.Pages.Add();
PdfPageBase page3 = document.Pages.Add();
page3.Canvas.DrawString("Hello World2", new PdfFont(PdfFontFamily.Helvetica, 30f), new PdfSolidBrush(Color.Black), 10, 10);
//save to PDF document
document.Pages[1].Rotation = PdfPageRotateAngle.RotateAngle180;
document.Pages.RemoveAt(0);
document.SaveToFile("FromHTML.pdf", FileFormat.PDF);
document.Close();
}
示例9: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
// Create one section
PdfSection section = doc.Sections.Add();
//Load image
PdfImage image = PdfImage.FromFile(@"..\..\..\..\..\..\Data\SalesReportChart.png");
float imageWidth = image.PhysicalDimension.Width / 2;
float imageHeight = image.PhysicalDimension.Height / 2;
foreach (PdfBlendMode mode in Enum.GetValues(typeof(PdfBlendMode)))
{
PdfPageBase page = section.Pages.Add();
float pageWidth = page.Canvas.ClientSize.Width;
float y = 0;
//title
y = y + 5;
PdfBrush brush = new PdfSolidBrush(Color.OrangeRed);
PdfTrueTypeFont font = new PdfTrueTypeFont(new Font("Arial", 12f, FontStyle.Bold));
PdfStringFormat format = new PdfStringFormat(PdfTextAlignment.Center);
String text = String.Format("Transparency Blend Mode: {0}", mode);
page.Canvas.DrawString(text, font, brush, pageWidth / 2, y, format);
SizeF size = font.MeasureString(text, format);
y = y + size.Height + 6;
page.Canvas.DrawImage(image, 0, y, imageWidth, imageHeight);
page.Canvas.Save();
float d = (page.Canvas.ClientSize.Width - imageWidth) / 5;
float x = d;
y = y + d / 2;
for (int i = 0; i < 5; i++)
{
float alpha = 1.0f / 6 * (5 - i);
page.Canvas.SetTransparency(alpha, alpha, mode);
page.Canvas.DrawImage(image, x, y, imageWidth, imageHeight);
x = x + d;
y = y + d / 2;
}
page.Canvas.Restore();
}
//Save pdf file.
doc.SaveToFile("Transparency.pdf");
doc.Close();
//Launching the Pdf file.
PDFDocumentViewer("Transparency.pdf");
}
示例10: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
//Draw pages
PdfPageBase lastPage = DrawPages(doc);
//script
String script
= "app.alert({"
+ " cMsg: \"I'll lead; you must follow me.\","
+ " nIcon: 3,"
+ " cTitle: \"JavaScript Action\""
+ "});";
PdfJavaScriptAction action1 = new PdfJavaScriptAction(script);
doc.AfterOpenAction = action1;
//script
script
= "app.alert({"
+ " cMsg: \"The firt page!\","
+ " nIcon: 3,"
+ " cTitle: \"JavaScript Action\""
+ "});";
PdfJavaScriptAction action2 = new PdfJavaScriptAction(script);
action1.NextAction = action2;
PdfDestination dest = new PdfDestination(lastPage);
dest.Zoom = 1;
PdfGoToAction action3 = new PdfGoToAction(dest);
action2.NextAction = action3;
//script
script
= "app.alert({"
+ " cMsg: \"Oh sorry, it's the last page. I'm missing!\","
+ " nIcon: 3,"
+ " cTitle: \"JavaScript Action\""
+ "});";
PdfJavaScriptAction action4 = new PdfJavaScriptAction(script);
action3.NextAction = action4;
//Save pdf file.
doc.SaveToFile("ActionChain.pdf");
doc.Close();
//Launching the Pdf file.
PDFDocumentViewer("ActionChain.pdf");
}
示例11: crearPdf
private static void crearPdf()
{
PdfDocument pdf = new PdfDocument();
PdfPageBase pagina = pdf.Pages.Add();
string[] lineasTxT = File.ReadAllLines(CFichero.rutaLibros);
string salida = "";
foreach (string linea in lineasTxT)
{
salida += linea + "\n";
}
pagina.Canvas.DrawString(salida, new PdfFont(PdfFontFamily.TimesRoman, 14), new PdfSolidBrush(Color.Black), 10, 10);
pdf.SaveToFile("Recibo.pdf");
pdf.Close();
}
示例12: Button1_Click
protected void Button1_Click(object sender, System.EventArgs e)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
// Create one page
PdfPageBase page = doc.Pages.Add();
DrawSpiro(page);
DrawPath(page);
//Save to browser
doc.SaveToHttpResponse("Shape.pdf", Response, HttpReadType.Save);
doc.Close();
}
示例13: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
String url = "http://www.e-iceblue.com/";
doc.LoadFromHTML(url, false, true, true);
//Save pdf file.
doc.SaveToFile("FromHTML.pdf");
doc.Close();
//Launching the Pdf file.
PDFDocumentViewer("FromHTML.pdf");
}
示例14: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//open pdf document
PdfDocument doc = new PdfDocument(@"..\..\..\..\..\..\Data\Sample3.pdf");
String pattern = "SplitDocument-{0}.pdf";
doc.Split(pattern);
String lastPageFileName
= String.Format(pattern, doc.Pages.Count - 1);
doc.Close();
//Launching the Pdf file.
PDFDocumentViewer(lastPageFileName);
}
示例15: button1_Click
private void button1_Click(object sender, EventArgs e)
{
//Create a pdf document.
PdfDocument doc = new PdfDocument();
doc.ViewerPreferences.PageLayout = PdfPageLayout.TwoColumnLeft;
//margin
PdfUnitConvertor unitCvtr = new PdfUnitConvertor();
PdfMargins margin = new PdfMargins();
margin.Top = unitCvtr.ConvertUnits(2.54f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Bottom = margin.Top;
margin.Left = unitCvtr.ConvertUnits(3.17f, PdfGraphicsUnit.Centimeter, PdfGraphicsUnit.Point);
margin.Right = margin.Left;
SetDocumentTemplate(doc, PdfPageSize.A4, margin);
//create section
PdfSection section = doc.Sections.Add();
section.PageSettings.Size = PdfPageSize.A4;
section.PageSettings.Margins = new PdfMargins(0);
SetSectionTemplate(section, PdfPageSize.A4, margin, "Section 1");
// Create one page
PdfNewPage page = section.Pages.Add();
//Draw page
DrawPage(page);
page = section.Pages.Add();
DrawPage(page);
page = section.Pages.Add();
DrawPage(page);
page = section.Pages.Add();
DrawPage(page);
page = section.Pages.Add();
DrawPage(page);
//Save pdf file.
doc.SaveToFile("Template.pdf");
doc.Close();
//Launching the Pdf file.
PDFDocumentViewer("Template.pdf");
}