HyperPDF
Ruby wrapper around the HyperPDF API
Installation
Add this line to your application's Gemfile:
gem 'hyperpdf'
And then execute:
$ bundle
Or install it yourself as:
$ gem install hyperpdf
Usage
Initialize new HyperPDF instance
pdf = HyperPDF.new('<htlm>...your html code here...</html>', user: "your_user_name", password: "your_password")
Get pdf document directly
# Write it to file File.open('filename.pdf', 'wb') do |f| f.write pdf.get end
# Or send it to user (Rails example) send_data(pdf.get, filename: 'hyperpdf.pdf', type: 'application/pdf')
Or upload it to your AWS S3 bucket
pdf.upload_to_s3('YOUR_BUCKET_NAME', 'filename.pdf', true)
NOTE! Before using 'upload_to_s3' method you need to give permission HyperPDF upload files to your bucket.
- Log into your AWS Console
- Choose S3 service
- Right click on the bucket you wish to give HyperPDF permission to write to
- From the context menu, click "Properties"
- On properties panel select "Permissions" and click on "Add bucket policy" button
- Paste the following policy into the dialog that appears (Replace YOUR_BUCKET_NAME with the name of the bucket you are adding this permission to):
{ "Version": "2008-10-17", "Statement": [ { "Sid": "AddCannedAcl", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::888261251835:root" }, "Action": [ "s3:PutObjectAcl", "s3:PutObject" ], "Resource": "arn:aws:s3:::YOUR_BUCKET_NAME/*" } ] }
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request