api2pdf
Advanced tools
| Metadata-Version: 2.1 | ||
| Name: api2pdf | ||
| Version: 0.0.11 | ||
| Summary: Wrapper for api2pdf.com library for converting html, urls, and word documents to pdf | ||
| Version: 2.0.0 | ||
| Summary: This client library is a wrapper for the Api2Pdf.com REST API. See full REST api documentation at https://www.api2pdf.com/documentation/v2. Api2Pdf is a powerful API that supports HTML to PDF, URL to PDF, HTML to Image, URL to Image, Thumbnail / image preview of an Office file, Office files (Word to PDF), HTML to Docx, HTML to excel, PDF to HTML, merge PDFs together, add bookmarks to PDFs, add passwords to PDFs | ||
| Home-page: https://github.com/api2pdf/api2pdf.python | ||
@@ -10,5 +10,5 @@ Author: Zack Schwartz | ||
| Description: # api2pdf.python | ||
| Python bindings for [Api2Pdf REST API](https://www.api2pdf.com/documentation) | ||
| Python bindings for [Api2Pdf REST API](https://www.api2pdf.com/documentation/v2) | ||
| Api2Pdf.com is a REST API for instantly generating PDF documents from HTML, URLs, Microsoft Office Documents (Word, Excel, PPT), and images. The API also supports merge / concatenation of two or more PDFs. Api2Pdf is a wrapper for popular libraries such as **wkhtmltopdf**, **Headless Chrome**, and **LibreOffice**. | ||
| Api2Pdf.com is a powerful REST API for instantly generating PDF and Office documents from HTML, URLs, Microsoft Office Documents (Word, Excel, PPT), Email files, and images. You can generate image preview or thumbnail of a PDF, office document, or email file. The API also supports merge / concatenation of two or more PDFs, setting passwords on PDFs, and adding bookmarks to PDFs. Api2Pdf is a wrapper for popular libraries such as **wkhtmltopdf**, **Headless Chrome**, **PdfSharp**, and **LibreOffice**. | ||
@@ -56,3 +56,3 @@ - [Installation](#installation) | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>') | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>') | ||
| print(api_response.result) | ||
@@ -65,9 +65,9 @@ | ||
| { | ||
| 'pdf': 'https://link-to-pdf-only-available-for-24-hours', | ||
| 'mbIn': 0.08421039581298828, | ||
| 'mbOut': 0.08830547332763672, | ||
| 'cost': 0.00017251586914062501, | ||
| 'success': True, | ||
| 'error': None, | ||
| 'responseId': '6e46637a-650d-46d5-af0b-3d7831baccbb' | ||
| 'FileUrl': 'https://link-to-pdf-only-available-for-24-hours', | ||
| 'MbOut': 0.08830547332763672, | ||
| 'Seconds': 9.43, | ||
| 'Cost': 0.00017251586914062501, | ||
| 'Success': True, | ||
| 'Error': None, | ||
| 'ResponseId': '6e46637a-650d-46d5-af0b-3d7831baccbb' | ||
| } | ||
@@ -77,3 +77,3 @@ | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>') | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>') | ||
| print(api_response) | ||
@@ -89,3 +89,3 @@ | ||
| ---- API2PDF RESPONSE ---- | ||
| {'pdf': 'https://link-to-pdf-only-available-for-24-hours', 'mbIn': 0.08421039581298828, 'mbOut': 0.08830547332763672, 'cost': 0.00017251586914062501, 'success': True, 'error': None, 'responseId': '163c4d25-25d7-4b82-bf50-907597d2ad46'} | ||
| {'ResponseId': '5ef656a7-2856-43f4-aae3-7b580b0e0421', 'MbOut': 0.012622, 'Cost': 0.000257195288, 'Seconds': 1.208, 'Error': None, 'Success': True, 'FileUrl': 'https://storage.googleapis.com/a2p-v2-storage/5ef656a7-2856-43f4-aae3-7b580b0e0421'} | ||
@@ -97,7 +97,7 @@ | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_html('<p>Hello, World</p>') | ||
| api_response = a2p_client.WkHtml.html_to_pdf('<p>Hello, World</p>') | ||
| **Convert HTML to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert HTML to PDF (ldownload PDF as a file and specify a file name)** | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_html('<p>Hello, World</p>', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.WkHtml.html_to_pdf('<p>Hello, World</p>', inline_pdf=True, file_name='test.pdf') | ||
@@ -111,11 +111,11 @@ **Convert HTML to PDF (use keyword arguments for advanced wkhtmltopdf settings)** | ||
| } | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_html('<p>Hello, World</p>', **options) | ||
| api_response = a2p_client.WkHtml.html_to_pdf('<p>Hello, World</p>', **options) | ||
| **Convert URL to PDF** | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_url('http://www.api2pdf.com') | ||
| api_response = a2p_client.WkHtml.url_to_pdf('http://www.api2pdf.com') | ||
| **Convert URL to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert URL to PDF (download PDF as a file and specify a file name)** | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_url('http://www.api2pdf.com', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.WkHtml.url_to_pdf('http://www.api2pdf.com', inline=False, file_name='test.pdf') | ||
@@ -129,3 +129,3 @@ **Convert URL to PDF (use keyword arguments for advanced wkhtmltopdf settings)** | ||
| } | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_url('http://www.api2pdf.com', **options) | ||
| api_response = a2p_client.WkHtml.url_to_pdf('http://www.api2pdf.com', **options) | ||
@@ -139,7 +139,7 @@ | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>') | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>') | ||
| **Convert HTML to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert HTML to PDF (download PDF as a file and specify a file name)** | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>', inline=False, file_name='test.pdf') | ||
@@ -152,11 +152,11 @@ **Convert HTML to PDF (use keyword arguments for advanced Headless Chrome settings)** | ||
| } | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>', **options) | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>', **options) | ||
| **Convert URL to PDF** | ||
| api_response = a2p_client.HeadlessChrome.convert_from_url('http://www.api2pdf.com') | ||
| api_response = a2p_client.Chrome.url_to_pdf('http://www.api2pdf.com') | ||
| **Convert URL to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert URL to PDF (download PDF as a file and specify a file name)** | ||
| api_response = a2p_client.HeadlessChrome.convert_from_url('http://www.api2pdf.com', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.Chrome.url_to_pdf('http://www.api2pdf.com', inline=False, file_name='test.pdf') | ||
@@ -169,4 +169,11 @@ **Convert URL to PDF (use keyword arguments for advanced Headless Chrome settings)** | ||
| } | ||
| api_response = a2p_client.HeadlessChrome.convert_from_url('http://www.api2pdf.com', **options) | ||
| api_response = a2p_client.Chrome.url_to_pdf('http://www.api2pdf.com', **options) | ||
| **Convert HTML to Image** | ||
| api_response = a2p_client.Chrome.html_to_image('<p>Hello, World</p>') | ||
| **Convert URL to Image** | ||
| api_response = a2p_client.Chrome.url_to_image('http://www.api2pdf.com') | ||
| --- | ||
@@ -176,19 +183,33 @@ | ||
| LibreOffice supports the conversion to PDF from the following file formats: | ||
| Convert any office file to PDF, image file to PDF, email file to PDF, HTML to Word, HTML to Excel, and PDF to HTML. Any file that can be reasonably opened by LibreOffice should be convertible. Additionally, we have an endpoint for generating a *thumbnail* of the first page of your PDF or Office Document. This is great for generating an image preview of your files to users. | ||
| - doc, docx, xls, xlsx, ppt, pptx, gif, jpg, png, bmp, rtf, txt, html | ||
| You must provide a url to the file. Our engine will consume the file at that URL and convert it. | ||
| You must provide a url to the file. Our engine will consume the file at that URL and convert it to the PDF. | ||
| **Convert Microsoft Office Document or Image to PDF** | ||
| api_response = a2p_client.LibreOffice.convert_from_url('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx') | ||
| api_response = a2p_client.LibreOffice.any_to_pdf('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx') | ||
| **Convert Microsoft Office Document or Image to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert Microsoft Office Document or Image to PDF (download PDF as a file and specify a file name)** | ||
| api_response = a2p_client.LibreOffice.convert_from_url('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.LibreOffice.any_to_pdf('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx', inline=False, file_name='test.pdf') | ||
| **Thumbnail or Image Preview of a PDF or Office Document or Email file** | ||
| api_response = a2p_client.LibreOffice.thumbnail('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx') | ||
| **Convert HTML to Microsoft Word or Docx** | ||
| api_response = a2p_client.LibreOffice.html_to_docx('http://www.api2pdf.com/wp-content/uploads/2021/01/sampleHtml.html') | ||
| **Convert HTML to Microsoft Excel or Xlsx** | ||
| api_response = a2p_client.LibreOffice.html_to_xlsx('http://www.api2pdf.com/wp-content/uploads/2021/01/sampleTables.html') | ||
| **Convert PDF to HTML** | ||
| api_response = a2p_client.LibreOffice.pdf_to_html('http://www.api2pdf.com/wp-content/uploads/2021/01/1a082b03-2bd6-4703-989d-0443a88e3b0f-4.pdf') | ||
| --- | ||
| ## <a name="merge"></a>Merge / Concatenate Two or More PDFs | ||
| ## <a name="merge"></a>PdfSharp - Merge / Concatenate Two or More PDFs, Add bookmarks to pdfs, add passwords to pdfs | ||
@@ -200,9 +221,23 @@ To use the merge endpoint, supply a list of urls to existing PDFs. The engine will consume all of the PDFs and merge them into a single PDF, in the order in which they were provided in the list. | ||
| links_to_pdfs = ['https://LINK-TO-PDF', 'https://LINK-TO-PDF'] | ||
| merge_result = a2p_client.merge(links_to_pdfs) | ||
| merge_result = a2p_client.PdfSharp.merge(links_to_pdfs) | ||
| **Merge PDFs from list of URLs to existing PDFs (load PDF in browser window and specify a file name)** | ||
| **Merge PDFs from list of URLs to existing PDFs (download PDF as a file and specify a file name)** | ||
| links_to_pdfs = ['https://LINK-TO-PDF', 'https://LINK-TO-PDF'] | ||
| merge_result = a2p_client.merge(links_to_pdfs, inline_pdf=True, file_name='test.pdf') | ||
| merge_result = a2p_client.PdfSharp.merge(links_to_pdfs, inline=True, file_name='test.pdf') | ||
| **Add bookmarks to existing PDF** | ||
| url = 'https://link-to-pdf | ||
| bookmarks = [ | ||
| { 'Page': 0, 'Title': 'Introduction' }, | ||
| { 'Page': 1, 'Title': 'Second page' } | ||
| ] | ||
| response = a2p.PdfSharp.add_bookmarks(url, bookmarks) | ||
| **Add password to existing PDF** | ||
| url = 'https://link-to-pdf | ||
| password = 'hello' | ||
| response = a2p.PdfSharp.add_password(url, password) | ||
| --- | ||
@@ -222,3 +257,3 @@ | ||
| links_to_pdfs = ['https://LINK-TO-PDF', 'https://LINK-TO-PDF'] | ||
| merge_result = a2p_client.merge(links_to_pdfs) | ||
| merge_result = a2p_client.PdfSharp.merge(links_to_pdfs) | ||
@@ -237,4 +272,4 @@ pdf_as_file_object = merge_result.download_pdf() | ||
| # generate a pdf | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello World</p>') | ||
| response_id = api_response.result['responseId'] | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello World</p>') | ||
| response_id = api_response.result['ResponseId'] | ||
@@ -241,0 +276,0 @@ # delete the pdf |
+94
-63
| import requests | ||
| import json | ||
| API2PDF_BASE_ENDPOINT = 'https://v2018.api2pdf.com' | ||
| API2PDF_MERGE_ENDPOINT = API2PDF_BASE_ENDPOINT + '/merge' | ||
| API2PDF_WKHTMLTOPDF_HTML = API2PDF_BASE_ENDPOINT + '/wkhtmltopdf/html' | ||
| API2PDF_WKHTMLTOPDF_URL = API2PDF_BASE_ENDPOINT + '/wkhtmltopdf/url' | ||
| API2PDF_CHROME_HTML = API2PDF_BASE_ENDPOINT + '/chrome/html' | ||
| API2PDF_CHROME_URL = API2PDF_BASE_ENDPOINT + '/chrome/url' | ||
| API2PDF_LIBREOFFICE_CONVERT = API2PDF_BASE_ENDPOINT + '/libreoffice/convert' | ||
| API2PDF_DELETE_PDF = API2PDF_BASE_ENDPOINT + '/pdf/{response_id}' | ||
| class Api2Pdf(object): | ||
| def __init__(self, api_key, tag=''): | ||
| def __init__(self, api_key, base_url='https://v2.api2pdf.com', tag=''): | ||
| self.api_key = api_key | ||
| self.tag = tag | ||
| self.base_url = base_url | ||
| @property | ||
| def WkHtmlToPdf(self): | ||
| return Api2Pdf_WkHtmlToPdf(self.api_key) | ||
| def WkHtml(self): | ||
| return Api2Pdf_WkHtml(self.api_key, self.base_url) | ||
| @property | ||
| def HeadlessChrome(self): | ||
| return Api2Pdf_HeadlessChromeToPdf(self.api_key) | ||
| def Chrome(self): | ||
| return Api2Pdf_Chrome(self.api_key, self.base_url) | ||
| @property | ||
| def LibreOffice(self): | ||
| return Api2Pdf_LibreOffice(self.api_key) | ||
| return Api2Pdf_LibreOffice(self.api_key, self.base_url) | ||
| def merge(self, list_of_urls, inline_pdf=False, file_name=None): | ||
| payload = { | ||
| 'urls': list_of_urls, | ||
| 'inlinePdf': inline_pdf | ||
| } | ||
| if file_name != None: | ||
| payload['fileName'] = file_name | ||
| return self._make_request(API2PDF_MERGE_ENDPOINT, payload) | ||
| @property | ||
| def PdfSharp(self): | ||
| return Api2Pdf_PdfSharp(self.api_key, self.base_url) | ||
| def delete(self, response_id): | ||
| headers = self.request_header | ||
| endpoint = API2PDF_DELETE_PDF.format(response_id=response_id) | ||
| response = requests.delete(endpoint, headers=headers) | ||
| return Api2PdfResponse(headers, endpoint, '', response) | ||
| endpoint = f'/file/{response_id}'.format(response_id=response_id) | ||
| full_endpoint = self.base_url + endpoint | ||
| response = requests.delete(full_endpoint, headers=headers) | ||
| return Api2PdfResponse(headers, full_endpoint, '', response) | ||
| def _make_html_payload(self, html, inline_pdf=False, file_name=None, **options): | ||
| def _build_base_payload(self, inline=True, file_name=None, **options): | ||
| payload = { | ||
| 'html': html, | ||
| 'inlinePdf': inline_pdf | ||
| 'inline': inline | ||
| } | ||
| if file_name != None: | ||
| payload['fileName'] = file_name | ||
| if options != None: | ||
@@ -57,18 +43,8 @@ payload['options'] = options | ||
| def _make_url_payload(self, url, inline_pdf=False, file_name=None, **options): | ||
| payload = { | ||
| 'url': url, | ||
| 'inlinePdf': inline_pdf | ||
| } | ||
| if file_name != None: | ||
| payload['fileName'] = file_name | ||
| if options != None: | ||
| payload['options'] = options | ||
| return payload | ||
| def _make_request(self, endpoint, payload): | ||
| headers = self.request_header | ||
| payload_as_json = json.dumps(payload) | ||
| response = requests.post(endpoint, data=payload_as_json, headers=headers) | ||
| return Api2PdfResponse(headers, endpoint, payload, response) | ||
| full_endpoint = self.base_url + endpoint | ||
| response = requests.post(full_endpoint, data=payload_as_json, headers=headers) | ||
| return Api2PdfResponse(headers, full_endpoint, payload, response) | ||
@@ -83,25 +59,80 @@ @property | ||
| class Api2Pdf_WkHtmlToPdf(Api2Pdf): | ||
| def convert_from_html(self, html, inline_pdf=False, file_name=None, **options): | ||
| payload = self._make_html_payload(html, inline_pdf=inline_pdf, file_name=file_name, **options) | ||
| return self._make_request(API2PDF_WKHTMLTOPDF_HTML, payload) | ||
| class Api2Pdf_WkHtml(Api2Pdf): | ||
| def html_to_pdf(self, html, inline=True, file_name=None, **options): | ||
| payload = self._build_base_payload(inline, file_name, **options) | ||
| payload['html'] = html | ||
| return self._make_request('/wkhtml/pdf/html', payload) | ||
| def convert_from_url(self, url, inline_pdf=False, file_name=None, **options): | ||
| payload = self._make_url_payload(url, inline_pdf=inline_pdf, file_name=file_name, **options) | ||
| return self._make_request(API2PDF_WKHTMLTOPDF_URL, payload) | ||
| def url_to_pdf(self, url, inline=True, file_name=None, **options): | ||
| payload = self._build_base_payload(inline, file_name, **options) | ||
| payload['url'] = url | ||
| return self._make_request('/wkhtml/pdf/url', payload) | ||
| class Api2Pdf_HeadlessChromeToPdf(Api2Pdf): | ||
| def convert_from_html(self, html, inline_pdf=False, file_name=None, **options): | ||
| payload = self._make_html_payload(html, inline_pdf=inline_pdf, file_name=file_name, **options) | ||
| return self._make_request(API2PDF_CHROME_HTML, payload) | ||
| class Api2Pdf_Chrome(Api2Pdf): | ||
| def html_to_pdf(self, html, inline=True, file_name=None, **options): | ||
| payload = self._build_base_payload(inline, file_name, **options) | ||
| payload['html'] = html | ||
| return self._make_request('/chrome/pdf/html', payload) | ||
| def convert_from_url(self, url, inline_pdf=False, file_name=None, **options): | ||
| payload = self._make_url_payload(url, inline_pdf=inline_pdf, file_name=file_name, **options) | ||
| return self._make_request(API2PDF_CHROME_URL, payload) | ||
| def url_to_pdf(self, url, inline=True, file_name=None, **options): | ||
| payload = self._build_base_payload(inline, file_name, **options) | ||
| payload['url'] = url | ||
| return self._make_request('/chrome/pdf/url', payload) | ||
| def html_to_image(self, html, inline=True, file_name=None, **options): | ||
| payload = self._build_base_payload(inline, file_name, **options) | ||
| payload['html'] = html | ||
| return self._make_request('/chrome/image/html', payload) | ||
| def url_to_image(self, url, inline=True, file_name=None, **options): | ||
| payload = self._build_base_payload(inline, file_name, **options) | ||
| payload['url'] = url | ||
| return self._make_request('/chrome/image/url', payload) | ||
| class Api2Pdf_LibreOffice(Api2Pdf): | ||
| def convert_from_url(self, url, inline_pdf=False, file_name=None): | ||
| payload = self._make_url_payload(url, inline_pdf=inline_pdf, file_name=file_name) | ||
| return self._make_request(API2PDF_LIBREOFFICE_CONVERT, payload) | ||
| def any_to_pdf(self, url, inline=True, file_name=None): | ||
| payload = self._build_base_payload(inline, file_name) | ||
| payload['url'] = url | ||
| return self._make_request('/libreoffice/any-to-pdf', payload) | ||
| def thumbnail(self, url, inline=True, file_name=None): | ||
| payload = self._build_base_payload(inline, file_name) | ||
| payload['url'] = url | ||
| return self._make_request('/libreoffice/thumbnail', payload) | ||
| def pdf_to_html(self, url, inline=True, file_name=None): | ||
| payload = self._build_base_payload(inline, file_name) | ||
| payload['url'] = url | ||
| return self._make_request('/libreoffice/pdf-to-html', payload) | ||
| def html_to_docx(self, url, inline=True, file_name=None): | ||
| payload = self._build_base_payload(inline, file_name) | ||
| payload['url'] = url | ||
| return self._make_request('/libreoffice/html-to-docx', payload) | ||
| def html_to_xlsx(self, url, inline=True, file_name=None): | ||
| payload = self._build_base_payload(inline, file_name) | ||
| payload['url'] = url | ||
| return self._make_request('/libreoffice/html-to-xlsx', payload) | ||
| class Api2Pdf_PdfSharp(Api2Pdf): | ||
| def merge(self, urls, inline=True, file_name=None): | ||
| payload = self._build_base_payload(inline, file_name) | ||
| payload['urls'] = urls | ||
| return self._make_request('/pdfsharp/merge', payload) | ||
| def add_bookmarks(self, url, bookmarks, inline=True, file_name=None): | ||
| payload = self._build_base_payload(inline, file_name) | ||
| payload['url'] = url | ||
| payload['bookmarks'] = bookmarks | ||
| return self._make_request('/pdfsharp/bookmarks', payload) | ||
| def add_password(self, url, userpassword, ownerpassword=None, inline=True, file_name=None): | ||
| payload = self._build_base_payload(inline, file_name) | ||
| payload['url'] = url | ||
| payload['userpassword'] = userpassword | ||
| if ownerpassword != None: | ||
| payload['ownerpassword'] = ownerpassword | ||
| return self._make_request('/pdfsharp/password', payload) | ||
| class Api2PdfResponse(object): | ||
@@ -130,7 +161,7 @@ def __init__(self, headers, endpoint, payload_as_json, response): | ||
| if self.result['success']: | ||
| downloaded_pdf = requests.get(self.result['pdf'], headers=USERAGENT) | ||
| data = downloaded_pdf.content | ||
| downloaded_file = requests.get(self.result['FileUrl'], headers=USERAGENT) | ||
| data = downloaded_file.content | ||
| return data | ||
| else: | ||
| raise FileNotFoundError("PDF never generated " + self.result['error']) | ||
| raise FileNotFoundError("File never generated " + self.result['error']) | ||
@@ -137,0 +168,0 @@ def __str__(self): |
+80
-45
| Metadata-Version: 2.1 | ||
| Name: api2pdf | ||
| Version: 0.0.11 | ||
| Summary: Wrapper for api2pdf.com library for converting html, urls, and word documents to pdf | ||
| Version: 2.0.0 | ||
| Summary: This client library is a wrapper for the Api2Pdf.com REST API. See full REST api documentation at https://www.api2pdf.com/documentation/v2. Api2Pdf is a powerful API that supports HTML to PDF, URL to PDF, HTML to Image, URL to Image, Thumbnail / image preview of an Office file, Office files (Word to PDF), HTML to Docx, HTML to excel, PDF to HTML, merge PDFs together, add bookmarks to PDFs, add passwords to PDFs | ||
| Home-page: https://github.com/api2pdf/api2pdf.python | ||
@@ -10,5 +10,5 @@ Author: Zack Schwartz | ||
| Description: # api2pdf.python | ||
| Python bindings for [Api2Pdf REST API](https://www.api2pdf.com/documentation) | ||
| Python bindings for [Api2Pdf REST API](https://www.api2pdf.com/documentation/v2) | ||
| Api2Pdf.com is a REST API for instantly generating PDF documents from HTML, URLs, Microsoft Office Documents (Word, Excel, PPT), and images. The API also supports merge / concatenation of two or more PDFs. Api2Pdf is a wrapper for popular libraries such as **wkhtmltopdf**, **Headless Chrome**, and **LibreOffice**. | ||
| Api2Pdf.com is a powerful REST API for instantly generating PDF and Office documents from HTML, URLs, Microsoft Office Documents (Word, Excel, PPT), Email files, and images. You can generate image preview or thumbnail of a PDF, office document, or email file. The API also supports merge / concatenation of two or more PDFs, setting passwords on PDFs, and adding bookmarks to PDFs. Api2Pdf is a wrapper for popular libraries such as **wkhtmltopdf**, **Headless Chrome**, **PdfSharp**, and **LibreOffice**. | ||
@@ -56,3 +56,3 @@ - [Installation](#installation) | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>') | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>') | ||
| print(api_response.result) | ||
@@ -65,9 +65,9 @@ | ||
| { | ||
| 'pdf': 'https://link-to-pdf-only-available-for-24-hours', | ||
| 'mbIn': 0.08421039581298828, | ||
| 'mbOut': 0.08830547332763672, | ||
| 'cost': 0.00017251586914062501, | ||
| 'success': True, | ||
| 'error': None, | ||
| 'responseId': '6e46637a-650d-46d5-af0b-3d7831baccbb' | ||
| 'FileUrl': 'https://link-to-pdf-only-available-for-24-hours', | ||
| 'MbOut': 0.08830547332763672, | ||
| 'Seconds': 9.43, | ||
| 'Cost': 0.00017251586914062501, | ||
| 'Success': True, | ||
| 'Error': None, | ||
| 'ResponseId': '6e46637a-650d-46d5-af0b-3d7831baccbb' | ||
| } | ||
@@ -77,3 +77,3 @@ | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>') | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>') | ||
| print(api_response) | ||
@@ -89,3 +89,3 @@ | ||
| ---- API2PDF RESPONSE ---- | ||
| {'pdf': 'https://link-to-pdf-only-available-for-24-hours', 'mbIn': 0.08421039581298828, 'mbOut': 0.08830547332763672, 'cost': 0.00017251586914062501, 'success': True, 'error': None, 'responseId': '163c4d25-25d7-4b82-bf50-907597d2ad46'} | ||
| {'ResponseId': '5ef656a7-2856-43f4-aae3-7b580b0e0421', 'MbOut': 0.012622, 'Cost': 0.000257195288, 'Seconds': 1.208, 'Error': None, 'Success': True, 'FileUrl': 'https://storage.googleapis.com/a2p-v2-storage/5ef656a7-2856-43f4-aae3-7b580b0e0421'} | ||
@@ -97,7 +97,7 @@ | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_html('<p>Hello, World</p>') | ||
| api_response = a2p_client.WkHtml.html_to_pdf('<p>Hello, World</p>') | ||
| **Convert HTML to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert HTML to PDF (ldownload PDF as a file and specify a file name)** | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_html('<p>Hello, World</p>', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.WkHtml.html_to_pdf('<p>Hello, World</p>', inline_pdf=True, file_name='test.pdf') | ||
@@ -111,11 +111,11 @@ **Convert HTML to PDF (use keyword arguments for advanced wkhtmltopdf settings)** | ||
| } | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_html('<p>Hello, World</p>', **options) | ||
| api_response = a2p_client.WkHtml.html_to_pdf('<p>Hello, World</p>', **options) | ||
| **Convert URL to PDF** | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_url('http://www.api2pdf.com') | ||
| api_response = a2p_client.WkHtml.url_to_pdf('http://www.api2pdf.com') | ||
| **Convert URL to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert URL to PDF (download PDF as a file and specify a file name)** | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_url('http://www.api2pdf.com', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.WkHtml.url_to_pdf('http://www.api2pdf.com', inline=False, file_name='test.pdf') | ||
@@ -129,3 +129,3 @@ **Convert URL to PDF (use keyword arguments for advanced wkhtmltopdf settings)** | ||
| } | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_url('http://www.api2pdf.com', **options) | ||
| api_response = a2p_client.WkHtml.url_to_pdf('http://www.api2pdf.com', **options) | ||
@@ -139,7 +139,7 @@ | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>') | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>') | ||
| **Convert HTML to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert HTML to PDF (download PDF as a file and specify a file name)** | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>', inline=False, file_name='test.pdf') | ||
@@ -152,11 +152,11 @@ **Convert HTML to PDF (use keyword arguments for advanced Headless Chrome settings)** | ||
| } | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>', **options) | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>', **options) | ||
| **Convert URL to PDF** | ||
| api_response = a2p_client.HeadlessChrome.convert_from_url('http://www.api2pdf.com') | ||
| api_response = a2p_client.Chrome.url_to_pdf('http://www.api2pdf.com') | ||
| **Convert URL to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert URL to PDF (download PDF as a file and specify a file name)** | ||
| api_response = a2p_client.HeadlessChrome.convert_from_url('http://www.api2pdf.com', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.Chrome.url_to_pdf('http://www.api2pdf.com', inline=False, file_name='test.pdf') | ||
@@ -169,4 +169,11 @@ **Convert URL to PDF (use keyword arguments for advanced Headless Chrome settings)** | ||
| } | ||
| api_response = a2p_client.HeadlessChrome.convert_from_url('http://www.api2pdf.com', **options) | ||
| api_response = a2p_client.Chrome.url_to_pdf('http://www.api2pdf.com', **options) | ||
| **Convert HTML to Image** | ||
| api_response = a2p_client.Chrome.html_to_image('<p>Hello, World</p>') | ||
| **Convert URL to Image** | ||
| api_response = a2p_client.Chrome.url_to_image('http://www.api2pdf.com') | ||
| --- | ||
@@ -176,19 +183,33 @@ | ||
| LibreOffice supports the conversion to PDF from the following file formats: | ||
| Convert any office file to PDF, image file to PDF, email file to PDF, HTML to Word, HTML to Excel, and PDF to HTML. Any file that can be reasonably opened by LibreOffice should be convertible. Additionally, we have an endpoint for generating a *thumbnail* of the first page of your PDF or Office Document. This is great for generating an image preview of your files to users. | ||
| - doc, docx, xls, xlsx, ppt, pptx, gif, jpg, png, bmp, rtf, txt, html | ||
| You must provide a url to the file. Our engine will consume the file at that URL and convert it. | ||
| You must provide a url to the file. Our engine will consume the file at that URL and convert it to the PDF. | ||
| **Convert Microsoft Office Document or Image to PDF** | ||
| api_response = a2p_client.LibreOffice.convert_from_url('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx') | ||
| api_response = a2p_client.LibreOffice.any_to_pdf('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx') | ||
| **Convert Microsoft Office Document or Image to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert Microsoft Office Document or Image to PDF (download PDF as a file and specify a file name)** | ||
| api_response = a2p_client.LibreOffice.convert_from_url('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.LibreOffice.any_to_pdf('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx', inline=False, file_name='test.pdf') | ||
| **Thumbnail or Image Preview of a PDF or Office Document or Email file** | ||
| api_response = a2p_client.LibreOffice.thumbnail('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx') | ||
| **Convert HTML to Microsoft Word or Docx** | ||
| api_response = a2p_client.LibreOffice.html_to_docx('http://www.api2pdf.com/wp-content/uploads/2021/01/sampleHtml.html') | ||
| **Convert HTML to Microsoft Excel or Xlsx** | ||
| api_response = a2p_client.LibreOffice.html_to_xlsx('http://www.api2pdf.com/wp-content/uploads/2021/01/sampleTables.html') | ||
| **Convert PDF to HTML** | ||
| api_response = a2p_client.LibreOffice.pdf_to_html('http://www.api2pdf.com/wp-content/uploads/2021/01/1a082b03-2bd6-4703-989d-0443a88e3b0f-4.pdf') | ||
| --- | ||
| ## <a name="merge"></a>Merge / Concatenate Two or More PDFs | ||
| ## <a name="merge"></a>PdfSharp - Merge / Concatenate Two or More PDFs, Add bookmarks to pdfs, add passwords to pdfs | ||
@@ -200,9 +221,23 @@ To use the merge endpoint, supply a list of urls to existing PDFs. The engine will consume all of the PDFs and merge them into a single PDF, in the order in which they were provided in the list. | ||
| links_to_pdfs = ['https://LINK-TO-PDF', 'https://LINK-TO-PDF'] | ||
| merge_result = a2p_client.merge(links_to_pdfs) | ||
| merge_result = a2p_client.PdfSharp.merge(links_to_pdfs) | ||
| **Merge PDFs from list of URLs to existing PDFs (load PDF in browser window and specify a file name)** | ||
| **Merge PDFs from list of URLs to existing PDFs (download PDF as a file and specify a file name)** | ||
| links_to_pdfs = ['https://LINK-TO-PDF', 'https://LINK-TO-PDF'] | ||
| merge_result = a2p_client.merge(links_to_pdfs, inline_pdf=True, file_name='test.pdf') | ||
| merge_result = a2p_client.PdfSharp.merge(links_to_pdfs, inline=True, file_name='test.pdf') | ||
| **Add bookmarks to existing PDF** | ||
| url = 'https://link-to-pdf | ||
| bookmarks = [ | ||
| { 'Page': 0, 'Title': 'Introduction' }, | ||
| { 'Page': 1, 'Title': 'Second page' } | ||
| ] | ||
| response = a2p.PdfSharp.add_bookmarks(url, bookmarks) | ||
| **Add password to existing PDF** | ||
| url = 'https://link-to-pdf | ||
| password = 'hello' | ||
| response = a2p.PdfSharp.add_password(url, password) | ||
| --- | ||
@@ -222,3 +257,3 @@ | ||
| links_to_pdfs = ['https://LINK-TO-PDF', 'https://LINK-TO-PDF'] | ||
| merge_result = a2p_client.merge(links_to_pdfs) | ||
| merge_result = a2p_client.PdfSharp.merge(links_to_pdfs) | ||
@@ -237,4 +272,4 @@ pdf_as_file_object = merge_result.download_pdf() | ||
| # generate a pdf | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello World</p>') | ||
| response_id = api_response.result['responseId'] | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello World</p>') | ||
| response_id = api_response.result['ResponseId'] | ||
@@ -241,0 +276,0 @@ # delete the pdf |
+78
-43
| # api2pdf.python | ||
| Python bindings for [Api2Pdf REST API](https://www.api2pdf.com/documentation) | ||
| Python bindings for [Api2Pdf REST API](https://www.api2pdf.com/documentation/v2) | ||
| Api2Pdf.com is a REST API for instantly generating PDF documents from HTML, URLs, Microsoft Office Documents (Word, Excel, PPT), and images. The API also supports merge / concatenation of two or more PDFs. Api2Pdf is a wrapper for popular libraries such as **wkhtmltopdf**, **Headless Chrome**, and **LibreOffice**. | ||
| Api2Pdf.com is a powerful REST API for instantly generating PDF and Office documents from HTML, URLs, Microsoft Office Documents (Word, Excel, PPT), Email files, and images. You can generate image preview or thumbnail of a PDF, office document, or email file. The API also supports merge / concatenation of two or more PDFs, setting passwords on PDFs, and adding bookmarks to PDFs. Api2Pdf is a wrapper for popular libraries such as **wkhtmltopdf**, **Headless Chrome**, **PdfSharp**, and **LibreOffice**. | ||
@@ -47,3 +47,3 @@ - [Installation](#installation) | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>') | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>') | ||
| print(api_response.result) | ||
@@ -56,9 +56,9 @@ | ||
| { | ||
| 'pdf': 'https://link-to-pdf-only-available-for-24-hours', | ||
| 'mbIn': 0.08421039581298828, | ||
| 'mbOut': 0.08830547332763672, | ||
| 'cost': 0.00017251586914062501, | ||
| 'success': True, | ||
| 'error': None, | ||
| 'responseId': '6e46637a-650d-46d5-af0b-3d7831baccbb' | ||
| 'FileUrl': 'https://link-to-pdf-only-available-for-24-hours', | ||
| 'MbOut': 0.08830547332763672, | ||
| 'Seconds': 9.43, | ||
| 'Cost': 0.00017251586914062501, | ||
| 'Success': True, | ||
| 'Error': None, | ||
| 'ResponseId': '6e46637a-650d-46d5-af0b-3d7831baccbb' | ||
| } | ||
@@ -68,3 +68,3 @@ | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>') | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>') | ||
| print(api_response) | ||
@@ -80,3 +80,3 @@ | ||
| ---- API2PDF RESPONSE ---- | ||
| {'pdf': 'https://link-to-pdf-only-available-for-24-hours', 'mbIn': 0.08421039581298828, 'mbOut': 0.08830547332763672, 'cost': 0.00017251586914062501, 'success': True, 'error': None, 'responseId': '163c4d25-25d7-4b82-bf50-907597d2ad46'} | ||
| {'ResponseId': '5ef656a7-2856-43f4-aae3-7b580b0e0421', 'MbOut': 0.012622, 'Cost': 0.000257195288, 'Seconds': 1.208, 'Error': None, 'Success': True, 'FileUrl': 'https://storage.googleapis.com/a2p-v2-storage/5ef656a7-2856-43f4-aae3-7b580b0e0421'} | ||
@@ -88,7 +88,7 @@ | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_html('<p>Hello, World</p>') | ||
| api_response = a2p_client.WkHtml.html_to_pdf('<p>Hello, World</p>') | ||
| **Convert HTML to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert HTML to PDF (ldownload PDF as a file and specify a file name)** | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_html('<p>Hello, World</p>', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.WkHtml.html_to_pdf('<p>Hello, World</p>', inline_pdf=True, file_name='test.pdf') | ||
@@ -102,11 +102,11 @@ **Convert HTML to PDF (use keyword arguments for advanced wkhtmltopdf settings)** | ||
| } | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_html('<p>Hello, World</p>', **options) | ||
| api_response = a2p_client.WkHtml.html_to_pdf('<p>Hello, World</p>', **options) | ||
| **Convert URL to PDF** | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_url('http://www.api2pdf.com') | ||
| api_response = a2p_client.WkHtml.url_to_pdf('http://www.api2pdf.com') | ||
| **Convert URL to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert URL to PDF (download PDF as a file and specify a file name)** | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_url('http://www.api2pdf.com', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.WkHtml.url_to_pdf('http://www.api2pdf.com', inline=False, file_name='test.pdf') | ||
@@ -120,3 +120,3 @@ **Convert URL to PDF (use keyword arguments for advanced wkhtmltopdf settings)** | ||
| } | ||
| api_response = a2p_client.WkHtmlToPdf.convert_from_url('http://www.api2pdf.com', **options) | ||
| api_response = a2p_client.WkHtml.url_to_pdf('http://www.api2pdf.com', **options) | ||
@@ -130,7 +130,7 @@ | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>') | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>') | ||
| **Convert HTML to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert HTML to PDF (download PDF as a file and specify a file name)** | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>', inline=False, file_name='test.pdf') | ||
@@ -143,11 +143,11 @@ **Convert HTML to PDF (use keyword arguments for advanced Headless Chrome settings)** | ||
| } | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello, World</p>', **options) | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello, World</p>', **options) | ||
| **Convert URL to PDF** | ||
| api_response = a2p_client.HeadlessChrome.convert_from_url('http://www.api2pdf.com') | ||
| api_response = a2p_client.Chrome.url_to_pdf('http://www.api2pdf.com') | ||
| **Convert URL to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert URL to PDF (download PDF as a file and specify a file name)** | ||
| api_response = a2p_client.HeadlessChrome.convert_from_url('http://www.api2pdf.com', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.Chrome.url_to_pdf('http://www.api2pdf.com', inline=False, file_name='test.pdf') | ||
@@ -160,4 +160,11 @@ **Convert URL to PDF (use keyword arguments for advanced Headless Chrome settings)** | ||
| } | ||
| api_response = a2p_client.HeadlessChrome.convert_from_url('http://www.api2pdf.com', **options) | ||
| api_response = a2p_client.Chrome.url_to_pdf('http://www.api2pdf.com', **options) | ||
| **Convert HTML to Image** | ||
| api_response = a2p_client.Chrome.html_to_image('<p>Hello, World</p>') | ||
| **Convert URL to Image** | ||
| api_response = a2p_client.Chrome.url_to_image('http://www.api2pdf.com') | ||
| --- | ||
@@ -167,19 +174,33 @@ | ||
| LibreOffice supports the conversion to PDF from the following file formats: | ||
| Convert any office file to PDF, image file to PDF, email file to PDF, HTML to Word, HTML to Excel, and PDF to HTML. Any file that can be reasonably opened by LibreOffice should be convertible. Additionally, we have an endpoint for generating a *thumbnail* of the first page of your PDF or Office Document. This is great for generating an image preview of your files to users. | ||
| - doc, docx, xls, xlsx, ppt, pptx, gif, jpg, png, bmp, rtf, txt, html | ||
| You must provide a url to the file. Our engine will consume the file at that URL and convert it. | ||
| You must provide a url to the file. Our engine will consume the file at that URL and convert it to the PDF. | ||
| **Convert Microsoft Office Document or Image to PDF** | ||
| api_response = a2p_client.LibreOffice.convert_from_url('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx') | ||
| api_response = a2p_client.LibreOffice.any_to_pdf('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx') | ||
| **Convert Microsoft Office Document or Image to PDF (load PDF in browser window and specify a file name)** | ||
| **Convert Microsoft Office Document or Image to PDF (download PDF as a file and specify a file name)** | ||
| api_response = a2p_client.LibreOffice.convert_from_url('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx', inline_pdf=True, file_name='test.pdf') | ||
| api_response = a2p_client.LibreOffice.any_to_pdf('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx', inline=False, file_name='test.pdf') | ||
| **Thumbnail or Image Preview of a PDF or Office Document or Email file** | ||
| api_response = a2p_client.LibreOffice.thumbnail('https://www.api2pdf.com/wp-content/themes/api2pdf/assets/samples/sample-word-doc.docx') | ||
| **Convert HTML to Microsoft Word or Docx** | ||
| api_response = a2p_client.LibreOffice.html_to_docx('http://www.api2pdf.com/wp-content/uploads/2021/01/sampleHtml.html') | ||
| **Convert HTML to Microsoft Excel or Xlsx** | ||
| api_response = a2p_client.LibreOffice.html_to_xlsx('http://www.api2pdf.com/wp-content/uploads/2021/01/sampleTables.html') | ||
| **Convert PDF to HTML** | ||
| api_response = a2p_client.LibreOffice.pdf_to_html('http://www.api2pdf.com/wp-content/uploads/2021/01/1a082b03-2bd6-4703-989d-0443a88e3b0f-4.pdf') | ||
| --- | ||
| ## <a name="merge"></a>Merge / Concatenate Two or More PDFs | ||
| ## <a name="merge"></a>PdfSharp - Merge / Concatenate Two or More PDFs, Add bookmarks to pdfs, add passwords to pdfs | ||
@@ -191,9 +212,23 @@ To use the merge endpoint, supply a list of urls to existing PDFs. The engine will consume all of the PDFs and merge them into a single PDF, in the order in which they were provided in the list. | ||
| links_to_pdfs = ['https://LINK-TO-PDF', 'https://LINK-TO-PDF'] | ||
| merge_result = a2p_client.merge(links_to_pdfs) | ||
| merge_result = a2p_client.PdfSharp.merge(links_to_pdfs) | ||
| **Merge PDFs from list of URLs to existing PDFs (load PDF in browser window and specify a file name)** | ||
| **Merge PDFs from list of URLs to existing PDFs (download PDF as a file and specify a file name)** | ||
| links_to_pdfs = ['https://LINK-TO-PDF', 'https://LINK-TO-PDF'] | ||
| merge_result = a2p_client.merge(links_to_pdfs, inline_pdf=True, file_name='test.pdf') | ||
| merge_result = a2p_client.PdfSharp.merge(links_to_pdfs, inline=True, file_name='test.pdf') | ||
| **Add bookmarks to existing PDF** | ||
| url = 'https://link-to-pdf | ||
| bookmarks = [ | ||
| { 'Page': 0, 'Title': 'Introduction' }, | ||
| { 'Page': 1, 'Title': 'Second page' } | ||
| ] | ||
| response = a2p.PdfSharp.add_bookmarks(url, bookmarks) | ||
| **Add password to existing PDF** | ||
| url = 'https://link-to-pdf | ||
| password = 'hello' | ||
| response = a2p.PdfSharp.add_password(url, password) | ||
| --- | ||
@@ -213,3 +248,3 @@ | ||
| links_to_pdfs = ['https://LINK-TO-PDF', 'https://LINK-TO-PDF'] | ||
| merge_result = a2p_client.merge(links_to_pdfs) | ||
| merge_result = a2p_client.PdfSharp.merge(links_to_pdfs) | ||
@@ -228,4 +263,4 @@ pdf_as_file_object = merge_result.download_pdf() | ||
| # generate a pdf | ||
| api_response = a2p_client.HeadlessChrome.convert_from_html('<p>Hello World</p>') | ||
| response_id = api_response.result['responseId'] | ||
| api_response = a2p_client.Chrome.html_to_pdf('<p>Hello World</p>') | ||
| response_id = api_response.result['ResponseId'] | ||
@@ -232,0 +267,0 @@ # delete the pdf |
+2
-2
@@ -8,6 +8,6 @@ import setuptools | ||
| name="api2pdf", | ||
| version="0.0.11", | ||
| version="2.0.0", | ||
| author="Zack Schwartz", | ||
| author_email="support@api2pdf.com", | ||
| description="Wrapper for api2pdf.com library for converting html, urls, and word documents to pdf", | ||
| description="This client library is a wrapper for the Api2Pdf.com REST API. See full REST api documentation at https://www.api2pdf.com/documentation/v2. Api2Pdf is a powerful API that supports HTML to PDF, URL to PDF, HTML to Image, URL to Image, Thumbnail / image preview of an Office file, Office files (Word to PDF), HTML to Docx, HTML to excel, PDF to HTML, merge PDFs together, add bookmarks to PDFs, add passwords to PDFs", | ||
| long_description=long_description, | ||
@@ -14,0 +14,0 @@ long_description_content_type="text/markdown", |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
44996
20.71%169
18.18%