Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7490809
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T15:46:17+00:00 2026-05-29T15:46:17+00:00

I did a code to generate a report of Crystal Reports in PDF…But it

  • 0

I did a code to generate a report of Crystal Reports in PDF…But it opens in the same page of the user did a search and clicked in the button…Have any ways to open the PDF in a new tab or page ?

My code is:

private void OpenPDF()
{
    ReportDocument Rel = new ReportDocument();
    Rel.Load(Server.MapPath("../Reports/Test.rpt"));
    BinaryReader stream = new BinaryReader(Rel.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
    Response.ClearContent();
    Response.ClearHeaders();
    Response.ContentType = "application/pdf";
    Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));
    Response.Flush();
    Response.Close(); 
}

Thanks for the help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T15:46:18+00:00Added an answer on May 29, 2026 at 3:46 pm

    In its most simplest interpretation, to open a new window or tab, the hyperlink to the page should have the target attribute set to "_blank".

    <a href="GeneratePDF.aspx" target="_blank">Link to open PDF in new window</a>
    

    Or you could create some Javascript that opens a new window instead. Make sure you call the Javascript function somewhere on the page.

    <script type="text/javascript">
    function loadPDF() {
       window.open('GeneratePDF.aspx','','scrollbars=no,menubar=no,height=600,width=800,resizable=yes,toolbar=no,location=no,status=no');
    }
    </script>
    

    Or this code will inform the web browser that the file is a download (rather than a page to view inside the browser window). I think this is the best approach because the user gets the choice of Opening or Saving the PDF. So this does not do what you’re asking for, but you might think it’s better.

    private void OpenPDF(string downloadAsFilename)
    {
        ReportDocument Rel = new ReportDocument();
        Rel.Load(Server.MapPath("../Reports/Test.rpt"));
        BinaryReader stream = new BinaryReader(Rel.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
        Response.ClearContent();
        Response.ClearHeaders();
        Response.ContentType = "application/pdf";
        Response.AddHeader("content-disposition", "attachment; filename=" + downloadAsFilename);
        Response.AddHeader("content-length", stream.BaseStream.Length.ToString());
        Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));
        Response.Flush();
        Response.Close(); 
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to generate crystal report in pdf format. I had done the same
I have Googled merge+cell+Javascript but did not find any suitable code to implement merge
I was running some code that did a printout in a swingworker. I was
I did a behavioral simulation of my code, and it works perfectly. The results
I did a ton of changes to our code and before I commit, I
I did not make any changes on the code. I dont receive any errors
Somehow my code doesn't work any more (it did work before with the exact
Last evening I did some housekeeping on our code repository - basically moved the
Did I not get enough sleep or what? This following code var frame=document.getElementById(viewer); frame.width=100;
according to this code i dont understand about NSClassFromString how did i know viewControllerName

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.