Initial commit
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
.venv
|
||||
__pycache__
|
||||
dist
|
||||
pdfuck.egg-info
|
||||
@@ -0,0 +1,70 @@
|
||||

|
||||
|
||||
[简体中文](README.md) | [**English**](README.en.md)
|
||||
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
[PDFuck](https://github.com/mmdjiji/pdfuck) is a tool to remove PDF editing password, which is used in CLI (command line) mode.
|
||||
|
||||
## Installation
|
||||
|
||||
Before installing, please ensure that you have installed Python (>=3.0) and its matching version of pip, and then enter the following command at the command prompt:
|
||||
|
||||
```bash
|
||||
pip install pdfuck
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Remove PDF password
|
||||
|
||||
For example, if you want to remove the password from the PDF file which is located in `example.pdf`, just enter the following command:
|
||||
|
||||
```bash
|
||||
pdfuck example.pdf
|
||||
```
|
||||
|
||||
The default path of the output file is `example.fucked.pdf`.
|
||||
|
||||
### Manually specify the output file path
|
||||
|
||||
If you want to specify the path of the output file manually, you can use the `-o` parameter, for example:
|
||||
|
||||
```bash
|
||||
pdfuck example.pdf -o target.pdf
|
||||
```
|
||||
|
||||
### PDF file requires opening password
|
||||
|
||||
Use the `-p` parameter to manually specify the opening password, for example:
|
||||
|
||||
```bash
|
||||
pdfuck example.pdf -p password
|
||||
```
|
||||
|
||||
## Credit
|
||||
|
||||
Thanks for the following open source projects. The completion of this project is inseparable from the code contributed by these authors.
|
||||
|
||||
* [pikepdf](https://github.com/pikepdf/pikepdf)
|
||||
|
||||
## Workflow
|
||||
|
||||
### Configure development environment
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### Build and test
|
||||
|
||||
```bash
|
||||
python -m build
|
||||
pip install --editable .
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[GPL-3.0](LICENSE)
|
||||
@@ -0,0 +1,70 @@
|
||||

|
||||
|
||||
[**简体中文**](README.md) | [English](README.en.md)
|
||||
|
||||
---
|
||||
|
||||
## 简介
|
||||
|
||||
[PDFuck](https://github.com/mmdjiji/pdfuck) 是一个去除 PDF 编辑密码的工具,以命令行方式使用。
|
||||
|
||||
## 安装
|
||||
|
||||
在安装前,请确保你安装了 Python (>=3.0) 及与之版本相匹配的 pip,然后在命令提示符中输入下面的命令:
|
||||
|
||||
```bash
|
||||
pip install pdfuck
|
||||
```
|
||||
|
||||
## 使用
|
||||
|
||||
### 去除 PDF 密码
|
||||
|
||||
例如,想要去除密码的 PDF 文件位于 `example.pdf`,只需输入下面的命令:
|
||||
|
||||
```bash
|
||||
pdfuck example.pdf
|
||||
```
|
||||
|
||||
输出文件的默认路径为 `example.fucked.pdf`。
|
||||
|
||||
### 手动指定输出文件路径
|
||||
|
||||
如果想要手动指定输出文件的路径,可以使用 `-o` 参数,例如:
|
||||
|
||||
```bash
|
||||
pdfuck example.pdf -o target.pdf
|
||||
```
|
||||
|
||||
### PDF 文件含有打开密码
|
||||
|
||||
使用 `-p` 参数手动指定打开密码,例如:
|
||||
|
||||
```bash
|
||||
pdfuck example.pdf -p password
|
||||
```
|
||||
|
||||
## 致谢
|
||||
|
||||
感谢以下开源项目,本项目的完成离不开这些作者贡献的代码。
|
||||
|
||||
* [pikepdf](https://github.com/pikepdf/pikepdf)
|
||||
|
||||
## 工作流
|
||||
|
||||
### 配置开发环境
|
||||
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### 构建与测试
|
||||
|
||||
```bash
|
||||
python -m build
|
||||
pip install --editable .
|
||||
```
|
||||
|
||||
## 开源协议
|
||||
|
||||
[GPL-3.0](LICENSE)
|
||||
@@ -0,0 +1,52 @@
|
||||
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 650 85" width="650" height="85" style="/*! background: #0d1117; */">
|
||||
<foreignObject width="100%" height="100%">
|
||||
<div xmlns="http://www.w3.org/1999/xhtml">
|
||||
<style>
|
||||
@keyframes gradientText {
|
||||
0% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
50% {
|
||||
background-position: 100% 50%;
|
||||
}
|
||||
100% {
|
||||
background-position: 0% 50%;
|
||||
}
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family:
|
||||
'Segoe UI',
|
||||
'Roboto',
|
||||
'Oxygen',
|
||||
'Ubuntu',
|
||||
'Cantarell',
|
||||
'Fira Sans',
|
||||
'Droid Sans',
|
||||
'Helvetica Neue',
|
||||
sans-serif;
|
||||
margin: 0;
|
||||
font-size: 3.75em;
|
||||
font-weight: 900;
|
||||
letter-spacing: -.05em;
|
||||
text-align: center;
|
||||
float: center;
|
||||
|
||||
}
|
||||
.text {
|
||||
background: -webkit-linear-gradient(right, #ff056e,#3c66ff);
|
||||
background: linear-gradient(270deg, #ff056e 0,#3c66ff);
|
||||
background-size: 350%;
|
||||
background-clip: text;
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
-webkit-animation: gradientText 3s ease infinite;
|
||||
animation: gradientText 3s ease infinite;
|
||||
}
|
||||
</style>
|
||||
<h1>
|
||||
<span class="text">PDFuck</span>
|
||||
</h1>
|
||||
</div>
|
||||
</foreignObject>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 1.5 KiB |
@@ -0,0 +1,38 @@
|
||||
# pdfuck.py
|
||||
# Author JiJi <i@mmdjiji.com>
|
||||
# GitHub https://github.com/mmdjiji/pdfuck
|
||||
|
||||
import argparse
|
||||
import pikepdf
|
||||
|
||||
def pdfuck(filepath, output, password):
|
||||
|
||||
# add '.fuck' sign for the output file
|
||||
if not output:
|
||||
splited = filepath.rsplit('.', 1)
|
||||
prefix = splited[0]
|
||||
output = prefix + '.fucked'
|
||||
if(len(splited) >= 2):
|
||||
suffix = splited[1]
|
||||
output += '.' + suffix
|
||||
|
||||
try:
|
||||
with pikepdf.open(filename_or_stream=filepath, password=password) as pdf:
|
||||
pdf.save(filename_or_stream=output)
|
||||
print('Decryption succeeded, saved to \'' + output + '\'')
|
||||
|
||||
except Exception as e:
|
||||
print(e)
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='PDFuck: Remove the password of your PDF file')
|
||||
parser.add_argument('filepath', metavar='<filepath>', type=str, help='path of the source PDF file')
|
||||
parser.add_argument('-o', '--output', metavar='<filepath>', type=str, help='path of the target PDF file')
|
||||
parser.add_argument('-p', '--password', metavar='<password>', type=str, help='reading password of the source PDF file')
|
||||
args = parser.parse_args()
|
||||
|
||||
filepath, output, password = args.filepath, args.output, args.password or ''
|
||||
pdfuck(filepath=filepath, output=output, password=password)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Binary file not shown.
@@ -0,0 +1,18 @@
|
||||
[metadata]
|
||||
name = pdfuck
|
||||
version = 1.0.0
|
||||
author = JiJi <i@mmdjiji.com>
|
||||
long_description = file: README.md
|
||||
license = GPL-3.0
|
||||
url = https://github.com/mmdjiji/pdfuck
|
||||
classifiers =
|
||||
Programming Language :: Python :: 3
|
||||
|
||||
[options]
|
||||
packages = find:
|
||||
install_requires =
|
||||
pikepdf
|
||||
|
||||
[options.entry_points]
|
||||
console_scripts =
|
||||
pdfuck = pdfuck:main
|
||||
Reference in New Issue
Block a user