Monzon Soft provides a PDF SDK that will make your application capable of saving PDF files in 15 minutes
|
MzPDF Toolkit VB.NET 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 VB.NET. Steps:
1. Open visual studio 2005
2. Create new project (visual Basic , Windows
application)
3. Open Form1.vb. Public Sub GeneratePDF()End Sub
Imports MZDocument
Public Class Form1Const page_height_inch As Double = 11 Const page_width_inch As Double = 8.5 Public Sub Progress(ByVal sender As Object, ByVal e As ProgressEventArgs) Dim currentPage As Integer = e.CurrentPageProgress Dim totalPage As Integer = e.CurrentPage * 100 / e.TotalPage Dim str As String = String.Format("Page : {0} of {1} ", e.CurrentPage, e.TotalPage) Application.DoEvents() If (False) Then e.Cancel = TrueElse e.Cancel = FalseEnd If End Sub
Public Sub GeneratePDF() Dim pdfOptions As PdfOptions pdfOptions = New PdfOptions()pdfOptions.Title = "Rectangle docment"pdfOptions.Subject = "Inch rectangle"pdfOptions.Author = "Auther - me"pdfOptions.Keywords = "Keywords ..."pdfOptions.Pdfcompress = TruepdfOptions.Jpgcompress = TruepdfOptions.PdfGenerateImage = TruepdfOptions.PdfGenerateText = TruepdfOptions.PdfGenerateGraphics = TruepdfOptions.PdfShowToolbar = TruepdfOptions.PdfShowMenuBar = TruepdfOptions.PdfShowWindowUI = TruepdfOptions.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 Dim doc As MZDocument.Document = New Document() AddHandler doc.Progress, AddressOf Progress ' ProgressEventArgs
doc.CreateDocument() 'create three pages For i As Integer = 1 To 3 Dim pageInfo As MZDocument.PageInfo = New PageInfo()
' Start the page. doc.StartPage(Document.LastPage, page_width_inch, page_height_inch, pageInfo, 0) Dim pageRectangle As Rectangle = New Rectangle(0, 0, CInt(page_width_inch * pageInfo.xDPI + 0.5), CInt(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. Dim rectangle As Rectangle = New Rectangle(CInt(1 * pageInfo.xDPI), CInt(1 * pageInfo.yDPI), CInt(1 * pageInfo.xDPI), CInt(1 * pageInfo.yDPI)) Dim pen As Pen = New Pen(Color.Black) pageInfo.PageGraphics.DrawRectangle(pen, rectangle) 'close current page doc.EndCurrentPage() Next i
doc.CloseDocument() Try doc.GeneratePDF( "c:\\VBRetanglePDF.pdf", pdfOptions)Catch documentException As DocumentException MessageBox.Show(documentException.Descreption, "Error")End Try 'delete document handle to clear doc.DeleteDocument() Catch documentException As DocumentException MessageBox.Show(documentException.Descreption, "Error")End Try End Sub
Private Sub GenereatePDFMenuItemToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GenereatePDFMenuItemToolStripMenuItem.Click GeneratePDF() End Sub End Class
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 |