Class: SelectPdf::HtmlToPdfClient
- Defined in:
- lib/selectpdf.rb
Overview
Html To Pdf Conversion with SelectPdf Online API.
Code sample:
Instance Attribute Summary
Attributes inherited from ApiClient
#api_async_endpoint, #api_endpoint, #api_web_elements_endpoint, #async_calls_max_pings, #async_calls_ping_interval, #number_of_pages
Instance Method Summary collapse
-
#background_color=(background_color) ⇒ Object
Specify the background color of the PDF page in RGB html format.
-
#conversion_delay=(conversion_delay) ⇒ Object
Introduce a delay (in seconds) before the actual conversion to allow the web page to fully load.
-
#convert_html_string(html_string) ⇒ Object
Convert the specified HTML string to PDF.
-
#convert_html_string_async(html_string) ⇒ Object
Convert the specified HTML string to PDF with an asynchronous call.
-
#convert_html_string_to_file(html_string, file_path) ⇒ Object
Convert the specified HTML string to PDF and writes the resulted PDF to a local file.
-
#convert_html_string_to_file_async(html_string, file_path) ⇒ Object
Convert the specified HTML string to PDF with an asynchronous call and writes the resulted PDF to a local file.
-
#convert_html_string_to_stream(html_string, stream) ⇒ Object
Convert the specified HTML string to PDF and writes the resulted PDF to an output stream.
-
#convert_html_string_to_stream_async(html_string, stream) ⇒ Object
Convert the specified HTML string to PDF with an asynchronous call and writes the resulted PDF to an output stream.
-
#convert_html_string_to_stream_with_base_url(html_string, base_url, stream) ⇒ Object
Convert the specified HTML string to PDF and writes the resulted PDF to an output stream.
-
#convert_html_string_to_stream_with_base_url_async(html_string, base_url, stream) ⇒ Object
Convert the specified HTML string to PDF with an asynchronous call and writes the resulted PDF to an output stream.
-
#convert_html_string_with_base_url(html_string, base_url) ⇒ Object
Convert the specified HTML string to PDF.
-
#convert_html_string_with_base_url_async(html_string, base_url) ⇒ Object
Convert the specified HTML string to PDF with an asynchronous call.
-
#convert_html_string_with_base_url_to_file(html_string, base_url, file_path) ⇒ Object
Convert the specified HTML string to PDF and writes the resulted PDF to a local file.
-
#convert_html_string_with_base_url_to_file_async(html_string, base_url, file_path) ⇒ Object
Convert the specified HTML string to PDF with an asynchronous call and writes the resulted PDF to a local file.
-
#convert_url(url) ⇒ Object
Convert the specified url to PDF.
-
#convert_url_async(url) ⇒ Object
Convert the specified url to PDF using an asynchronous call.
-
#convert_url_to_file(url, file_path) ⇒ Object
Convert the specified url to PDF and writes the resulted PDF to a local file.
-
#convert_url_to_file_async(url, file_path) ⇒ Object
Convert the specified url to PDF using an asynchronous call and writes the resulted PDF to a local file.
-
#convert_url_to_stream(url, stream) ⇒ Object
Convert the specified url to PDF and writes the resulted PDF to an output stream.
-
#convert_url_to_stream_async(url, stream) ⇒ Object
Convert the specified url to PDF using an asynchronous call and writes the resulted PDF to an output stream.
-
#cookies=(cookies) ⇒ Object
Set HTTP cookies for the web page being converted.
-
#disable_external_links=(disable_external_links) ⇒ Object
Do not create external links in the PDF.
-
#disable_internal_links=(disable_internal_links) ⇒ Object
Do not create internal links in the PDF.
-
#disable_javascript=(disable_javascript) ⇒ Object
Do not run JavaScript in web pages.
-
#doc_add_creation_date=(doc_add_creation_date) ⇒ Object
Add the date and time when the PDF document was created to the PDF document information.
-
#doc_author=(doc_author) ⇒ Object
Set the name of the PDF document author.
-
#doc_keywords=(doc_keywords) ⇒ Object
Set the PDF document keywords.
-
#doc_subject=(doc_subject) ⇒ Object
Set the subject of the PDF document.
-
#doc_title=(doc_title) ⇒ Object
Set the PDF document title.
-
#draw_html_background=(draw_html_background) ⇒ Object
Set a flag indicating if the web page background is rendered in PDF.
-
#footer_base_url=(footer_base_url) ⇒ Object
Set an optional base url parameter can be used together with the footer HTML to resolve relative paths from the html string.
-
#footer_display_on_even_pages=(footer_display_on_even_pages) ⇒ Object
Control the visibility of the footer on the even numbered pages of the generated pdf document.
-
#footer_display_on_first_page=(footer_display_on_first_page) ⇒ Object
Control the visibility of the footer on the first page of the generated pdf document.
-
#footer_display_on_last_page=(footer_display_on_last_page) ⇒ Object
Add a special footer on the last page of the generated pdf document only.
-
#footer_display_on_odd_pages=(footer_display_on_odd_pages) ⇒ Object
Control the visibility of the footer on the odd numbered pages of the generated pdf document.
-
#footer_height=(footer_height) ⇒ Object
The height of the pdf document footer.
-
#footer_html=(footer_html) ⇒ Object
Set the raw html that is converted and rendered in the pdf document footer.
-
#footer_url=(footer_url) ⇒ Object
Set the url of the web page that is converted and rendered in the PDF document footer.
-
#footer_web_page_height=(footer_web_page_height) ⇒ Object
Set the height in pixels used by the converter’s internal browser window during the conversion of the footer content.
-
#footer_web_page_width=(footer_web_page_width) ⇒ Object
Set the width in pixels used by the converter’s internal browser window during the conversion of the footer content.
-
#header_base_url=(header_base_url) ⇒ Object
Set an optional base url parameter can be used together with the header HTML to resolve relative paths from the html string.
-
#header_display_on_even_pages=(header_display_on_even_pages) ⇒ Object
Control the visibility of the header on the even numbered pages of the generated pdf document.
-
#header_display_on_first_page=(header_display_on_first_page) ⇒ Object
Control the visibility of the header on the first page of the generated pdf document.
-
#header_display_on_odd_pages=(header_display_on_odd_pages) ⇒ Object
Control the visibility of the header on the odd numbered pages of the generated pdf document.
-
#header_height=(header_height) ⇒ Object
The height of the pdf document header.
-
#header_html=(header_html) ⇒ Object
Set the raw html that is converted and rendered in the pdf document header.
-
#header_url=(header_url) ⇒ Object
Set the url of the web page that is converted and rendered in the PDF document header.
-
#header_web_page_height=(header_web_page_height) ⇒ Object
Set the height in pixels used by the converter’s internal browser window during the conversion of the header content.
-
#header_web_page_width=(header_web_page_width) ⇒ Object
Set the width in pixels used by the converter’s internal browser window during the conversion of the header content.
-
#initialize(api_key) ⇒ HtmlToPdfClient
constructor
Construct the Html To Pdf Client.
-
#keep_images_together=(keep_images_together) ⇒ Object
Avoid breaking images between PDF pages.
-
#margin_bottom=(margin_bottom) ⇒ Object
Set bottom margin of the PDF pages.
-
#margin_left=(margin_left) ⇒ Object
Set left margin of the PDF pages.
-
#margin_right=(margin_right) ⇒ Object
Set right margin of the PDF pages.
-
#margin_top=(margin_top) ⇒ Object
Set top margin of the PDF pages.
-
#margins=(margin) ⇒ Object
Set all margins of the PDF pages to the same value.
-
#max_load_time=(max_load_time) ⇒ Object
Set the maximum amount of time (in seconds) that the convert will wait for the page to load.
-
#min_load_time=(min_load_time) ⇒ Object
Introduce a delay (in seconds) before the actual conversion to allow the web page to fully load.
-
#navigation_timeout=(navigation_timeout) ⇒ Object
Set the maximum amount of time (in seconds) that the convert will wait for the page to load.
-
#owner_password=(owner_password) ⇒ Object
Set PDF owner password.
-
#page_breaks_enhanced_algorithm=(page_breaks_enhanced_algorithm) ⇒ Object
Get or set a flag indicating if an enhanced custom page breaks algorithm is used.
-
#page_height=(page_height) ⇒ Object
Set PDF page height in points.
-
#page_numbers=(page_numbers) ⇒ Object
Show page numbers.
-
#page_numbers_alignment=(page_numbers_alignment) ⇒ Object
Set the alignment of the page numbers text.
-
#page_numbers_color=(page_numbers_color) ⇒ Object
Specify the color of the page numbers text in #RRGGBB html format.
-
#page_numbers_first=(page_numbers_first) ⇒ Object
Control the page number for the first page being rendered.
-
#page_numbers_font_name=(page_numbers_font_name) ⇒ Object
Set the font used to display the page numbers text.
-
#page_numbers_font_size=(page_numbers_font_size) ⇒ Object
Set the size of the font used to display the page numbers.
-
#page_numbers_offset=(page_numbers_offset) ⇒ Object
Control the total number of pages offset in the generated pdf document.
-
#page_numbers_pos_y=(page_numbers_pos_y) ⇒ Object
Specify the position in points on the vertical where the page numbers text is displayed in the footer.
-
#page_numbers_template=(page_numbers_template) ⇒ Object
Set the text that is used to display the page numbers.
-
#page_orientation=(page_orientation) ⇒ Object
Set PDF page orientation.
-
#page_size=(page_size) ⇒ Object
Set PDF page size.
-
#page_width=(page_width) ⇒ Object
Set PDF page width in points.
-
#pdf_bookmarks_selectors=(pdf_bookmarks_selectors) ⇒ Object
Generate automatic bookmarks in pdf.
-
#pdf_hide_elements=(pdf_hide_elements) ⇒ Object
Exclude page elements from the conversion.
-
#pdf_name=(pdf_name) ⇒ Object
Specify the name of the pdf document that will be created.
-
#pdf_show_only_element_id=(pdf_show_only_element_id) ⇒ Object
Convert only a specific section of the web page to pdf.
-
#pdf_web_elements_selectors=(pdf_web_elements_selectors) ⇒ Object
Get the locations of page elements from the conversion.
-
#render_on_timeout=(render_on_timeout) ⇒ Object
Try to render the PDF even in case of the web page loading timeout.
-
#rendering_engine=(rendering_engine) ⇒ Object
Set the rendering engine used for the HTML to PDF conversion.
-
#scale_images=(scale_images) ⇒ Object
Set a flag indicating if the images from the page are scaled during the conversion process.
-
#secure_protocol=(secure_protocol) ⇒ Object
Set the protocol used for secure (HTTPS) connections.
-
#set_custom_parameter(parameter_name, parameter_value) ⇒ Object
Set a custom parameter.
-
#show_footer=(show_footer) ⇒ Object
Control if a custom footer is displayed in the generated PDF document.
-
#show_header=(show_header) ⇒ Object
Control if a custom header is displayed in the generated PDF document.
-
#single_page_pdf=(single_page_pdf) ⇒ Object
Generate a single page PDF.
-
#skip_decoding=(skip_decoding) ⇒ Object
Internal use only.
-
#startup_mode=(startup_mode) ⇒ Object
Set converter startup mode.
-
#use_css_print=(use_css_print) ⇒ Object
Specify if the CSS Print media type is used instead of the Screen media type.
-
#user_password=(user_password) ⇒ Object
Set PDF user password.
-
#viewer_center_window=(viewer_center_window) ⇒ Object
Set a flag specifying whether to position the document’s window in the center of the screen.
-
#viewer_display_doc_title=(viewer_display_doc_title) ⇒ Object
Set a flag specifying whether the window’s title bar should display the document title taken from document information.
-
#viewer_fit_window=(viewer_fit_window) ⇒ Object
Set a flag specifying whether to resize the document’s window to fit the size of the first displayed page.
-
#viewer_hide_menu_bar=(viewer_hide_menu_bar) ⇒ Object
Set a flag specifying whether to hide the pdf viewer application’s menu bar when the document is active.
-
#viewer_hide_toolbar=(viewer_hide_toolbar) ⇒ Object
Set a flag specifying whether to hide the pdf viewer application’s tool bars when the document is active.
-
#viewer_hide_window_ui=(viewer_hide_window_ui) ⇒ Object
Set a flag specifying whether to hide user interface elements in the document’s window (such as scroll bars and navigation controls), leaving only the document’s contents displayed.
-
#viewer_page_layout=(viewer_page_layout) ⇒ Object
Set the page layout to be used when the document is opened in a PDF viewer.
-
#viewer_page_mode=(viewer_page_mode) ⇒ Object
Set the document page mode when the pdf document is opened in a PDF viewer.
-
#web_elements ⇒ Object
Get the locations of certain web elements.
-
#web_page_height=(web_page_height) ⇒ Object
Set the height used by the converter’s internal browser window in pixels.
-
#web_page_width=(web_page_width) ⇒ Object
Set the width used by the converter’s internal browser window in pixels.
Constructor Details
#initialize(api_key) ⇒ HtmlToPdfClient
Construct the Html To Pdf Client.
478 479 480 481 482 |
# File 'lib/selectpdf.rb', line 478 def initialize(api_key) super() @api_endpoint = 'https://selectpdf.com/api2/convert/' @parameters['key'] = api_key end |
Instance Method Details
#background_color=(background_color) ⇒ Object
Specify the background color of the PDF page in RGB html format. The default is #FFFFFF.
961 962 963 964 965 966 967 |
# File 'lib/selectpdf.rb', line 961 def background_color=(background_color) unless /^#?[0-9a-fA-F]{6}$/.match(background_color) raise ApiException.new('Color value must be in #RRGGBB format.'), 'Color value must be in #RRGGBB format.' end @parameters['background_color'] = background_color end |
#conversion_delay=(conversion_delay) ⇒ Object
Introduce a delay (in seconds) before the actual conversion to allow the web page to fully load. This method is an alias for min_load_time. The default value is 1 second. Use a larger value if the web page has content that takes time to render when it is displayed in the browser.
920 921 922 |
# File 'lib/selectpdf.rb', line 920 def conversion_delay=(conversion_delay) self.min_load_time = conversion_delay end |
#convert_html_string(html_string) ⇒ Object
Convert the specified HTML string to PDF.
741 742 743 |
# File 'lib/selectpdf.rb', line 741 def convert_html_string(html_string) convert_html_string_with_base_url(html_string, nil) end |
#convert_html_string_async(html_string) ⇒ Object
Convert the specified HTML string to PDF with an asynchronous call.
764 765 766 |
# File 'lib/selectpdf.rb', line 764 def convert_html_string_async(html_string) convert_html_string_with_base_url_async(html_string, nil) end |
#convert_html_string_to_file(html_string, file_path) ⇒ Object
Convert the specified HTML string to PDF and writes the resulted PDF to a local file.
757 758 759 |
# File 'lib/selectpdf.rb', line 757 def convert_html_string_to_file(html_string, file_path) convert_html_string_with_base_url_to_file(html_string, nil, file_path) end |
#convert_html_string_to_file_async(html_string, file_path) ⇒ Object
Convert the specified HTML string to PDF with an asynchronous call and writes the resulted PDF to a local file.
780 781 782 |
# File 'lib/selectpdf.rb', line 780 def convert_html_string_to_file_async(html_string, file_path) convert_html_string_with_base_url_to_file_async(html_string, nil, file_path) end |
#convert_html_string_to_stream(html_string, stream) ⇒ Object
Convert the specified HTML string to PDF and writes the resulted PDF to an output stream.
749 750 751 |
# File 'lib/selectpdf.rb', line 749 def convert_html_string_to_stream(html_string, stream) convert_html_string_to_stream_with_base_url(html_string, nil, stream) end |
#convert_html_string_to_stream_async(html_string, stream) ⇒ Object
Convert the specified HTML string to PDF with an asynchronous call and writes the resulted PDF to an output stream.
772 773 774 |
# File 'lib/selectpdf.rb', line 772 def convert_html_string_to_stream_async(html_string, stream) convert_html_string_to_stream_with_base_url_async(html_string, nil, stream) end |
#convert_html_string_to_stream_with_base_url(html_string, base_url, stream) ⇒ Object
Convert the specified HTML string to PDF and writes the resulted PDF to an output stream. Use a base url to resolve relative paths to resources.
646 647 648 649 650 651 652 653 |
# File 'lib/selectpdf.rb', line 646 def convert_html_string_to_stream_with_base_url(html_string, base_url, stream) @parameters.delete('url') @parameters['async'] = 'False' @parameters['html'] = html_string @parameters['base_url'] = base_url unless base_url.nil? || base_url.empty? perform_post(stream) end |
#convert_html_string_to_stream_with_base_url_async(html_string, base_url, stream) ⇒ Object
Convert the specified HTML string to PDF with an asynchronous call and writes the resulted PDF to an output stream. Use a base url to resolve relative paths to resources.
718 719 720 721 |
# File 'lib/selectpdf.rb', line 718 def convert_html_string_to_stream_with_base_url_async(html_string, base_url, stream) result = convert_html_string_with_base_url_async(html_string, base_url) stream.write(result) end |
#convert_html_string_with_base_url(html_string, base_url) ⇒ Object
Convert the specified HTML string to PDF. Use a base url to resolve relative paths to resources.
632 633 634 635 636 637 638 639 |
# File 'lib/selectpdf.rb', line 632 def convert_html_string_with_base_url(html_string, base_url) @parameters.delete('url') @parameters['async'] = 'False' @parameters['html'] = html_string @parameters['base_url'] = base_url unless base_url.nil? || base_url.empty? perform_post end |
#convert_html_string_with_base_url_async(html_string, base_url) ⇒ Object
Convert the specified HTML string to PDF with an asynchronous call. Use a base url to resolve relative paths to resources.
680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 |
# File 'lib/selectpdf.rb', line 680 def convert_html_string_with_base_url_async(html_string, base_url) @parameters.delete('url') @parameters['html'] = html_string @parameters['base_url'] = base_url unless base_url.nil? || base_url.empty? job_id = start_async_job if job_id.nil? || job_id.empty? raise ApiException.new('An error occurred launching the asynchronous call.'), 'An error occurred launching the asynchronous call.' end no_pings = 0 while no_pings < @async_calls_max_pings no_pings += 1 # sleep for a few seconds before next ping sleep(@async_calls_ping_interval) async_job_client = AsyncJobClient.new(@parameters['key'], @job_id) async_job_client.api_endpoint = @api_async_endpoint result = async_job_client.result next if result.nil? @number_of_pages = async_job_client.number_of_pages return result end raise ApiException.new('Asynchronous call did not finish in expected timeframe.'), 'Asynchronous call did not finish in expected timeframe.' end |
#convert_html_string_with_base_url_to_file(html_string, base_url, file_path) ⇒ Object
Convert the specified HTML string to PDF and writes the resulted PDF to a local file. Use a base url to resolve relative paths to resources.
660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 |
# File 'lib/selectpdf.rb', line 660 def convert_html_string_with_base_url_to_file(html_string, base_url, file_path) @parameters.delete('url') @parameters['async'] = 'False' @parameters['html'] = html_string @parameters['base_url'] = base_url unless base_url.nil? || base_url.empty? begin File.open(file_path, 'wb') do |file| perform_post(file) end rescue ApiException FileUtils.rm(file_path) if File.exist?(file_path) raise end end |
#convert_html_string_with_base_url_to_file_async(html_string, base_url, file_path) ⇒ Object
Convert the specified HTML string to PDF with an asynchronous call and writes the resulted PDF to a local file. Use a base url to resolve relative paths to resources.
728 729 730 731 732 733 734 735 736 |
# File 'lib/selectpdf.rb', line 728 def convert_html_string_with_base_url_to_file_async(html_string, base_url, file_path) result = convert_html_string_with_base_url_async(html_string, base_url) File.open(file_path, 'wb') do |file| file.write(result) end rescue ApiException FileUtils.rm(file_path) if File.exist?(file_path) raise end |
#convert_url(url) ⇒ Object
Convert the specified url to PDF. SelectPdf online API can convert http:// and https:// publicly available urls.
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
# File 'lib/selectpdf.rb', line 489 def convert_url(url) if !url.downcase.start_with?('http://') && !url.downcase.start_with?('https://') raise ApiException.new('The supported protocols for the converted webpage are http:// and https://.'), 'The supported protocols for the converted webpage are http:// and https://.' end if url.downcase.start_with?('http://localhost') raise ApiException.new('Cannot convert local urls. SelectPdf online API can only convert publicly available urls.'), 'Cannot convert local urls. SelectPdf online API can only convert publicly available urls.' end @parameters['url'] = url @parameters.delete('html') @parameters.delete('base_url') @parameters['async'] = 'False' perform_post end |
#convert_url_async(url) ⇒ Object
Convert the specified url to PDF using an asynchronous call. SelectPdf online API can convert http:// and https:// publicly available urls.
562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 |
# File 'lib/selectpdf.rb', line 562 def convert_url_async(url) if !url.downcase.start_with?('http://') && !url.downcase.start_with?('https://') raise ApiException.new('The supported protocols for the converted webpage are http:// and https://.'), 'The supported protocols for the converted webpage are http:// and https://.' end if url.downcase.start_with?('http://localhost') raise ApiException.new('Cannot convert local urls. SelectPdf online API can only convert publicly available urls.'), 'Cannot convert local urls. SelectPdf online API can only convert publicly available urls.' end @parameters['url'] = url @parameters.delete('html') @parameters.delete('base_url') job_id = start_async_job if job_id.nil? || job_id.empty? raise ApiException.new('An error occurred launching the asynchronous call.'), 'An error occurred launching the asynchronous call.' end no_pings = 0 while no_pings < @async_calls_max_pings no_pings += 1 # sleep for a few seconds before next ping sleep(@async_calls_ping_interval) async_job_client = AsyncJobClient.new(@parameters['key'], @job_id) async_job_client.api_endpoint = @api_async_endpoint result = async_job_client.result next if result.nil? @number_of_pages = async_job_client.number_of_pages return result end raise ApiException.new('Asynchronous call did not finish in expected timeframe.'), 'Asynchronous call did not finish in expected timeframe.' end |
#convert_url_to_file(url, file_path) ⇒ Object
Convert the specified url to PDF and writes the resulted PDF to a local file. SelectPdf online API can convert http:// and https:// publicly available urls.
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 |
# File 'lib/selectpdf.rb', line 533 def convert_url_to_file(url, file_path) if !url.downcase.start_with?('http://') && !url.downcase.start_with?('https://') raise ApiException.new('The supported protocols for the converted webpage are http:// and https://.'), 'The supported protocols for the converted webpage are http:// and https://.' end if url.downcase.start_with?('http://localhost') raise ApiException.new('Cannot convert local urls. SelectPdf online API can only convert publicly available urls.'), 'Cannot convert local urls. SelectPdf online API can only convert publicly available urls.' end @parameters['url'] = url @parameters.delete('html') @parameters.delete('base_url') @parameters['async'] = 'False' begin File.open(file_path, 'wb') do |file| perform_post(file) end rescue ApiException FileUtils.rm(file_path) if File.exist?(file_path) raise end end |
#convert_url_to_file_async(url, file_path) ⇒ Object
Convert the specified url to PDF using an asynchronous call and writes the resulted PDF to a local file. SelectPdf online API can convert http:// and https:// publicly available urls.
618 619 620 621 622 623 624 625 626 |
# File 'lib/selectpdf.rb', line 618 def convert_url_to_file_async(url, file_path) result = convert_url_async(url) File.open(file_path, 'wb') do |file| file.write(result) end rescue ApiException FileUtils.rm(file_path) if File.exist?(file_path) raise end |
#convert_url_to_stream(url, stream) ⇒ Object
Convert the specified url to PDF and writes the resulted PDF to an output stream. SelectPdf online API can convert http:// and https:// publicly available urls.
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
# File 'lib/selectpdf.rb', line 511 def convert_url_to_stream(url, stream) if !url.downcase.start_with?('http://') && !url.downcase.start_with?('https://') raise ApiException.new('The supported protocols for the converted webpage are http:// and https://.'), 'The supported protocols for the converted webpage are http:// and https://.' end if url.downcase.start_with?('http://localhost') raise ApiException.new('Cannot convert local urls. SelectPdf online API can only convert publicly available urls.'), 'Cannot convert local urls. SelectPdf online API can only convert publicly available urls.' end @parameters['url'] = url @parameters.delete('html') @parameters.delete('base_url') @parameters['async'] = 'False' perform_post(stream) end |
#convert_url_to_stream_async(url, stream) ⇒ Object
Convert the specified url to PDF using an asynchronous call and writes the resulted PDF to an output stream. SelectPdf online API can convert http:// and https:// publicly available urls.
608 609 610 611 |
# File 'lib/selectpdf.rb', line 608 def convert_url_to_stream_async(url, stream) result = convert_url_async(url) stream.write(result) end |
#cookies=(cookies) ⇒ Object
Set HTTP cookies for the web page being converted.
1453 1454 1455 |
# File 'lib/selectpdf.rb', line 1453 def () @parameters['cookies_string'] = URI.encode_www_form() end |
#disable_external_links=(disable_external_links) ⇒ Object
Do not create external links in the PDF. The default value is False and external links are created.
993 994 995 |
# File 'lib/selectpdf.rb', line 993 def disable_external_links=(disable_external_links) @parameters['disable_external_links'] = disable_external_links end |
#disable_internal_links=(disable_internal_links) ⇒ Object
Do not create internal links in the PDF. The default value is False and internal links are created.
986 987 988 |
# File 'lib/selectpdf.rb', line 986 def disable_internal_links=(disable_internal_links) @parameters['disable_internal_links'] = disable_internal_links end |
#disable_javascript=(disable_javascript) ⇒ Object
Do not run JavaScript in web pages. The default value is False and javascript is executed.
979 980 981 |
# File 'lib/selectpdf.rb', line 979 def disable_javascript=(disable_javascript) @parameters['disable_javascript'] = disable_javascript end |
#doc_add_creation_date=(doc_add_creation_date) ⇒ Object
Add the date and time when the PDF document was created to the PDF document information. The default value is False.
1042 1043 1044 |
# File 'lib/selectpdf.rb', line 1042 def doc_add_creation_date=(doc_add_creation_date) @parameters['doc_add_creation_date'] = doc_add_creation_date end |
#doc_author=(doc_author) ⇒ Object
Set the name of the PDF document author.
1035 1036 1037 |
# File 'lib/selectpdf.rb', line 1035 def () @parameters['doc_author'] = end |
#doc_keywords=(doc_keywords) ⇒ Object
Set the PDF document keywords.
1028 1029 1030 |
# File 'lib/selectpdf.rb', line 1028 def doc_keywords=(doc_keywords) @parameters['doc_keywords'] = doc_keywords end |
#doc_subject=(doc_subject) ⇒ Object
Set the subject of the PDF document.
1021 1022 1023 |
# File 'lib/selectpdf.rb', line 1021 def doc_subject=(doc_subject) @parameters['doc_subject'] = doc_subject end |
#doc_title=(doc_title) ⇒ Object
Set the PDF document title.
1014 1015 1016 |
# File 'lib/selectpdf.rb', line 1014 def doc_title=(doc_title) @parameters['doc_title'] = doc_title end |
#draw_html_background=(draw_html_background) ⇒ Object
Set a flag indicating if the web page background is rendered in PDF. The default value is TRUE.
972 973 974 |
# File 'lib/selectpdf.rb', line 972 def draw_html_background=(draw_html_background) @parameters['draw_html_background'] = draw_html_background end |
#footer_base_url=(footer_base_url) ⇒ Object
Set an optional base url parameter can be used together with the footer HTML to resolve relative paths from the html string.
1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 |
# File 'lib/selectpdf.rb', line 1239 def () if !.downcase.start_with?('http://') && !.downcase.start_with?('https://') raise ApiException.new('The supported protocols for the converted webpage are http:// and https://.'), 'The supported protocols for the converted webpage are http:// and https://.' end if .downcase.start_with?('http://localhost') raise ApiException.new('Cannot convert local urls. SelectPdf online API can only convert publicly available urls.'), 'Cannot convert local urls. SelectPdf online API can only convert publicly available urls.' end @parameters['footer_base_url'] = end |
#footer_display_on_even_pages=(footer_display_on_even_pages) ⇒ Object
Control the visibility of the footer on the even numbered pages of the generated pdf document. The default value is True.
1268 1269 1270 |
# File 'lib/selectpdf.rb', line 1268 def () @parameters['footer_display_on_even_pages'] = end |
#footer_display_on_first_page=(footer_display_on_first_page) ⇒ Object
Control the visibility of the footer on the first page of the generated pdf document. The default value is True.
1254 1255 1256 |
# File 'lib/selectpdf.rb', line 1254 def () @parameters['footer_display_on_first_page'] = end |
#footer_display_on_last_page=(footer_display_on_last_page) ⇒ Object
Add a special footer on the last page of the generated pdf document only. The default value is False. Use footer_url or footer_html and footer_base_url to specify the content of the last page footer. Use footer_height to specify the height of the special last page footer.
1277 1278 1279 |
# File 'lib/selectpdf.rb', line 1277 def () @parameters['footer_display_on_last_page'] = end |
#footer_display_on_odd_pages=(footer_display_on_odd_pages) ⇒ Object
Control the visibility of the footer on the odd numbered pages of the generated pdf document. The default value is True.
1261 1262 1263 |
# File 'lib/selectpdf.rb', line 1261 def () @parameters['footer_display_on_odd_pages'] = end |
#footer_height=(footer_height) ⇒ Object
The height of the pdf document footer. This height is specified in points. 1 point is 1/72 inch. The default value is 50.
1210 1211 1212 |
# File 'lib/selectpdf.rb', line 1210 def () @parameters['footer_height'] = end |
#footer_html=(footer_html) ⇒ Object
Set the raw html that is converted and rendered in the pdf document footer.
1232 1233 1234 |
# File 'lib/selectpdf.rb', line 1232 def () @parameters['footer_html'] = end |
#footer_url=(footer_url) ⇒ Object
Set the url of the web page that is converted and rendered in the PDF document footer.
1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 |
# File 'lib/selectpdf.rb', line 1217 def () if !.downcase.start_with?('http://') && !.downcase.start_with?('https://') raise ApiException.new('The supported protocols for the converted webpage are http:// and https://.'), 'The supported protocols for the converted webpage are http:// and https://.' end if .downcase.start_with?('http://localhost') raise ApiException.new('Cannot convert local urls. SelectPdf online API can only convert publicly available urls.'), 'Cannot convert local urls. SelectPdf online API can only convert publicly available urls.' end @parameters['footer_url'] = end |
#footer_web_page_height=(footer_web_page_height) ⇒ Object
Set the height in pixels used by the converter’s internal browser window during the conversion of the footer content. The default value is 0px and it means that the page height is automatically calculated by the converter.
1292 1293 1294 |
# File 'lib/selectpdf.rb', line 1292 def () @parameters['footer_web_page_height'] = end |
#footer_web_page_width=(footer_web_page_width) ⇒ Object
Set the width in pixels used by the converter’s internal browser window during the conversion of the footer content. The default value is 1024px.
1284 1285 1286 |
# File 'lib/selectpdf.rb', line 1284 def () @parameters['footer_web_page_width'] = end |
#header_base_url=(header_base_url) ⇒ Object
Set an optional base url parameter can be used together with the header HTML to resolve relative paths from the html string.
1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 |
# File 'lib/selectpdf.rb', line 1152 def header_base_url=(header_base_url) if !header_base_url.downcase.start_with?('http://') && !header_base_url.downcase.start_with?('https://') raise ApiException.new('The supported protocols for the converted webpage are http:// and https://.'), 'The supported protocols for the converted webpage are http:// and https://.' end if header_base_url.downcase.start_with?('http://localhost') raise ApiException.new('Cannot convert local urls. SelectPdf online API can only convert publicly available urls.'), 'Cannot convert local urls. SelectPdf online API can only convert publicly available urls.' end @parameters['header_base_url'] = header_base_url end |
#header_display_on_even_pages=(header_display_on_even_pages) ⇒ Object
Control the visibility of the header on the even numbered pages of the generated pdf document. The default value is True.
1181 1182 1183 |
# File 'lib/selectpdf.rb', line 1181 def header_display_on_even_pages=(header_display_on_even_pages) @parameters['header_display_on_even_pages'] = header_display_on_even_pages end |
#header_display_on_first_page=(header_display_on_first_page) ⇒ Object
Control the visibility of the header on the first page of the generated pdf document. The default value is True.
1167 1168 1169 |
# File 'lib/selectpdf.rb', line 1167 def header_display_on_first_page=(header_display_on_first_page) @parameters['header_display_on_first_page'] = header_display_on_first_page end |
#header_display_on_odd_pages=(header_display_on_odd_pages) ⇒ Object
Control the visibility of the header on the odd numbered pages of the generated pdf document. The default value is True.
1174 1175 1176 |
# File 'lib/selectpdf.rb', line 1174 def header_display_on_odd_pages=(header_display_on_odd_pages) @parameters['header_display_on_odd_pages'] = header_display_on_odd_pages end |
#header_height=(header_height) ⇒ Object
The height of the pdf document header. This height is specified in points. 1 point is 1/72 inch. The default value is 50.
1123 1124 1125 |
# File 'lib/selectpdf.rb', line 1123 def header_height=(header_height) @parameters['header_height'] = header_height end |
#header_html=(header_html) ⇒ Object
Set the raw html that is converted and rendered in the pdf document header.
1145 1146 1147 |
# File 'lib/selectpdf.rb', line 1145 def header_html=(header_html) @parameters['header_html'] = header_html end |
#header_url=(header_url) ⇒ Object
Set the url of the web page that is converted and rendered in the PDF document header.
1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 |
# File 'lib/selectpdf.rb', line 1130 def header_url=(header_url) if !header_url.downcase.start_with?('http://') && !header_url.downcase.start_with?('https://') raise ApiException.new('The supported protocols for the converted webpage are http:// and https://.'), 'The supported protocols for the converted webpage are http:// and https://.' end if header_url.downcase.start_with?('http://localhost') raise ApiException.new('Cannot convert local urls. SelectPdf online API can only convert publicly available urls.'), 'Cannot convert local urls. SelectPdf online API can only convert publicly available urls.' end @parameters['header_url'] = header_url end |
#header_web_page_height=(header_web_page_height) ⇒ Object
Set the height in pixels used by the converter’s internal browser window during the conversion of the header content. The default value is 0px and it means that the page height is automatically calculated by the converter.
1196 1197 1198 |
# File 'lib/selectpdf.rb', line 1196 def header_web_page_height=(header_web_page_height) @parameters['header_web_page_height'] = header_web_page_height end |
#header_web_page_width=(header_web_page_width) ⇒ Object
Set the width in pixels used by the converter’s internal browser window during the conversion of the header content. The default value is 1024px.
1188 1189 1190 |
# File 'lib/selectpdf.rb', line 1188 def header_web_page_width=(header_web_page_width) @parameters['header_web_page_width'] = header_web_page_width end |
#keep_images_together=(keep_images_together) ⇒ Object
Avoid breaking images between PDF pages. The default value is False and images are split between pages if larger.
1007 1008 1009 |
# File 'lib/selectpdf.rb', line 1007 def keep_images_together=(keep_images_together) @parameters['keep_images_together'] = keep_images_together end |
#margin_bottom=(margin_bottom) ⇒ Object
Set bottom margin of the PDF pages. Default value is 5pt.
840 841 842 |
# File 'lib/selectpdf.rb', line 840 def margin_bottom=(margin_bottom) @parameters['margin_bottom'] = margin_bottom end |
#margin_left=(margin_left) ⇒ Object
Set left margin of the PDF pages. Default value is 5pt.
847 848 849 |
# File 'lib/selectpdf.rb', line 847 def margin_left=(margin_left) @parameters['margin_left'] = margin_left end |
#margin_right=(margin_right) ⇒ Object
Set right margin of the PDF pages. Default value is 5pt.
833 834 835 |
# File 'lib/selectpdf.rb', line 833 def margin_right=(margin_right) @parameters['margin_right'] = margin_right end |
#margin_top=(margin_top) ⇒ Object
Set top margin of the PDF pages. Default value is 5pt.
826 827 828 |
# File 'lib/selectpdf.rb', line 826 def margin_top=(margin_top) @parameters['margin_top'] = margin_top end |
#margins=(margin) ⇒ Object
Set all margins of the PDF pages to the same value. Default value is 5pt.
854 855 856 857 858 859 |
# File 'lib/selectpdf.rb', line 854 def margins=(margin) @parameters['margin_top'] = margin @parameters['margin_right'] = margin @parameters['margin_bottom'] = margin @parameters['margin_left'] = margin end |
#max_load_time=(max_load_time) ⇒ Object
Set the maximum amount of time (in seconds) that the convert will wait for the page to load. This method is an alias for navigation_timeout. A timeout error is displayed when this time elapses. The default value is 30 seconds. Use a larger value (up to 120 seconds allowed) for pages that take a long time to load.
928 929 930 |
# File 'lib/selectpdf.rb', line 928 def max_load_time=(max_load_time) @parameters['max_load_time'] = max_load_time end |
#min_load_time=(min_load_time) ⇒ Object
Introduce a delay (in seconds) before the actual conversion to allow the web page to fully load. This property is an alias for conversion_delay. The default value is 1 second. Use a larger value if the web page has content that takes time to render when it is displayed in the browser.
912 913 914 |
# File 'lib/selectpdf.rb', line 912 def min_load_time=(min_load_time) @parameters['min_load_time'] = min_load_time end |
#navigation_timeout=(navigation_timeout) ⇒ Object
Set the maximum amount of time (in seconds) that the convert will wait for the page to load. This method is an alias for max_load_time. A timeout error is displayed when this time elapses. The default value is 30 seconds. Use a larger value (up to 120 seconds allowed) for pages that take a long time to load.
936 937 938 |
# File 'lib/selectpdf.rb', line 936 def () self.max_load_time = end |
#owner_password=(owner_password) ⇒ Object
Set PDF owner password.
889 890 891 |
# File 'lib/selectpdf.rb', line 889 def owner_password=(owner_password) @parameters['owner_password'] = owner_password end |
#page_breaks_enhanced_algorithm=(page_breaks_enhanced_algorithm) ⇒ Object
Get or set a flag indicating if an enhanced custom page breaks algorithm is used. The enhanced algorithm is a little bit slower but it will prevent the appearance of hidden text in the PDF when custom page breaks are used. The default value for this property is False.
1446 1447 1448 |
# File 'lib/selectpdf.rb', line 1446 def page_breaks_enhanced_algorithm=(page_breaks_enhanced_algorithm) @parameters['page_breaks_enhanced_algorithm'] = page_breaks_enhanced_algorithm end |
#page_height=(page_height) ⇒ Object
Set PDF page height in points. Default value is 842pt (A4 page height in points). 1pt = 1/72 inch. This is taken into account only if page size is set to SelectPdf::PageSize::CUSTOM using page_size property.
808 809 810 |
# File 'lib/selectpdf.rb', line 808 def page_height=(page_height) @parameters['page_height'] = page_height end |
#page_numbers=(page_numbers) ⇒ Object
Show page numbers. Default value is True. Page numbers will be displayed in the footer of the PDF document.
1299 1300 1301 |
# File 'lib/selectpdf.rb', line 1299 def page_numbers=(page_numbers) @parameters['page_numbers'] = page_numbers end |
#page_numbers_alignment=(page_numbers_alignment) ⇒ Object
Set the alignment of the page numbers text. The default value is SelectPdf::PageNumbersAlignment::RIGHT.
1343 1344 1345 1346 1347 1348 1349 1350 |
# File 'lib/selectpdf.rb', line 1343 def page_numbers_alignment=(page_numbers_alignment) unless [1, 2, 3].include?(page_numbers_alignment) raise ApiException.new('Allowed values for Page Numbers Alignment: 1 (Left), 2 (Center), 3 (Right).'), 'Allowed values for Page Numbers Alignment: 1 (Left), 2 (Center), 3 (Right).' end @parameters['page_numbers_alignment'] = page_numbers_alignment end |
#page_numbers_color=(page_numbers_color) ⇒ Object
Specify the color of the page numbers text in #RRGGBB html format. The default value is #333333.
1355 1356 1357 1358 1359 1360 1361 |
# File 'lib/selectpdf.rb', line 1355 def page_numbers_color=(page_numbers_color) unless /^#?[0-9a-fA-F]{6}$/.match(page_numbers_color) raise ApiException.new('Color value must be in #RRGGBB format.'), 'Color value must be in #RRGGBB format.' end @parameters['page_numbers_color'] = page_numbers_color end |
#page_numbers_first=(page_numbers_first) ⇒ Object
Control the page number for the first page being rendered. The default value is 1.
1306 1307 1308 |
# File 'lib/selectpdf.rb', line 1306 def page_numbers_first=(page_numbers_first) @parameters['page_numbers_first'] = page_numbers_first end |
#page_numbers_font_name=(page_numbers_font_name) ⇒ Object
Set the font used to display the page numbers text. The default value is “Helvetica”.
1329 1330 1331 |
# File 'lib/selectpdf.rb', line 1329 def page_numbers_font_name=(page_numbers_font_name) @parameters['page_numbers_font_name'] = page_numbers_font_name end |
#page_numbers_font_size=(page_numbers_font_size) ⇒ Object
Set the size of the font used to display the page numbers. The default value is 10 points.
1336 1337 1338 |
# File 'lib/selectpdf.rb', line 1336 def page_numbers_font_size=(page_numbers_font_size) @parameters['page_numbers_font_size'] = page_numbers_font_size end |
#page_numbers_offset=(page_numbers_offset) ⇒ Object
Control the total number of pages offset in the generated pdf document. The default value is 0.
1313 1314 1315 |
# File 'lib/selectpdf.rb', line 1313 def page_numbers_offset=(page_numbers_offset) @parameters['page_numbers_offset'] = page_numbers_offset end |
#page_numbers_pos_y=(page_numbers_pos_y) ⇒ Object
Specify the position in points on the vertical where the page numbers text is displayed in the footer. The default value is 10 points.
1366 1367 1368 |
# File 'lib/selectpdf.rb', line 1366 def page_numbers_pos_y=(page_numbers_pos_y) @parameters['page_numbers_pos_y'] = page_numbers_pos_y end |
#page_numbers_template=(page_numbers_template) ⇒ Object
Set the text that is used to display the page numbers. It can contain the placeholder {page_number} for the current page number and {total_pages} for the total number of pages. The default value is “Page: {page_number} of {total_pages}”.
1322 1323 1324 |
# File 'lib/selectpdf.rb', line 1322 def page_numbers_template=(page_numbers_template) @parameters['page_numbers_template'] = page_numbers_template end |
#page_orientation=(page_orientation) ⇒ Object
Set PDF page orientation. Default value is Portrait.
815 816 817 818 819 820 821 |
# File 'lib/selectpdf.rb', line 815 def page_orientation=(page_orientation) unless /(?i)^(Portrait|Landscape)$/.match(page_orientation) raise ApiException.new('Allowed values for Page Orientation: Portrait, Landscape.'), 'Allowed values for Page Orientation: Portrait, Landscape.' end @parameters['page_orientation'] = page_orientation end |
#page_size=(page_size) ⇒ Object
Set PDF page size. Default value is A4. If page size is set to Custom, use setPageWidth and setPageHeight methods to set the custom width/height of the PDF pages.
788 789 790 791 792 793 794 |
# File 'lib/selectpdf.rb', line 788 def page_size=(page_size) unless /(?i)^(Custom|A0|A1|A2|A3|A4|A5|A6|A7|A8|Letter|HalfLetter|Ledger|Legal)$/.match(page_size) raise ApiException.new('Allowed values for Page Size: Custom, A0, A1, A2, A3, A4, A5, A6, A7, A8, Letter, HalfLetter, Ledger, Legal.'), 'Allowed values for Page Size: Custom, A0, A1, A2, A3, A4, A5, A6, A7, A8, Letter, HalfLetter, Ledger, Legal.' end @parameters['page_size'] = page_size end |
#page_width=(page_width) ⇒ Object
Set PDF page width in points. Default value is 595pt (A4 page width in points). 1pt = 1/72 inch. This is taken into account only if page size is set to SelectPdf::PageSize::CUSTOM using page_size property.
800 801 802 |
# File 'lib/selectpdf.rb', line 800 def page_width=(page_width) @parameters['page_width'] = page_width end |
#pdf_bookmarks_selectors=(pdf_bookmarks_selectors) ⇒ Object
Generate automatic bookmarks in pdf. The elements that will be bookmarked are defined using CSS selectors. For example, the selector for all the H1 elements is “H1”, the selector for all the elements with the CSS class name ‘myclass’ is “*.myclass” and the selector for the elements with the id ‘myid’ is “*#myid”. Read more about CSS selectors <a href=“www.w3schools.com/cssref/css_selectors.asp” target=“_blank”>here</a>.
1375 1376 1377 |
# File 'lib/selectpdf.rb', line 1375 def pdf_bookmarks_selectors=(pdf_bookmarks_selectors) @parameters['pdf_bookmarks_selectors'] = pdf_bookmarks_selectors end |
#pdf_hide_elements=(pdf_hide_elements) ⇒ Object
Exclude page elements from the conversion. The elements that will be excluded are defined using CSS selectors. For example, the selector for all the H1 elements is “H1”, the selector for all the elements with the CSS class name ‘myclass’ is “*.myclass” and the selector for the elements with the id ‘myid’ is “*#myid”. Read more about CSS selectors <a href=“www.w3schools.com/cssref/css_selectors.asp” target=“_blank”>here</a>.
1384 1385 1386 |
# File 'lib/selectpdf.rb', line 1384 def pdf_hide_elements=(pdf_hide_elements) @parameters['pdf_hide_elements'] = pdf_hide_elements end |
#pdf_name=(pdf_name) ⇒ Object
Specify the name of the pdf document that will be created. The default value is Document.pdf.
864 865 866 |
# File 'lib/selectpdf.rb', line 864 def pdf_name=(pdf_name) @parameters['pdf_name'] = pdf_name end |
#pdf_show_only_element_id=(pdf_show_only_element_id) ⇒ Object
Convert only a specific section of the web page to pdf. The section that will be converted to pdf is specified by the html element ID. The element can be anything (image, table, table row, div, text, etc).
1393 1394 1395 |
# File 'lib/selectpdf.rb', line 1393 def pdf_show_only_element_id=(pdf_show_only_element_id) @parameters['pdf_show_only_element_id'] = pdf_show_only_element_id end |
#pdf_web_elements_selectors=(pdf_web_elements_selectors) ⇒ Object
Get the locations of page elements from the conversion. The elements that will have their locations retrieved are defined using CSS selectors. For example, the selector for all the H1 elements is “H1”, the selector for all the elements with the CSS class name ‘myclass’ is “*.myclass” and the selector for the elements with the id ‘myid’ is “*#myid”. Read more about CSS selectors <a href=“www.w3schools.com/cssref/css_selectors.asp” target=“_blank”>here</a>.
1402 1403 1404 |
# File 'lib/selectpdf.rb', line 1402 def pdf_web_elements_selectors=(pdf_web_elements_selectors) @parameters['pdf_web_elements_selectors'] = pdf_web_elements_selectors end |
#render_on_timeout=(render_on_timeout) ⇒ Object
Try to render the PDF even in case of the web page loading timeout. The default value is False and an exception is raised in case of web page navigation timeout.
1000 1001 1002 |
# File 'lib/selectpdf.rb', line 1000 def render_on_timeout=(render_on_timeout) @parameters['render_on_timeout'] = render_on_timeout end |
#rendering_engine=(rendering_engine) ⇒ Object
Set the rendering engine used for the HTML to PDF conversion. Default value is WebKit.
871 872 873 874 875 876 877 |
# File 'lib/selectpdf.rb', line 871 def rendering_engine=(rendering_engine) unless /(?i)^(WebKit|Restricted|Blink)$/.match(rendering_engine) raise ApiException.new('Allowed values for Rendering Engine: WebKit, Restricted, Blink.'), 'Allowed values for Rendering Engine: WebKit, Restricted, Blink.' end @parameters['engine'] = rendering_engine end |
#scale_images=(scale_images) ⇒ Object
Set a flag indicating if the images from the page are scaled during the conversion process. The default value is False and images are not scaled.
1429 1430 1431 |
# File 'lib/selectpdf.rb', line 1429 def scale_images=(scale_images) @parameters['scale_images'] = scale_images end |
#secure_protocol=(secure_protocol) ⇒ Object
Set the protocol used for secure (HTTPS) connections. Set this only if you have an older server that only works with older SSL connections.
943 944 945 946 947 948 949 |
# File 'lib/selectpdf.rb', line 943 def secure_protocol=(secure_protocol) unless [0, 1, 2].include?(secure_protocol) raise ApiException.new('Allowed values for Secure Protocol: 0 (TLS 1.1 or newer), 1 (TLS 1.0), 2 (SSL v3 only).'), 'Allowed values for Secure Protocol: 0 (TLS 1.1 or newer), 1 (TLS 1.0), 2 (SSL v3 only).' end @parameters['protocol'] = secure_protocol end |
#set_custom_parameter(parameter_name, parameter_value) ⇒ Object
Set a custom parameter. Do not use this method unless advised by SelectPdf.
1461 1462 1463 |
# File 'lib/selectpdf.rb', line 1461 def set_custom_parameter(parameter_name, parameter_value) @parameters[parameter_name] = parameter_value end |
#show_footer=(show_footer) ⇒ Object
Control if a custom footer is displayed in the generated PDF document. The default value is False.
1203 1204 1205 |
# File 'lib/selectpdf.rb', line 1203 def () @parameters['show_footer'] = end |
#show_header=(show_header) ⇒ Object
Control if a custom header is displayed in the generated PDF document. The default value is False.
1116 1117 1118 |
# File 'lib/selectpdf.rb', line 1116 def show_header=(show_header) @parameters['show_header'] = show_header end |
#single_page_pdf=(single_page_pdf) ⇒ Object
Generate a single page PDF. The converter will automatically resize the PDF page to fit all the content in a single page. The default value of this property is False and the PDF will contain several pages if the content is large.
1437 1438 1439 |
# File 'lib/selectpdf.rb', line 1437 def single_page_pdf=(single_page_pdf) @parameters['single_page_pdf'] = single_page_pdf end |
#skip_decoding=(skip_decoding) ⇒ Object
Internal use only.
1422 1423 1424 |
# File 'lib/selectpdf.rb', line 1422 def skip_decoding=(skip_decoding) @parameters['skip_decoding'] = skip_decoding end |
#startup_mode=(startup_mode) ⇒ Object
Set converter startup mode. The default value is SelectPdf::StartupMode::AUTOMATIC and the conversion is started immediately. By default this is set to SelectPdf::StartupMode::AUTOMATIC and the conversion is started as soon as the page loads (and conversion delay set with conversion_delay elapses). If set to SelectPdf::StartupMode::MANUAL, the conversion is started only by a javascript call to SelectPdf.startConversion() from within the web page.
1411 1412 1413 1414 1415 1416 1417 |
# File 'lib/selectpdf.rb', line 1411 def startup_mode=(startup_mode) unless /(?i)^(Automatic|Manual)$/.match(startup_mode) raise ApiException.new('Allowed values for Startup Mode: Automatic, Manual.'), 'Allowed values for Startup Mode: Automatic, Manual.' end @parameters['startup_mode'] = startup_mode end |
#use_css_print=(use_css_print) ⇒ Object
Specify if the CSS Print media type is used instead of the Screen media type. The default value is FALSE.
954 955 956 |
# File 'lib/selectpdf.rb', line 954 def use_css_print=(use_css_print) @parameters['use_css_print'] = use_css_print end |
#user_password=(user_password) ⇒ Object
Set PDF user password.
882 883 884 |
# File 'lib/selectpdf.rb', line 882 def user_password=(user_password) @parameters['user_password'] = user_password end |
#viewer_center_window=(viewer_center_window) ⇒ Object
Set a flag specifying whether to position the document’s window in the center of the screen. The default value is False.
1074 1075 1076 |
# File 'lib/selectpdf.rb', line 1074 def viewer_center_window=(viewer_center_window) @parameters['viewer_center_window'] = viewer_center_window end |
#viewer_display_doc_title=(viewer_display_doc_title) ⇒ Object
Set a flag specifying whether the window’s title bar should display the document title taken from document information. The default value is False.
1081 1082 1083 |
# File 'lib/selectpdf.rb', line 1081 def viewer_display_doc_title=(viewer_display_doc_title) @parameters['viewer_display_doc_title'] = viewer_display_doc_title end |
#viewer_fit_window=(viewer_fit_window) ⇒ Object
Set a flag specifying whether to resize the document’s window to fit the size of the first displayed page. The default value is False.
1088 1089 1090 |
# File 'lib/selectpdf.rb', line 1088 def viewer_fit_window=(viewer_fit_window) @parameters['viewer_fit_window'] = viewer_fit_window end |
#viewer_hide_menu_bar=(viewer_hide_menu_bar) ⇒ Object
Set a flag specifying whether to hide the pdf viewer application’s menu bar when the document is active. The default value is False.
1095 1096 1097 |
# File 'lib/selectpdf.rb', line 1095 def () @parameters['viewer_hide_menu_bar'] = end |
#viewer_hide_toolbar=(viewer_hide_toolbar) ⇒ Object
Set a flag specifying whether to hide the pdf viewer application’s tool bars when the document is active. The default value is False.
1102 1103 1104 |
# File 'lib/selectpdf.rb', line 1102 def () @parameters['viewer_hide_toolbar'] = end |
#viewer_hide_window_ui=(viewer_hide_window_ui) ⇒ Object
Set a flag specifying whether to hide user interface elements in the document’s window (such as scroll bars and navigation controls), leaving only the document’s contents displayed.
1109 1110 1111 |
# File 'lib/selectpdf.rb', line 1109 def viewer_hide_window_ui=(viewer_hide_window_ui) @parameters['viewer_hide_window_ui'] = viewer_hide_window_ui end |
#viewer_page_layout=(viewer_page_layout) ⇒ Object
Set the page layout to be used when the document is opened in a PDF viewer. The default value is SelectPdf::PageLayout::ONE_COLUMN.
Use constants from SelectPdf::PageLayout class.
1050 1051 1052 1053 1054 1055 1056 |
# File 'lib/selectpdf.rb', line 1050 def viewer_page_layout=(viewer_page_layout) unless [0, 1, 2, 3].include?(viewer_page_layout) raise ApiException.new('Allowed values for Page Layout: 0 (Single Page), 1 (One Column), 2 (Two Column Left), 3 (Two Column Right).'), 'Allowed values for Page Layout: 0 (Single Page), 1 (One Column), 2 (Two Column Left), 3 (Two Column Right).' end @parameters['viewer_page_layout'] = viewer_page_layout end |
#viewer_page_mode=(viewer_page_mode) ⇒ Object
Set the document page mode when the pdf document is opened in a PDF viewer. The default value is SelectPdf::PageMode::USE_NONE.
Use constants from SelectPdf::PageMode class.
1062 1063 1064 1065 1066 1067 1068 1069 |
# File 'lib/selectpdf.rb', line 1062 def viewer_page_mode=(viewer_page_mode) unless [0, 1, 2, 3, 4, 5].include?(viewer_page_mode) raise ApiException.new('Allowed values for Page Mode: 0 (Use None), 1 (Use Outlines), 2 (Use Thumbs), 3 (Full Screen), 4 (Use OC), 5 (Use Attachments).'), 'Allowed values for Page Mode: 0 (Use None), 1 (Use Outlines), 2 (Use Thumbs), 3 (Full Screen), 4 (Use OC), 5 (Use Attachments).' end @parameters['viewer_page_mode'] = viewer_page_mode end |
#web_elements ⇒ Object
Get the locations of certain web elements. This is retrieved if pdf_web_elements_selectors parameter is set and elements were found to match the selectors.
1468 1469 1470 1471 1472 1473 |
# File 'lib/selectpdf.rb', line 1468 def web_elements web_elements_client = WebElementsClient.new(@parameters['key'], @job_id) web_elements_client.api_endpoint = @api_web_elements_endpoint web_elements_client.web_elements end |
#web_page_height=(web_page_height) ⇒ Object
Set the height used by the converter’s internal browser window in pixels. The default value is 0px and it means that the page height is automatically calculated by the converter.
904 905 906 |
# File 'lib/selectpdf.rb', line 904 def web_page_height=(web_page_height) @parameters['web_page_height'] = web_page_height end |
#web_page_width=(web_page_width) ⇒ Object
Set the width used by the converter’s internal browser window in pixels. The default value is 1024px.
896 897 898 |
# File 'lib/selectpdf.rb', line 896 def web_page_width=(web_page_width) @parameters['web_page_width'] = web_page_width end |