PdfPasswordRemover is a small Windows Forms application that removes the password from a PDF file.
The user picks a PDF, optionally types its user password, and the app writes an unprotected copy to
a second file. The PDF handling itself is not implemented here, it comes from the NuGet package
iTextSharp. The repository ships a GUI application
with an installer, it is not published as a NuGet package: no GeneratePackageOnBuild, no push
script for a package.
One solution src/PdfPasswordRemover.sln with exactly one project:
src/PdfPasswordRemover/PdfPasswordRemover.csproj,OutputTypeWinExe,UseWindowsForms, the whole application.
Layout inside src/PdfPasswordRemover:
Program.cs: the[STAThread]entry point,Application.Run(new Main()).Main.csplusMain.Designer.csandMain.resx: the single form.Main.csholds the logic,Main.Designer.csis generated designer code, do not hand edit it against the designer. The form loads a PDF, and if the password box is empty it brute forces the password, otherwise it removes the given password. It also drives the language combo box and the show/hide password button.RemovePassword.csplusIRemovePassword.cs:CopyPdfopens the PDF with iTextSharp and copies every page into a new, unprotected document. This is the one place that touches iTextSharp.languages/de-DE.xmlandlanguages/en-US.xml: the translation files consumed byHaemmerElectronics.SeppPenner.Language. Both are copied next to the executable (CopyToOutputDirectory=Always).GlobalUsings.cs: all usings of the project.Icon.icoandLicense.txt: the application icon and the license shipped next to the executable.
Repository root: README.md (the only user documentation), Changelog.md, License.txt (MIT),
Screenshot_DE.PNG and Screenshot_EN.PNG (linked from the README), .editorconfig lives under
src, .gitattributes and .gitignore at the root. There is no Updating.md and no
HowToUse.md.
Setup/ holds the Inno Setup script PdfPasswordRemover-Setup.iss, the build helper
build-setup-files.bat and the built installer PdfPasswordRemover-Setup.exe.
dotnet build src/PdfPasswordRemover.slnThere are no unit tests in this repository, so there is nothing to dotnet test. A behaviour
change is verified by running the app and by building the installer, see the last two bullets.
- Single target framework
net10.0-windows, no multi-targeting. The project isWinExewithUseWindowsForms, so it only builds on Windows.RuntimeIdentifiersiswin-x64. - All build properties live directly in
PdfPasswordRemover.csproj. There is noDirectory.Build.propsin this repository. TreatWarningsAsErrorsis enabled, so every warning breaks the build, NuGet warnings (NU****) from restore included. A clean build reports zero warnings, keep it that way.NU1701,NU1703andNU1803are suppressed viaNoWarn(iTextSharp resolves through the .NET Framework compatibility shim, which raisesNU1701). Fix warnings instead of extending that list.NuGetAuditandNuGetAuditMode=allare on, so a vulnerable transitive package fails the build too.- Versions come from GitVersion.MsBuild out of the git tags, for example
1.0.9-1for the first commit after tag1.0.8. Never edit a version property or an assembly version by hand. The form title isApplication.ProductName + " " + Application.ProductVersion, so an untagged build shows a prerelease string likePdfPasswordRemover 1.0.9-1+Branch.master.Sha...in the window caption. - Restore needs nuget.org. If a private feed is configured globally on the machine and answers 404
for public packages, restore fails with
NU1301. Then build with an explicit source:dotnet build src/PdfPasswordRemover.sln --source https://api.nuget.org/v3/index.json. - Running the app: start
PdfPasswordRemover.exefrom the build or publish output. It is a GUI, it writes nothing to stdout, judge a run by the window coming up with the loaded languages, not by console output. - Building the installer:
Setup/build-setup-files.batpublishes self contained tobin/publishand removes the*.pdb, then Inno Setup'sISCC.execompilesSetup/PdfPasswordRemover-Setup.issintoSetup/PdfPasswordRemover-Setup.exe.
Follow the surrounding code, it is consistent throughout every file:
- File header comment block with
<copyright file="..." company="Hämmer Electronics">and a<summary>, then the file-scoped namespace. - XML doc comments on every type and every member, private members included, no exceptions.
Implementations of an interface member additionally carry
<inheritdoc cref="..."/>and<seealso cref="..."/>pointing at that interface. Nullable,ImplicitUsingsandLangVersion latestare enabled.- New
usingdirectives go intoGlobalUsings.cs, inside the existing#pragma warning disable IDE0065block, never at the top of a file. The editorconfig requires usings inside the namespace (csharp_using_directive_placement=inside_namespace:warning), which global usings cannot satisfy, that is what the pragma is for. Do not add other pragmas. The comment text in that block is German because Visual Studio generated it, leave it alone. - Fields, properties, methods and events are always accessed with
this.qualification (dotnet_style_qualification_for_*at severitywarning). src/.editorconfigalso enforces braces everywhere, no multiple blank lines, four spaces, CRLF, UTF-8, file scoped namespaces,Systemusings sorted first andIDE0005as warning. Analyzer warnings are fixed, not silenced.
Do not silently "clean up" these, they are existing behaviour:
- iTextSharp is the iText 5 line, do not "upgrade" to iText7. The package id
iTextSharp(5.5.13.x) is the last iText 5 release. iText 7 is the separate packageitext7with a completely different API.dotnet list package --outdatedwill never suggest the jump because they are different ids, and a switch would rewriteRemovePassword.cs. Stay oniTextSharp. PdfReader.unethicalreading = true.RemovePassword.CopyPdfsets this static flag so iTextSharp opens a PDF that carries an owner password without the owner password. Removing the line makes the app refuse exactly the files it exists to open.- The password is encoded as ASCII.
CopyPdfdoesEncoding.ASCII.GetBytes(userPassword), so a password with non-ASCII characters is mangled before it reaches iTextSharp. Existing behaviour, left as is. - Brute force never reports success. When the password box is empty,
BruteForceUserPasswordwalksBruteforcing(all strings of length 1 to 16 over a large charset) and callsCopyPdffor each candidate inside atrythat swallows every exception. A correct guess simply writes the output file, a wrong one throws and is ignored, and the loop keeps going. There is no progress, no cancel and no "found it" signal, and for a real password it runs effectively forever. This is the original design, do not quietly rewrite it into a real cracker. GetWordreturnsnullfor an unknown key.HaemmerElectronics.SeppPenner.Languagehas no fallback to another language. Every key a call site uses must exist in bothde-DE.xmlanden-US.xml. The error dialog title uses the keyErrorTitle(Fehler/Error), added in version 1.0.9.0 together with the message box fix below.- The error message box had text and title swapped. Up to 1.0.8.0
TryLoadPdfFilecalledMessageBox.Show(ex.StackTrace, ex.Message, ...), so the stack trace was the message and the exception message was the window caption. Since 1.0.9.0 the caption is the localizedErrorTitleand the body is the message followed by the stack trace. Do not swap it back. - The language files are UTF-8 without BOM, tab indented, CRLF. They are edited by hand and read by the language library, keep the tabs and the encoding when you touch them, do not let an editor reformat them to spaces or add a BOM.
- The installer is published self contained.
build-setup-files.batrunsdotnet publish -c Release -r win-x64 --self-contained true. The-r win-x64is required, a bare--self-containedwithout a runtime identifier fails the publish. The resultingruntimeconfig.jsoncarriesincludedFrameworks, so the target machine needs no installed .NET runtime, at the price of a much larger installer. - The
.issis UTF-8 with a BOM. Inno Setup 6 only reads a script as UTF-8 when a BOM is present, otherwise it falls back to the system code page. The script containsHämmer Electronicsand a copyright sign, so the BOM has to stay, do not save it as "UTF-8 without BOM". Keep CRLF. - The installer exe is not tracked, it hangs on the release.
Setup/PdfPasswordRemover-Setup.exewas committed withgit add -fagainst the*.exerule up to and including 1.0.9, one new binary per release. Do not add it back. Icon.icoandLicense.txtexist twice. There is a copy undersrc/(used by the.issasSetupIconFile) and a copy undersrc/PdfPasswordRemover/(the application icon and the license shipped next to the executable). Keep both in sync when either changes.- Badges without CI in the repository.
README.mdlinks an AppVeyor build and a Snyk scan that are configured outside of this repository. There is no.githubfolder and no pipeline file here. src/PdfPasswordRemover.sln.DotSettingsis tracked and holds nothing but a ReSharper user dictionary. Leave it alone..gitattributessets* text=auto, every rule of the Visual Studio template below it is commented out. Any binary file that must not be normalized needs its own explicit rule.
The release order matters, the tag has to sit on the commit that the installer is built from, so that GitVersion burns the plain release version into the shipped exe instead of a prerelease string.
- Make the change and add a
Changelog.mdentry at the top in the existing format:* **Version 1.0.9.0 (2026-08-15)** : Short description. - Bump
MyAppVersioninSetup/PdfPasswordRemover-Setup.issto the same four part version (keep the BOM and CRLF). - Commit those changes.
- Tag that commit with the plain three part version number, no
vprefix (1.0.9,1.0.8, ...). The existing tags are lightweight tags, create new ones the same way. - Run
Setup/build-setup-files.batwhileHEADis the tagged commit, then compile the installer withISCC.exe. The exe now carries the plain version. - Push the commits and the tag.
- Attach
Setup/PdfPasswordRemover-Setup.exeto the GitHub release of that tag. Never commit the installer.Setup/is theOutputDirof the Inno Setup script, so the file lands there during the build and.gitignorecovers it afterwards.
The version in the Changelog.md has four parts (1.0.9.0), the tag has three (1.0.9).
GitVersion turns the tag into the assembly version, so an untagged commit produces something like
1.0.9-1+Branch.master.Sha....
For step 7 there is no gh on this machine. The GitHub API does the job, with the token that
git push already uses, so nothing has to be stored anywhere:
c=$(printf "protocol=https\nhost=github.com\n\n" | git credential fill)
tok=$(printf "%s" "$c" | grep '^password=' | cut -d= -f2-)
id=$(curl -s -X POST -H "Authorization: Bearer $tok" \
https://api.github.com/repos/SeppPenner/PdfPasswordRemover/releases \
-d '{"tag_name":"1.0.10","name":"1.0.10"}' | grep -m1 '"id"' | tr -dc 0-9)
curl -s -X POST -H "Authorization: Bearer $tok" -H "Content-Type: application/octet-stream" \
--data-binary @Setup/PdfPasswordRemover-Setup.exe \
"https://uploads.github.com/repos/SeppPenner/PdfPasswordRemover/releases/$id/assets?name=PdfPasswordRemover-Setup.exe"Never print that token, and never write it into a file.
- Never amend a commit. No
git commit --amend, not for a typo in the message, not to add a forgotten file, not even when the commit is still local. Write a follow-up commit instead. The release versions come from tags on exact commits, an amended commit leaves its tag pointing at a commit that no longer exists in the branch.
- Commit messages are written in English only: short, precise subject line, explanatory body when needed.
- Code comments and comments in project files such as
.csprojare always English, regardless of the language used in the conversation. - No em dashes or en dashes (
—,–), neither in prose, commit messages, code comments nor documentation. Use a regular hyphen, comma, colon, parentheses or a separate sentence. - German texts (documentation, chat replies) always use real umlauts and ß, never ASCII
transliterations such as
ae,oe,ueorss. Identifiers, file names and configuration keys stay unchanged where umlauts are technically undesirable.