This page describes how to use the Pdfcrowd online API to join multiple PDF files or update PDF attributes
in Ruby.
The API is user-friendly and can be integrated into your application with just a few lines of code.
Installation
You can install the client library from rubygems.org
Here are Ruby examples for quickly getting started with the API.
See more examples.
require"pdfcrowd"begin# create the API client instanceclient=Pdfcrowd::PdfToPdfClient.new("demo","ce544b6ea52a5621fb9d55f8b542d14d")# configure the conversionclient.addPdfFile("/path/to/cover.pdf")client.addPdfFile("/path/to/proposal.pdf")client.addPdfFile("/path/to/price.pdf")client.addPdfFile("/path/to/contact.pdf")# run the conversion and write the result to a fileclient.convertToFile("offer.pdf")rescuePdfcrowd::Error=>whySTDERR.puts"Pdfcrowd Error: #{why}"raiseend
require"pdfcrowd"begin# create the API client instanceclient=Pdfcrowd::PdfToPdfClient.new("demo","ce544b6ea52a5621fb9d55f8b542d14d")# configure the conversionclient.addPdfRawData(open('/path/to/cover.pdf','rb').read())client.addPdfRawData(open('/path/to/proposal.pdf','rb').read())client.addPdfRawData(open('/path/to/price.pdf','rb').read())client.addPdfRawData(open('/path/to/contact.pdf','rb').read())# run the conversion and write the result to a fileclient.convertToFile("offer.pdf")rescuePdfcrowd::Error=>whySTDERR.puts"Pdfcrowd Error: #{why}"raiseend
require"pdfcrowd"begin# create the API client instanceclient=Pdfcrowd::PdfToPdfClient.new("demo","ce544b6ea52a5621fb9d55f8b542d14d")# configure the conversionclient.addPdfFile("/path/to/proposal.pdf")client.setPageWatermark("/path/to/watermark.pdf")# run the conversion and write the result to a fileclient.convertToFile("company_offer.pdf")rescuePdfcrowd::Error=>whySTDERR.puts"Pdfcrowd Error: #{why}"raiseend
Authentication
The credentials to access the API are your Pdfcrowd username and the API key.
You can try out the API without registering using the following demo
credentials:
It is recommended that you implement error handling to catch errors
that the API may return, see the example code below. A list of status
codes and their description can be found
here.
begin# call the API rescuePdfcrowd::Error=>why# print the errorSTDERR.puts"Pdfcrowd Error: #{why}"# print the error codeSTDERR.puts"Pdfcrowd Error Code: #{why.getCode()}"# print the error messageSTDERR.puts"Pdfcrowd Error Message: #{why.getMessage()}"end