Skip to content

Commit

Permalink
Merge pull request #11 from jafacakes2011/rename-download-pdf
Browse files Browse the repository at this point in the history
Rename download_pdf to download_file
  • Loading branch information
apexdodge authored Aug 2, 2021
2 parents bc5aabb + 9982b2e commit dc69d55
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,9 +224,9 @@ To use the merge endpoint, supply a list of urls to existing PDFs. The engine wi

## <a name="helpers"></a>Helper Methods

**Api2PdfResponse: download_pdf()**
**Api2PdfResponse: download_file()**

On any `Api2PdfResponse` that succesfully generated a pdf, you can use the handy `download_pdf()` method to download the pdf to a file-like object which you can then save to your local cache. If the pdf generation was unsuccessful, it will throw a FileNotFoundException.
On any `Api2PdfResponse` that succesfully generated a pdf, you can use the handy `download_file()` method to download the pdf to a file-like object which you can then save to your local cache. If the pdf generation was unsuccessful, it will throw a FileNotFoundException.

```
from api2pdf import Api2Pdf
Expand All @@ -236,7 +236,7 @@ a2p_client = Api2Pdf('YOUR-API-KEY')
links_to_pdfs = ['https://LINK-TO-PDF', 'https://LINK-TO-PDF']
merge_result = a2p_client.PdfSharp.merge(links_to_pdfs)
pdf_as_file_object = merge_result.download_pdf()
pdf_as_file_object = merge_result.download_file()
```

**Delete a PDF on Command with delete(response_id)**
Expand Down
2 changes: 1 addition & 1 deletion api2pdf/api2pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ def request(self):
def result(self):
return self._result

def download_pdf(self):
def download_file(self):
USERAGENT = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'}
if self.result['Success']:
downloaded_file = requests.get(self.result['FileUrl'], headers=USERAGENT)
Expand Down

0 comments on commit dc69d55

Please sign in to comment.