目录

科研文献编辑权限修改

目录
misaraty 更新 | 2025-11-15
前言
在科研中,我们常常遇到明明未加密的PDF文献却无法编辑。因为Nature等期刊常使用矢量路径字体、对象流压缩或权限标记,使普通PDF编辑器无法对其进行修改。而Ghostscript只需一条命令就能将这类PDF重建为结构干净、可复制、可编辑的版本。

下载

运行

1
gswin64c.exe -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile="out.pdf" -f "in.pdf"
  • 修改当前目录的所有PDF,
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
import os
import subprocess
from pathlib import Path
os.chdir(os.path.split(os.path.realpath(__file__))[0])

BASE = Path(".")
GS = "gswin64c.exe"

for pdf in BASE.glob("*.pdf"):
    in_file = str(pdf)
    out_file = str(pdf.with_name(pdf.stem + "_out.pdf"))
    cmd = [
        GS,
        "-sDEVICE=pdfwrite",
        "-dNOPAUSE",
        "-dBATCH",
        f"-sOutputFile={out_file}",
        in_file
    ]
    subprocess.run(cmd, shell=True)