cancel
Showing results for 
Search instead for 
Did you mean: 

Export into pdf raise an error?

Former Member
0 Kudos

Hai to all,

I'm using Crystal Report 11.5, Asp.net2.0-C#.

I dynamically bind some records to the report document. Now i write the code to export the data into pdf file.

BindEveryThing();

MemoryStream oStream; // using System.IO

oStream = (MemoryStream)

boReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);

Response.Clear();

Response.Buffer= true;

Response.ContentType = "application/pdf";

Response.BinaryWrite(oStream.ToArray());

HttpContext.Current.ApplicationInstance.CompleteRequest();

The problem is after the above code reached

i'm getting two errors as

Adobe Reader cannot open CA2V0915.pdf because it is either not a supported file type or because the file has been damaged (for example it was sent as an email attachment and wasnt correctly decoded

Threre was an error openning this document Acrobat cannot open this file because there is a modal dialog open.

Experts please help me solve this problem>

Thanks in advance.

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Generally, this kind of error message appears because by default the PDF file is saved to the temp folder. It could be that the temp folder on your computer is full and cannot accept any more files.

Try to remove some files from the temp folder and see how it goes.

Cheers

Alphonse

Former Member
0 Kudos

Hi Alphonse Kouassi ,

I cleared all temp files from my machine, but now also i have the same problem

There was an error opening this document. This file is

damaged and could not be repaired

former_member184995
Active Contributor
0 Kudos

Try adding a Response.End(); after you do the BinaryWrite.

Former Member
0 Kudos

Hi Jason Everly ,

When i use response.end then i got this error

ThreadAbortException so that microsoft suggest instead of Response.End write HttpContext.Current.ApplicationInstance.CompleteRequest

Ref: http://support.microsoft.com/kb/312629/EN-US/

Now i'm having the error as

*"There was an error opening this document. This file is

damaged and could not be repaired"*

Could you you tell me what is the problem and how to solve this?

ted_ueda
Employee
Employee
0 Kudos

Try running [Filemon|http://technet.microsoft.com/en-us/sysinternals/bb896642.aspx] and [Fiddler|http://www.fiddlertool.com/] on the client machine, to trace out whether:

1. The PDF file is being written to temp folder.

2. The PDF file is being opened by Adobe.

If it is being written to temp folder, try opening it in Notepad to see if you can detect any corruption (or even a HTML error message).

Also - are you trying to access via SSL (https instead of http)?

Sincerely,

Ted Ueda

Former Member
0 Kudos

Hi Ted Ueda

Thanks for your response. Actualy this error raised whenever i select the PDF format file so, i checked my temp folders there is no pdf files, this error is raise during file creation then how can i open it by notepad format.

My real problem is write the code for export the records into PDF. Whenever i click this button suddenly it raise this error.

This is my sample code

Load();

ExportExcel vwPage = (ExportExcel)vwExport;

MemoryStream oStream; // using System.IO

oStream = (MemoryStream)

boReportDocument.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);

vwPage.Response.Clear();

vwPage.Response.Buffer = true;

vwPage.Response.ContentType = "application/vnd.ms-excel";

vwPage.Response.BinaryWrite(oStream.ToArray());

HttpContext.Current.ApplicationInstance.CompleteRequest();

ted_ueda
Employee
Employee
0 Kudos

Did you try running Filemon or Fiddler? Or would you like to try more random steps to try and isolate where it's breaking down?

Sincerely,

Ted Ueda

former_member183750
Active Contributor
0 Kudos

I think the place to start on all of this is with a simple sample app that does not use exportostream. Rather, simply export to pdf from the app. This file;

https://smpdl.sap-ag.de/~sapidp/012002523100006252822008E/net_win_smpl.exe

contains a number of sample apps. I'd start with vbnet_win_exportopdf and see if you can export from that app. Use a "saved data" report so you do not have to code the database logon.

vbnet_win_simplepreviewreport may also be a good app. See if exporting from the viewer works.

All of the above and the whole thread assumes (though the question was not posed) that you can export to pdf from the CR designer(?).

Ludek