selectpdf 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +79 -2
- data/lib/selectpdf.rb +1099 -4
- data/samples/pdf_merge.rb +40 -0
- data/samples/pdf_to_text.rb +45 -0
- data/samples/search_pdf.rb +38 -0
- metadata +8 -3
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'selectpdf'
|
2
|
+
|
3
|
+
$stdout.sync = true
|
4
|
+
|
5
|
+
print "This is SelectPdf-#{SelectPdf::CLIENT_VERSION}\n"
|
6
|
+
|
7
|
+
test_url = 'https://selectpdf.com/demo/files/selectpdf.pdf'
|
8
|
+
test_pdf = 'Input.pdf'
|
9
|
+
local_file = 'Result.pdf'
|
10
|
+
api_key = 'Your API key here'
|
11
|
+
|
12
|
+
begin
|
13
|
+
client = SelectPdf::PdfMergeClient.new(api_key)
|
14
|
+
|
15
|
+
# set parameters - see full list at https://selectpdf.com/pdf-merge-api/
|
16
|
+
|
17
|
+
# specify the pdf files that will be merged (order will be preserved in the final pdf)
|
18
|
+
client.add_file(test_pdf) # add PDF from local file
|
19
|
+
client.add_url_file(test_url) # add PDF from public url
|
20
|
+
# client.add_file(test_pdf, 'pdf_password') # add PDF (that requires a password) from local file
|
21
|
+
# client.add_url_file(test_url, 'pdf_password') # add PDF (that requires a password) from public url
|
22
|
+
|
23
|
+
print "Starting pdf merge ...\n"
|
24
|
+
|
25
|
+
# merge pdfs to local file
|
26
|
+
client.save_to_file(local_file)
|
27
|
+
|
28
|
+
# merge pdfs to memory
|
29
|
+
# pdf = client.save
|
30
|
+
|
31
|
+
print "Finished! Number of pages: #{client.number_of_pages}.\n"
|
32
|
+
|
33
|
+
# get API usage
|
34
|
+
usage_client = SelectPdf::UsageClient.new(api_key)
|
35
|
+
usage = usage_client.get_usage(FALSE)
|
36
|
+
print("Usage: #{usage}\n")
|
37
|
+
print('Conversions remained this month: ', usage['available'], "\n")
|
38
|
+
rescue SelectPdf::ApiException => e
|
39
|
+
print("An error occurred: #{e}")
|
40
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'selectpdf'
|
2
|
+
|
3
|
+
$stdout.sync = true
|
4
|
+
|
5
|
+
print "This is SelectPdf-#{SelectPdf::CLIENT_VERSION}\n"
|
6
|
+
|
7
|
+
test_url = 'https://selectpdf.com/demo/files/selectpdf.pdf'
|
8
|
+
test_pdf = 'Input.pdf'
|
9
|
+
local_file = 'Result.txt'
|
10
|
+
api_key = 'Your API key here'
|
11
|
+
|
12
|
+
begin
|
13
|
+
client = SelectPdf::PdfToTextClient.new(api_key)
|
14
|
+
|
15
|
+
# set parameters - see full list at https://selectpdf.com/pdf-to-text-api/
|
16
|
+
client.start_page = 1 # start page (processing starts from here)
|
17
|
+
client.end_page = 0 # end page (set 0 to process file til the end)
|
18
|
+
client.output_format = SelectPdf::OutputFormat::TEXT # set output format (Text or HTML)
|
19
|
+
|
20
|
+
print "Starting pdf to text ...\n"
|
21
|
+
|
22
|
+
# convert local pdf to local text file
|
23
|
+
client.text_from_file_to_file(test_pdf, local_file)
|
24
|
+
|
25
|
+
# extract text from local pdf to memory
|
26
|
+
# text = client.text_from_file(test_pdf)
|
27
|
+
# print text
|
28
|
+
|
29
|
+
# convert pdf from public url to local text file
|
30
|
+
# client.text_from_url_to_file(test_url, local_file)
|
31
|
+
|
32
|
+
# extract text from pdf from public url to memory
|
33
|
+
# text = client.text_from_url(test_url)
|
34
|
+
# print text
|
35
|
+
|
36
|
+
print "Finished! Number of pages processed: #{client.number_of_pages}.\n"
|
37
|
+
|
38
|
+
# get API usage
|
39
|
+
usage_client = SelectPdf::UsageClient.new(api_key)
|
40
|
+
usage = usage_client.get_usage(FALSE)
|
41
|
+
print("Usage: #{usage}\n")
|
42
|
+
print('Conversions remained this month: ', usage['available'], "\n")
|
43
|
+
rescue SelectPdf::ApiException => e
|
44
|
+
print("An error occurred: #{e}")
|
45
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'selectpdf'
|
2
|
+
|
3
|
+
$stdout.sync = true
|
4
|
+
|
5
|
+
print "This is SelectPdf-#{SelectPdf::CLIENT_VERSION}\n"
|
6
|
+
|
7
|
+
test_url = 'https://selectpdf.com/demo/files/selectpdf.pdf'
|
8
|
+
test_pdf = 'Input.pdf'
|
9
|
+
api_key = 'Your API key here'
|
10
|
+
|
11
|
+
begin
|
12
|
+
client = SelectPdf::PdfToTextClient.new(api_key)
|
13
|
+
|
14
|
+
# set parameters - see full list at https://selectpdf.com/pdf-to-text-api/
|
15
|
+
client.start_page = 1 # start page (processing starts from here)
|
16
|
+
client.end_page = 0 # end page (set 0 to process file til the end)
|
17
|
+
client.output_format = SelectPdf::OutputFormat::TEXT # set output format (Text or HTML)
|
18
|
+
|
19
|
+
print "Starting search pdf ...\n"
|
20
|
+
|
21
|
+
# search local pdf
|
22
|
+
results = client.search_file(test_pdf, 'pdf')
|
23
|
+
|
24
|
+
# search pdf from public url
|
25
|
+
# results = client.search_url(test_url, 'pdf')
|
26
|
+
|
27
|
+
print "Search results: #{results}.\nSearch results count: #{results.length}\n"
|
28
|
+
|
29
|
+
print "Finished! Number of pages processed: #{client.number_of_pages}.\n"
|
30
|
+
|
31
|
+
# get API usage
|
32
|
+
usage_client = SelectPdf::UsageClient.new(api_key)
|
33
|
+
usage = usage_client.get_usage(FALSE)
|
34
|
+
print("Usage: #{usage}\n")
|
35
|
+
print('Conversions remained this month: ', usage['available'], "\n")
|
36
|
+
rescue SelectPdf::ApiException => e
|
37
|
+
print("An error occurred: #{e}")
|
38
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selectpdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SelectPdf
|
@@ -14,6 +14,8 @@ description: |2
|
|
14
14
|
SelectPdf Online REST API is a professional solution for managing PDF documents online.
|
15
15
|
SelectPdf cloud API consists of the following:
|
16
16
|
HTML to PDF REST API – 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.
|
17
|
+
PDF to TEXT REST API – 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.
|
18
|
+
PDF Merge REST API – SelectPdf Pdf Merge REST API is an online solution that lets you merge local or remote PDFs into a final PDF document.
|
17
19
|
email: support@selectpdf.com
|
18
20
|
executables: []
|
19
21
|
extensions: []
|
@@ -24,6 +26,9 @@ files:
|
|
24
26
|
- lib/selectpdf.rb
|
25
27
|
- samples/html_to_pdf_headers_and_footers.rb
|
26
28
|
- samples/html_to_pdf_main.rb
|
29
|
+
- samples/pdf_merge.rb
|
30
|
+
- samples/pdf_to_text.rb
|
31
|
+
- samples/search_pdf.rb
|
27
32
|
- samples/simple_html_string_to_pdf.rb
|
28
33
|
- samples/simple_url_to_pdf.rb
|
29
34
|
homepage: https://selectpdf.com/html-to-pdf-api/
|
@@ -48,6 +53,6 @@ requirements: []
|
|
48
53
|
rubygems_version: 3.1.4
|
49
54
|
signing_key:
|
50
55
|
specification_version: 4
|
51
|
-
summary: SelectPdf Online REST API client library for Ruby. Contains
|
52
|
-
to PDF
|
56
|
+
summary: SelectPdf Online REST API client library for Ruby. Contains HTML to PDF converter,
|
57
|
+
PDF merge, PDF to text extractor, search PDF.
|
53
58
|
test_files: []
|