Monzon Soft provides a PDF SDK that will make your application capable of saving PDF files in 15 minutes
|
MzPDF Toolkit C# Tutorial:
Introduction: This tutorial will show you how to integrate Mozon MzPDF toolkit in your own application in less than 15 minutes. After that you will have your application PDF-enabled. This tutorial will explain how to create a PDF with 3 pages, each page contains 1x1 inch rectangle using C#. Steps:
1. Open
visual studio 2005 2.
Create new project (visual C# , Windows application) 3. Open
Form1.cs. const double page_height_inch = 11;
// use the following condition if you want to interrupt the operation. // we are setting this to false for now.
if ( false ) using MZDocument;
namespace WindowsApplication1{
public partial class Form1 : Form{ const double page_width_inch = 8.5; const double page_height_inch = 11; public Form1() { InitializeComponent(); } public void Progress2(object sender, ProgressEventArgs e) { int currentPage = e.CurrentPageProgress; int total = e.CurrentPage * 100 / e.TotalPage;String str = String.Format("Page : {0} of {1} ", e.CurrentPage, e.TotalPage); Application.DoEvents(); if (false) e.Cancel = true;else e.Cancel = false;}
public void GeneratePDF() { PdfOptions pdfOptions = new PdfOptions();pdfOptions.Title = "Rectangle docment";pdfOptions.Subject = "Inch rectangle";pdfOptions.Author = "Auther - me";pdfOptions.Keywords = "Keywords ...";pdfOptions.Pdfcompress = true;pdfOptions.Jpgcompress = true;pdfOptions.PdfGenerateImage = true;pdfOptions.PdfGenerateText = true;pdfOptions.PdfGenerateGraphics = true;pdfOptions.PdfShowToolbar = true;pdfOptions.PdfShowMenuBar = true;pdfOptions.PdfShowWindowUI = true;pdfOptions.PageNo = 2; // open PDF in page 2pdfOptions.Version = PdfVersion.OneDotThree; //version 1.3pdfOptions.Magnification = PdfMagnification.Custom;pdfOptions.CustomMag = 50; pdfOptions.PageMode = PdfPageMode.Thumbs;pdfOptions.PageLayout = PdfPageLayout.TwoLColumn; try{ MZDocument. Document doc = new Document();doc.Progress += new EventHandler<ProgressEventArgs>(Progress2);doc.CreateDocument(); //create three pages for(int i = 1; i<= 3; i++) { MZDocument. PageInfo pageInfo = new PageInfo();// Start the page. doc.StartPage( Document.LastPage, page_width_inch, page_height_inch, pageInfo, 0); Rectangle pageRectangle = new Rectangle(0, 0, (int)(page_width_inch * pageInfo.xDPI + 0.5), (int)(page_height_inch * pageInfo.yDPI + 0.5));//OR (Same result) //Rectangle = pageInfo.RectPage; //use page info DPI to calculate the drawing rectangle. // Draw 1 inch rectangle. Rectangle rectangle = new Rectangle((int)(1*pageInfo.xDPI),(int)(1*pageInfo.yDPI),(int)(1*pageInfo.xDPI),(int)(1*pageInfo.yDPI)); Pen pen = new Pen(Color.Black); pageInfo.PageGraphics.DrawRectangle(pen,rectangle); // close current pagedoc.EndCurrentPage(); } doc.CloseDocument(); try { doc.GeneratePDF( "c:\\RetanglePDF.pdf", pdfOptions);} catch (DocumentException documentException) { MessageBox.Show(documentException.Descreption, "Error");} // delete document handle to cleardoc.DeleteDocument(); } catch(DocumentException documentException){ MessageBox.Show(documentException.Descreption, "Error");} } private void GeneratePDFMenuItem_Click(object sender, EventArgs e) { GeneratePDF(); } } }
Download MzPDF Toolkit:The MzPDF toolkit (Evaluation version) can be downloaded from the downloads page. Order MzPDF Toolkit: To order MzPDF toolkit, go to the order page. Contact Us:If you have any notes or questions please drop us a line and we will be glad to help. |
|||||||||||||||||||||||||||||||||
PDF SDK to generate PDF files quickly and easily |
Home . PDF SDK . Contact Us . About Us Copyright © 2011 - Mozon Software |