Export to PDF - Problem

edited 4:15PM in FastReport .NET
Hello everyone,

Using FastReports.NET we are building Report which is exported in PDF.

Everything seems Ok and it works fine, unless we got (in several situation) in an unexpected error that There was an error opening the document. The file is damaged and could not be repaired.

We are mainly doing everything from code behind working on ASP.NET 2.0.

I have one TextObject which is bound to the Report Title.

Code:
TextObject repT = new TextObject();
myRep.Text = "Report Title 1";
myRep.FillColor = System.Drawing.Color.Silver;
myRep.Left = Units.Centimeters * (float)2;
myRep.Top = Units.Centimeters * (float)0.5;
myRep.Width = Units.Centimeters * (float)4;
myRep.Height = Units.Centimeters * (float)0.75;
System.Drawing.Font font = new System.Drawing.Font("Arial", 15.75F);
myRep.Font = font;

page1.ReportTitle.Objects.Add(myRep); //adding the object to page ReportTitle

So, if I leave it like this, it would work great. If I put text with length less then 7 characters, like myRep.Text = "Rep"; it will produce the above said Error.

One more thing to note: When the complete report is created, we use MemoryStream as Stream to write the report, like:
MemoryStream Strm = new MemoryStream();
report.Export(pdfexport,Strm);

Any suggestion?

Thank you,
Hajan

Comments

  • edited 4:15PM
    hajan wrote: »
    Hello everyone,

    Using FastReports.NET we are building Report which is exported in PDF.

    Everything seems Ok and it works fine, unless we got (in several situation) in an unexpected error that There was an error opening the document. The file is damaged and could not be repaired.

    We are mainly doing everything from code behind working on ASP.NET 2.0.

    I have one TextObject which is bound to the Report Title.

    Code:
    TextObject repT = new TextObject();
    myRep.Text = "Report Title 1";
    myRep.FillColor = System.Drawing.Color.Silver;
    myRep.Left = Units.Centimeters * (float)2;
    myRep.Top = Units.Centimeters * (float)0.5;
    myRep.Width = Units.Centimeters * (float)4;
    myRep.Height = Units.Centimeters * (float)0.75;
    System.Drawing.Font font = new System.Drawing.Font("Arial", 15.75F);
    myRep.Font = font;

    page1.ReportTitle.Objects.Add(myRep); //adding the object to page ReportTitle

    So, if I leave it like this, it would work great. If I put text with length less then 7 characters, like myRep.Text = "Rep"; it will produce the above said Error.

    One more thing to note: When the complete report is created, we use MemoryStream as Stream to write the report, like:
    MemoryStream Strm = new MemoryStream();
    report.Export(pdfexport,Strm);

    Any suggestion?

    Thank you,
    Hajan

    I have been trying around to find a solution to this the whole day, and finally have found. It was related to the HttpContext of the page and the MemoryStream.
    Everything else is OK regarding the FastReports.NET including converting to local fonts etc.

    Thanks for reading me >

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.