Show binary file into the page

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have to show a pdf when a page is load...
I have a byte[] variable with the pdf...

I try to make a Response.BinaryWrite(variable) but i cant open the pdf...

How could i make it?
 
Hi,

you have to load it in a separated page, as you need to change the content
type to binary.
Here I post a piece of code where I do it, it's a little different as I
create a file instead of using a stream:

ExportFormatType format =ExportFormatType.PortableDocFormat;
string file =Server.MapPath("/TSR") + @"\report.pdf";
string contenttype = "application/pdf";

try
{
CrystalDecisions.Shared.PageMargins margins =
reportDocument1.PrintOptions.PageMargins;

margins.leftMargin = 2;
margins.topMargin = 0;
margins.rightMargin = 0;
margins.bottomMargin = 0;

reportDocument1.PrintOptions.ApplyPageMargins( margins);

reportDocument1.ExportToDisk( format, file);

Response.Redirect( "/TSR/" + theWO.Code + ".pdf", true);

}
catch{}

cheers,
 
Back
Top