Hi, i generate a pdf file from C#(VS2005) via the ReportViewer control .The pdf has a picture and text.
How can i prevent a user to be able to copy text/images from that file.
Here is code i use to create pdf file.

private void CreatePDFfromTXT(string textFile, string pdfFile, string reportFile)
            RichTextBox rch = new RichTextBox();
            rch.Text = new StreamReader(textFile).ReadToEnd();
            Microsoft.Reporting.WinForms.ReportParameter repParm = new Microsoft.Reporting.WinForms.ReportParameter("paramText", rch.Text);//this will put decrypted text file content in report
            Microsoft.Reporting.WinForms.ReportParameter repParm2 = new Microsoft.Reporting.WinForms.ReportParameter("paramLineCount", (rch.Lines.Length - 1).ToString());//this is to count text file lines
            Microsoft.Reporting.WinForms.ReportParameter repParm3 = new Microsoft.Reporting.WinForms.ReportParameter("paramUserLoginName", Main.userLoggedIn);

            ReportViewer repVwr = new ReportViewer();
            repVwr.LocalReport.LoadReportDefinition(new FileStream(reportFile, FileMode.Open));
            repVwr.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter[] { repParm, repParm2, repParm3 });
            string sReportFormatType = "PDF";
            Warning[] warnings;
            string[] streamids;
            string mimeType;
            string encoding;
            string extension = "";
            byte[] bytes = repVwr.LocalReport.Render(
            sReportFormatType, null, out mimeType, out encoding,
            out extension,
            out streamids, out warnings);
            FileStream fs = new FileStream(pdfFile,FileMode.Create);
            fs.Write(bytes, 0, bytes.Length);

Notice the method ...LocalReport.Render(.....
It uses a lot of parameters which are set to null/nothing(maybe changing one of them might help).

Or should i use iTextSharp(but then i won't have ease of use as report viewer , and i'm worried about how well iTextSharp handles cross compatibility :Adobe 7,8,9)


This article has been dead for over six months. Start a new discussion instead.