LuaLaTeX를 사용한 PDF 보안/암호화

LuaLaTeX를 사용한 PDF 보안/암호화

LuaLaTeX를 사용하여 PDF 파일(예: 인쇄/복사/... 액세스 제어)을 보호할 수 있는지 궁금합니다.타사 소프트웨어를 사용하지 않고좋다QPDF또는 목록에 나열된 것pdfcrypt패키지.

좀 더 나이가 많은우편명령 으로 가능하다고 말하지만 \special예제에서는 XeTeX를 사용하고 LuaLaTeX로 테스트하는 동안 실제로 예상대로 작동하지 않습니다. 그들은 실제로 LuaLaTeX와 동등한 것이 없다고 말합니다:

\special{pdf:encrypt ownerpw (abc) userpw (xyz) length 128 perm 2052}
\documentclass{article}
\begin{document}
This is a test.
\end{document}

LuaLaTeXs 백엔드 프리미티브로 가능할까요 \pdfextension?

LuaLaTeX로만 가능하다면 누군가 나에게 MWE를 보여줄 수 있다면 감사하겠습니다.

고마워요,
데이브

답변1

덕분에@user202729다음을 통해 PDF 파일 보안/암호화를 자동화할 수 있었습니다.QPDF(선적 서류 비치) LuaLaTeX 내에서.

PDF를 후처리하는 동안마무리_실행단계에서는 Lua의 패턴 일치를 통해 출력 디렉터리를 읽습니다.

local outdir = nil
for i = 0, #arg, 1 do
    if string.find(arg[i], "%-+output%-d[irectory]*%=?%s?") then
        outdir = string.gsub(arg[i], "%-+output%-d[irectory]*%=?%s?", "")
    end
end

메모: 모든 인수 형식이 여기에 포함되는지 정확히 말할 수는 없습니다. 적어도 모든 인수 형식이 여기에 포함됩니다.@user202729게시했습니다여기인식됩니다.

그런 다음 QPDF는 원하는 인수를 사용하여 실행됩니다.

os.execute((outdir ~= nil and "cd " .. outdir .. " &&" or "") .. "qpdf " .. tex.jobname .. ".pdf --encrypt userpw ownerpw 256 --accessibility=y --assemble=y --extract=y --form=y --modify-other=y --print=full -- " .. tex.jobname .. "_secure.pdf")

전체 MWE(Windows 10):

\documentclass{book}

\usepackage{luacode}

\begin{luacode}
    luatexbase.add_to_callback("wrapup_run", function()
        local outdir = nil
        for i = 0, #arg, 1 do
            if string.find(arg[i], "%-+output%-d[irectory]*%=?%s?") then
                outdir = string.gsub(arg[i], "%-+output%-d[irectory]*%=?%s?", "")
            end
        end
        os.execute((outdir ~= nil and "cd " .. outdir .. " &&" or "") .. "qpdf " .. tex.jobname .. ".pdf --encrypt userpw ownerpw 256 --accessibility=y --assemble=y --extract=y --form=y --modify-other=y --print=full -- " .. tex.jobname .. "_secure.pdf")
    end, "Callback to secure pdf")
\end{luacode}

\begin{document}
    Hello World!
\end{document}

관련 정보