├── .gitattributes ├── .gitignore ├── Readme.md ├── WpfPdfUnblocker.sln ├── WpfPdfUnblocker ├── App.config ├── Application.xaml ├── Application.xaml.vb ├── Artboard.png ├── Artboard.svg ├── Class1.vb ├── Group.svg ├── MainWindow.xaml ├── MainWindow.xaml.vb ├── My Project │ ├── AssemblyInfo.vb │ ├── MyExtensions │ │ └── MyWpfExtension.vb │ ├── Resources.Designer.vb │ ├── Resources.resx │ ├── Settings.Designer.vb │ └── Settings.settings ├── PDFUnlocker.dll ├── PDFUnlocker.dll.config ├── Untitled.sketch ├── Window1.xaml ├── Window1.xaml.vb ├── WpfPdfUnblocker.vbproj ├── icons8_pdf.ico ├── logo.png ├── logo.psd ├── packages.config └── 项目2.ico ├── screenshot.png └── screenshot1.png /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Oo]ut/ 33 | [Ll]og/ 34 | [Ll]ogs/ 35 | 36 | # Visual Studio 2015/2017 cache/options directory 37 | .vs/ 38 | # Uncomment if you have tasks that create the project's static files in wwwroot 39 | #wwwroot/ 40 | 41 | # Visual Studio 2017 auto generated files 42 | Generated\ Files/ 43 | 44 | # MSTest test Results 45 | [Tt]est[Rr]esult*/ 46 | [Bb]uild[Ll]og.* 47 | 48 | # NUnit 49 | *.VisualState.xml 50 | TestResult.xml 51 | nunit-*.xml 52 | 53 | # Build Results of an ATL Project 54 | [Dd]ebugPS/ 55 | [Rr]eleasePS/ 56 | dlldata.c 57 | 58 | # Benchmark Results 59 | BenchmarkDotNet.Artifacts/ 60 | 61 | # .NET Core 62 | project.lock.json 63 | project.fragment.lock.json 64 | artifacts/ 65 | 66 | # ASP.NET Scaffolding 67 | ScaffoldingReadMe.txt 68 | 69 | # StyleCop 70 | StyleCopReport.xml 71 | 72 | # Files built by Visual Studio 73 | *_i.c 74 | *_p.c 75 | *_h.h 76 | *.ilk 77 | *.meta 78 | *.obj 79 | *.iobj 80 | *.pch 81 | *.pdb 82 | *.ipdb 83 | *.pgc 84 | *.pgd 85 | *.rsp 86 | *.sbr 87 | *.tlb 88 | *.tli 89 | *.tlh 90 | *.tmp 91 | *.tmp_proj 92 | *_wpftmp.csproj 93 | *.log 94 | *.vspscc 95 | *.vssscc 96 | .builds 97 | *.pidb 98 | *.svclog 99 | *.scc 100 | 101 | # Chutzpah Test files 102 | _Chutzpah* 103 | 104 | # Visual C++ cache files 105 | ipch/ 106 | *.aps 107 | *.ncb 108 | *.opendb 109 | *.opensdf 110 | *.sdf 111 | *.cachefile 112 | *.VC.db 113 | *.VC.VC.opendb 114 | 115 | # Visual Studio profiler 116 | *.psess 117 | *.vsp 118 | *.vspx 119 | *.sap 120 | 121 | # Visual Studio Trace Files 122 | *.e2e 123 | 124 | # TFS 2012 Local Workspace 125 | $tf/ 126 | 127 | # Guidance Automation Toolkit 128 | *.gpState 129 | 130 | # ReSharper is a .NET coding add-in 131 | _ReSharper*/ 132 | *.[Rr]e[Ss]harper 133 | *.DotSettings.user 134 | 135 | # TeamCity is a build add-in 136 | _TeamCity* 137 | 138 | # DotCover is a Code Coverage Tool 139 | *.dotCover 140 | 141 | # AxoCover is a Code Coverage Tool 142 | .axoCover/* 143 | !.axoCover/settings.json 144 | 145 | # Coverlet is a free, cross platform Code Coverage Tool 146 | coverage*.json 147 | coverage*.xml 148 | coverage*.info 149 | 150 | # Visual Studio code coverage results 151 | *.coverage 152 | *.coveragexml 153 | 154 | # NCrunch 155 | _NCrunch_* 156 | .*crunch*.local.xml 157 | nCrunchTemp_* 158 | 159 | # MightyMoose 160 | *.mm.* 161 | AutoTest.Net/ 162 | 163 | # Web workbench (sass) 164 | .sass-cache/ 165 | 166 | # Installshield output folder 167 | [Ee]xpress/ 168 | 169 | # DocProject is a documentation generator add-in 170 | DocProject/buildhelp/ 171 | DocProject/Help/*.HxT 172 | DocProject/Help/*.HxC 173 | DocProject/Help/*.hhc 174 | DocProject/Help/*.hhk 175 | DocProject/Help/*.hhp 176 | DocProject/Help/Html2 177 | DocProject/Help/html 178 | 179 | # Click-Once directory 180 | publish/ 181 | 182 | # Publish Web Output 183 | *.[Pp]ublish.xml 184 | *.azurePubxml 185 | # Note: Comment the next line if you want to checkin your web deploy settings, 186 | # but database connection strings (with potential passwords) will be unencrypted 187 | *.pubxml 188 | *.publishproj 189 | 190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 191 | # checkin your Azure Web App publish settings, but sensitive information contained 192 | # in these scripts will be unencrypted 193 | PublishScripts/ 194 | 195 | # NuGet Packages 196 | *.nupkg 197 | # NuGet Symbol Packages 198 | *.snupkg 199 | # The packages folder can be ignored because of Package Restore 200 | **/[Pp]ackages/* 201 | # except build/, which is used as an MSBuild target. 202 | !**/[Pp]ackages/build/ 203 | # Uncomment if necessary however generally it will be regenerated when needed 204 | #!**/[Pp]ackages/repositories.config 205 | # NuGet v3's project.json files produces more ignorable files 206 | *.nuget.props 207 | *.nuget.targets 208 | 209 | # Microsoft Azure Build Output 210 | csx/ 211 | *.build.csdef 212 | 213 | # Microsoft Azure Emulator 214 | ecf/ 215 | rcf/ 216 | 217 | # Windows Store app package directories and files 218 | AppPackages/ 219 | BundleArtifacts/ 220 | Package.StoreAssociation.xml 221 | _pkginfo.txt 222 | *.appx 223 | *.appxbundle 224 | *.appxupload 225 | 226 | # Visual Studio cache files 227 | # files ending in .cache can be ignored 228 | *.[Cc]ache 229 | # but keep track of directories ending in .cache 230 | !?*.[Cc]ache/ 231 | 232 | # Others 233 | ClientBin/ 234 | ~$* 235 | *~ 236 | *.dbmdl 237 | *.dbproj.schemaview 238 | *.jfm 239 | *.pfx 240 | *.publishsettings 241 | orleans.codegen.cs 242 | 243 | # Including strong name files can present a security risk 244 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 245 | #*.snk 246 | 247 | # Since there are multiple workflows, uncomment next line to ignore bower_components 248 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 249 | #bower_components/ 250 | 251 | # RIA/Silverlight projects 252 | Generated_Code/ 253 | 254 | # Backup & report files from converting an old project file 255 | # to a newer Visual Studio version. Backup files are not needed, 256 | # because we have git ;-) 257 | _UpgradeReport_Files/ 258 | Backup*/ 259 | UpgradeLog*.XML 260 | UpgradeLog*.htm 261 | ServiceFabricBackup/ 262 | *.rptproj.bak 263 | 264 | # SQL Server files 265 | *.mdf 266 | *.ldf 267 | *.ndf 268 | 269 | # Business Intelligence projects 270 | *.rdl.data 271 | *.bim.layout 272 | *.bim_*.settings 273 | *.rptproj.rsuser 274 | *- [Bb]ackup.rdl 275 | *- [Bb]ackup ([0-9]).rdl 276 | *- [Bb]ackup ([0-9][0-9]).rdl 277 | 278 | # Microsoft Fakes 279 | FakesAssemblies/ 280 | 281 | # GhostDoc plugin setting file 282 | *.GhostDoc.xml 283 | 284 | # Node.js Tools for Visual Studio 285 | .ntvs_analysis.dat 286 | node_modules/ 287 | 288 | # Visual Studio 6 build log 289 | *.plg 290 | 291 | # Visual Studio 6 workspace options file 292 | *.opt 293 | 294 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 295 | *.vbw 296 | 297 | # Visual Studio LightSwitch build output 298 | **/*.HTMLClient/GeneratedArtifacts 299 | **/*.DesktopClient/GeneratedArtifacts 300 | **/*.DesktopClient/ModelManifest.xml 301 | **/*.Server/GeneratedArtifacts 302 | **/*.Server/ModelManifest.xml 303 | _Pvt_Extensions 304 | 305 | # Paket dependency manager 306 | .paket/paket.exe 307 | paket-files/ 308 | 309 | # FAKE - F# Make 310 | .fake/ 311 | 312 | # CodeRush personal settings 313 | .cr/personal 314 | 315 | # Python Tools for Visual Studio (PTVS) 316 | __pycache__/ 317 | *.pyc 318 | 319 | # Cake - Uncomment if you are using it 320 | # tools/** 321 | # !tools/packages.config 322 | 323 | # Tabs Studio 324 | *.tss 325 | 326 | # Telerik's JustMock configuration file 327 | *.jmconfig 328 | 329 | # BizTalk build output 330 | *.btp.cs 331 | *.btm.cs 332 | *.odx.cs 333 | *.xsd.cs 334 | 335 | # OpenCover UI analysis results 336 | OpenCover/ 337 | 338 | # Azure Stream Analytics local run output 339 | ASALocalRun/ 340 | 341 | # MSBuild Binary and Structured Log 342 | *.binlog 343 | 344 | # NVidia Nsight GPU debugger configuration file 345 | *.nvuser 346 | 347 | # MFractors (Xamarin productivity tool) working folder 348 | .mfractor/ 349 | 350 | # Local History for Visual Studio 351 | .localhistory/ 352 | 353 | # BeatPulse healthcheck temp database 354 | healthchecksdb 355 | 356 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 357 | MigrationBackup/ 358 | 359 | # Ionide (cross platform F# VS Code tools) working folder 360 | .ionide/ 361 | 362 | # Fody - auto-generated XML schema 363 | FodyWeavers.xsd -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # PdfUnlocker PDF解锁小工具 2 | 3 | ![](https://github.com/1357310795/WpfPdfUnlocker/raw/master/screenshot.png) 4 | 5 | # 适用情况 6 | 被密码锁定的pdf文档(尤其是允许打开的) 7 | ![](https://github.com/1357310795/WpfPdfUnlocker/raw/master/screenshot1.png) -------------------------------------------------------------------------------- /WpfPdfUnblocker.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31019.35 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "WpfPdfUnblocker", "WpfPdfUnblocker\WpfPdfUnblocker.vbproj", "{3E7EDD53-0BE7-4467-B58C-10ACABC864A9}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {3E7EDD53-0BE7-4467-B58C-10ACABC864A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {3E7EDD53-0BE7-4467-B58C-10ACABC864A9}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {3E7EDD53-0BE7-4467-B58C-10ACABC864A9}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {3E7EDD53-0BE7-4467-B58C-10ACABC864A9}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {B5279763-68BB-4F2E-A021-F8C9CA084400} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/App.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/Application.xaml: -------------------------------------------------------------------------------- 1 |  6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/Application.xaml.vb: -------------------------------------------------------------------------------- 1 | Class Application 2 | 3 | ' 应用程序级事件(例如 Startup、Exit 和 DispatcherUnhandledException) 4 | ' 可以在此文件中进行处理。 5 | 6 | End Class 7 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/Artboard.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1357310795/WpfPdfUnlocker/f6ab622461596e35530875155965c4c86379124d/WpfPdfUnblocker/Artboard.png -------------------------------------------------------------------------------- /WpfPdfUnblocker/Artboard.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Lunacy 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/Class1.vb: -------------------------------------------------------------------------------- 1 | Imports System.IO 2 | Imports System.Text 3 | Imports iTextSharp.text 4 | Imports iTextSharp.text.pdf 5 | 6 | Public Class Class1 7 | Public Shared Function removeByITextSharp(s As String, t As String, ByRef err As String) As Boolean 8 | Dim result As Boolean 9 | Try 10 | Dim flag As Boolean = False 11 | Dim document As Document = Nothing 12 | Dim pdfWriter As PdfWriter = Nothing 13 | Dim pdfReader As PdfReader = Nothing 14 | pdfReader = New PdfReader(s) 15 | Dim pageSize As Rectangle = pdfReader.GetPageSize(1) 16 | document = New Document(pageSize) 17 | pdfWriter = PdfWriter.GetInstance(document, New FileStream(t, FileMode.Create)) 18 | 19 | If pdfReader IsNot Nothing Then 20 | document.Open() 21 | Dim directContent As PdfContentByte = pdfWriter.DirectContent 22 | For i As Integer = 1 To pdfReader.NumberOfPages 23 | document.SetPageSize(pdfReader.GetPageSizeWithRotation(i)) 24 | document.NewPage() 25 | Dim importedPage As PdfImportedPage = pdfWriter.GetImportedPage(pdfReader, i) 26 | Dim pageRotation As Integer = pdfReader.GetPageRotation(i) 27 | pdfReader.GetPageSizeWithRotation(i) 28 | If pageRotation = 270 Then 29 | directContent.AddTemplate(importedPage, 0F, 1.0F, -1.0F, 0F, pdfReader.GetPageSizeWithRotation(i).Width, 0F) 30 | ElseIf pageRotation = 90 Then 31 | directContent.AddTemplate(importedPage, 0F, -1.0F, 1.0F, 0F, 0F, pdfReader.GetPageSizeWithRotation(i).Height) 32 | ElseIf pageRotation = 180 Then 33 | directContent.AddTemplate(importedPage, -1.0F, 0F, 0F, -1.0F, pdfReader.GetPageSizeWithRotation(i).Width, pdfReader.GetPageSizeWithRotation(i).Height) 34 | Else 35 | directContent.AddTemplate(importedPage, 1.0F, 0F, 0F, 1.0F, 0F, 0F) 36 | End If 37 | Next 38 | document.Close() 39 | flag = True 40 | End If 41 | result = flag 42 | Catch ex2 As Exception 43 | err = ex2.Message 44 | result = False 45 | End Try 46 | Return result 47 | End Function 48 | Public Shared Function removeByITextSharpWithPass(s As String, t As String, pass As String, ByRef err As String) As Boolean 49 | Dim result As Boolean 50 | Try 51 | Dim flag As Boolean = False 52 | Dim document As Document = Nothing 53 | Dim pdfWriter As PdfWriter = Nothing 54 | Dim pdfReader As PdfReader = Nothing 55 | 56 | Dim bytes As Byte() = Encoding.ASCII.GetBytes(pass) 57 | pdfReader = New PdfReader(s, bytes) 58 | Dim pageSize2 As Rectangle = pdfReader.GetPageSize(1) 59 | document = New Document(pageSize2) 60 | pdfWriter = PdfWriter.GetInstance(document, New FileStream(t, FileMode.Create)) 61 | Dim permissions As Integer = pdfReader.Permissions 62 | 63 | If pdfReader IsNot Nothing Then 64 | document.Open() 65 | Dim directContent As PdfContentByte = pdfWriter.DirectContent 66 | For i As Integer = 1 To pdfReader.NumberOfPages 67 | document.SetPageSize(pdfReader.GetPageSizeWithRotation(i)) 68 | document.NewPage() 69 | Dim importedPage As PdfImportedPage = pdfWriter.GetImportedPage(pdfReader, i) 70 | Dim pageRotation As Integer = pdfReader.GetPageRotation(i) 71 | pdfReader.GetPageSizeWithRotation(i) 72 | If pageRotation = 270 Then 73 | directContent.AddTemplate(importedPage, 0F, 1.0F, -1.0F, 0F, pdfReader.GetPageSizeWithRotation(i).Width, 0F) 74 | ElseIf pageRotation = 90 Then 75 | directContent.AddTemplate(importedPage, 0F, -1.0F, 1.0F, 0F, 0F, pdfReader.GetPageSizeWithRotation(i).Height) 76 | ElseIf pageRotation = 180 Then 77 | directContent.AddTemplate(importedPage, -1.0F, 0F, 0F, -1.0F, pdfReader.GetPageSizeWithRotation(i).Width, pdfReader.GetPageSizeWithRotation(i).Height) 78 | Else 79 | directContent.AddTemplate(importedPage, 1.0F, 0F, 0F, 1.0F, 0F, 0F) 80 | End If 81 | Next 82 | document.Close() 83 | flag = True 84 | End If 85 | result = flag 86 | Catch ex2 As Exception 87 | err = ex2.Message 88 | result = False 89 | End Try 90 | Return result 91 | End Function 92 | 93 | End Class 94 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/Group.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | Created with Lunacy 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/MainWindow.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 19 | 21 | 输入文件: 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 输出前缀: 36 | Unlock - 37 | 输出后缀: 38 | 39 | 40 | 41 | 42 | 43 | 等待解锁 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/MainWindow.xaml.vb: -------------------------------------------------------------------------------- 1 | Imports System.ComponentModel 2 | Imports System.IO 3 | Imports Microsoft.Win32 4 | 5 | Class MainWindow 6 | Public Class pdfunlock 7 | Implements INotifyPropertyChanged 8 | Public statein As String 9 | Public Property state As String 10 | Get 11 | Return Me.statein 12 | End Get 13 | Set(value As String) 14 | Me.statein = value 15 | Me.OnPropertyChanged(New PropertyChangedEventArgs("state")) 16 | End Set 17 | End Property 18 | Public Property path As String 19 | Public Sub New(i As String, j As String) 20 | Me.statein = i 21 | Me.path = j 22 | End Sub 23 | 24 | Public Event PropertyChanged(ByVal sender As Object, ByVal e As PropertyChangedEventArgs) Implements INotifyPropertyChanged.PropertyChanged 25 | 26 | Public Sub OnPropertyChanged(e As PropertyChangedEventArgs) 27 | RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("state")) 28 | End Sub 29 | 30 | End Class 31 | 32 | Dim x1, x2 As List(Of String) 33 | Dim displayArray As BindingList(Of pdfunlock) = New BindingList(Of pdfunlock) 34 | Private Sub Window_Loaded(sender As Object, e As RoutedEventArgs) 35 | 'Class1.removeByITextSharp("H:\文档\!2020猿辅导系列图书pdf\化学\高中化学——猿题库——小猿热搜——化学实验典型题100.pdf", 36 | '"H:\文档\!2020猿辅导系列图书pdf\化学\cs.pdf") 37 | List1.ItemsSource = displayArray 38 | Gridview1.Columns(0).Width = 100 39 | Gridview1.Columns(0).Width = Double.NaN 40 | End Sub 41 | 42 | Private Sub Init_Clicked(sender As Object, e As RoutedEventArgs) 43 | Dim openFileDialog As OpenFileDialog = New OpenFileDialog() 44 | openFileDialog.AddExtension = True 45 | openFileDialog.CheckFileExists = True 46 | openFileDialog.CheckPathExists = True 47 | openFileDialog.DefaultExt = "*.pdf" 48 | openFileDialog.Filter = "Acrobat PDF Files (*.pdf)|*.pdf|All files(*.*)|*.*" 49 | openFileDialog.Multiselect = True 50 | If openFileDialog.ShowDialog() Then 51 | For Each i In openFileDialog.FileNames() 52 | displayArray.Add(New pdfunlock("等待解锁", i)) 53 | Next 54 | End If 55 | End Sub 56 | 57 | Private Sub Go_Clicked(sender As Object, e As RoutedEventArgs) 58 | For Each i In displayArray 59 | i.state = "等待解锁" 60 | Next 61 | x1 = New List(Of String) 62 | x2 = New List(Of String) 63 | For Each s As pdfunlock In List1.Items 64 | Dim t As FileInfo = New FileInfo(s.path) 65 | Dim n = t.Name.Replace(t.Extension, "") 66 | Dim o = t.DirectoryName & "\" & t1.Text & n & t2.Text & t.Extension 67 | Console.WriteLine(o) 68 | x1.Add(s.path) 69 | x2.Add(o) 70 | Next 71 | gobutton.IsEnabled = False 72 | progtext.Text = "解锁完成:0/" & x1.Count 73 | 'prog.Visibility = Visibility.Visible 74 | Dim th As New Threading.Thread(AddressOf doit) 75 | th.Start() 76 | End Sub 77 | 78 | Public Delegate Function D2(s As String) As String 79 | Private Sub doit() 80 | For i = 0 To x1.Count - 1 81 | Dim err As String = "" 82 | Dim f As Boolean = Class1.removeByITextSharp(x1(i), x2(i), err) 83 | If Not f And err.ToUpper.Contains("PASSWORD") Then 84 | Dim num As Integer = 0 85 | 86 | Dim delegate2 As D2 = New D2(AddressOf getpassword) 87 | Dim result As String = Me.Dispatcher.Invoke(delegate2, {x1(i)}) 88 | 89 | If Class1.removeByITextSharpWithPass(x1(i), x2(i), result, err) Then 90 | f = True 91 | End If 92 | End If 93 | Me.Dispatcher.Invoke(New Action(Of Int32, Boolean, String)(AddressOf AfterEach), {i, f, err}) 94 | Next 95 | Me.Dispatcher.Invoke(AddressOf AfterAll) 96 | End Sub 97 | 98 | 99 | Public Function getpassword(s As String) As String 100 | Dim frmPassword As Window1 = New Window1() 101 | frmPassword.text1.Text = "请输入文件 " & s & " 的密码" 102 | frmPassword.ShowDialog() 103 | Return frmPassword.pass1.Text 104 | End Function 105 | 106 | Private Sub Del_Clicked(sender As Object, e As RoutedEventArgs) 107 | Dim t As List(Of pdfunlock) = New List(Of pdfunlock) 108 | For Each i As pdfunlock In List1.SelectedItems 109 | t.Add(i) 110 | Next 111 | For Each i As pdfunlock In t 112 | displayArray.Remove(i) 113 | Next 114 | End Sub 115 | 116 | Private Sub DelAll_Clicked(sender As Object, e As RoutedEventArgs) 117 | displayArray.Clear() 118 | End Sub 119 | 120 | Private Sub Open_Clicked(sender As Object, e As RoutedEventArgs) 121 | If List1.SelectedItems.Count <> 1 Then 122 | MessageBox.Show("请只选择一个项", "", MessageBoxButton.OK, MessageBoxImage.Information) 123 | Return 124 | End If 125 | Process.Start(TryCast(List1.SelectedItem, pdfunlock).path) 126 | End Sub 127 | 128 | Private Sub OpenFolder_Clicked(sender As Object, e As RoutedEventArgs) 129 | If List1.SelectedItems.Count <> 1 Then 130 | MessageBox.Show("请只选择一个项", "", MessageBoxButton.OK, MessageBoxImage.Information) 131 | Return 132 | End If 133 | Dim t As FileInfo = New FileInfo(TryCast(List1.SelectedItem, pdfunlock).path) 134 | Process.Start("explorer", "/select," & t.FullName) 135 | 'MessageBox.Show("/select," & t.FullName) 136 | End Sub 137 | 138 | Private Sub AfterEach(i As Int32, f As Boolean, err As String) 139 | If f Then 140 | TryCast(displayArray(i), pdfunlock).state = "解锁成功" 141 | Gridview1.Columns(0).Width = 100 142 | Gridview1.Columns(0).Width = Double.NaN 143 | Else 144 | TryCast(displayArray(i), pdfunlock).state = "解锁失败:" & err 145 | Gridview1.Columns(0).Width = 100 146 | Gridview1.Columns(0).Width = Double.NaN 147 | End If 148 | progbar.Value = (i + 1) / x1.Count 149 | progtext.Text = "解锁完成:" & (i + 1) & "/" & x1.Count 150 | End Sub 151 | 152 | Private Sub Image_MouseDown(sender As Object, e As MouseButtonEventArgs) 153 | Process.Start("https://github.com/1357310795/WpfPdfUnblocker") 154 | End Sub 155 | 156 | Private Sub AfterAll() 157 | gobutton.IsEnabled = True 158 | progbar.Value = 0 159 | progtext.Text = "完毕!" 160 | End Sub 161 | End Class 162 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/My Project/AssemblyInfo.vb: -------------------------------------------------------------------------------- 1 | Imports System 2 | Imports System.Globalization 3 | Imports System.Reflection 4 | Imports System.Resources 5 | Imports System.Runtime.InteropServices 6 | Imports System.Windows 7 | 8 | ' 有关程序集的一般信息由以下 9 | ' 控制。更改这些特性值可修改 10 | ' 与程序集关联的信息。 11 | 12 | '查看程序集特性的值 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | '若要开始生成可本地化的应用程序,请设置 23 | '在您的 .vbproj 文件中的 内设置 CultureYouAreCodingWith。 24 | '例如,如果您在源文件中使用的是美国英语, 25 | '请将 设置为“en-US”。 然后取消下面对 26 | 'NeutralResourceLanguage 特性的注释。 更新下面行中的“en-US” 27 | '以与项目文件中的 UICulture 设置匹配。 28 | 29 | ' 30 | 31 | 32 | 'ThemeInfo 特性说明在何处可以找到任何特定于主题的和一般性的资源词典。 33 | '第一个参数: 特定于主题的资源词典的位置 34 | '(未在页面中找到资源时使用, 35 | '或应用程序资源字典中找到时使用) 36 | 37 | '第二个参数: 一般性资源词典的位置 38 | '(未在页面中找到资源时使用, 39 | '资源词典中找到资源时使用) 40 | 41 | 42 | 43 | 44 | '如果此项目向 COM 公开,则下列 GUID 用于 typelib 的 ID 45 | 46 | 47 | ' 程序集的版本信息由下列四个值组成: 48 | ' 49 | ' 主版本 50 | ' 次版本 51 | ' 生成号 52 | ' 修订号 53 | ' 54 | '可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 55 | '通过使用 "*",如下所示: 56 | ' 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/My Project/MyExtensions/MyWpfExtension.vb: -------------------------------------------------------------------------------- 1 | #If _MyType <> "Empty" Then 2 | 3 | Namespace My 4 | ''' 5 | ''' 用于定义“我的 WPF 命名空间”中的可用属性的模块 6 | ''' 7 | ''' 8 | _ 9 | Module MyWpfExtension 10 | Private s_Computer As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Devices.Computer) 11 | Private s_User As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.ApplicationServices.User) 12 | Private s_Windows As New ThreadSafeObjectProvider(Of MyWindows) 13 | Private s_Log As New ThreadSafeObjectProvider(Of Global.Microsoft.VisualBasic.Logging.Log) 14 | ''' 15 | ''' 返回正在运行的应用程序的应用程序对象 16 | ''' 17 | _ 18 | Friend ReadOnly Property Application() As Application 19 | Get 20 | Return CType(Global.System.Windows.Application.Current, Application) 21 | End Get 22 | End Property 23 | ''' 24 | ''' 返回有关主机计算机的信息。 25 | ''' 26 | _ 27 | Friend ReadOnly Property Computer() As Global.Microsoft.VisualBasic.Devices.Computer 28 | Get 29 | Return s_Computer.GetInstance() 30 | End Get 31 | End Property 32 | ''' 33 | ''' 返回当前用户的信息。 如果希望使用当前的 34 | ''' Windows 用户凭据来运行应用程序,请调用 My.User.InitializeWithWindowsUser()。 35 | ''' 36 | _ 37 | Friend ReadOnly Property User() As Global.Microsoft.VisualBasic.ApplicationServices.User 38 | Get 39 | Return s_User.GetInstance() 40 | End Get 41 | End Property 42 | ''' 43 | ''' 返回应用程序日志。可以使用应用程序的配置文件配置侦听器。 44 | ''' 45 | _ 46 | Friend ReadOnly Property Log() As Global.Microsoft.VisualBasic.Logging.Log 47 | Get 48 | Return s_Log.GetInstance() 49 | End Get 50 | End Property 51 | 52 | ''' 53 | ''' 返回项目中定义的 Windows 集合。 54 | ''' 55 | _ 56 | Friend ReadOnly Property Windows() As MyWindows 57 | _ 58 | Get 59 | Return s_Windows.GetInstance() 60 | End Get 61 | End Property 62 | _ 63 | _ 64 | Friend NotInheritable Class MyWindows 65 | _ 66 | Private Shared Function Create__Instance__(Of T As {New, Global.System.Windows.Window})(ByVal Instance As T) As T 67 | If Instance Is Nothing Then 68 | If s_WindowBeingCreated IsNot Nothing Then 69 | If s_WindowBeingCreated.ContainsKey(GetType(T)) = True Then 70 | Throw New Global.System.InvalidOperationException("The window cannot be accessed via My.Windows from the Window constructor.") 71 | End If 72 | Else 73 | s_WindowBeingCreated = New Global.System.Collections.Hashtable() 74 | End If 75 | s_WindowBeingCreated.Add(GetType(T), Nothing) 76 | Return New T() 77 | s_WindowBeingCreated.Remove(GetType(T)) 78 | Else 79 | Return Instance 80 | End If 81 | End Function 82 | _ 83 | _ 84 | Private Sub Dispose__Instance__(Of T As Global.System.Windows.Window)(ByRef instance As T) 85 | instance = Nothing 86 | End Sub 87 | _ 88 | _ 89 | Public Sub New() 90 | MyBase.New() 91 | End Sub 92 | Private Shared s_WindowBeingCreated As Global.System.Collections.Hashtable 93 | Public Overrides Function Equals(ByVal o As Object) As Boolean 94 | Return MyBase.Equals(o) 95 | End Function 96 | Public Overrides Function GetHashCode() As Integer 97 | Return MyBase.GetHashCode 98 | End Function 99 | _ 100 | _ 101 | Friend Overloads Function [GetType]() As Global.System.Type 102 | Return GetType(MyWindows) 103 | End Function 104 | Public Overrides Function ToString() As String 105 | Return MyBase.ToString 106 | End Function 107 | End Class 108 | End Module 109 | End Namespace 110 | Partial Class Application 111 | Inherits Global.System.Windows.Application 112 | _ 113 | _ 114 | Friend ReadOnly Property Info() As Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo 115 | _ 116 | Get 117 | Return New Global.Microsoft.VisualBasic.ApplicationServices.AssemblyInfo(Global.System.Reflection.Assembly.GetExecutingAssembly()) 118 | End Get 119 | End Property 120 | End Class 121 | #End If -------------------------------------------------------------------------------- /WpfPdfUnblocker/My Project/Resources.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:$clrversion$ 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | 15 | Namespace My.Resources 16 | 17 | 'This class was auto-generated by the StronglyTypedResourceBuilder 18 | 'class via a tool like ResGen or Visual Studio. 19 | 'To add or remove a member, edit your .ResX file then rerun ResGen 20 | 'with the /str option, or rebuild your VS project. 21 | ''' 22 | ''' A strongly-typed resource class, for looking up localized strings, etc. 23 | ''' 24 | _ 28 | Friend Module Resources 29 | 30 | Private resourceMan As Global.System.Resources.ResourceManager 31 | 32 | Private resourceCulture As Global.System.Globalization.CultureInfo 33 | 34 | ''' 35 | ''' Returns the cached ResourceManager instance used by this class. 36 | ''' 37 | _ 38 | Friend ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager 39 | Get 40 | If Object.ReferenceEquals(resourceMan, Nothing) Then 41 | Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("$safeprojectname$.Resources", GetType(Resources).Assembly) 42 | resourceMan = temp 43 | End If 44 | Return resourceMan 45 | End Get 46 | End Property 47 | 48 | ''' 49 | ''' Overrides the current thread's CurrentUICulture property for all 50 | ''' resource lookups using this strongly typed resource class. 51 | ''' 52 | _ 53 | Friend Property Culture() As Global.System.Globalization.CultureInfo 54 | Get 55 | Return resourceCulture 56 | End Get 57 | Set(ByVal value As Global.System.Globalization.CultureInfo) 58 | resourceCulture = value 59 | End Set 60 | End Property 61 | End Module 62 | End Namespace 63 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/My Project/Resources.resx: -------------------------------------------------------------------------------- 1 |  2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | text/microsoft-resx 107 | 108 | 109 | 2.0 110 | 111 | 112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 113 | 114 | 115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/My Project/Settings.Designer.vb: -------------------------------------------------------------------------------- 1 | '------------------------------------------------------------------------------ 2 | ' 3 | ' This code was generated by a tool. 4 | ' Runtime Version:4.0.30319.42000 5 | ' 6 | ' Changes to this file may cause incorrect behavior and will be lost if 7 | ' the code is regenerated. 8 | ' 9 | '------------------------------------------------------------------------------ 10 | 11 | Option Strict On 12 | Option Explicit On 13 | 14 | 15 | Namespace My 16 | 17 | _ 20 | Partial Friend NotInheritable Class MySettings 21 | Inherits Global.System.Configuration.ApplicationSettingsBase 22 | 23 | Private Shared defaultInstance As MySettings = CType(Global.System.Configuration.ApplicationSettingsBase.Synchronized(New MySettings), MySettings) 24 | 25 | #Region "My.Settings Auto-Save Functionality" 26 | #If _MyType = "WindowsForms" Then 27 | Private Shared addedHandler As Boolean 28 | 29 | Private Shared addedHandlerLockObject As New Object 30 | 31 | _ 32 | Private Shared Sub AutoSaveSettings(ByVal sender As Global.System.Object, ByVal e As Global.System.EventArgs) 33 | If My.Application.SaveMySettingsOnExit Then 34 | My.Settings.Save() 35 | End If 36 | End Sub 37 | #End If 38 | #End Region 39 | 40 | Public Shared ReadOnly Property [Default]() As MySettings 41 | Get 42 | 43 | #If _MyType = "WindowsForms" Then 44 | If Not addedHandler Then 45 | SyncLock addedHandlerLockObject 46 | If Not addedHandler Then 47 | AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings 48 | addedHandler = True 49 | End If 50 | End SyncLock 51 | End If 52 | #End If 53 | Return defaultInstance 54 | End Get 55 | End Property 56 | End Class 57 | End Namespace 58 | 59 | Namespace My 60 | 61 | _ 64 | Friend Module MySettingsProperty 65 | 66 | _ 67 | Friend ReadOnly Property Settings() As Global.WpfPdfUnblocker.My.MySettings 68 | Get 69 | Return Global.WpfPdfUnblocker.My.MySettings.Default 70 | End Get 71 | End Property 72 | End Module 73 | End Namespace 74 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/My Project/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/PDFUnlocker.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1357310795/WpfPdfUnlocker/f6ab622461596e35530875155965c4c86379124d/WpfPdfUnblocker/PDFUnlocker.dll -------------------------------------------------------------------------------- /WpfPdfUnblocker/PDFUnlocker.dll.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /WpfPdfUnblocker/Untitled.sketch: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/1357310795/WpfPdfUnlocker/f6ab622461596e35530875155965c4c86379124d/WpfPdfUnblocker/Untitled.sketch -------------------------------------------------------------------------------- /WpfPdfUnblocker/Window1.xaml: -------------------------------------------------------------------------------- 1 |  9 | 10 | 11 | 12 |