selectpdf 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,61 @@
1
+ require 'selectpdf'
2
+
3
+ $stdout.sync = true
4
+
5
+ print "This is SelectPdf-#{SelectPdf::CLIENT_VERSION}\n"
6
+
7
+ url = 'https://selectpdf.com'
8
+ local_file = 'Test.pdf'
9
+ api_key = 'Your API key here'
10
+
11
+ begin
12
+ client = SelectPdf::HtmlToPdfClient.new(api_key)
13
+
14
+ # set parameters - see full list at https://selectpdf.com/html-to-pdf-api/
15
+
16
+ client.margins = 0 # PDF page margins
17
+ client.page_breaks_enhanced_algorithm = TRUE # enhanced page break algorithm
18
+
19
+ # header properties
20
+ client.show_header = TRUE # display header
21
+ # client.header_height = 50 # header height
22
+ # client.header_url = url # header url
23
+ client.header_html = 'This is the <b>HEADER</b>!!!!' # header html
24
+
25
+ # footer properties
26
+ client.show_footer = TRUE # display footer
27
+ # client.footer_height = 60 # footer height
28
+ # client.footer_url = url # footer url
29
+ client.footer_html = 'This is the <b>FOOTER</b>!!!!' # footer html
30
+
31
+ # footer page numbers
32
+ client.page_numbers = TRUE # show page numbers in footer
33
+ client.page_numbers_template = '{page_number} / {total_pages}' # page numbers template
34
+ client.page_numbers_font_name = 'Verdanda' # page numbers font name
35
+ client.page_numbers_font_size = 12 # page numbers font size
36
+ client.page_numbers_alignment = SelectPdf::PageNumbersAlignment::CENTER # page numbers alignment
37
+
38
+ print "Starting conversion ...\n"
39
+
40
+ # convert url to file
41
+ client.convert_url_to_file(url, local_file)
42
+
43
+ # convert url to memory
44
+ # pdf = client.convert_url(url)
45
+
46
+ # convert html string to file
47
+ # client.convert_html_string_to_file('This is some <b>html</b>.', local_file)
48
+
49
+ # convert html string to memory
50
+ # pdf = client.convert_html_string('This is some <b>html</b>.')
51
+
52
+ print "Finished! Number of pages: #{client.number_of_pages}.\n"
53
+
54
+ # get API usage
55
+ usage_client = SelectPdf::UsageClient.new(api_key)
56
+ usage = usage_client.get_usage(FALSE)
57
+ print("Usage: #{usage}\n")
58
+ print('Conversions remained this month: ', usage['available'], "\n")
59
+ rescue SelectPdf::ApiException => e
60
+ print("An error occurred: #{e}")
61
+ end
@@ -0,0 +1,64 @@
1
+ require 'selectpdf'
2
+
3
+ $stdout.sync = true
4
+
5
+ print "This is SelectPdf-#{SelectPdf::CLIENT_VERSION}\n"
6
+
7
+ url = 'https://selectpdf.com'
8
+ local_file = 'Test.pdf'
9
+ api_key = 'Your API key here'
10
+
11
+ begin
12
+ client = SelectPdf::HtmlToPdfClient.new(api_key)
13
+
14
+ # set parameters - see full list at https://selectpdf.com/html-to-pdf-api/
15
+
16
+ client.page_size = SelectPdf::PageSize::A4 # PDF page size
17
+ client.page_orientation = SelectPdf::PageOrientation::PORTRAIT # PDF page orientation
18
+ client.margins = 0 # PDF page margins
19
+ client.rendering_engine = SelectPdf::RenderingEngine::WEBKIT # rendering engine
20
+ client.conversion_delay = 1 # conversion delay
21
+ client.navigation_timeout = 30 # navigation timeout
22
+ client.page_numbers = FALSE # page numbers
23
+ client.page_breaks_enhanced_algorithm = TRUE # enhanced page break algorithm
24
+
25
+ # additional properties
26
+
27
+ # client.use_css_print = TRUE # enable CSS media print
28
+ # client.disable_javascript = TRUE # disable javascript
29
+ # client.disable_internal_links = TRUE # disable internal links
30
+ # client.disable_external_links = TRUE # disable external links
31
+ # client.keep_images_together = TRUE # keep images together
32
+ # client.scale_images = TRUE # scale images to create smaller pdfs
33
+ # client.single_page_pdf = TRUE # generate a single page PDF
34
+ # client.user_password = 'password' # secure the PDF with a password
35
+
36
+ # generate automatic bookmarks
37
+
38
+ # client.pdf_bookmarks_selectors = 'H1, H2' # create outlines (bookmarks) for the specified elements
39
+ # client.viewer_page_mode = SelectPdf::PageMode::USE_OUTLINES # display outlines (bookmarks) in viewer
40
+
41
+ print "Starting conversion ...\n"
42
+
43
+ # convert url to file
44
+ client.convert_url_to_file(url, local_file)
45
+
46
+ # convert url to memory
47
+ # pdf = client.convert_url(url)
48
+
49
+ # convert html string to file
50
+ # client.convert_html_string_to_file('This is some <b>html</b>.', local_file)
51
+
52
+ # convert html string to memory
53
+ # pdf = client.convert_html_string('This is some <b>html</b>.')
54
+
55
+ print "Finished! Number of pages: #{client.number_of_pages}.\n"
56
+
57
+ # get API usage
58
+ usage_client = SelectPdf::UsageClient.new(api_key)
59
+ usage = usage_client.get_usage(FALSE)
60
+ print("Usage: #{usage}\n")
61
+ print('Conversions remained this month: ', usage['available'], "\n")
62
+ rescue SelectPdf::ApiException => e
63
+ print("An error occurred: #{e}")
64
+ end
@@ -0,0 +1,19 @@
1
+ require 'selectpdf'
2
+ print "This is SelectPdf-#{SelectPdf::CLIENT_VERSION}\n"
3
+
4
+ html = 'This is a <b>test HTML</b>.'
5
+ local_file = 'Test.pdf'
6
+ api_key = 'Your API key here'
7
+
8
+ begin
9
+ api = SelectPdf::HtmlToPdfClient.new(api_key)
10
+
11
+ api.page_size = SelectPdf::PageSize::A4
12
+ api.margins = 0
13
+ api.page_numbers = FALSE
14
+ api.page_breaks_enhanced_algorithm = TRUE
15
+
16
+ api.convert_html_string_to_file(html, local_file)
17
+ rescue SelectPdf::ApiException => e
18
+ print("An error occurred: #{e}")
19
+ end
@@ -0,0 +1,19 @@
1
+ require 'selectpdf'
2
+ print "This is SelectPdf-#{SelectPdf::CLIENT_VERSION}\n"
3
+
4
+ url = 'https://selectpdf.com'
5
+ local_file = 'Test.pdf'
6
+ api_key = 'Your API key here'
7
+
8
+ begin
9
+ api = SelectPdf::HtmlToPdfClient.new(api_key)
10
+
11
+ api.page_size = SelectPdf::PageSize::A4
12
+ api.margins = 0
13
+ api.page_numbers = FALSE
14
+ api.page_breaks_enhanced_algorithm = TRUE
15
+
16
+ api.convert_url_to_file(url, local_file)
17
+ rescue SelectPdf::ApiException => e
18
+ print("An error occurred: #{e}")
19
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: selectpdf
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.0
5
+ platform: ruby
6
+ authors:
7
+ - SelectPdf
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-11-17 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: |2
14
+ SelectPdf Online REST API is a professional solution for managing PDF documents online.
15
+ SelectPdf cloud API consists of the following:
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
+ email: support@selectpdf.com
18
+ executables: []
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - CHANGELOG.md
23
+ - README.md
24
+ - lib/selectpdf.rb
25
+ - samples/html_to_pdf_headers_and_footers.rb
26
+ - samples/html_to_pdf_main.rb
27
+ - samples/simple_html_string_to_pdf.rb
28
+ - samples/simple_url_to_pdf.rb
29
+ homepage: https://selectpdf.com/html-to-pdf-api/
30
+ licenses:
31
+ - MIT
32
+ metadata: {}
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubygems_version: 3.1.4
49
+ signing_key:
50
+ specification_version: 4
51
+ summary: SelectPdf Online REST API client library for Ruby. Contains a powerful HTML
52
+ to PDF converter.
53
+ test_files: []