Link to home
Start Free TrialLog in
Avatar of jyx
jyx

asked on

In VB how to export crystal report to PDF format?

Or in VB how to send the crystal report automatically to another person by email?
Can I do it using crystal report print engine calls?
Where and how could I find related help document?
BTW, I am using crystal 5, do I have to upgrade to crystal 8?
Avatar of DRRYAN3
DRRYAN3

If you upgrade to Crystal 8.5 you can directly export to PDF format.  In versions prior to that you had to use the PDFWriter driver.

Following is VB code which I've used since v7.0 for sending an email....which I cannot find here at home.  I'll post it from the office tomorrow.

You can find all sorts of programming tips and sample code at http://www.crystaldecisions.com.  You have to be a registered user to get to some of it.

DRRYAN3
Avatar of jyx

ASKER

Thanks.
It seems our boss doesn't want to upgrade the crystal. Now we are using crystal 5. We were thinking about using PDFWriter, I noticed after I installed Acrobat it automatically added PDFWriter as a printer. I still have no idea how to use it.
Using the pdfwriter with a file name set in advance can be done by setting your printer to the pdfwriter and using code similar to the following to modify the .INI file before each printout:

Public Sub SetPDFDestination(PDFPathName As String)
  ' Passed path name should include .pdf extension
 
  ' Modify the PDFWRITR.INI file to turn off the dialog and
  ' quietly send our report to the passed path name
  Dim fso As New FileSystemObject
  Dim fil As File
  Dim ts As TextStream
  Const PDFIni = "C:\WINDOWS\SYSTEM\PDFWRITR.INI"
  ' Delete existing PDFWRITR INI file
  On Error Resume Next
  fso.DeleteFile (PDFIni)
  On Error GoTo 0
  Set ts = fso.CreateTextFile(PDFIni, True)
  ts.Write ("[Acrobat PDFWriter]" & vbCrLf)
  ts.Write ("compatibility=1" & vbCrLf)
  ts.Write ("bExecViewer=0" & vbCrLf)
  ts.Write ("PDFFileName=" & PDFPathName & vbCrLf)
  ts.Close
  Set ts = Nothing
  Set fil = Nothing
  Set fso = Nothing
 
  ' Setup Registry key and value in case we are on NT
  x = RegistryStuff.SetRegValue(HKEY_CURRENT_USER, "Software\Adobe\Acrobat PDFWriter", "PDFFileName", PDFPathName)
End Sub

I have found it necessary to pause for a second or two after calling this or to manually flush writes to disk.  This works for W9x - see the registry key for NT/2K

After you modify the .INI, set your printer to "Acrobat PDFWriter" and print your report.  If your .INI file modifications weren't made, you'll be prompted for a file name.

Note that you must recreate the .INI file for each and every report.

DRRYAN3
Avatar of jyx

ASKER

I will try this, thank you!
Avatar of jyx

ASKER

DRRYAN3, I did not find the "C:\WINDOWS\SYSTEM\PDFWRITR.INI", it seems in my computer it is "c:\winnt4\system32\spool\drivers\w32x86\2\__pdf.ini".

Another question is "should I ask all the users to install Adobe Acrobat on their machines? Could I install it on the server side and save the files into pdf files quitely on the server side?"

Thanks a lot!
Avatar of jyx

ASKER

In my other machine, I can not find this kind of "ini" file at all.
ASKER CERTIFIED SOLUTION
Avatar of DRRYAN3
DRRYAN3

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ran across http://www.activepdf.com/ this evening.  Claims to be server side pdf creation.

DRRYAN3
This question has been open for some time now.  Please return and either
1.  Accept an answer
2.  Post a comment stating that you need more information
3.  Ask Community Support to delete the question if you feel the information here has no value to you or anyone else.
4.  Ask Community Support to PAQ the question because your question was not answered but you feel the information here may be of some value to others.

Community Support is here:  https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt and you can leave a message by posting a zero point question.  Be sure to reference the question ID, found in the Address bar of your browser.

Thanks
DRRYAN3
Avatar of jyx

ASKER

Sorry...Last month I did not get a chance to logon the website...I appreciate your comment and it is really useful...I will definately accept an answer but for now I still need your help.  

If I use crystal 8.5, do you have some sample code about how to export the crystal report to pdf format like this:  

VBPEExportToDisk(intReportHandle, RTrim(fileName) & ".xls", "U2FXLS.dll", UXF_Xls5Type, True, True, "", "")

Please also include the defination of the constant for pdf format.

Or please tell me where to get the related help information. I checked the crystal website but did not find the information which I need.

Thanks!
Avatar of jyx

ASKER

Now I can use crystal 8.5 to export to pdf directly. At the same time, we are still trying to print to pdf writer from crystal 5...did not succeed yet...maybe still need your help...that's why I did not close this question. Thanks and sorry for the delay.  
Avatar of jyx

ASKER

Now I can use crystal 8.5 to export to pdf directly. At the same time, we are still trying to print to pdf writer from crystal 5...did not succeed yet...maybe still need your help...that's why I did not close this question. Thanks and sorry for the delay.  
Avatar of jyx

ASKER

the regret is when I use crystal 8.5 export to pdf format, it seems some lines in my report is missing. :(