boutique replica bags up ideas

the best replique rolex and prices here.

julia highlight 99j hair color 10a quality straight human hair lace front wigs 8 - 24 inches pre plucked hairline 13x4 inches lace front brazilian wig onlinefor sale

C# – remove password protection from PDF document

Updated on     Kisan Patel

Problem:
How to remove password protection from PDF document in C#?
How can I remove PDF password in C#?
How to open the password protected pdf using C#?

Solution:

To remove password or open password protected pdf document using C#, you need to use c# PDFsharp library.

Here is the C# example using PDFsharp:

private void GeneratePdf(string InputFile)
{
      PdfDocument maindoc = PdfReader.Open(InputFile, PdfDocumentOpenMode.Import);

      PdfDocument OutputDoc = new PdfDocument();

      foreach (PdfPage page in maindoc.Pages)
      {
            OutputDoc.AddPage(page);
      }

      OutputDoc.Save(folderPath + "\\" + fileName);
      maindoc.Dispose();
      OutputDoc.Dispose();
}

Following C# example will generate pdf with the user password.

private void GeneratePdf(string InputFile)
{
      PdfDocument maindoc = PdfReader.Open(InputFile, "password",PdfDocumentOpenMode.Import);
      //Use the property HasOwnerPermissions to decide whether the used password
      // was the user or the owner password.   
      bool hasOwnerAccess = maindoc.SecuritySettings.HasOwnerPermissions;
      
      PdfDocument OutputDoc = new PdfDocument();

      foreach (PdfPage page in maindoc.Pages)
      {
            OutputDoc.AddPage(page);
      }

      OutputDoc.Save(folderPath + "\\" + fileName);
      maindoc.Dispose();
      OutputDoc.Dispose();
}

Source: http://www.pdfsharp.com/PDFsharp/index.php?option=com_content&task=view&id=39&Itemid=50


C#

Leave a Reply