Link to home
Start Free TrialLog in
Avatar of shulamitg
shulamitg

asked on

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

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.
Avatar of frodoman
frodoman
Flag of United States of America image

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.
Avatar of Mike McCracken
Mike McCracken

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

mlmcc
Avatar of shulamitg

ASKER

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

ASKER CERTIFIED SOLUTION
Avatar of frodoman
frodoman
Flag of United States of America image

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
What version of the Acrobat reader are you using?  Have you tried upgrading to the latest?

mlmcc

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.  
SOLUTION
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