Developer Tools
|
Office Productivity Applications
|
Enterprise Solutions
|
|||||||||||||||||||||||||||
Important
This product has been discontinued. Please check our old products page for more information.
This tip features a code snippet that exports to PDF from Crystal Reports. Crystal Reports components are used to print a report with Gnostice Print2eDoc as the printer. A PDF document creation profile created with Gnostice Print2eDoc SDK is used to generate the report in PDF.
First, the components that need to be placed on a form:
Now, over to the code snippet. Please follow the code comments closely.
Code Snippet in C# ================== // Create a Print2eDoc printer object Print2eDocSDK.gtPrint2eDoc PrinterObj = new Print2eDocSDK.gtPrint2eDoc(); // Create a string containing fonts that need not be embedded string[] NeverEmbedFontNames = { "Arial Unicode MS", "Lucida Sans Unicode", "Verdana" }; // Create a Print2eDoc document creation profile gtProfileSettingsX ProfileObj; // Specify Print2eDoc printer settings for PDF output PrinterObj.ShowPreview = true; PrinterObj.ShowSaveDialog = false; PrinterObj.ShowSettingsDialog = true; PrinterObj.ViewGeneratedDocuments = true; PrinterObj.UseCustomDocumentName = true; PrinterObj.SourceApplication = TxgtSourceApplication.Other; PrinterObj.OutputDocumentName = @"CrystalReportOutput1"; PrinterObj.DefaultOutputDirectory = @"C:\CReports"; PrinterObj.OutputDocumentFormat = TxgtDocumentFormat.PDF; PrinterObj.FileExistsOption = TxgtFileExistsOption.feAddTrailNumber; ProfileObj = PrinterObj.CurrentProfile; // Specify document information properties ProfileObj.DocInfoAuthor = "Your name"; ProfileObj.DocInfoTitle = "Your CrystalReport report title"; ProfileObj.DocInfoSubject = "Your CrystalReport subject"; // Specify PDF content selection settings ProfileObj.PDFRenderTextItem = true; ProfileObj.PDFRenderImageItem = true; ProfileObj.PDFRenderDrawingItem = true; // === Optional settings begin here === // Specify font embedding settings ProfileObj.PDFFontEmbeding = TxgtTTFontEmbedding.feFull; ProfileObj.PDFFontNeverEmbed = true; ProfileObj.PDFFontNeverEmbedList = (object) NeverEmbedFontNames; ProfileObj.PDFExportAsImage = false; // Specify PDF compression settings ProfileObj.PDFTextCompressionLevel = TxgtCompressionLevel.clNormal; ProfileObj.PDFImage24BitColorDepth = TxgtColorDepth.pf24Bit; ProfileObj.PDFImage24BitCompressionType = TxgtPDFColorImageCompressionType.pdfColorImgJPEG; ProfileObj.PDFImage24BitJPEGQuality = TxgtJPEGQuality.jqHighest; ProfileObj.PDFImage24BitResolution = TxgtResolution.res200DPI; ProfileObj.PDFImage8BitColorDepth = TxgtColorDepth.pf16Bit; ProfileObj.PDFImage8BitCompressionType = TxgtPDFColorImageCompressionType.pdfColorImgJPEG; ProfileObj.PDFImage8BitJPEGQuality = TxgtJPEGQuality.jqHighest; ProfileObj.PDFImage8BitResolution = TxgtResolution.res100DPI; // Specify PDF encryption settings ProfileObj.PDFEncryptEnabled = true; ProfileObj.PDFEncryptLevel = TxgtPDFEncryptionLevel.el128Bit; ProfileObj.PDFEncryptUserAccessibility = true; ProfileObj.PDFEncryptUserAllowCopy = true; ProfileObj.PDFEncryptUserAllowPrint = false; ProfileObj.PDFEncryptUserHighResolutionPrint = false; ProfileObj.PDFEncryptUserPass = "xyz"; ProfileObj.PDFEncryptOwnerPass = "123"; // Specify PDF viewer preferences ProfileObj.PDFViewerPrefPageInitialView = TxgtPageInitialView.pmShowThumbnails; ProfileObj.PDFViewerPrefPageLayout = TxgtPageLayout.plContinous; ProfileObj.PDFViewerPrefShowMenubar = true; ProfileObj.PDFViewerPrefShowNavigationControls = true; ProfileObj.PDFViewerPrefFitWindow = true; PrinterObj.ApplyChangesToCurrentProfile(); // === Optional settings end here === // Load report document reportDocument1.Load( "CR_doc1.rpt", CrystalDecisions.Shared.OpenReportMethod.OpenReportByTempCopy); if (reportDocument1.IsLoaded) { // Select Print2eDoc as printer to which the report // must be printed reportDocument1.PrintOptions.PrinterName = "Gnostice Print2eDoc"; // Print the report reportDocument1.PrintToPrinter(1, true, 0, 0); }
| Privacy | Legal | Feedback | Newsletter | © 2002-2010 Gnostice Information Technologies Private Limited. All rights reserved. |
This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows users are advised to use Microsoft ClearType Tuning for optimal experience. Linux and other users can enable font smoothing, as supported by their OS. Also, please use the latest version of a standards-compliant browser such as Opera, FireFox, Chrome or Safari.