This page serves as a guide for using the PDFCrowd API to convert images to PDF in Python applications.
Below are Python examples to help you quickly get started with the API. Explore our additional examples for more insights.
It is recommended that you implement error handling to catch errors the API may return. Effective error handling is vital as it ensures application stability and provides clearer diagnostics. See the example code below for guidance on implementing error handling, and refer to this list of status codes for more information.
try: # Call the API except pdfcrowd.Error as why: # Log the complete error sys.stderr.write('PDFCrowd Error: {}\n'.format(why)) # Log the HTTP status code sys.stderr.write('Status Code: {}\n'.format(why.getStatusCode())) # Log the reason code sys.stderr.write('Reason Code: {}\n'.format(why.getReasonCode())) # Log the error message sys.stderr.write('Error Message: {}\n'.format(why.getMessage())) # Log the documentation link sys.stderr.write('Documentation Link: {}\n'.format(why.getDocumentationLink()))
Refer to the Image to PDF Python Reference for a description of all API methods.