How to convert CSV to PDF from URL for CSV to PDF API in Python with PDF.co Web API

How to convert CSV to PDF from URL in Python with easy ByteScout code samples to make CSV to PDF API. Step-by-step tutorial

If you want a quick and easy way to add a required functionality into your application then check this sample source code documentation. PDF.co Web API was designed to assist CSV to PDF API in Python. PDF.co Web API is the Rest API that provides set of data extraction functions, tools for documents manipulation, splitting and merging of pdf files. Includes built-in OCR, images recognition, can generate and read barcodes from images, scans and pdf.

If you want to speed up the application’s code writing then Python code samples for Python developers help to implement using PDF.co Web API. This Python sample code can be used by copying and pasting into your project. Once done,just compile your project and click Run. Enjoy writing a code with ready-to-use sample Python codes to implement CSV to PDF API using PDF.co Web API.

Free! Free! Free! ByteScout free trial version is available for FREE download from our website. Programming tutorials along with source code samples are assembled.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

ConvertCsvToPdfFromUrl.py
      
import os import requests # pip install requests # The authentication key (API Key). # Get your own by registering at https://app.pdf.co/documentation/api API_KEY = "******************************************" # Base URL for PDF.co Web API requests BASE_URL = "https://api.pdf.co/v1" # Direct URL of source CSV file. SourceFileURL = "https://bytescout-com.s3.amazonaws.com/files/demo-files/cloud-api/csv-to-pdf/sample.csv" # Destination PDF file name DestinationFile = ".\\result.pdf" def main(args = None): convertCSVToPDF(SourceFileURL, DestinationFile) def convertCSVToPDF(uploadedFileUrl, destinationFile): """Converts CSV to PDF using PDF.co Web API""" # Prepare URL for 'CSV To PDF' API request url = "{}/pdf/convert/from/csv?name={}&url={}".format( BASE_URL, os.path.basename(destinationFile), uploadedFileUrl ) # Execute request and get response as JSON response = requests.get(url, headers={ "x-api-key": API_KEY, "content-type": "application/octet-stream" }) if (response.status_code == 200): json = response.json() if json["error"] == False: # Get URL of result file resultFileUrl = json["url"] # Download result file r = requests.get(resultFileUrl, stream=True) if (r.status_code == 200): with open(destinationFile, 'wb') as file: for chunk in r: file.write(chunk) print(f"Result file saved as \"{destinationFile}\" file.") else: print(f"Request error: {response.status_code} {response.reason}") else: # Show service reported error print(json["message"]) else: print(f"Request error: {response.status_code} {response.reason}") if __name__ == '__main__': main()

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit PDF.co Web API Home Page

Explore PDF.co Web API Documentation

Explore Samples

Sign Up for PDF.co Web API Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

VIDEO

ON-PREMISE OFFLINE SDK

60 Day Free Trial or Visit PDF.co Web API Home Page

Explore PDF.co Web API Documentation

Explore Samples

Sign Up for PDF.co Web API Online Training

ON-DEMAND REST WEB API

Get Your API Key

Explore Web API Docs

Explore Web API Samples

Related Samples: