是否可以检查PDF是否使用ghostscript进行密码保护? [英] is it possible to check if pdf is password protected using ghostscript?

查看:92
本文介绍了是否可以检查PDF是否使用ghostscript进行密码保护?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检查PDF是否已使用ghostscript进行密码保护? 命令是什么? 我知道您可以使用ghostscript剥离pdf密码, 但是我要做的只是检查PDF是否受密码保护或启用了安全性.

is it possible to check if pdf is password protected using ghostscript? what would be the command? I know you can strip pdf password using ghostscript, but all I want to do is just checking if PDF is password protected or security enabled.

推荐答案

checkuserpasswdPDF.sh:

#!/bin/sh

GS=~/gs/bin/gs
output=`$GS -dBATCH -sNODISPLAY "$1" 2>&1`
gsexit=$?

if [ "$gsexit" == "0" ]; then
  echo "Not user-password protected"
  exit 0;
else
  found=`echo "$output" |grep -o "This file requires a password"`
  if [ -z "$found" ]; then
    echo "Failed to invoke gs" 
    exit $gsexit
  else
    echo "Protected"
    exit 0;
  fi  
fi

检查受用户密码保护的PDF:.

Checks for user-password protected PDFs: checkuserpasswdPDF.sh test.pdf.

GS忽略了所有者密码(请参阅这个).

GS disregards owner-passwords (see this).

这篇关于是否可以检查PDF是否使用ghostscript进行密码保护?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆