Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# PDF
I'm now working with iTextSharp to fill in pdf fields with values. I got it working but everything is based on access from the web. I'm trying to do it via a console app not web responses involved. Below is the code that will open the resulting pdf file from a HttpContext. My question is there an equivalent way to open a pdf for viewing locally without using HttpContext?
 
var response = HttpContext.Current.Response;
 
if (!string.IsNullOrEmpty(attachmentFilename))
    response.AddHeader("Content-Disposition", "attachment; filename=" + attachmentFilename);
 
response.ContentType = "application/pdf";
response.BinaryWrite(contents);
response.End();
Posted 14-Sep-11 5:59am
ehwash838

1 solution

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

Solution 1

Hi
 
If you write this dat pdf file will open in user system pdf reader.User get a msg window with options like "open" ,"save".If user clicks open that file is open in pdf reader.
 
There are somany webcontrols for viewing pdf in webpage locally without showing msg window like as in previous situation.In this case you can just set filepath property of that webcontrol no need to pass your file to user in response object.
 

You've to show pdf in your webpage only like google docs if we click on view link it shows in google docs with editor.
 
Am I right .
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 436
1 Maciej Los 249
2 BillWoodruff 199
3 /\jmot 180
4 Suraj Sahoo | Coding Passion 170
0 OriginalGriff 8,484
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,639
3 Maciej Los 5,159
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 14 Sep 2011
Copyright © CodeProject, 1999-2014
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