We help IT Professionals succeed at work.

Export Crystal Report to pdt Error  "File does not begin with '%pdf-" only on some computers

shulamitg
shulamitg asked
on
1,044 Views
Last Modified: 2009-12-16
I have a problem -in my dot net web application, I export my crystal report to pdf.  In some computers it works great and some computers get
the error : File does not begin with '%pdf-'  -
what can I do in my code to make sure it works on all comuters ?
my code is the following:
to my function displaypdf I send my crystal report:

       private void DisplayPDF(ReportDocument rep)
          {
               Stream stm = rep.ExportToStream(ExportFormatType.PortableDocFormat);
               byte[] buff = new byte[stm.Length];
               stm.Position = 0;
               stm.Read(buff, 0, buff.Length);
               Response.ContentType = "Application/pdf";
               Response.OutputStream.Write(buff, 0, buff.Length);
               Response.End();
          }

Again I want to stress that on some computers it works great and on some not what can I do in my code that will make it work everywhere.
Comment
Watch Question

Commented:
File does not begin with '%pdf-'  is an Acrobat message indicating that the format is corrupt.  The most likely cause of this is that the machines with problems have an older version of Acrobat Reader on them.  Try updating to a more recent version and the problem should resolve.

If it doesn't, then there may be an old dll creating the pdf that is at the root of the problem.  Check your application deployment and make sure all of your dependencies are included.
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
Are you exporting from several machines or from a single machine and sharing the reports?

mlmcc

Author

Commented:
I run the report on the IIS server and then as you see in my above code sends it to the client as pdf.

In the comupter that we have the problem we uninstalled the explorer and the acrobat reader and reinstalled every thing again, and it still has the problem.  what's intersting is that on the same computer some times it does open my pdf with no problem and some times it give the error.

Any other ideas ????

Shulamit

Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013

Commented:
What version of the Acrobat reader are you using?  Have you tried upgrading to the latest?

mlmcc

Author

Commented:
I am talking about the same report .  and on the same computer some time it works some time it doesn't.   the version is 5.  
Mike McCrackenSenior Consultant
CERTIFIED EXPERT
Most Valuable Expert 2011
Top Expert 2013
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.