PDF 파일 암호 해독

소유자 암호로 PDF 암호 해독

.NET을 통해 Python용 Aspose.PDF 와 함께 소유자 암호를 사용하여 암호로 보호된 PDF 문서의 암호를 해독합니다.이 작업을 수행하면 암호화가 제거되고 문서에 제한 없이 액세스할 수 있습니다.

  1. ‘PDF 파일 보안’ 객체를 생성합니다.
  2. ‘bind_pdf () ‘메서드를 사용하여 암호화된 PDF를 로드합니다.
  3. 문서의 암호를 해독합니다.
  4. 해독한 PDF를 저장합니다.
from io import FileIO
import sys
from os import path
import aspose.pdf as ap
import aspose.pdf.facades as pdf_facades

sys.path.append(path.join(path.dirname(__file__), ".."))

from config import set_license, initialize_data_dir


# Decrypt PDF with Owner Password
def decrypt_pdf_with_owner_password(infile, outfile):
    """Decrypt a PDF document using the owner password."""
    # Create PdfFileSecurity object
    file_security = pdf_facades.PdfFileSecurity()

    # Bind PDF document
    file_security.bind_pdf(infile)

    # Decrypt the PDF
    file_security.decrypt_file("owner_password")

    # Save decrypted PDF
    file_security.save(outfile)

예외 없이 PDF 암호 해독 시도

PDF 문서는 액세스 및 사용을 제한하는 암호로 보호되는 경우가 많습니다.이러한 문서에 완전히 액세스하거나 수정하려면 암호화를 제거해야 할 수 있습니다..NET을 통해 Python용 Aspose.PDF 를 사용하여 소유자 암호를 사용하여 보안 PDF 문서의 암호를 해독하여 암호화 및 액세스 제한을 제거하세요.

  1. ‘PDF 파일 보안’ 객체를 생성합니다.
  2. 입력 PDF를 바인딩합니다.
  3. PDF의 암호를 해독합니다.
  4. 출력 PDF를 저장합니다.
from io import FileIO
import sys
from os import path
import aspose.pdf as ap
import aspose.pdf.facades as pdf_facades

sys.path.append(path.join(path.dirname(__file__), ".."))

from config import set_license, initialize_data_dir


# Try Decrypt PDF Without Exception
def try_decrypt_pdf_without_exception(infile, outfile):
    """Attempt to decrypt a PDF without throwing an exception on failure."""
    # Create PdfFileSecurity object
    file_security = pdf_facades.PdfFileSecurity()

    # Bind PDF document
    file_security.bind_pdf(infile)

    # Attempt to decrypt the PDF
    result = file_security.try_decrypt_file("owner_password")

    # Save only if decryption was successful
    if result:
        file_security.save(outfile)
    else:
        print("Decryption failed. Check password or document security.")