C# .NET - How we Create Non Editable Pdf Using C#

Asked By ALOK RANJAN on 29-Jan-13 01:44 AM
Hi....Everyone

I need some from you guys. I am getting some pdf files from folder and I have to give that data to end user. That data should not be editable. So how can i achieve this problem.

 pdf format . plz help me it's very urgent for me.


Best Regards

ALOK RANJAN

White Ashlin replied to ALOK RANJAN on 29-Jan-13 02:38 AM
If you want to create non editable PDF, you may encrypt the PDF by setting owner password and user password,owner password have all the right to edit the PDF file, while user password has to subject to the restrictions set by owner password, please see the code in this project:
http://pdf.software.informer.com

or directly go there:

http://www.e-iceblue.com/Knowledgebase/Spire.PDF/Program-Guide/Encrypt-PDF-with-Spire.PDF-for-.NET.html
RAJESH VEMUNOORI replied to ALOK RANJAN on 29-Jan-13 04:12 AM
Hi ALOK,

Please try this in your .cs file...

  Response.ContentType = "application/pdf";
          Response.AddHeader("content-disposition", "attachment;filename= " + Session["UserName"] + "_ProjectReport.pdf");
          Response.Cache.SetCacheability(HttpCacheability.NoCache);
          StringWriter sw = new StringWriter();
          sw.WriteLine("<table align=center><tr><td>" + dgDgrid.Caption + "</td></tr></table>");
          sw.WriteLine("<br /><br />");
          HtmlTextWriter hw = new HtmlTextWriter(sw);
          dgDgrid.RenderControl(hw);
          StringReader sr = new StringReader(sw.ToString());
          Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f);
          HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
          PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
          pdfDoc.Open();
          pdfDoc.AddHeader("Head", "Project Report");
          //iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance(HttpContext.Current.Request.PhysicalApplicationPath + "Images\\Logo.png");
          //pdfDoc.Add(img);
          htmlparser.Parse(sr);
          pdfDoc.Close();
          Response.Write(pdfDoc);
          Response.End();


where dgDgrid is your dataset....



Regards,
Rajesh.
Keating Megan replied to RAJESH VEMUNOORI on 29-Jan-13 08:16 PM
Look at this project ,it must be helpful:

https://pdfapi.codeplex.com