Introduction
This tool allows you to remove the "security" from a PDF File. It has not been widely tested, but has worked on any PDF file that was marked Secure that I was able to open without a password.
Why would you want to do this? Many secure PDF files are set so that you can not copy text from them or print them. This can be really frustrating at times, especially when you are studying the material and you want to put together a study sheet, or something to that effect.
Background
A while back, I purchased an exam study guide, which came with a companion CD containing the book in PDF format. Unfortunately, the file was marked as secure, so when I tried to copy out the "Suggested Practices" section from each chapter, I was not able to, nor could I print any of the pieces. This led me to develop this very small application.
Using the code
The tool is very simple. I use the PDFSharp library to read in the original PDF. I then copy each page to a new PDF file and save it.
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
Dim ofd As New OpenFileDialog()
If ofd.ShowDialog() <> Windows.Forms.DialogResult.OK Then
Exit Sub
End If
Dim maindoc As PdfDocument = PdfReader.Open(ofd.OpenFile(), _
PdfDocumentOpenMode.Import)
Dim OutputDoc As PdfDocument = New PdfDocument()
For Each page As PdfPage In maindoc.Pages
OutputDoc.AddPage(page)
Next
Dim sfd As New SaveFileDialog()
If sfd.ShowDialog() <> Windows.Forms.DialogResult.OK Then
maindoc.Dispose()
OutputDoc.Dispose()
Exit Sub
End If
OutputDoc.Save(sfd.OpenFile(), True)
maindoc.Dispose()
OutputDoc.Dispose()
Me.Close()
End Sub
Points of interest
I thought it was funny how easy it was to do this. I expected something a little more complicated, though if it had been, I probably would have just given up on it.
History
- Version 1.0 - Initial release.