Click here to Skip to main content
13,195,379 members (67,268 online)
Rate this:
Please Sign up or sign in to vote.

I have an 3.5 web application using itextsharp (coded in C#) to create a pdf file in the browser. The form allows the user to select a document from a dropdown list which is then outptut as a pdf file in a tab. Another request for a different document opens another new pdf file in a new (different) tab. This works using Visual Studio 2010 but, on the server (IIS 7.0.6), the same document opens in the new tab, no matter which new document is selected.

A snippet of the code:

// The following line did not make a difference:
// opens PDF in next new tab:

What am I missing?
Any help is greatly appreciated.
Posted 6-Feb-13 4:39am
Where is your content type?

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I found and succesfully tested the following code on IIS 7 (a different Pdf file is opened each time I choose a different document). However I am not sure how to generate the Pdf file into a new tab each time a new document is requested. I prefer a new tab instead of having the Pdf file open in the same window as the form. Any ideas? (Thank you in advance.)

To avoid the original problem on IIS, MemoryStream was used:
_DocMemoryStream = new MemoryStream();
_Document = new Document(PageSize.A4, 1, 1, 10, 10);
 _PdfWriter = PdfWriter.GetInstance(_Document, _DocMemoryStream);
// Update _Document content here...
Response.ContentType = "application/pdf";
//Write the document to the response stream:
Response.OutputStream.Write(_DocMemoryStream.GetBuffer(), 0, _DocMemoryStream.GetBuffer().Length);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.171019.1 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100