|
1 |
| -# selectpdf-api-ruby-client |
2 |
| -Ruby client for SelectPdf Online REST API |
| 1 | +# SelectPdf Online REST API - Ruby Client |
| 2 | + |
| 3 | +SelectPdf Online REST API is a professional solution for managing PDF documents online. It now has a dedicated, easy to use, Ruby client library that can be setup in minutes. |
| 4 | + |
| 5 | +## Installation |
| 6 | + |
| 7 | +Install SelectPdf Ruby Client for Online API via [RubyGems](https://rubygems.org/gems/selectpdf). |
| 8 | + |
| 9 | +``` |
| 10 | +gem install selectpdf |
| 11 | +``` |
| 12 | + |
| 13 | +OR |
| 14 | + |
| 15 | +Download [selectpdf-api-ruby-client-1.4.0.zip](https://github.com/selectpdf/selectpdf-api-ruby-client/releases/download/1.4.0/selectpdf-api-ruby-client-1.4.0.zip), unzip it and run: |
| 16 | + |
| 17 | +``` |
| 18 | +cd selectpdf-api-ruby-client-1.4.0 |
| 19 | +gem build selectpdf.gemspec |
| 20 | +gem install selectpdf-1.4.0.gem |
| 21 | +``` |
| 22 | + |
| 23 | +OR |
| 24 | + |
| 25 | +Clone [selectpdf-api-ruby-client](https://github.com/selectpdf/selectpdf-api-ruby-client) from Github and install the library. |
| 26 | + |
| 27 | +``` |
| 28 | +git clone https://github.com/selectpdf/selectpdf-api-ruby-client |
| 29 | +cd selectpdf-api-ruby-client |
| 30 | +gem build selectpdf.gemspec |
| 31 | +gem install selectpdf-1.4.0.gem |
| 32 | +``` |
| 33 | + |
| 34 | +## HTML To PDF API - Ruby Client |
| 35 | + |
| 36 | +SelectPdf HTML To PDF Online REST API is a professional solution that lets you create PDF from web pages and raw HTML code in your applications. The API is easy to use and the integration takes only a few lines of code. |
| 37 | + |
| 38 | +### Features |
| 39 | + |
| 40 | +* Create PDF from any web page or html string. |
| 41 | +* Full html5/css3/javascript support. |
| 42 | +* Set PDF options such as page size and orientation, margins, security, web page settings. |
| 43 | +* Set PDF viewer options and PDF document information. |
| 44 | +* Create custom headers and footers for the pdf document. |
| 45 | +* Hide web page elements during the conversion. |
| 46 | +* Automatically generate bookmarks during the html to pdf conversion. |
| 47 | +* Support for partial page conversion. |
| 48 | +* Works in all programming languages. |
| 49 | + |
| 50 | +Sign up for for free to get instant API access to SelectPdf [HTML to PDF API](https://selectpdf.com/html-to-pdf-api/). |
| 51 | + |
| 52 | +### Sample Code |
| 53 | + |
| 54 | +```ruby |
| 55 | + require 'selectpdf' |
| 56 | + print "This is SelectPdf-#{SelectPdf::CLIENT_VERSION}\n" |
| 57 | + |
| 58 | + url = 'https://selectpdf.com' |
| 59 | + local_file = 'Test.pdf' |
| 60 | + api_key = 'Your API key here' |
| 61 | + |
| 62 | + begin |
| 63 | + api = SelectPdf::HtmlToPdfClient.new(api_key) |
| 64 | + |
| 65 | + api.page_size = SelectPdf::PageSize::A4 |
| 66 | + api.margins = 0 |
| 67 | + api.page_numbers = FALSE |
| 68 | + api.page_breaks_enhanced_algorithm = TRUE |
| 69 | + |
| 70 | + api.convert_url_to_file(url, local_file) |
| 71 | + rescue SelectPdf::ApiException => e |
| 72 | + print("An error occurred: #{e}") |
| 73 | + end |
| 74 | +``` |
| 75 | + |
| 76 | +## Pdf Merge API |
| 77 | + |
| 78 | +SelectPdf Pdf Merge REST API is an online solution that lets you merge local or remote PDFs into a final PDF document. |
| 79 | + |
| 80 | +### Features |
| 81 | + |
| 82 | +* Merge local PDF document. |
| 83 | +* Merge remote PDF from public url. |
| 84 | +* Set PDF viewer options and PDF document information. |
| 85 | +* Secure generated PDF with a password. |
| 86 | +* Works in all programming languages. |
| 87 | + |
| 88 | +See [PDF Merge API](https://selectpdf.com/pdf-merge-api/) page for full list of parameters. |
| 89 | + |
| 90 | +### Sample Code |
| 91 | + |
| 92 | +```ruby |
| 93 | + require 'selectpdf' |
| 94 | + print "This is SelectPdf-#{SelectPdf::CLIENT_VERSION}\n" |
| 95 | + |
| 96 | + test_url = 'https://selectpdf.com/demo/files/selectpdf.pdf' |
| 97 | + test_pdf = 'Input.pdf' |
| 98 | + local_file = 'Result.pdf' |
| 99 | + api_key = 'Your API key here' |
| 100 | + |
| 101 | + begin |
| 102 | + client = SelectPdf::PdfMergeClient.new(api_key) |
| 103 | + |
| 104 | + # specify the pdf files that will be merged (order will be preserved in the final pdf) |
| 105 | + client.add_file(test_pdf) # add PDF from local file |
| 106 | + client.add_url_file(test_url) # add PDF from public url |
| 107 | + |
| 108 | + # merge pdfs to local file |
| 109 | + client.save_to_file(local_file) |
| 110 | + rescue SelectPdf::ApiException => e |
| 111 | + print("An error occurred: #{e}") |
| 112 | + end |
| 113 | +``` |
| 114 | + |
| 115 | +## Pdf To Text API |
| 116 | + |
| 117 | +SelectPdf Pdf To Text REST API is an online solution that lets you extract text from your PDF documents or search your PDF document for certain words. |
| 118 | + |
| 119 | +### Features |
| 120 | + |
| 121 | +* Extract text from PDF. |
| 122 | +* Search PDF. |
| 123 | +* Specify start and end page for partial file processing. |
| 124 | +* Specify output format (plain text or html). |
| 125 | +* Use a PDF from an online location (url) or upload a local PDF document. |
| 126 | + |
| 127 | +See [Pdf To Text API](https://selectpdf.com/pdf-to-text-api/) page for full list of parameters. |
| 128 | + |
| 129 | +### Sample Code |
| 130 | + |
| 131 | +```ruby |
| 132 | + require 'selectpdf' |
| 133 | + print "This is SelectPdf-#{SelectPdf::CLIENT_VERSION}\n" |
| 134 | + |
| 135 | + test_pdf = 'Input.pdf' |
| 136 | + local_file = 'Result.txt' |
| 137 | + api_key = 'Your API key here' |
| 138 | + |
| 139 | + begin |
| 140 | + client = SelectPdf::PdfToTextClient.new(api_key) |
| 141 | + |
| 142 | + # set parameters - see full list at https://selectpdf.com/pdf-to-text-api/ |
| 143 | + client.start_page = 1 # start page (processing starts from here) |
| 144 | + client.end_page = 0 # end page (set 0 to process file til the end) |
| 145 | + client.output_format = SelectPdf::OutputFormat::TEXT # set output format (Text or HTML) |
| 146 | + |
| 147 | + print "Starting pdf to text ...\n" |
| 148 | + |
| 149 | + # convert local pdf to local text file |
| 150 | + client.text_from_file_to_file(test_pdf, local_file) |
| 151 | + |
| 152 | + print "Finished! Number of pages processed: #{client.number_of_pages}.\n" |
| 153 | + rescue SelectPdf::ApiException => e |
| 154 | + print("An error occurred: #{e}") |
| 155 | + end |
| 156 | +``` |
| 157 | + |
0 commit comments