require "docraptor" DocRaptor.configure do |config| config.username = "YOUR_API_KEY_HERE" # this key works in test mode! end docraptor = DocRaptor::DocApi.new begin response = docraptor.create_doc( test: true, # test documents are free but watermarked document_type: "pdf", document_content: "Hello World!", # document_url: "http://docraptor.com/examples/invoice.html", # javascript: false, ) # create_doc() returns a binary string File.write("docraptor-hello.pdf", response, mode: "wb") puts "Successfully created docraptor-hello.pdf!" rescue DocRaptor::ApiError => error puts "#{error.class}: #{error.message}" puts error.code puts error.response_body puts error.backtrace[0..3].join("\n") end