PDFsharp & MigraDoc Foundation https://forum.pdfsharp.net/ |
|
Just trying to set Security Permissions https://forum.pdfsharp.net/viewtopic.php?f=2&t=2085 |
Page 1 of 1 |
Author: | cosmokenney [ Thu Jul 12, 2012 10:28 pm ] |
Post subject: | Just trying to set Security Permissions |
I'm simply trying to set SecuritySettings on a PDF (in the form of a byte array) that is returned by the ReportViewer object in Visual Studio 2010. I have verified that the PDF returned by the ReportViewer is a valid two page PDF document. The problem is when I open it with the PdfReader, set the settings and save it, the result is a two page PDF document where both pages are completely blank. With the exception of the MemoryStreams, this is pretty much a verbatim copy of the "Protect Document" example. Any suggestions? Code: byte[] bytes = viewer.LocalReport.Render( "PDF", null, out mimeType, out encoding, out extension, out streamIds, out warnings ); MemoryStream ms = new MemoryStream( bytes ); PdfDocument pdfDoc = PdfReader.Open( ms ); var settings = pdfDoc.SecuritySettings; settings.PermitAssembleDocument = false; settings.PermitExtractContent = false; settings.PermitModifyDocument = false; settings.PermitAccessibilityExtractContent = false; MemoryStream oms = new MemoryStream( ); pdfDoc.Save( oms ); bytes = oms.ToArray( ); page.Response.Buffer = true; page.Response.Clear( ); page.Response.ContentType = mimeType; page.Response.AddHeader( "content-disposition", "inline" //"attachment; filename=" + clientFileName + "." + extension ); page.Response.BinaryWrite( bytes ); page.Response.Flush( ); Thanks. Ken. |
Author: | () => true [ Fri Jul 13, 2012 1:24 pm ] |
Post subject: | Re: Just trying to set Security Permissions |
Can you tell the ReportViewer to create "HumanReadablePDF"? See also: viewtopic.php?p=1613#p1613 viewtopic.php?f=2&t=832 |
Author: | cosmokenney [ Fri Jul 13, 2012 5:02 pm ] |
Post subject: | Re: Just trying to set Security Permissions |
() => true wrote: Can you tell the ReportViewer to create "HumanReadablePDF"? See also: viewtopic.php?p=1613#p1613 viewtopic.php?f=2&t=832 Excellent! That's an easy fix. My bad for not searching the forum for SSRS. I assumed the issue was PDFSharp ![]() So, although this is now producing a readable PDF, it does not effect my ability to copy text. I assume that this is the correct setting to prevent copy: settings.PermitExtractContent = false; settings.PermitAccessibilityExtractContent = false; Any thoughts? Ken. |
Author: | cosmokenney [ Mon Jul 16, 2012 5:52 pm ] |
Post subject: | Re: Just trying to set Security Permissions |
Hi, I'm bumping this, because I really need resolution on it. My deadline quickly approaches. Thanks. |
Author: | () => true [ Tue Jul 17, 2012 8:20 pm ] |
Post subject: | Re: Just trying to set Security Permissions |
cosmokenney wrote: So, although this is now producing a readable PDF, it does not effect my ability to copy text. I assume that this is the correct setting to prevent copy: Looks good. IIRC you have to set an Owner password to make this work.settings.PermitExtractContent = false; settings.PermitAccessibilityExtractContent = false; Any thoughts? Do not set a User password if you want to enable users to open the file without entering a password. |
Author: | cosmokenney [ Sat Jul 21, 2012 4:53 pm ] |
Post subject: | Re: Just trying to set Security Permissions |
() => true wrote: cosmokenney wrote: So, although this is now producing a readable PDF, it does not effect my ability to copy text. I assume that this is the correct setting to prevent copy: Looks good. IIRC you have to set an Owner password to make this work.settings.PermitExtractContent = false; settings.PermitAccessibilityExtractContent = false; Any thoughts? Do not set a User password if you want to enable users to open the file without entering a password. Yes, Owner Password did the trick. Thanks. |
Page 1 of 1 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |