Šioje temoje pateikiami išsamūs veiksmai, kaip įdiegti python, kad paleistumėte Aspose.Pdf, skirtą Python per .NET. Laikoma, kad .NET Framework sukonfigūruotas bet kurioje iš Microsoft Windows, Linux arba MacOS pagrįstų operacinės sistemos ir nurodo įdiegti visą reikalingą programinę įrangą, kad Python paleistumėte Aspose.Pdf kodą. Atlikdami šiuos veiksmus įdiegsime Python ir sukursime naują PDF failą, kad patikrintume aplinką.
Veiksmai, kaip įdiegti Python, kad paleistumėte Aspose.Pdf for Python per .NET
- Laikoma, kad turite Microsoft Windows, Linux arba macOS operacinę sistemą, sukonfigūruotą su .NET framework palaikymu. Norėdami gauti daugiau informacijos, apsilankykite Install .NET on Windows, Linux, and macOS
- Įdiekite Python plėtinį VS Code.
- Įdiekite Python 3.9.6
- Įdiekite komandą Pip
- Įdiekite naujausią Aspose.Pdf for Python via .NET versiją naudodami Pip
- Sukurkite ir vykdykite Aspose-Pdf kodą Python, kad sukurtumėte PDF failą
Jei jau sukūrėte pirmuosius du veiksmus atitinkančią aplinką, galite jų nepaisyti ir pereiti prie tolesnių komandų terminale arba komandų eilutėje Windows, Linux ar MacOS aplinkoje. Norėdami įdiegti Aspose.Pdf, turite įdiegti Python ir Pip3.
Scenarijus, skirtas įdiegti Python, kad paleistumėte Aspose.Pdf for Python per .NET
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 |
Jei .NET Framework, Python 3.9.6 ir PIP jau nustatyti jūsų aplinkoje, galite pradėti nuo 5 veiksmo ir naudoti API. Rekomenduojama naudoti Python 3.9.6 su API vietoj senesnių Python2.x versijų.
Taip pat pateikiamas pagrindinis darbo pavyzdys, naudojant API, kad būtų galima patikrinti diegimą. Galite naudoti kitus pavyzdžius ir tyrinėti API funkcijas, kad galėtumėte dirbti su skirtingais pavyzdžiais, kuriuos norite sukurti naudodami API.