• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 955
  • Last Modified:

VB6 and CR 8.5 - Generate multiple PDF's from a single report

Hello all,

I've been looking all around for an answer to this question, so I figured I'd come to the experts instead of wasting any more time.  I've got a VB6 application in which I am generating a PDF export of a Crystal Reports 8.5 report.  This part is working "flawlessly", but I've been tasked with finding a way to actually generate SEPARATE PDF's for each page of that report, instead of one single PDF.  Here are the two main problems I'm running into:

1) I'd simply do a loop through each record and generate the individual PDF's, but my data source may contain multiple records for a single page of the report.  That, of course, means that, in certain circumstances, I'd end up with multiple pages where there should only be one.

2) I could manually split the PDF once it has been created, but the file creation and handling is taken care of by another department, and I really need this to be an automated process.

So, my primary question at this point is this: Is there a way through the VB6 code to do one of the following:

A) Get the actual number of pages that will be in the PDF (NOT the number of records in the recordset).  This way I can do a loop with that count as my maximum value, and generate each page individually using the PDFFirstPageNumber and PDFLastPageNumber properties to generate each page as its own PDF file.

B) Tell the Crystal Reports DLL to split the pages automatically.  I can't find any methods or properties in the DLL that appear to make that happen.

C) Other suggestions for how to best make this work...

Thanks for your time, experts.  Your assistance is greatly appreciated.  Here's a sample of the code I'm using for the PDF creation:

        Dim Viewer As CRAXDDRT.Application
        Dim Report As CRAXDDRT.Report
        Dim CRXData As CRAXDDRT.Database
        
        Set Viewer = New CRAXDDRT.Application
        Set Report = Viewer.OpenReport(AppInfo.ReportPath & "ReportFile.rpt", 1)
        
        Set CRXData = Report.Database
        
        CRXData.Tables(1).Location = PATH
        CRXData.SetDataSource rPolicy, 3, 1
        
        ' *********************************************************************
        ' ** Generate a PDF copy of the report, then display it for the user **
        ' *********************************************************************
        Report.ExportOptions.FormatType = crEFTPortableDocFormat
        Report.ExportOptions.DestinationType = crEDTDiskFile
        Report.ExportOptions.DiskFileName = AppInfo.ArchivePath & "Report " & Format(DateOfPolicy, "yyyymmdd") & ".pdf"
        Report.ExportOptions.PDFExportAllPages = True
        Report.Export False

Open in new window

0
khufford19
Asked:
khufford19
  • 3
  • 2
1 Solution
 
GJParkerCommented:
It's been a while since I looked at this sort of thing but from memory most PDF splitters run on the principal of running and exporting the report multiple times based on a group in the report.

Certainly in Version 8.5 I don't think it is possible to do what you want although there may be moer functionality in the newer versions.

Good Luck
0
 
khufford19Author Commented:
Well, I thought I had a solution using the GetReportVariableValue("TotalPageCount") method of the Report object, but when I tried to actually read the property, I got a "Permission Denied" error.  I even tried throwing that value into a different formula field in the report file itself, but I got the same error.  Well, it was worth a shot, anyway.

I suppose my next step is going to probably be to loop through my original recordset, then create a smaller "temporary" recordset based on the original identifier, and generate each one of those as individual reports.

@GJ - Thanks for the words of encouragement.  Somehow I just "assumed" that something like this would be much simpler.  Well, we all know what we get when we assume...
0
 
Brook BraswellApplication Development ManagerCommented:
When your report is generated you can get the number of total pages with the PrintingStatus property

dim New_APP as NEW craxdrt.Application
dim New_Report as CRAXDRT.Report
Set New_Report = New_App.OpenReport("YourReport.rpt",1)

' set your report parameters...

dim nPages as long
nPages = New_Report.PrintingStatus.NumberOfPages




0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Brook BraswellApplication Development ManagerCommented:
                              Dim nPages As Long
                               Dim cPage As Single
                               nPages = New_Report.PrintingStatus.NumberOfPages
                               For cPage = 1 To nPages
                                   New_Report.ExportOptions.PDFExportAllPages = False
                                   New_Report.ExportOptions.PDFFirstPageNumber = cPage
                                   New_Report.ExportOptions.PDFLastPageNumber = cPage
                                   New_Report.ExportOptions.DestinationType = crEDTDiskFile
                                   New_Report.ExportOptions.DiskFileName = App.Path & "\OutPut\REPORT_PAGE" & Format(cPage, "00") & ".pdf"
                                   New_Report.ExportOptions.FormatType = crEFTPortableDocFormat
                                   New_Report.DisplayProgressDialog = False
                                   New_Report.Export False
                                   
                               Next
                               MsgBox "EXPORT OF ALL " & nPages & " IS COMPLETE"
0
 
khufford19Author Commented:
@ Brook - Oh, holy crap!  I saw that property in there, but never even THOUGHT to look at it for the number of pages.  Wow!  You've just made my life 1000% better!

Of course, I just realized that I may still have to loop through the original recordset like I was considering earlier, simply because of the way I need to set up the file names of the individual PDF files (I need to use a value from the recordset), but this definitely makes my day.  Thank you SO much!
0
 
Brook BraswellApplication Development ManagerCommented:
No problems, glad to help
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now