我需要添加提取 PDF 的密码。
Dim FileName As String
Dim FilePath As String
FileName = Me.Full_Name & "_" & Me.ID
FilePath = "C:\Users\Desktop\" & FileName & ".Pdf"
DoCmd.OutputTo acOutputReport, "Report", acFormatPDF, FilePath
MsgBox "Exported Successfully"
这里有一个使用 Ghostscript 的解决方案。首先像你已经做的那样打印你的 pdf,然后调用下面的函数。Ghostscript 在许可协议下是免费的,afaik
Public Function fctPDO_Print_pdf_GhostScript(strFile_for_pdf As String, Optional strUserPassword As String = "", Optional strOwnerPassword As String = "") As String
' http://www.herber.de/forum/archiv/1164to1168/1165503_Zusammenfuehren_von_PDF_Files.html#1165503
' https://stackoverflow.com/questions/49953421/ghostscript-with-aes-256-password-protection-for-pdf-2-0-documents
' PDO: Prints a pdf (originally multi-pdf). Requires Ghostscript, and read/write rights.
' Existing files are overwritten without asking.
' Provide both passwords to lock. Ghostscript does rc4 , being comparatively unsafe.
'
On Error Resume Next
Dim fso As Object, WshShell As Object
Dim strZielOrdner As String
Dim strQuellOrdner As String
Dim strCommand As String
Dim strGhostScript As String
Dim strFile_with_Path As String
Dim strTargetFile_without_Path As String
Set fso = CreateObject("Scripting.FileSystemObject")
'Path to gswin32c.exe
strGhostScript = "C:\Program Files (x86)\gs\gs9.19\bin\gswin32c.exe"
' Define folder
strQuellOrdner = "D:\PDO_test"
strZielOrdner = "D:\PDO_test"
' Shell-command prepare
strZielOrdner = fso.GetFolder(strZielOrdner).ShortPath
strGhostScript = fso.GetFile(strGhostScript).ShortPath
strCommand = strGhostScript & " -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite"
' PDO: Passwort-Phrase, with Ghostscript only RC4 possible...
If ((strUserPassword <> "") And (strOwnerPassword <> "")) Then
strCommand = strCommand & " -sOwnerPassword=" & strOwnerPassword & " -sUserPassword=" & strUserPassword & " -dCompatibilityLevel=2.0"
End If
strCommand = strCommand & " -sOutputFile=" & Chr(34)
strCommand = strCommand & strZielOrdner & "\" 'PDO: Danach kommt die Zieldatei und die einzelnen, anzubindenden Dateien.
strTargetFile_without_Path = "Beratungsprotokoll_2018_Sammel.pdf"
strFile_with_Path = strFile_for_pdf
' PDO: Gesamtcommand pt togehter ad executed
strCommand = strCommand & strTargetFile_without_Path & Chr(34) & strFile_with_Path
Debug.Print strCommand
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run strCommand, 0, True
Set WshShell = Nothing
fctPDO_Print_pdf_GhostScript = strZielOrdner & "\" & strTargetFile_without_Path
' Cleanup:
Err_Handler:
Set fso = Nothing
MsgBox "Done"
End Function
本站系公益性非盈利分享网址,本文来自用户投稿,不代表边看边学立场,如若转载,请注明出处
评论列表(6条)