Package: aspose-pdf
Product Page|Documentation|Demos|Blog|API Reference|Search|Free Support|Temporary LicenseTry ourFree Online Appsdemonstrating some of the most popular Aspose.PDF functionality.Aspose.PDF for Python via .NETis a native library that enables the developers to add PDF processing capabilities to their applications. It can be used to generate or read, convert and manipulate PDF files without the use of Adobe Acrobat.Aspose.PDF for Python via .NETallows to perform a range of document processing tasks such as form processing, get and set metadata information, text and page manipulation, management of annotations, add or remove bookmarks and watermarks, attachments, custom font handling and much more.
Check out theLanding PagesofAspose.PDF for Python via .NETfor a more detailed description of the features and possibilities of the library.General PDF FeaturesSupports most established PDF standards and PDF specifications.Ability to read & export PDFs in multiple image formats including BMP, GIF, JPEG & PNG.Set basic information (e.g. author, creator) of the PDF document.Configure PDF Page properties (e.g. width, height, cropbox, bleedbox etc.).Set page numbering, bookmark level, page sizes etc.Ability to work with text, paragraphs, headings, hyperlinks, graphs, attachments etc.Supported PDF versionsAspose.PDF for Python via .NETsupports PDF versions 1.2, 1.3, 1.4, 1.5, 1.6, 1.7 and 2.0.Conversion FeaturesAspose.PDF for Python via .NETlibrary allows you to successfully, quickly and easily convert your PDF documents to the most popular formats and vice versa.Convert PDF to Word, Excel, and PowerPoint.Convert PDF to Images formats.Convert PDF file to HTML format and vice versa.Convert PDF to EPUB, Text, XPS, etc.Convert EPUB, Markdown, Text, XPS, PostScript, XML, LaTex to PDF.Package FeaturesAdd, search, extract and replace text in PDF files.Add/delete, extract and replace images.Insert, delete, split PDF pages.Set and get XMP metadata.Validate (PDF/A-1a, PDF/A-1b).Work with bookmarks, annotations, PDF forms, stamps, watermarks and more.Supported File FormatsThe following table indicates the file formats thatAspose.PDF for Python via .NETcan load and Save.FormatDescriptionLoadSaveRemarksPDFPortable Document FormatYesYesCGMComputer Graphics Metafile for 2D vector graphicsYesNoEPUBEbook file formatYesYesHTMLHTML FormatYesYesTeXLaTex typesetting file formatYesYesMHTMHTML DocumentYesNoPCLPrinter Control Language FilesYesNoPSPostscript FilesYesNoSVGScalable Vector Graphics (An XML-based vector image format)YesYesXMLXML FormatYesYesXPSXPS DocumentsYesYesXSLFOXSL-FO is part of XSL file which is used for the transformation and formatting of XML dataYesNoMDMarkdown FormatYesNoXLSSaves the document in the Microsoft Excel SpreadSheetNoYesXLSXSaves the document in the Microsoft Excel 2007 formatNoYesPPTXSaves the document in the Microsoft PowerPoint Presentations formatNoYesDOCSaves the document in the Microsoft Word formatNoYesDOCXSaves the document in the Microsoft Word formatNoYesMobiXMLSaves the document in eBook MobiXML Standard formatNoYesJPEGSaves the document in JPEG FormatYesYesEMFEnhanced metafile format (EMF)YesYesPNGSaves the document in PNG FormatYesYesBMPSaves the document in BMP FormatYesYesGIFGraphic Interchange FormatNoYesTIFFSaves the document as Single or Multi-Page TIFF ImageYesYesTextSave the document int Text FormatYesYesPlatform IndependenceAspose.PDF for Python via .NETcan be used to develop 32-bit and 64-bit Python applications for different operating systems (such as Windows and Linux) where Python 3.7 or later is installed.Get StartedRunpip install aspose-pdfto fetch the package. If you already haveAspose.PDF for Python via .NETand want to get the latest version, please runpip install --upgrade aspose-pdf.To learn more aboutAspose.PDF for Python via .NETand explore the basic requirements and features of the library, check out the followingAspose.PDF for Python via .NET Documentationpages for other use cases.Create a PDF file from scratch in PythonIn the next code snippet, we are creating a PDF document fron scratch containing the text “Hello World!”. After installingAspose.PDF for Python via .NETin your environment, you can execute below code sample to see how Aspose.PDF API works.Below code snippet follows these steps:Instantiate a Document object.Add a Page to the document object.Create a TextFragment object.Add TextFragment to Paragraph collection of the page.Save the resultant PDF document.The following code snippet is a “Hello, World!” program to exhibit working ofAspose.PDF for Python via .NETAPI:importaspose.pdfasap# Initialize document objectdocument=ap.Document()# Add pagepage=document.pages.add()# Initialize textfragment objecttext_fragment=ap.text.TextFragment("Hello,world!")# Add text fragment to new pagepage.paragraphs.add(text_fragment)# Save updated PDFdocument.save("output.pdf")Example of converting HTML to PDFAspose.PDF for Python via .NETis a PDF manipulation API that lets you convert any existing HTML documents to PDF format. The process of converting HTML to PDF can be flexibly customized.Below code snippet follows these steps:Create an instance of the HtmlLoadOptions object.Initialize Document object.Save output PDF document by calling Document.Save() method.importaspose.pdfasap# Instantiate an object of HtmlLoadOptionsoptions=ap.HtmlLoadOptions()# Convert HTML to PDFdocument=ap.Document("input.html",options)# Save PDFdocument.save("output.pdf")Example of converting PDF to SVGAspose.PDF for Python via .NETsupports the feature to convert SVG image to PDF format. To accomplish this requirement, the SvgSaveOptions class has been introduced into the Aspose.PDF namespace. Instantiate an object of SvgSaveOptions and pass it as a second argument to the Document.Save(..) method.Below code snippet follows these steps:Create an object of the Document class.Create SvgSaveOptions object with needed settings.Call the Document.Save() method and pass it SvgSaveOptions object convert the PDF document to SVG.importaspose.pdfasap# Open PDF documentdocument=ap.Document("input.pdf")# Instantiate an object of SvgSaveOptionssaveOptions=ap.SvgSaveOptions()# Do not compress SVG image to Zip archivesaveOptions.compress_output_to_zip_archive=FalsesaveOptions.treat_target_file_name_as_directory=True# Save the output in SVG filesdocument.save("output.svg",saveOptions)Merge PDF FilesMerge multiple PDF into single file in Python with Aspose.PDF programmatically. PDF files are merged such that the first one is joined at the end of the other document.Below code snippet follows these steps:Open first document.Open second document.Add pages of second document to the first.Save concatenated output file.importaspose.pdfasap# Open first documentdocument1=ap.Document("input_1.pdf")# Open second documentdocument2=ap.Document("input_2.pdf")# Add pages of second document to the firstdocument1.pages.add(document2.pages)# Save concatenated output filedocument1.save("output.pdf")Print PDF to XPS printerYou can print a PDF file to an XPS printer, or some other soft printer for that matter, using the PdfViewer class.Below code snippet follows these steps:Create an object of the PdfViewer class.Open the PDF file using the bind_pdf method.Set different print settings using the PrinterSettings and PageSettings classes.Set the printer_name property to the XPS or other printer.Print document using the print_document_with_settings method.importaspose.pdfasapimportaspose.pydrawingasdrawing# Create PdfViewer objectviewer=ap.facades.PdfViewer()# Open input PDF fileviewer.bind_pdf("input.pdf")# Set attributes for printing# Print the file with adjusted sizeviewer.auto_resize=True# Print the file with adjusted rotationviewer.auto_rotate=True# Do not produce the page number dialog when printingviewer.print_page_dialog=False# Create objects for printer and page settingsps=drawing.printing.PrinterSettings()pgs=drawing.printing.PageSettings()# Set XPS/PDF printer nameps.printer_name="Microsoft XPS Document Writer"# Or set the PDF printer# ps.printer_name = "Adobe PDF"# Set PageSize(if required)pgs.paper_size=drawing.printing.PaperSize("A4",827,1169)# Set PageMargins(if required)pgs.margins=drawing.printing.Margins(0,0,0,0)# Print document using printer and page settingsviewer.print_document_with_settings(pgs,ps)# Close the PDF file after printingviewer.close()Product Page|Documentation|Demos|Blog|API Reference|Search|Free Support|Temporary License