Ruby Code Sample to Create PDF from HTML Using REST API


/ Published in: Ruby
Save to your folder(s)

This code sample shows how Ruby developers can create PDF file from HTML using Aspose.Pdf for Cloud API in their REST applications.


Copy this code and paste it in your HTML
  1. app_sid = '77******-1***-4***-a***-8***********'
  2. app_key = '89******************************'
  3. Aspose::Cloud::Common::AsposeApp.new(app_sid, app_key)
  4.  
  5. #build URI to create PDF from HTML
  6. str_uri = 'http://api.aspose.com/v1.1/pdf/outPdfFile.pdf?templateFile=HtmlExample1.html&templateType=html'
  7.  
  8. #sign URI
  9. signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  10. RestClient.put(signed_uri, '', {:accept=>'application/json'})
  11.  
  12. #build URI to download output file
  13. str_uri = 'http://api.aspose.com/v1.1/storage/file/outPdfFile.pdf'
  14.  
  15. #sign URI
  16. signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)
  17. response_stream = RestClient.get(signed_uri, :accept => 'application/json')
  18. Aspose::Cloud::Common::Utils.save_file(response_stream, "outPdfFile.pdf")
  19. p 'done'

URL: http://www.aspose.com/docs/display/pdfcloud/Create+PDF+from+HTML

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.