Click here to Skip to main content
11,799,426 members (74,043 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# ASP.NET IIS itextsharp

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
Sergey Alexandrovich Kryukov at 6-Feb-13 11:08am
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
0 OriginalGriff 473
1 CPallini 410
2 Richard MacCutchan 319
3 phil.o 244
4 Kornfeld Eliyahu Peter 205
0 OriginalGriff 2,475
1 Maciej Los 1,860
2 KrunalRohit 1,496
3 CPallini 1,465
4 Richard MacCutchan 1,149

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 6 Feb 2013
Copyright © CodeProject, 1999-2015
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