Solved

Exporting Crystal Report 8.5 file to PDF using VB6 Coding

Posted on 2006-06-19
17
1,850 Views
Last Modified: 2012-06-21
When I export Crystal Report 8.5 File to PDF file through VB6 code export is successful but cannot open the PDF file.
Error: File does not begin with '%PDF-'.

If I export the same report file directly from crystal reports to PDF then I can open the PDF file.
0
Comment
Question by:VENKATGVR
  • 7
  • 3
  • 2
  • +1
17 Comments
 
LVL 32

Expert Comment

by:jhance
ID: 16937955
A PDF file will begin with the characters:

%PDF-1.3

or similar.  The "1.3" represents the PDF version used and that may change.

It sounds like you're doing something wrong.  Why don't you post the code you are using as it might be easier to find your mistake.
0
 

Author Comment

by:VENKATGVR
ID: 16941798
Hi Jhance,

Here is my code.

CRPT.Destination = crptToFile
CRPT.PrintFileName = "C:\Analysis\Rpt001.PDF"
CRPT.PrintFileType = crptCSV
CRPT.Action = 2

The Crystal version I am using is 8.5 and the PDF version is 5.0.
The file Rpt001.pdf is created but Error: File does not begin with '%PDF-'.


Thanks.
0
 
LVL 32

Expert Comment

by:jhance
ID: 16943147
>>>CRPT.PrintFileType = crptCSV

That's asking for a CSV file, NOT a PDF.  How about trying:

CRPT.PrintFileType = crptPDF

instead?
0
 

Author Comment

by:VENKATGVR
ID: 16951706
Jhance,

I tried with CRPT.PrintFileType = crptPDF, it gives error....!
0
 
LVL 32

Expert Comment

by:jhance
ID: 16954484
What error?
0
 
LVL 1

Expert Comment

by:chandurs
ID: 16955002
Try this program, which used Craxdrt control
dim crapp as craxdrt.application
dim crRpt as craxdrt.report
 set crRpt = crapp.openreport("your reportname")
crRpt.exportoptions.formattype=crEFTPortableDocFormat
crRpt.Exportoptions.DestinationType=crEDTDiskFile
crRpt.Exportoptions.DiskFileName = "pdf Filename with path"

CrRpt.Export False

You have to add reference to CRAXDRT dll in your project
0
 
LVL 7

Expert Comment

by:assyst
ID: 16960874
Try this....

Disable the "Display PDF in Browser" option in your reader software.

Use Start - Programs - Adobe Reader to run the program directly (instead of embedded inside the web browser).
Pull down the Edit menu and choose Preferences.
In the Internet settings page, de-select (uncheck) the "Display PDF in Browser" option.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:VENKATGVR
ID: 16963128
Hi Chandu,
To declare as craxdrt.application what Reference I should add in VB project..
0
 

Author Comment

by:VENKATGVR
ID: 16963135
Hi Assyst,
I did as what you said but still I get the same error.
0
 
LVL 7

Expert Comment

by:assyst
ID: 16966918
Whats your Adobe reader version.

Please try installing Adobe Reader 7

And try opening the file after exporting from crystal report.
0
 

Author Comment

by:VENKATGVR
ID: 16969846

ThanQ..!

Right now I am using version 5.
I'll install version 7 and test.
0
 

Author Comment

by:VENKATGVR
ID: 16972344
Assyst,

I installed Version 7, but still says file is currepted when I open the exported file.
0
 
LVL 1

Accepted Solution

by:
chandurs earned 500 total points
ID: 16987984
VenkatGVR, Dll you need to refer in your project is CRAXDRT.dll. It should show as "crystal report Viewer Control" in your project reference list. physical location of the file will be something like this "C:program files\seagate software\viewers\activeXviewer".
Let me know if this one helps or not
0
 

Author Comment

by:VENKATGVR
ID: 17009628

Chandu,
ThanQ..!
I'll do that and let you know.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
firstswap challenge 20 68
C Programming - If Statement 8 72
index Out OF Range Exception error 4 54
Please help| Getting the syntax error in below query. 2 48
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now