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 7046433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:39:00+00:00 2026-05-28T02:39:00+00:00

I recently encountered an issue regarding outputting a PDF generated in iTextSharp into a

  • 0

I recently encountered an issue regarding outputting a PDF generated in iTextSharp into a new window and haven’t been able to figure out a way to fix the issue.

This problem only seems to occur in IE, and upon the new window opening, it remains blank and doesn’t seem to load the PDF at all. (Where as Chrome and Firefox seem to work just fine)

I’ll go through an overview of the process in hopes of providing some assistance to you all:

Step 1:

The User clicks the “Print” button that I have within a View, and this calls the following Javascript to execute:

window.open($("#PrintURL").val(), 'Print_Preview', 'resizable=1');

Step 2:

The URL that is called pulls the appropriate data into a model and then passes that into a partial view, which is passed into a PDFResult, as shown:

//Grabs the Data
var data = reportAgent.GetData();

//Builds a string that contains the Report layout and builds the Report
string html = ControllerContext.RenderPartialAsString("~/Views/Reports/Report.cshtml", data);

return new PDFResult(html, ...);

Step 3:

Within the PDFResult ExecuteResult() method, I build the document that the Report will output, and adjust other parameters, such as PageSize, Headers and Footers.

public override void ExecuteResult(ControllerContext context)
{
    //Sets Response to output a PDF
    var response = context.HttpContext.Response;
    response.ContentType = "application/pdf";

    //Generate Document
    Document document = new Document();

    //Sets Page Size and Styles

    //Build Headers and Footers and Add to Document

    //Builds the document writer and prepares a Print Dialog upon opening
    PdfWriter writer = PdfWriter.GetInstance(document, context.HttpContext.Response.OutputStream);      
    PdfAction action = new PdfAction(PdfAction.PRINTDIALOG);
    writer.SetOpenAction(action);     
    writer.PageEvent = page;
    document.Open();

    //Iterates through the html string that was passed in and formats the document

    document.Close();
}

I cannot seem to figure out why the new window simply remains blank in Internet Explorer, while a majority of other browsers seem to work just fine. (I know I have had this same process work in IE in the past, I’m just stumped currently.)

Any idea/suggestions to improve this process would be greatly appreciated.

UPDATE


I was testing out some of the changes suggested, and when I removed the areas that would build the document and just added the following:

document.Add(new Phrase("TEST"));

which would add just a single line to the PDF and then generate it. I received an “Internet Explorer cannot display the webpage” error, with the option to Diagnose Connection Problems. When clicking the Diagnose Connection Problems option, and it finishes, the PDF is loaded as intended.

Could this be an issue with the PDF not being “ready” when the new window attempts to load it?

(This is in IE8)

  • 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-28T02:39:00+00:00Added an answer on May 28, 2026 at 2:39 am

    I managed to finally solve this issue. It appears that the window was opening prior to the PDF being ready to be displayed. (This was determined by simply refreshing the window and then the PDF would appear properly.)

    So rather than opening the window to a specific URL, I generated a window and opened the URL from within the window, which seemed to fix the issue.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently encountered a printing issue in Firefox that eventually turned out to be
Recently I have encountered an issue with Scribd where searching via Scribd API (docs.search)
I've recently encountered an issue with the multi-threaded nature of the BizTalk Mapper and
I use Rails 3.0.6 with mongoID 2.0.2. Recently I encountered an issue with save!
I have been using Automapper in our projects and just recently ran into an
I've recently encountered an issue where I have an ObservableCollection bound to a ListView.
I'm quite new at WPF and recently encountered a problem. I got an ObservableCollection<
Recently, I encountered a very strange issue, this issue only happens in Windows XP
I recently encountered a problem where a value was null if accessed with Request.Form
I recently encountered an odd problem with RSACryptoServiceProvider.VerifyHash . I have a web application

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.