742 字
4 分钟
破解加密ppt文件使其能够正常转换为pdf
2025-10-21 22:05

PS:方法来自LINUX DO的 @pengzhile 佬友#

1.首先打开WinRAR或者7Zip之类的压缩软件(ppt本身是一种压缩文件)#

2.在文件资源管理器中找到要解除加密的ppt/pptx文件#

3.右键打开压缩文件#

3.打开ppt文件#

1.jpg

5.右键编辑(查看)这个 /ppt/presentation.xml文件#

2.jpg

6.Ctrl+F查找 modifyVerifier#

3.png

7.然后把这个整个p标签给干掉,然后保存文件,更新压缩包内容,于是就能编辑ppt了。有了编辑ppt的权限,就能用Adobe acrobat转换为pdf了;或者用powerpoint打开,到主页左侧可以看到使用Adobe acrobat转换为pdf#

解除加密批处理脚本(@pengzhile)#

点击展开查看代码详情
import os
import shutil
import zipfile
import tempfile
import argparse
from lxml import etree
from concurrent.futures import ProcessPoolExecutor, as_completed
import multiprocessing
def remove_modify_verifier(input_pptx, output_pptx):
try:
with tempfile.TemporaryDirectory() as tmpdir:
with zipfile.ZipFile(input_pptx, 'r') as zip_ref:
zip_ref.extractall(tmpdir)
presentation_xml_path = os.path.join(tmpdir, 'ppt', 'presentation.xml')
if not os.path.exists(presentation_xml_path):
return False, "找不到 ppt/presentation.xml 文件。"
parser = etree.XMLParser(remove_blank_text=True)
tree = etree.parse(presentation_xml_path, parser)
root = tree.getroot()
namespaces = {'p': 'http://schemas.openxmlformats.org/presentationml/2006/main'}
modify_verifiers = root.findall('.//p:modifyVerifier', namespaces)
if not modify_verifiers:
pass
else:
for verifier in modify_verifiers:
parent = verifier.getparent()
parent.remove(verifier)
tree.write(presentation_xml_path, xml_declaration=True, encoding='UTF-8', pretty_print=True)
with zipfile.ZipFile(output_pptx, 'w', zipfile.ZIP_DEFLATED) as zip_out:
for foldername, subfolders, filenames in os.walk(tmpdir):
for filename in filenames:
file_path = os.path.join(foldername, filename)
rel_path = os.path.relpath(file_path, tmpdir)
zip_out.write(file_path, rel_path)
return True, None
except Exception as e:
return False, str(e)
def process_file(file_path, output_dir):
try:
filename = os.path.basename(file_path)
output_path = os.path.join(output_dir, filename)
success, error = remove_modify_verifier(file_path, output_path)
if success:
return (file_path, True, None)
else:
return (file_path, False, error)
except Exception as e:
return (file_path, False, str(e))
def main():
parser = argparse.ArgumentParser(description='将只读 PPTX/PPT 文件转换为可编辑的 PPTX 文件。')
parser.add_argument('path', nargs='?', help='输入的PPTX/PPT文件或文件夹路径')
args = parser.parse_args()
input_folder = 'input'
output_folder = 'output'
if os.path.isdir(input_folder):
input_paths = []
for root_dir, _, files in os.walk(input_folder):
for file in files:
if file.lower().endswith(('.pptx', '.ppt')):
input_paths.append(os.path.join(root_dir, file))
elif args.path:
if os.path.isdir(args.path):
input_paths = []
for root_dir, _, files in os.walk(args.path):
for file in files:
if file.lower().endswith(('.pptx', '.ppt')):
input_paths.append(os.path.join(root_dir, file))
elif os.path.isfile(args.path) and args.path.lower().endswith(('.pptx', '.ppt')):
input_paths = [args.path]
else:
print("错误:指定的路径不是有效的PPTX/PPT文件或文件夹。")
return
else:
print("错误:当前目录下不存在 'input' 文件夹,且未提供输入路径。请指定输入文件或文件夹路径。")
return
if not input_paths:
print("没有找到需要处理的PPTX/PPT文件。")
return
os.makedirs(output_folder, exist_ok=True)
total = len(input_paths)
success_count = 0
fail_count = 0
fail_details = []
cpu_count = multiprocessing.cpu_count()
with ProcessPoolExecutor(max_workers=cpu_count) as executor:
future_to_file = {executor.submit(process_file, file_path, output_folder): file_path for file_path in input_paths}
for future in as_completed(future_to_file):
file_path = future_to_file[future]
try:
_, success, error = future.result()
if success:
success_count += 1
else:
fail_count += 1
fail_details.append((file_path, error))
except Exception as e:
fail_count += 1
fail_details.append((file_path, str(e)))
print(f"遍历 {total} 个文件,已成功 {success_count} 个文件,失败 {fail_count} 个文件。")
if fail_count > 0:
print("失败的文件及原因:")
for file, reason in fail_details:
print(f"{file}: {reason}")
if __name__ == "__main__":
main()
Terminal window
复制一下,保存为比如说我保存:ppt_remove_readonly.py
然后在同级目录下放一个input文件夹,里面放若干个你需要破解只读属性的pptx
然后python运行这个脚本就行了。嗷对了,需要pip install lxml
然后很快就会自动处理成可编辑的PPT了,输出到output文件夹中。
然后你可以批量转换为pdf了

4.png

破解加密ppt文件使其能够正常转换为pdf
https://fuwari.vercel.app/posts/破解加密ppt文件使其能够正常转换为pdf/
作者
BANLAN
发布于
2025-10-21
许可协议
CC BY-NC-SA 4.0