이 주제에는 Python을 설치하여 .NET을 통해 Python용 Aspose.Pdf를 실행하는 방법에 대한 자세한 단계가 수반됩니다. Microsoft Windows, Linux 또는 macOS 기반 운영 체제에서 .NET Framework를 구성한 것으로 간주되며 Python에서 Aspose.Pdf 코드를 실행하는 데 필요한 모든 소프트웨어를 설치하도록 지시합니다. 이 단계에서 Python을 설치하고 새 PDF 파일을 생성하여 환경을 확인합니다.
.NET을 통해 Python용 Aspose.Pdf를 실행하기 위해 Python을 설치하는 단계
- .NET 프레임워크 지원으로 구성된 Microsoft Windows, Linux 또는 macOS 운영 체제가 있는 것으로 간주됩니다. 자세한 내용은 Install .NET on Windows, Linux, and macOS을 참조하십시오.
- VS Code에 Python 확장 설치
- Python 3.9.6 설치
- 핍 명령 설치
- Pip을 사용하여 최신 버전의 Aspose.Pdf for Python via .NET 설치
- Python용 Aspose-Pdf 코드를 생성 및 실행하여 PDF 파일 생성
처음 두 단계를 만족하는 환경을 이미 구축했다면 무시하고 Windows, Linux 또는 macOS 환경의 터미널 또는 명령 프롬프트에서 후속 명령을 진행할 수 있습니다. Aspose.Pdf를 설치하려면 Python과 Pip3를 설치해야 합니다.
.NET을 통해 Python용 Aspose.Pdf를 실행하기 위해 Python을 설치하는 스크립트
1. Install .NET Framework (Required for Ubuntu only) | |
#For Ubuntu | |
apt update | |
apt upgrade | |
apt install sudo | |
sudo apt update | |
sudo apt install wget | |
wget -q https://packages.microsoft.com/config/ubuntu/19.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb | |
sudo dpkg -i packages-microsoft-prod.deb | |
sudo apt-get update | |
sudo apt-get install apt-transport-https | |
sudo apt-get update | |
sudo apt-get install dotnet-sdk-3.1 | |
2. Install Python 3.9.6 | |
#For Ubuntu | |
sudo apt install -y python3.9 | |
# For MS Windows and macOS | |
install using MSI or DMG package. Be sure to select the check box to set the path during the installation | |
3. Installing Pip Command | |
# For Ubuntu | |
sudo apt install python3-pip | |
# For Windows and Mac | |
python3 -m pip install --upgrade pip | |
4. Install Aspose.Pdf | |
python3 -m pip install aspose-pdf | |
# Additional requirements for Ubuntu to install libgdiplus and libc6-dev | |
# For Ubuntu only | |
apt-get update | |
apt-get install -y libgdiplus | |
cd /usr/lib && ln -s libgdiplus.so gdiplus.dll | |
apt-get install -y --no-install-recommends libc6-dev | |
5. Write a sample program and save it as SamplePdf.Py and execute the Program | |
python3 SamplePdf.py | |
import aspose.pdf as pdf | |
# Create the empty PDF file | |
pdfDocument = pdf.Document() | |
# Insert the page in the PDF | |
pdfPage = pdfDocument.pages.add() | |
# Save the PDF on the disk | |
pdfDocument.save("GeneratedPdf.pdf") | |
print("Process completed") | |
6. Run the sample using the following command | |
python3 SamplePdf.py |
.NET Framework, Python 3.9.6 및 PIP가 환경에 이미 설정되어 있으면 5단계부터 시작하여 API를 사용할 수 있습니다. 이전 Python2.x 버전 대신 API와 함께 Python 3.9.6을 사용하는 것이 좋습니다.
설치 확인을 위해 API를 사용하는 기본 작업 샘플 코드도 제공됩니다. 다른 샘플을 사용하고 API 기능을 탐색하여 API를 사용하여 생성하려는 다양한 예제로 작업할 수 있습니다.