Monzon Soft provides a PDF SDK that will make your application capable of saving PDF files in 15 minutes
|
MzPDF Toolkit 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. We are going to use Microsoft’s WordPad application to demonstrate how you can add PDF support capabilities to any application very easily using the MzPDF toolkit. Note: We will use the source code of Microsoft’s WordPad application which can be downloaded from Microsoft’s website as a sample. Steps: 1. Go to the following Microsoft site and download Microsoft WordPad source code from there. http://msdn2.microsoft.com/en-us/library/51y8h3tk(VS.80).aspx Note: If you cannot find this URL for any reason, you can always search the web for "WORDPAD Sample: The Windows Application" which will lead you to the download site. 2. Save the downloaded code under c:\MZPDF\Demos\wordpad Note: We’re assuming that you downloaded MzPDF toolkit and installed it on the path c:\MZPDF. If the toolkit was installed on a different path, you’ll need to make the proper changes. 3. Run the Visual Studio application and open the WordPad project you just downloaded. After that open the file “wordpvw.cpp” and add the following header and function:
// Add MzPDF.h include file // First, prepare the RichEdit control FORMATRANGE fr; memset(&fr,0,sizeof(fr)); // Calculate device area in twips SetRect(&fr.rcPage,0,0,(int)(8.5*1440),(int)(11*1440)); // Calculate the render area in twips SetRect( &fr.rc, 0, 0, fr.rcPage.right , fr.rcPage.bottom ); // Set the min & max characters to be printed. fr.chrg.cpMin = 0; fr.chrg.cpMax = -1; // Get length of all characters in the file long lTextLength = GetTextLength(); long lCharNumber = 0; // Now add Mozon PDF toolkit // Create document MZDOCHANDLE hPdfDocument; if ( MZ_ERR_SUCCESS != mzCreateDocument(&hPdfDocument) ) { MessageBox("Error creating document"); return; } // Repeat until we reach to the last character in the rtf file while(lCharNumber < lTextLength) { // Fill Pageinfo Structure MZPAGEINFO PageInfo; PageInfo.uStructSize = sizeof(MZPAGEINFO); // Start the page and make it A4 (8.5*11 inch). if(MZ_ERR_SUCCESS != mzStartPage(hPdfDocument,-1,8.5,11,&PageInfo,NULL)) continue; // Ask RichEdit control to use MzPDF Device context to draw instead of the windows DC. fr.hdc = PageInfo.hPageDC; lCharNumber = GetRichEditCtrl().FormatRange(&fr,TRUE); // Now close the current page by calling mzEndCurrentPage( hPdfDocument ); // Set number the minimum character number to be for next page, this issue is needed for // RichEdit control fr.chrg.cpMin = lCharNumber; } // After we finished drawing on the PDF file, close the document. mzCloseDocument ( hPdfDocument ); // Then generate your PDF mzGeneratePDF( hPdfDocument , TEXT("c:\\rtf.pdf") ,NULL,NULL,NULL); // No need for the hPdfDocument handle anymore so, delete it. mzDeleteDocument( hPdfDocument ); // Use ShellExecute function to see the generated file. ShellExecute(NULL,"open","c:\\rtf.pdf",0,0,SW_SHOW); 6. Add \MZPDF\Lib\mzpdflib.lib to your project. 7. Add a menu item called "Generate PDF" and integrate it with OnGeneratePdf() function we wrote above. 8. We’re done. Now you have finished integrating our MzPDF toolkit in the Microsoft WordPad. You can imagine how easy it would be for you to integrate our PDF toolkit into your application. You can run the app and open any RTF file. After that click on "Generate PDF" menu item and you will get your PDF file written for you. How we did it? The MzPDF toolkit was designed to provide you with a device context (dc), which can be used to draw in the same way you draw on your application’s hDC. It’s as simple as that! Just replace your application’s hDC with our PdfDC and you’re done. This is exactly what we did above. We took the WordPad’s printing code module and modified it to use PdfDC instead of the printer’s DC. Full code is here
// Add MzPDF.h include file 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 |