pdfcrowd 4.10.0 → 5.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +5 -5
  2. data/lib/pdfcrowd.rb +1350 -695
  3. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 73bc7e703513651b2b2c314dccb8789d12ecd7a5
4
- data.tar.gz: c24923fce2dc420d331939ca1bc399b48e345fc8
2
+ SHA256:
3
+ metadata.gz: 2ce783233a9cfb07981027de99484b52696c70ac36865066e263cb4524fc3aa8
4
+ data.tar.gz: 8af414bdd2dd8822fcd83c02cf52837baa32449c46270aa19be1c2799c503ada
5
5
  SHA512:
6
- metadata.gz: 62cb40465cbf4696711f51a1ae8e8075e4301ca389acef6a8b23a8ab7567b6c3d5ac62becfb58947b955269c00f47b13875eae6dcbf32e1f31fe393173496f4d
7
- data.tar.gz: 67b8144a6827003b289aae2fb920261eb6261d17b77e5dd655058c207d8f6d7f4a79f9658ec4e96cf2a36ae24394e6257b41953d8402a26ddb6cfcfab283e95e
6
+ metadata.gz: ea0a791e71eedbb2145fb754f9fb39a86583c5b5c7e4e00be87bc622a3299eca1267f1d111ee995fca6093cc5939643dda74c317aab13d067a420cf2b6e851c5
7
+ data.tar.gz: 110f85f489157e5db520340ca0d7ce68a14933566dbd2be2e2d5b338b4bdeb03dad99b143fbaee388a09e4c99e00477cbe51004fcb20aa14eec30145a4d2657b
data/lib/pdfcrowd.rb CHANGED
@@ -530,7 +530,7 @@ end
530
530
  module Pdfcrowd
531
531
  HOST = ENV["PDFCROWD_HOST"] || 'api.pdfcrowd.com'
532
532
  MULTIPART_BOUNDARY = '----------ThIs_Is_tHe_bOUnDary_$'
533
- CLIENT_VERSION = '4.10.0'
533
+ CLIENT_VERSION = '5.1.1'
534
534
 
535
535
  class ConnectionHelper
536
536
  def initialize(user_name, api_key)
@@ -541,13 +541,14 @@ module Pdfcrowd
541
541
 
542
542
  setProxy(nil, nil, nil, nil)
543
543
  setUseHttp(false)
544
- setUserAgent('pdfcrowd_ruby_client/4.10.0 (http://pdfcrowd.com)')
544
+ setUserAgent('pdfcrowd_ruby_client/5.1.1 (https://pdfcrowd.com)')
545
545
 
546
546
  @retry_count = 1
547
+ @converter_version = '20.10'
547
548
  end
548
549
 
549
550
  def post(fields, files, raw_data, out_stream = nil)
550
- request = ConnectionHelper.create_request()
551
+ request = create_request()
551
552
  request.body = ConnectionHelper.encode_multipart_post_data(fields, files, raw_data)
552
553
  request.content_type = 'multipart/form-data; boundary=' + MULTIPART_BOUNDARY
553
554
  do_post(request, out_stream)
@@ -565,6 +566,10 @@ module Pdfcrowd
565
566
  @retry_count = retry_count
566
567
  end
567
568
 
569
+ def setConverterVersion(converter_version)
570
+ @converter_version = converter_version
571
+ end
572
+
568
573
  def setProxy(host, port, user_name, password)
569
574
  @proxy_host = host
570
575
  @proxy_port = port
@@ -596,6 +601,10 @@ module Pdfcrowd
596
601
  @output_size
597
602
  end
598
603
 
604
+ def getConverterVersion()
605
+ @converter_version
606
+ end
607
+
599
608
  private
600
609
 
601
610
  def reset_response_data()
@@ -608,8 +617,8 @@ module Pdfcrowd
608
617
  @retry = 0
609
618
  end
610
619
 
611
- def self.create_request()
612
- Net::HTTP::Post.new('/convert/')
620
+ def create_request()
621
+ Net::HTTP::Post.new('/convert/%s/' % @converter_version)
613
622
  end
614
623
 
615
624
  def self.add_file_field(name, file_name, data, body)
@@ -724,7 +733,7 @@ module Pdfcrowd
724
733
  end
725
734
 
726
735
  def self.create_invalid_value_message(value, field, converter, hint, id)
727
- message = "Invalid value '%s' for a field '%s'." % [value, field]
736
+ message = "Invalid value '%s' for %s." % [value, field]
728
737
  message += " " + hint if hint
729
738
  return message + " " + "Details: https://www.pdfcrowd.com/doc/api/%s/ruby/#%s" % [converter, id]
730
739
  end
@@ -754,7 +763,7 @@ module Pdfcrowd
754
763
  # * *Returns* - Byte array containing the conversion output.
755
764
  def convertUrl(url)
756
765
  unless /(?i)^https?:\/\/.*$/.match(url)
757
- raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "html-to-pdf", "The supported protocols are http:// and https://.", "convert_url"), 470);
766
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "convert_url"), 470);
758
767
  end
759
768
 
760
769
  @fields['url'] = url
@@ -767,7 +776,7 @@ module Pdfcrowd
767
776
  # * +out_stream+ - The output stream that will contain the conversion output.
768
777
  def convertUrlToStream(url, out_stream)
769
778
  unless /(?i)^https?:\/\/.*$/.match(url)
770
- raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "html-to-pdf", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
779
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "html-to-pdf", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
771
780
  end
772
781
 
773
782
  @fields['url'] = url
@@ -780,7 +789,7 @@ module Pdfcrowd
780
789
  # * +file_path+ - The output file path. The string must not be empty.
781
790
  def convertUrlToFile(url, file_path)
782
791
  if (!(!file_path.nil? && !file_path.empty?))
783
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-pdf", "The string must not be empty.", "convert_url_to_file"), 470);
792
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "html-to-pdf", "The string must not be empty.", "convert_url_to_file"), 470);
784
793
  end
785
794
 
786
795
  output_file = open(file_path, "wb")
@@ -800,7 +809,7 @@ module Pdfcrowd
800
809
  # * *Returns* - Byte array containing the conversion output.
801
810
  def convertFile(file)
802
811
  if (!(File.file?(file) && !File.zero?(file)))
803
- raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-pdf", "The file must exist and not be empty.", "convert_file"), 470);
812
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "html-to-pdf", "The file must exist and not be empty.", "convert_file"), 470);
804
813
  end
805
814
 
806
815
  @files['file'] = file
@@ -813,7 +822,7 @@ module Pdfcrowd
813
822
  # * +out_stream+ - The output stream that will contain the conversion output.
814
823
  def convertFileToStream(file, out_stream)
815
824
  if (!(File.file?(file) && !File.zero?(file)))
816
- raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-pdf", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
825
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "html-to-pdf", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
817
826
  end
818
827
 
819
828
  @files['file'] = file
@@ -826,7 +835,7 @@ module Pdfcrowd
826
835
  # * +file_path+ - The output file path. The string must not be empty.
827
836
  def convertFileToFile(file, file_path)
828
837
  if (!(!file_path.nil? && !file_path.empty?))
829
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-pdf", "The string must not be empty.", "convert_file_to_file"), 470);
838
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "html-to-pdf", "The string must not be empty.", "convert_file_to_file"), 470);
830
839
  end
831
840
 
832
841
  output_file = open(file_path, "wb")
@@ -846,7 +855,7 @@ module Pdfcrowd
846
855
  # * *Returns* - Byte array containing the conversion output.
847
856
  def convertString(text)
848
857
  if (!(!text.nil? && !text.empty?))
849
- raise Error.new(Pdfcrowd.create_invalid_value_message(text, "text", "html-to-pdf", "The string must not be empty.", "convert_string"), 470);
858
+ raise Error.new(Pdfcrowd.create_invalid_value_message(text, "convertString", "html-to-pdf", "The string must not be empty.", "convert_string"), 470);
850
859
  end
851
860
 
852
861
  @fields['text'] = text
@@ -859,7 +868,7 @@ module Pdfcrowd
859
868
  # * +out_stream+ - The output stream that will contain the conversion output.
860
869
  def convertStringToStream(text, out_stream)
861
870
  if (!(!text.nil? && !text.empty?))
862
- raise Error.new(Pdfcrowd.create_invalid_value_message(text, "text", "html-to-pdf", "The string must not be empty.", "convert_string_to_stream"), 470);
871
+ raise Error.new(Pdfcrowd.create_invalid_value_message(text, "convertStringToStream::text", "html-to-pdf", "The string must not be empty.", "convert_string_to_stream"), 470);
863
872
  end
864
873
 
865
874
  @fields['text'] = text
@@ -872,7 +881,7 @@ module Pdfcrowd
872
881
  # * +file_path+ - The output file path. The string must not be empty.
873
882
  def convertStringToFile(text, file_path)
874
883
  if (!(!file_path.nil? && !file_path.empty?))
875
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-pdf", "The string must not be empty.", "convert_string_to_file"), 470);
884
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStringToFile::file_path", "html-to-pdf", "The string must not be empty.", "convert_string_to_file"), 470);
876
885
  end
877
886
 
878
887
  output_file = open(file_path, "wb")
@@ -886,42 +895,80 @@ module Pdfcrowd
886
895
  end
887
896
  end
888
897
 
898
+ # Convert the contents of an input stream.
899
+ #
900
+ # * +in_stream+ - The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript).
901
+ # * *Returns* - Byte array containing the conversion output.
902
+ def convertStream(in_stream)
903
+ @raw_data['stream'] = in_stream.read
904
+ @helper.post(@fields, @files, @raw_data)
905
+ end
906
+
907
+ # Convert the contents of an input stream and write the result to an output stream.
908
+ #
909
+ # * +in_stream+ - The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript).
910
+ # * +out_stream+ - The output stream that will contain the conversion output.
911
+ def convertStreamToStream(in_stream, out_stream)
912
+ @raw_data['stream'] = in_stream.read
913
+ @helper.post(@fields, @files, @raw_data, out_stream)
914
+ end
915
+
916
+ # Convert the contents of an input stream and write the result to a local file.
917
+ #
918
+ # * +in_stream+ - The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript).
919
+ # * +file_path+ - The output file path. The string must not be empty.
920
+ def convertStreamToFile(in_stream, file_path)
921
+ if (!(!file_path.nil? && !file_path.empty?))
922
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "html-to-pdf", "The string must not be empty.", "convert_stream_to_file"), 470);
923
+ end
924
+
925
+ output_file = open(file_path, "wb")
926
+ begin
927
+ convertStreamToStream(in_stream, output_file)
928
+ output_file.close()
929
+ rescue Error => why
930
+ output_file.close()
931
+ FileUtils.rm(file_path)
932
+ raise
933
+ end
934
+ end
935
+
889
936
  # Set the output page size.
890
937
  #
891
- # * +page_size+ - Allowed values are A2, A3, A4, A5, A6, Letter.
938
+ # * +size+ - Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.
892
939
  # * *Returns* - The converter object.
893
- def setPageSize(page_size)
894
- unless /(?i)^(A2|A3|A4|A5|A6|Letter)$/.match(page_size)
895
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_size, "page_size", "html-to-pdf", "Allowed values are A2, A3, A4, A5, A6, Letter.", "set_page_size"), 470);
940
+ def setPageSize(size)
941
+ unless /(?i)^(A0|A1|A2|A3|A4|A5|A6|Letter)$/.match(size)
942
+ raise Error.new(Pdfcrowd.create_invalid_value_message(size, "setPageSize", "html-to-pdf", "Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.", "set_page_size"), 470);
896
943
  end
897
944
 
898
- @fields['page_size'] = page_size
945
+ @fields['page_size'] = size
899
946
  self
900
947
  end
901
948
 
902
949
  # Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
903
950
  #
904
- # * +page_width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
951
+ # * +width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
905
952
  # * *Returns* - The converter object.
906
- def setPageWidth(page_width)
907
- unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(page_width)
908
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_width, "page_width", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_page_width"), 470);
953
+ def setPageWidth(width)
954
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
955
+ raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setPageWidth", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_page_width"), 470);
909
956
  end
910
957
 
911
- @fields['page_width'] = page_width
958
+ @fields['page_width'] = width
912
959
  self
913
960
  end
914
961
 
915
962
  # Set the output page height. Use -1 for a single page PDF. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
916
963
  #
917
- # * +page_height+ - Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
964
+ # * +height+ - Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
918
965
  # * *Returns* - The converter object.
919
- def setPageHeight(page_height)
920
- unless /(?i)^\-1$|^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(page_height)
921
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_height, "page_height", "html-to-pdf", "Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_page_height"), 470);
966
+ def setPageHeight(height)
967
+ unless /(?i)^0$|^\-1$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
968
+ raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setPageHeight", "html-to-pdf", "Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_page_height"), 470);
922
969
  end
923
970
 
924
- @fields['page_height'] = page_height
971
+ @fields['page_height'] = height
925
972
  self
926
973
  end
927
974
 
@@ -942,7 +989,7 @@ module Pdfcrowd
942
989
  # * *Returns* - The converter object.
943
990
  def setOrientation(orientation)
944
991
  unless /(?i)^(landscape|portrait)$/.match(orientation)
945
- raise Error.new(Pdfcrowd.create_invalid_value_message(orientation, "orientation", "html-to-pdf", "Allowed values are landscape, portrait.", "set_orientation"), 470);
992
+ raise Error.new(Pdfcrowd.create_invalid_value_message(orientation, "setOrientation", "html-to-pdf", "Allowed values are landscape, portrait.", "set_orientation"), 470);
946
993
  end
947
994
 
948
995
  @fields['orientation'] = orientation
@@ -951,62 +998,62 @@ module Pdfcrowd
951
998
 
952
999
  # Set the output page top margin.
953
1000
  #
954
- # * +margin_top+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1001
+ # * +top+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
955
1002
  # * *Returns* - The converter object.
956
- def setMarginTop(margin_top)
957
- unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(margin_top)
958
- raise Error.new(Pdfcrowd.create_invalid_value_message(margin_top, "margin_top", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_top"), 470);
1003
+ def setMarginTop(top)
1004
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(top)
1005
+ raise Error.new(Pdfcrowd.create_invalid_value_message(top, "setMarginTop", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_top"), 470);
959
1006
  end
960
1007
 
961
- @fields['margin_top'] = margin_top
1008
+ @fields['margin_top'] = top
962
1009
  self
963
1010
  end
964
1011
 
965
1012
  # Set the output page right margin.
966
1013
  #
967
- # * +margin_right+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1014
+ # * +right+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
968
1015
  # * *Returns* - The converter object.
969
- def setMarginRight(margin_right)
970
- unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(margin_right)
971
- raise Error.new(Pdfcrowd.create_invalid_value_message(margin_right, "margin_right", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_right"), 470);
1016
+ def setMarginRight(right)
1017
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(right)
1018
+ raise Error.new(Pdfcrowd.create_invalid_value_message(right, "setMarginRight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_right"), 470);
972
1019
  end
973
1020
 
974
- @fields['margin_right'] = margin_right
1021
+ @fields['margin_right'] = right
975
1022
  self
976
1023
  end
977
1024
 
978
1025
  # Set the output page bottom margin.
979
1026
  #
980
- # * +margin_bottom+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1027
+ # * +bottom+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
981
1028
  # * *Returns* - The converter object.
982
- def setMarginBottom(margin_bottom)
983
- unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(margin_bottom)
984
- raise Error.new(Pdfcrowd.create_invalid_value_message(margin_bottom, "margin_bottom", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_bottom"), 470);
1029
+ def setMarginBottom(bottom)
1030
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(bottom)
1031
+ raise Error.new(Pdfcrowd.create_invalid_value_message(bottom, "setMarginBottom", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_bottom"), 470);
985
1032
  end
986
1033
 
987
- @fields['margin_bottom'] = margin_bottom
1034
+ @fields['margin_bottom'] = bottom
988
1035
  self
989
1036
  end
990
1037
 
991
1038
  # Set the output page left margin.
992
1039
  #
993
- # * +margin_left+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1040
+ # * +left+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
994
1041
  # * *Returns* - The converter object.
995
- def setMarginLeft(margin_left)
996
- unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(margin_left)
997
- raise Error.new(Pdfcrowd.create_invalid_value_message(margin_left, "margin_left", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_left"), 470);
1042
+ def setMarginLeft(left)
1043
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(left)
1044
+ raise Error.new(Pdfcrowd.create_invalid_value_message(left, "setMarginLeft", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_left"), 470);
998
1045
  end
999
1046
 
1000
- @fields['margin_left'] = margin_left
1047
+ @fields['margin_left'] = left
1001
1048
  self
1002
1049
  end
1003
1050
 
1004
1051
  # Disable page margins.
1005
1052
  #
1006
- # * +no_margins+ - Set to true to disable margins.
1053
+ # * +value+ - Set to true to disable margins.
1007
1054
  # * *Returns* - The converter object.
1008
- def setNoMargins(no_margins)
1009
- @fields['no_margins'] = no_margins
1055
+ def setNoMargins(value)
1056
+ @fields['no_margins'] = value
1010
1057
  self
1011
1058
  end
1012
1059
 
@@ -1025,104 +1072,202 @@ module Pdfcrowd
1025
1072
  self
1026
1073
  end
1027
1074
 
1075
+ # Set the page range to print.
1076
+ #
1077
+ # * +pages+ - A comma separated list of page numbers or ranges.
1078
+ # * *Returns* - The converter object.
1079
+ def setPrintPageRange(pages)
1080
+ unless /^(?:\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*))\s*,\s*)*\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*))\s*$/.match(pages)
1081
+ raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setPrintPageRange", "html-to-pdf", "A comma separated list of page numbers or ranges.", "set_print_page_range"), 470);
1082
+ end
1083
+
1084
+ @fields['print_page_range'] = pages
1085
+ self
1086
+ end
1087
+
1088
+ # Set an offset between physical and logical page numbers.
1089
+ #
1090
+ # * +offset+ - Integer specifying page offset.
1091
+ # * *Returns* - The converter object.
1092
+ def setPageNumberingOffset(offset)
1093
+ @fields['page_numbering_offset'] = offset
1094
+ self
1095
+ end
1096
+
1097
+ # Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
1098
+ #
1099
+ # * +x+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
1100
+ # * *Returns* - The converter object.
1101
+ def setContentAreaX(x)
1102
+ unless /(?i)^0$|^\-?[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(x)
1103
+ raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setContentAreaX", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.", "set_content_area_x"), 470);
1104
+ end
1105
+
1106
+ @fields['content_area_x'] = x
1107
+ self
1108
+ end
1109
+
1110
+ # Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
1111
+ #
1112
+ # * +y+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
1113
+ # * *Returns* - The converter object.
1114
+ def setContentAreaY(y)
1115
+ unless /(?i)^0$|^\-?[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(y)
1116
+ raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setContentAreaY", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.", "set_content_area_y"), 470);
1117
+ end
1118
+
1119
+ @fields['content_area_y'] = y
1120
+ self
1121
+ end
1122
+
1123
+ # Set the width of the content area. It should be at least 1 inch.
1124
+ #
1125
+ # * +width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1126
+ # * *Returns* - The converter object.
1127
+ def setContentAreaWidth(width)
1128
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
1129
+ raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setContentAreaWidth", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_content_area_width"), 470);
1130
+ end
1131
+
1132
+ @fields['content_area_width'] = width
1133
+ self
1134
+ end
1135
+
1136
+ # Set the height of the content area. It should be at least 1 inch.
1137
+ #
1138
+ # * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1139
+ # * *Returns* - The converter object.
1140
+ def setContentAreaHeight(height)
1141
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
1142
+ raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setContentAreaHeight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_content_area_height"), 470);
1143
+ end
1144
+
1145
+ @fields['content_area_height'] = height
1146
+ self
1147
+ end
1148
+
1149
+ # Set the content area position and size. The content area enables to specify a web page area to be converted.
1150
+ #
1151
+ # * +x+ - Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
1152
+ # * +y+ - Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
1153
+ # * +width+ - Set the width of the content area. It should be at least 1 inch. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1154
+ # * +height+ - Set the height of the content area. It should be at least 1 inch. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1155
+ # * *Returns* - The converter object.
1156
+ def setContentArea(x, y, width, height)
1157
+ setContentAreaX(x)
1158
+ setContentAreaY(y)
1159
+ setContentAreaWidth(width)
1160
+ setContentAreaHeight(height)
1161
+ self
1162
+ end
1163
+
1164
+ # Specifies behavior in presence of CSS @page rules. It may affect the page size, margins and orientation.
1165
+ #
1166
+ # * +mode+ - The page rule mode. Allowed values are default, mode1, mode2.
1167
+ # * *Returns* - The converter object.
1168
+ def setCssPageRuleMode(mode)
1169
+ unless /(?i)^(default|mode1|mode2)$/.match(mode)
1170
+ raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setCssPageRuleMode", "html-to-pdf", "Allowed values are default, mode1, mode2.", "set_css_page_rule_mode"), 470);
1171
+ end
1172
+
1173
+ @fields['css_page_rule_mode'] = mode
1174
+ self
1175
+ end
1176
+
1028
1177
  # Load an HTML code from the specified URL and use it as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
1029
1178
  #
1030
- # * +header_url+ - The supported protocols are http:// and https://.
1179
+ # * +url+ - The supported protocols are http:// and https://.
1031
1180
  # * *Returns* - The converter object.
1032
- def setHeaderUrl(header_url)
1033
- unless /(?i)^https?:\/\/.*$/.match(header_url)
1034
- raise Error.new(Pdfcrowd.create_invalid_value_message(header_url, "header_url", "html-to-pdf", "The supported protocols are http:// and https://.", "set_header_url"), 470);
1181
+ def setHeaderUrl(url)
1182
+ unless /(?i)^https?:\/\/.*$/.match(url)
1183
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setHeaderUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_header_url"), 470);
1035
1184
  end
1036
1185
 
1037
- @fields['header_url'] = header_url
1186
+ @fields['header_url'] = url
1038
1187
  self
1039
1188
  end
1040
1189
 
1041
1190
  # Use the specified HTML code as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
1042
1191
  #
1043
- # * +header_html+ - The string must not be empty.
1192
+ # * +html+ - The string must not be empty.
1044
1193
  # * *Returns* - The converter object.
1045
- def setHeaderHtml(header_html)
1046
- if (!(!header_html.nil? && !header_html.empty?))
1047
- raise Error.new(Pdfcrowd.create_invalid_value_message(header_html, "header_html", "html-to-pdf", "The string must not be empty.", "set_header_html"), 470);
1194
+ def setHeaderHtml(html)
1195
+ if (!(!html.nil? && !html.empty?))
1196
+ raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setHeaderHtml", "html-to-pdf", "The string must not be empty.", "set_header_html"), 470);
1048
1197
  end
1049
1198
 
1050
- @fields['header_html'] = header_html
1199
+ @fields['header_html'] = html
1051
1200
  self
1052
1201
  end
1053
1202
 
1054
1203
  # Set the header height.
1055
1204
  #
1056
- # * +header_height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1205
+ # * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1057
1206
  # * *Returns* - The converter object.
1058
- def setHeaderHeight(header_height)
1059
- unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(header_height)
1060
- raise Error.new(Pdfcrowd.create_invalid_value_message(header_height, "header_height", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_header_height"), 470);
1207
+ def setHeaderHeight(height)
1208
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
1209
+ raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setHeaderHeight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_header_height"), 470);
1061
1210
  end
1062
1211
 
1063
- @fields['header_height'] = header_height
1212
+ @fields['header_height'] = height
1064
1213
  self
1065
1214
  end
1066
1215
 
1067
1216
  # Load an HTML code from the specified URL and use it as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
1068
1217
  #
1069
- # * +footer_url+ - The supported protocols are http:// and https://.
1218
+ # * +url+ - The supported protocols are http:// and https://.
1070
1219
  # * *Returns* - The converter object.
1071
- def setFooterUrl(footer_url)
1072
- unless /(?i)^https?:\/\/.*$/.match(footer_url)
1073
- raise Error.new(Pdfcrowd.create_invalid_value_message(footer_url, "footer_url", "html-to-pdf", "The supported protocols are http:// and https://.", "set_footer_url"), 470);
1220
+ def setFooterUrl(url)
1221
+ unless /(?i)^https?:\/\/.*$/.match(url)
1222
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setFooterUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_footer_url"), 470);
1074
1223
  end
1075
1224
 
1076
- @fields['footer_url'] = footer_url
1225
+ @fields['footer_url'] = url
1077
1226
  self
1078
1227
  end
1079
1228
 
1080
1229
  # Use the specified HTML as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
1081
1230
  #
1082
- # * +footer_html+ - The string must not be empty.
1231
+ # * +html+ - The string must not be empty.
1083
1232
  # * *Returns* - The converter object.
1084
- def setFooterHtml(footer_html)
1085
- if (!(!footer_html.nil? && !footer_html.empty?))
1086
- raise Error.new(Pdfcrowd.create_invalid_value_message(footer_html, "footer_html", "html-to-pdf", "The string must not be empty.", "set_footer_html"), 470);
1233
+ def setFooterHtml(html)
1234
+ if (!(!html.nil? && !html.empty?))
1235
+ raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setFooterHtml", "html-to-pdf", "The string must not be empty.", "set_footer_html"), 470);
1087
1236
  end
1088
1237
 
1089
- @fields['footer_html'] = footer_html
1238
+ @fields['footer_html'] = html
1090
1239
  self
1091
1240
  end
1092
1241
 
1093
1242
  # Set the footer height.
1094
1243
  #
1095
- # * +footer_height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1244
+ # * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1096
1245
  # * *Returns* - The converter object.
1097
- def setFooterHeight(footer_height)
1098
- unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(footer_height)
1099
- raise Error.new(Pdfcrowd.create_invalid_value_message(footer_height, "footer_height", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_footer_height"), 470);
1246
+ def setFooterHeight(height)
1247
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
1248
+ raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setFooterHeight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_footer_height"), 470);
1100
1249
  end
1101
1250
 
1102
- @fields['footer_height'] = footer_height
1251
+ @fields['footer_height'] = height
1103
1252
  self
1104
1253
  end
1105
1254
 
1106
- # Set the page range to print.
1255
+ # Disable horizontal page margins for header and footer. The header/footer contents width will be equal to the physical page width.
1107
1256
  #
1108
- # * +pages+ - A comma seperated list of page numbers or ranges.
1257
+ # * +value+ - Set to true to disable horizontal margins for header and footer.
1109
1258
  # * *Returns* - The converter object.
1110
- def setPrintPageRange(pages)
1111
- unless /^(?:\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*))\s*,\s*)*\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*))\s*$/.match(pages)
1112
- raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "pages", "html-to-pdf", "A comma seperated list of page numbers or ranges.", "set_print_page_range"), 470);
1113
- end
1114
-
1115
- @fields['print_page_range'] = pages
1259
+ def setNoHeaderFooterHorizontalMargins(value)
1260
+ @fields['no_header_footer_horizontal_margins'] = value
1116
1261
  self
1117
1262
  end
1118
1263
 
1119
1264
  # The page header is not printed on the specified pages.
1120
1265
  #
1121
- # * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma seperated list of page numbers.
1266
+ # * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma separated list of page numbers.
1122
1267
  # * *Returns* - The converter object.
1123
1268
  def setExcludeHeaderOnPages(pages)
1124
1269
  unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
1125
- raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "pages", "html-to-pdf", "A comma seperated list of page numbers.", "set_exclude_header_on_pages"), 470);
1270
+ raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setExcludeHeaderOnPages", "html-to-pdf", "A comma separated list of page numbers.", "set_exclude_header_on_pages"), 470);
1126
1271
  end
1127
1272
 
1128
1273
  @fields['exclude_header_on_pages'] = pages
@@ -1131,209 +1276,229 @@ module Pdfcrowd
1131
1276
 
1132
1277
  # The page footer is not printed on the specified pages.
1133
1278
  #
1134
- # * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma seperated list of page numbers.
1279
+ # * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma separated list of page numbers.
1135
1280
  # * *Returns* - The converter object.
1136
1281
  def setExcludeFooterOnPages(pages)
1137
1282
  unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
1138
- raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "pages", "html-to-pdf", "A comma seperated list of page numbers.", "set_exclude_footer_on_pages"), 470);
1283
+ raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setExcludeFooterOnPages", "html-to-pdf", "A comma separated list of page numbers.", "set_exclude_footer_on_pages"), 470);
1139
1284
  end
1140
1285
 
1141
1286
  @fields['exclude_footer_on_pages'] = pages
1142
1287
  self
1143
1288
  end
1144
1289
 
1145
- # Set an offset between physical and logical page numbers.
1290
+ # Set the scaling factor (zoom) for the header and footer.
1146
1291
  #
1147
- # * +offset+ - Integer specifying page offset.
1292
+ # * +factor+ - The percentage value. The value must be in the range 10-500.
1148
1293
  # * *Returns* - The converter object.
1149
- def setPageNumberingOffset(offset)
1150
- @fields['page_numbering_offset'] = offset
1294
+ def setHeaderFooterScaleFactor(factor)
1295
+ if (!(Integer(factor) >= 10 && Integer(factor) <= 500))
1296
+ raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setHeaderFooterScaleFactor", "html-to-pdf", "The value must be in the range 10-500.", "set_header_footer_scale_factor"), 470);
1297
+ end
1298
+
1299
+ @fields['header_footer_scale_factor'] = factor
1151
1300
  self
1152
1301
  end
1153
1302
 
1154
- # Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
1303
+ # Apply the first page of the watermark PDF to every page of the output PDF.
1155
1304
  #
1156
- # * +content_area_x+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
1305
+ # * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
1157
1306
  # * *Returns* - The converter object.
1158
- def setContentAreaX(content_area_x)
1159
- unless /(?i)^\-?[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(content_area_x)
1160
- raise Error.new(Pdfcrowd.create_invalid_value_message(content_area_x, "content_area_x", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.", "set_content_area_x"), 470);
1307
+ def setPageWatermark(watermark)
1308
+ if (!(File.file?(watermark) && !File.zero?(watermark)))
1309
+ raise Error.new(Pdfcrowd.create_invalid_value_message(watermark, "setPageWatermark", "html-to-pdf", "The file must exist and not be empty.", "set_page_watermark"), 470);
1161
1310
  end
1162
1311
 
1163
- @fields['content_area_x'] = content_area_x
1312
+ @files['page_watermark'] = watermark
1164
1313
  self
1165
1314
  end
1166
1315
 
1167
- # Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
1316
+ # Load a watermark PDF from the specified URL and apply the first page of the watermark PDF to every page of the output PDF.
1168
1317
  #
1169
- # * +content_area_y+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
1318
+ # * +url+ - The supported protocols are http:// and https://.
1170
1319
  # * *Returns* - The converter object.
1171
- def setContentAreaY(content_area_y)
1172
- unless /(?i)^\-?[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(content_area_y)
1173
- raise Error.new(Pdfcrowd.create_invalid_value_message(content_area_y, "content_area_y", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.", "set_content_area_y"), 470);
1320
+ def setPageWatermarkUrl(url)
1321
+ unless /(?i)^https?:\/\/.*$/.match(url)
1322
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageWatermarkUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_page_watermark_url"), 470);
1174
1323
  end
1175
1324
 
1176
- @fields['content_area_y'] = content_area_y
1325
+ @fields['page_watermark_url'] = url
1177
1326
  self
1178
1327
  end
1179
1328
 
1180
- # Set the width of the content area. It should be at least 1 inch.
1329
+ # Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
1181
1330
  #
1182
- # * +content_area_width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1331
+ # * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
1183
1332
  # * *Returns* - The converter object.
1184
- def setContentAreaWidth(content_area_width)
1185
- unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(content_area_width)
1186
- raise Error.new(Pdfcrowd.create_invalid_value_message(content_area_width, "content_area_width", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_content_area_width"), 470);
1333
+ def setMultipageWatermark(watermark)
1334
+ if (!(File.file?(watermark) && !File.zero?(watermark)))
1335
+ raise Error.new(Pdfcrowd.create_invalid_value_message(watermark, "setMultipageWatermark", "html-to-pdf", "The file must exist and not be empty.", "set_multipage_watermark"), 470);
1187
1336
  end
1188
1337
 
1189
- @fields['content_area_width'] = content_area_width
1338
+ @files['multipage_watermark'] = watermark
1190
1339
  self
1191
1340
  end
1192
1341
 
1193
- # Set the height of the content area. It should be at least 1 inch.
1342
+ # Load a watermark PDF from the specified URL and apply each page of the specified watermark PDF to the corresponding page of the output PDF.
1194
1343
  #
1195
- # * +content_area_height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1344
+ # * +url+ - The supported protocols are http:// and https://.
1196
1345
  # * *Returns* - The converter object.
1197
- def setContentAreaHeight(content_area_height)
1198
- unless /(?i)^[0-9]*(\.[0-9]+)?(pt|px|mm|cm|in)$/.match(content_area_height)
1199
- raise Error.new(Pdfcrowd.create_invalid_value_message(content_area_height, "content_area_height", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_content_area_height"), 470);
1346
+ def setMultipageWatermarkUrl(url)
1347
+ unless /(?i)^https?:\/\/.*$/.match(url)
1348
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageWatermarkUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_watermark_url"), 470);
1200
1349
  end
1201
1350
 
1202
- @fields['content_area_height'] = content_area_height
1351
+ @fields['multipage_watermark_url'] = url
1203
1352
  self
1204
1353
  end
1205
1354
 
1206
- # Set the content area position and size. The content area enables to specify a web page area to be converted.
1355
+ # Apply the first page of the specified PDF to the background of every page of the output PDF.
1207
1356
  #
1208
- # * +x+ - Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
1209
- # * +y+ - Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
1210
- # * +width+ - Set the width of the content area. It should be at least 1 inch. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1211
- # * +height+ - Set the height of the content area. It should be at least 1 inch. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1357
+ # * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
1212
1358
  # * *Returns* - The converter object.
1213
- def setContentArea(x, y, width, height)
1214
- setContentAreaX(x)
1215
- setContentAreaY(y)
1216
- setContentAreaWidth(width)
1217
- setContentAreaHeight(height)
1359
+ def setPageBackground(background)
1360
+ if (!(File.file?(background) && !File.zero?(background)))
1361
+ raise Error.new(Pdfcrowd.create_invalid_value_message(background, "setPageBackground", "html-to-pdf", "The file must exist and not be empty.", "set_page_background"), 470);
1362
+ end
1363
+
1364
+ @files['page_background'] = background
1218
1365
  self
1219
1366
  end
1220
1367
 
1221
- # Apply the first page of the watermark PDF to every page of the output PDF.
1368
+ # Load a background PDF from the specified URL and apply the first page of the background PDF to every page of the output PDF.
1222
1369
  #
1223
- # * +page_watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
1370
+ # * +url+ - The supported protocols are http:// and https://.
1224
1371
  # * *Returns* - The converter object.
1225
- def setPageWatermark(page_watermark)
1226
- if (!(File.file?(page_watermark) && !File.zero?(page_watermark)))
1227
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_watermark, "page_watermark", "html-to-pdf", "The file must exist and not be empty.", "set_page_watermark"), 470);
1372
+ def setPageBackgroundUrl(url)
1373
+ unless /(?i)^https?:\/\/.*$/.match(url)
1374
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageBackgroundUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_page_background_url"), 470);
1228
1375
  end
1229
1376
 
1230
- @files['page_watermark'] = page_watermark
1377
+ @fields['page_background_url'] = url
1231
1378
  self
1232
1379
  end
1233
1380
 
1234
- # Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
1381
+ # Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
1235
1382
  #
1236
- # * +multipage_watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
1383
+ # * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
1237
1384
  # * *Returns* - The converter object.
1238
- def setMultipageWatermark(multipage_watermark)
1239
- if (!(File.file?(multipage_watermark) && !File.zero?(multipage_watermark)))
1240
- raise Error.new(Pdfcrowd.create_invalid_value_message(multipage_watermark, "multipage_watermark", "html-to-pdf", "The file must exist and not be empty.", "set_multipage_watermark"), 470);
1385
+ def setMultipageBackground(background)
1386
+ if (!(File.file?(background) && !File.zero?(background)))
1387
+ raise Error.new(Pdfcrowd.create_invalid_value_message(background, "setMultipageBackground", "html-to-pdf", "The file must exist and not be empty.", "set_multipage_background"), 470);
1241
1388
  end
1242
1389
 
1243
- @files['multipage_watermark'] = multipage_watermark
1390
+ @files['multipage_background'] = background
1244
1391
  self
1245
1392
  end
1246
1393
 
1247
- # Apply the first page of the specified PDF to the background of every page of the output PDF.
1394
+ # Load a background PDF from the specified URL and apply each page of the specified background PDF to the corresponding page of the output PDF.
1248
1395
  #
1249
- # * +page_background+ - The file path to a local background PDF file. The file must exist and not be empty.
1396
+ # * +url+ - The supported protocols are http:// and https://.
1250
1397
  # * *Returns* - The converter object.
1251
- def setPageBackground(page_background)
1252
- if (!(File.file?(page_background) && !File.zero?(page_background)))
1253
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_background, "page_background", "html-to-pdf", "The file must exist and not be empty.", "set_page_background"), 470);
1398
+ def setMultipageBackgroundUrl(url)
1399
+ unless /(?i)^https?:\/\/.*$/.match(url)
1400
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageBackgroundUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_background_url"), 470);
1254
1401
  end
1255
1402
 
1256
- @files['page_background'] = page_background
1403
+ @fields['multipage_background_url'] = url
1257
1404
  self
1258
1405
  end
1259
1406
 
1260
- # Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
1407
+ # The page background color in RGB or RGBA hexadecimal format. The color fills the entire page regardless of the margins.
1261
1408
  #
1262
- # * +multipage_background+ - The file path to a local background PDF file. The file must exist and not be empty.
1409
+ # * +color+ - The value must be in RRGGBB or RRGGBBAA hexadecimal format.
1263
1410
  # * *Returns* - The converter object.
1264
- def setMultipageBackground(multipage_background)
1265
- if (!(File.file?(multipage_background) && !File.zero?(multipage_background)))
1266
- raise Error.new(Pdfcrowd.create_invalid_value_message(multipage_background, "multipage_background", "html-to-pdf", "The file must exist and not be empty.", "set_multipage_background"), 470);
1411
+ def setPageBackgroundColor(color)
1412
+ unless /^[0-9a-fA-F]{6,8}$/.match(color)
1413
+ raise Error.new(Pdfcrowd.create_invalid_value_message(color, "setPageBackgroundColor", "html-to-pdf", "The value must be in RRGGBB or RRGGBBAA hexadecimal format.", "set_page_background_color"), 470);
1267
1414
  end
1268
1415
 
1269
- @files['multipage_background'] = multipage_background
1416
+ @fields['page_background_color'] = color
1270
1417
  self
1271
1418
  end
1272
1419
 
1273
- # The page background color in RGB or RGBA hexadecimal format. The color fills the entire page regardless of the margins.
1420
+ # Use the print version of the page if available (@media print).
1274
1421
  #
1275
- # * +page_background_color+ - The value must be in RRGGBB or RRGGBBAA hexadecimal format.
1422
+ # * +value+ - Set to true to use the print version of the page.
1276
1423
  # * *Returns* - The converter object.
1277
- def setPageBackgroundColor(page_background_color)
1278
- unless /^[0-9a-fA-F]{6,8}$/.match(page_background_color)
1279
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_background_color, "page_background_color", "html-to-pdf", "The value must be in RRGGBB or RRGGBBAA hexadecimal format.", "set_page_background_color"), 470);
1280
- end
1281
-
1282
- @fields['page_background_color'] = page_background_color
1424
+ def setUsePrintMedia(value)
1425
+ @fields['use_print_media'] = value
1283
1426
  self
1284
1427
  end
1285
1428
 
1286
1429
  # Do not print the background graphics.
1287
1430
  #
1288
- # * +no_background+ - Set to true to disable the background graphics.
1431
+ # * +value+ - Set to true to disable the background graphics.
1289
1432
  # * *Returns* - The converter object.
1290
- def setNoBackground(no_background)
1291
- @fields['no_background'] = no_background
1433
+ def setNoBackground(value)
1434
+ @fields['no_background'] = value
1292
1435
  self
1293
1436
  end
1294
1437
 
1295
1438
  # Do not execute JavaScript.
1296
1439
  #
1297
- # * +disable_javascript+ - Set to true to disable JavaScript in web pages.
1440
+ # * +value+ - Set to true to disable JavaScript in web pages.
1298
1441
  # * *Returns* - The converter object.
1299
- def setDisableJavascript(disable_javascript)
1300
- @fields['disable_javascript'] = disable_javascript
1442
+ def setDisableJavascript(value)
1443
+ @fields['disable_javascript'] = value
1301
1444
  self
1302
1445
  end
1303
1446
 
1304
1447
  # Do not load images.
1305
1448
  #
1306
- # * +disable_image_loading+ - Set to true to disable loading of images.
1449
+ # * +value+ - Set to true to disable loading of images.
1307
1450
  # * *Returns* - The converter object.
1308
- def setDisableImageLoading(disable_image_loading)
1309
- @fields['disable_image_loading'] = disable_image_loading
1451
+ def setDisableImageLoading(value)
1452
+ @fields['disable_image_loading'] = value
1310
1453
  self
1311
1454
  end
1312
1455
 
1313
1456
  # Disable loading fonts from remote sources.
1314
1457
  #
1315
- # * +disable_remote_fonts+ - Set to true disable loading remote fonts.
1458
+ # * +value+ - Set to true disable loading remote fonts.
1459
+ # * *Returns* - The converter object.
1460
+ def setDisableRemoteFonts(value)
1461
+ @fields['disable_remote_fonts'] = value
1462
+ self
1463
+ end
1464
+
1465
+ # Specifies how iframes are handled.
1466
+ #
1467
+ # * +iframes+ - Allowed values are all, same-origin, none.
1316
1468
  # * *Returns* - The converter object.
1317
- def setDisableRemoteFonts(disable_remote_fonts)
1318
- @fields['disable_remote_fonts'] = disable_remote_fonts
1469
+ def setLoadIframes(iframes)
1470
+ unless /(?i)^(all|same-origin|none)$/.match(iframes)
1471
+ raise Error.new(Pdfcrowd.create_invalid_value_message(iframes, "setLoadIframes", "html-to-pdf", "Allowed values are all, same-origin, none.", "set_load_iframes"), 470);
1472
+ end
1473
+
1474
+ @fields['load_iframes'] = iframes
1319
1475
  self
1320
1476
  end
1321
1477
 
1322
1478
  # Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
1323
1479
  #
1324
- # * +block_ads+ - Set to true to block ads in web pages.
1480
+ # * +value+ - Set to true to block ads in web pages.
1325
1481
  # * *Returns* - The converter object.
1326
- def setBlockAds(block_ads)
1327
- @fields['block_ads'] = block_ads
1482
+ def setBlockAds(value)
1483
+ @fields['block_ads'] = value
1328
1484
  self
1329
1485
  end
1330
1486
 
1331
1487
  # Set the default HTML content text encoding.
1332
1488
  #
1333
- # * +default_encoding+ - The text encoding of the HTML content.
1489
+ # * +encoding+ - The text encoding of the HTML content.
1490
+ # * *Returns* - The converter object.
1491
+ def setDefaultEncoding(encoding)
1492
+ @fields['default_encoding'] = encoding
1493
+ self
1494
+ end
1495
+
1496
+ # Set the locale for the conversion. This may affect the output format of dates, times and numbers.
1497
+ #
1498
+ # * +locale+ - The locale code according to ISO 639.
1334
1499
  # * *Returns* - The converter object.
1335
- def setDefaultEncoding(default_encoding)
1336
- @fields['default_encoding'] = default_encoding
1500
+ def setLocale(locale)
1501
+ @fields['locale'] = locale
1337
1502
  self
1338
1503
  end
1339
1504
 
@@ -1366,24 +1531,6 @@ module Pdfcrowd
1366
1531
  self
1367
1532
  end
1368
1533
 
1369
- # Use the print version of the page if available (@media print).
1370
- #
1371
- # * +use_print_media+ - Set to true to use the print version of the page.
1372
- # * *Returns* - The converter object.
1373
- def setUsePrintMedia(use_print_media)
1374
- @fields['use_print_media'] = use_print_media
1375
- self
1376
- end
1377
-
1378
- # Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
1379
- #
1380
- # * +no_xpdfcrowd_header+ - Set to true to disable sending X-Pdfcrowd HTTP header.
1381
- # * *Returns* - The converter object.
1382
- def setNoXpdfcrowdHeader(no_xpdfcrowd_header)
1383
- @fields['no_xpdfcrowd_header'] = no_xpdfcrowd_header
1384
- self
1385
- end
1386
-
1387
1534
  # Set cookies that are sent in Pdfcrowd HTTP requests.
1388
1535
  #
1389
1536
  # * +cookies+ - The cookie string.
@@ -1395,10 +1542,10 @@ module Pdfcrowd
1395
1542
 
1396
1543
  # Do not allow insecure HTTPS connections.
1397
1544
  #
1398
- # * +verify_ssl_certificates+ - Set to true to enable SSL certificate verification.
1545
+ # * +value+ - Set to true to enable SSL certificate verification.
1399
1546
  # * *Returns* - The converter object.
1400
- def setVerifySslCertificates(verify_ssl_certificates)
1401
- @fields['verify_ssl_certificates'] = verify_ssl_certificates
1547
+ def setVerifySslCertificates(value)
1548
+ @fields['verify_ssl_certificates'] = value
1402
1549
  self
1403
1550
  end
1404
1551
 
@@ -1420,55 +1567,64 @@ module Pdfcrowd
1420
1567
  self
1421
1568
  end
1422
1569
 
1570
+ # Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
1571
+ #
1572
+ # * +value+ - Set to true to disable sending X-Pdfcrowd HTTP header.
1573
+ # * *Returns* - The converter object.
1574
+ def setNoXpdfcrowdHeader(value)
1575
+ @fields['no_xpdfcrowd_header'] = value
1576
+ self
1577
+ end
1578
+
1423
1579
  # Run a custom JavaScript after the document is loaded and ready to print. The script is intended for post-load DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
1424
1580
  #
1425
- # * +custom_javascript+ - A string containing a JavaScript code. The string must not be empty.
1581
+ # * +javascript+ - A string containing a JavaScript code. The string must not be empty.
1426
1582
  # * *Returns* - The converter object.
1427
- def setCustomJavascript(custom_javascript)
1428
- if (!(!custom_javascript.nil? && !custom_javascript.empty?))
1429
- raise Error.new(Pdfcrowd.create_invalid_value_message(custom_javascript, "custom_javascript", "html-to-pdf", "The string must not be empty.", "set_custom_javascript"), 470);
1583
+ def setCustomJavascript(javascript)
1584
+ if (!(!javascript.nil? && !javascript.empty?))
1585
+ raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setCustomJavascript", "html-to-pdf", "The string must not be empty.", "set_custom_javascript"), 470);
1430
1586
  end
1431
1587
 
1432
- @fields['custom_javascript'] = custom_javascript
1588
+ @fields['custom_javascript'] = javascript
1433
1589
  self
1434
1590
  end
1435
1591
 
1436
1592
  # Run a custom JavaScript right after the document is loaded. The script is intended for early DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
1437
1593
  #
1438
- # * +on_load_javascript+ - A string containing a JavaScript code. The string must not be empty.
1594
+ # * +javascript+ - A string containing a JavaScript code. The string must not be empty.
1439
1595
  # * *Returns* - The converter object.
1440
- def setOnLoadJavascript(on_load_javascript)
1441
- if (!(!on_load_javascript.nil? && !on_load_javascript.empty?))
1442
- raise Error.new(Pdfcrowd.create_invalid_value_message(on_load_javascript, "on_load_javascript", "html-to-pdf", "The string must not be empty.", "set_on_load_javascript"), 470);
1596
+ def setOnLoadJavascript(javascript)
1597
+ if (!(!javascript.nil? && !javascript.empty?))
1598
+ raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setOnLoadJavascript", "html-to-pdf", "The string must not be empty.", "set_on_load_javascript"), 470);
1443
1599
  end
1444
1600
 
1445
- @fields['on_load_javascript'] = on_load_javascript
1601
+ @fields['on_load_javascript'] = javascript
1446
1602
  self
1447
1603
  end
1448
1604
 
1449
1605
  # Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
1450
1606
  #
1451
- # * +custom_http_header+ - A string containing the header name and value separated by a colon.
1607
+ # * +header+ - A string containing the header name and value separated by a colon.
1452
1608
  # * *Returns* - The converter object.
1453
- def setCustomHttpHeader(custom_http_header)
1454
- unless /^.+:.+$/.match(custom_http_header)
1455
- raise Error.new(Pdfcrowd.create_invalid_value_message(custom_http_header, "custom_http_header", "html-to-pdf", "A string containing the header name and value separated by a colon.", "set_custom_http_header"), 470);
1609
+ def setCustomHttpHeader(header)
1610
+ unless /^.+:.+$/.match(header)
1611
+ raise Error.new(Pdfcrowd.create_invalid_value_message(header, "setCustomHttpHeader", "html-to-pdf", "A string containing the header name and value separated by a colon.", "set_custom_http_header"), 470);
1456
1612
  end
1457
1613
 
1458
- @fields['custom_http_header'] = custom_http_header
1614
+ @fields['custom_http_header'] = header
1459
1615
  self
1460
1616
  end
1461
1617
 
1462
- # Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. The maximum value is determined by your API license.
1618
+ # Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. Your API license defines the maximum wait time by "Max Delay" parameter.
1463
1619
  #
1464
- # * +javascript_delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
1620
+ # * +delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
1465
1621
  # * *Returns* - The converter object.
1466
- def setJavascriptDelay(javascript_delay)
1467
- if (!(Integer(javascript_delay) >= 0))
1468
- raise Error.new(Pdfcrowd.create_invalid_value_message(javascript_delay, "javascript_delay", "html-to-pdf", "Must be a positive integer number or 0.", "set_javascript_delay"), 470);
1622
+ def setJavascriptDelay(delay)
1623
+ if (!(Integer(delay) >= 0))
1624
+ raise Error.new(Pdfcrowd.create_invalid_value_message(delay, "setJavascriptDelay", "html-to-pdf", "Must be a positive integer number or 0.", "set_javascript_delay"), 470);
1469
1625
  end
1470
1626
 
1471
- @fields['javascript_delay'] = javascript_delay
1627
+ @fields['javascript_delay'] = delay
1472
1628
  self
1473
1629
  end
1474
1630
 
@@ -1478,7 +1634,7 @@ module Pdfcrowd
1478
1634
  # * *Returns* - The converter object.
1479
1635
  def setElementToConvert(selectors)
1480
1636
  if (!(!selectors.nil? && !selectors.empty?))
1481
- raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "selectors", "html-to-pdf", "The string must not be empty.", "set_element_to_convert"), 470);
1637
+ raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setElementToConvert", "html-to-pdf", "The string must not be empty.", "set_element_to_convert"), 470);
1482
1638
  end
1483
1639
 
1484
1640
  @fields['element_to_convert'] = selectors
@@ -1491,7 +1647,7 @@ module Pdfcrowd
1491
1647
  # * *Returns* - The converter object.
1492
1648
  def setElementToConvertMode(mode)
1493
1649
  unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode)
1494
- raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "mode", "html-to-pdf", "Allowed values are cut-out, remove-siblings, hide-siblings.", "set_element_to_convert_mode"), 470);
1650
+ raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setElementToConvertMode", "html-to-pdf", "Allowed values are cut-out, remove-siblings, hide-siblings.", "set_element_to_convert_mode"), 470);
1495
1651
  end
1496
1652
 
1497
1653
  @fields['element_to_convert_mode'] = mode
@@ -1504,7 +1660,7 @@ module Pdfcrowd
1504
1660
  # * *Returns* - The converter object.
1505
1661
  def setWaitForElement(selectors)
1506
1662
  if (!(!selectors.nil? && !selectors.empty?))
1507
- raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "selectors", "html-to-pdf", "The string must not be empty.", "set_wait_for_element"), 470);
1663
+ raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setWaitForElement", "html-to-pdf", "The string must not be empty.", "set_wait_for_element"), 470);
1508
1664
  end
1509
1665
 
1510
1666
  @fields['wait_for_element'] = selectors
@@ -1513,27 +1669,27 @@ module Pdfcrowd
1513
1669
 
1514
1670
  # Set the viewport width in pixels. The viewport is the user's visible area of the page.
1515
1671
  #
1516
- # * +viewport_width+ - The value must be in the range 96-65000.
1672
+ # * +width+ - The value must be in the range 96-65000.
1517
1673
  # * *Returns* - The converter object.
1518
- def setViewportWidth(viewport_width)
1519
- if (!(Integer(viewport_width) >= 96 && Integer(viewport_width) <= 65000))
1520
- raise Error.new(Pdfcrowd.create_invalid_value_message(viewport_width, "viewport_width", "html-to-pdf", "The value must be in the range 96-65000.", "set_viewport_width"), 470);
1674
+ def setViewportWidth(width)
1675
+ if (!(Integer(width) >= 96 && Integer(width) <= 65000))
1676
+ raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setViewportWidth", "html-to-pdf", "The value must be in the range 96-65000.", "set_viewport_width"), 470);
1521
1677
  end
1522
1678
 
1523
- @fields['viewport_width'] = viewport_width
1679
+ @fields['viewport_width'] = width
1524
1680
  self
1525
1681
  end
1526
1682
 
1527
1683
  # Set the viewport height in pixels. The viewport is the user's visible area of the page.
1528
1684
  #
1529
- # * +viewport_height+ - Must be a positive integer number.
1685
+ # * +height+ - Must be a positive integer number.
1530
1686
  # * *Returns* - The converter object.
1531
- def setViewportHeight(viewport_height)
1532
- if (!(Integer(viewport_height) > 0))
1533
- raise Error.new(Pdfcrowd.create_invalid_value_message(viewport_height, "viewport_height", "html-to-pdf", "Must be a positive integer number.", "set_viewport_height"), 470);
1687
+ def setViewportHeight(height)
1688
+ if (!(Integer(height) > 0))
1689
+ raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setViewportHeight", "html-to-pdf", "Must be a positive integer number.", "set_viewport_height"), 470);
1534
1690
  end
1535
1691
 
1536
- @fields['viewport_height'] = viewport_height
1692
+ @fields['viewport_height'] = height
1537
1693
  self
1538
1694
  end
1539
1695
 
@@ -1550,164 +1706,142 @@ module Pdfcrowd
1550
1706
 
1551
1707
  # Set the rendering mode.
1552
1708
  #
1553
- # * +rendering_mode+ - The rendering mode. Allowed values are default, viewport.
1709
+ # * +mode+ - The rendering mode. Allowed values are default, viewport.
1554
1710
  # * *Returns* - The converter object.
1555
- def setRenderingMode(rendering_mode)
1556
- unless /(?i)^(default|viewport)$/.match(rendering_mode)
1557
- raise Error.new(Pdfcrowd.create_invalid_value_message(rendering_mode, "rendering_mode", "html-to-pdf", "Allowed values are default, viewport.", "set_rendering_mode"), 470);
1711
+ def setRenderingMode(mode)
1712
+ unless /(?i)^(default|viewport)$/.match(mode)
1713
+ raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setRenderingMode", "html-to-pdf", "Allowed values are default, viewport.", "set_rendering_mode"), 470);
1558
1714
  end
1559
1715
 
1560
- @fields['rendering_mode'] = rendering_mode
1716
+ @fields['rendering_mode'] = mode
1561
1717
  self
1562
1718
  end
1563
1719
 
1564
1720
  # Specifies the scaling mode used for fitting the HTML contents to the print area.
1565
1721
  #
1566
- # * +smart_scaling_mode+ - The smart scaling mode. Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit.
1722
+ # * +mode+ - The smart scaling mode. Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, mode1.
1567
1723
  # * *Returns* - The converter object.
1568
- def setSmartScalingMode(smart_scaling_mode)
1569
- unless /(?i)^(default|disabled|viewport-fit|content-fit|single-page-fit)$/.match(smart_scaling_mode)
1570
- raise Error.new(Pdfcrowd.create_invalid_value_message(smart_scaling_mode, "smart_scaling_mode", "html-to-pdf", "Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit.", "set_smart_scaling_mode"), 470);
1724
+ def setSmartScalingMode(mode)
1725
+ unless /(?i)^(default|disabled|viewport-fit|content-fit|single-page-fit|mode1)$/.match(mode)
1726
+ raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setSmartScalingMode", "html-to-pdf", "Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, mode1.", "set_smart_scaling_mode"), 470);
1571
1727
  end
1572
1728
 
1573
- @fields['smart_scaling_mode'] = smart_scaling_mode
1729
+ @fields['smart_scaling_mode'] = mode
1574
1730
  self
1575
1731
  end
1576
1732
 
1577
1733
  # Set the scaling factor (zoom) for the main page area.
1578
1734
  #
1579
- # * +scale_factor+ - The percentage value. The value must be in the range 10-500.
1735
+ # * +factor+ - The percentage value. The value must be in the range 10-500.
1580
1736
  # * *Returns* - The converter object.
1581
- def setScaleFactor(scale_factor)
1582
- if (!(Integer(scale_factor) >= 10 && Integer(scale_factor) <= 500))
1583
- raise Error.new(Pdfcrowd.create_invalid_value_message(scale_factor, "scale_factor", "html-to-pdf", "The value must be in the range 10-500.", "set_scale_factor"), 470);
1737
+ def setScaleFactor(factor)
1738
+ if (!(Integer(factor) >= 10 && Integer(factor) <= 500))
1739
+ raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "html-to-pdf", "The value must be in the range 10-500.", "set_scale_factor"), 470);
1584
1740
  end
1585
1741
 
1586
- @fields['scale_factor'] = scale_factor
1587
- self
1588
- end
1589
-
1590
- # Set the scaling factor (zoom) for the header and footer.
1591
- #
1592
- # * +header_footer_scale_factor+ - The percentage value. The value must be in the range 10-500.
1593
- # * *Returns* - The converter object.
1594
- def setHeaderFooterScaleFactor(header_footer_scale_factor)
1595
- if (!(Integer(header_footer_scale_factor) >= 10 && Integer(header_footer_scale_factor) <= 500))
1596
- raise Error.new(Pdfcrowd.create_invalid_value_message(header_footer_scale_factor, "header_footer_scale_factor", "html-to-pdf", "The value must be in the range 10-500.", "set_header_footer_scale_factor"), 470);
1597
- end
1598
-
1599
- @fields['header_footer_scale_factor'] = header_footer_scale_factor
1600
- self
1601
- end
1602
-
1603
- # Disable the intelligent shrinking strategy that tries to optimally fit the HTML contents to a PDF page.
1604
- #
1605
- # * +disable_smart_shrinking+ - Set to true to disable the intelligent shrinking strategy.
1606
- # * *Returns* - The converter object.
1607
- def setDisableSmartShrinking(disable_smart_shrinking)
1608
- @fields['disable_smart_shrinking'] = disable_smart_shrinking
1742
+ @fields['scale_factor'] = factor
1609
1743
  self
1610
1744
  end
1611
1745
 
1612
1746
  # Set the quality of embedded JPEG images. A lower quality results in a smaller PDF file but can lead to compression artifacts.
1613
1747
  #
1614
- # * +jpeg_quality+ - The percentage value. The value must be in the range 1-100.
1748
+ # * +quality+ - The percentage value. The value must be in the range 1-100.
1615
1749
  # * *Returns* - The converter object.
1616
- def setJpegQuality(jpeg_quality)
1617
- if (!(Integer(jpeg_quality) >= 1 && Integer(jpeg_quality) <= 100))
1618
- raise Error.new(Pdfcrowd.create_invalid_value_message(jpeg_quality, "jpeg_quality", "html-to-pdf", "The value must be in the range 1-100.", "set_jpeg_quality"), 470);
1750
+ def setJpegQuality(quality)
1751
+ if (!(Integer(quality) >= 1 && Integer(quality) <= 100))
1752
+ raise Error.new(Pdfcrowd.create_invalid_value_message(quality, "setJpegQuality", "html-to-pdf", "The value must be in the range 1-100.", "set_jpeg_quality"), 470);
1619
1753
  end
1620
1754
 
1621
- @fields['jpeg_quality'] = jpeg_quality
1755
+ @fields['jpeg_quality'] = quality
1622
1756
  self
1623
1757
  end
1624
1758
 
1625
1759
  # Specify which image types will be converted to JPEG. Converting lossless compression image formats (PNG, GIF, ...) to JPEG may result in a smaller PDF file.
1626
1760
  #
1627
- # * +convert_images_to_jpeg+ - The image category. Allowed values are none, opaque, all.
1761
+ # * +images+ - The image category. Allowed values are none, opaque, all.
1628
1762
  # * *Returns* - The converter object.
1629
- def setConvertImagesToJpeg(convert_images_to_jpeg)
1630
- unless /(?i)^(none|opaque|all)$/.match(convert_images_to_jpeg)
1631
- raise Error.new(Pdfcrowd.create_invalid_value_message(convert_images_to_jpeg, "convert_images_to_jpeg", "html-to-pdf", "Allowed values are none, opaque, all.", "set_convert_images_to_jpeg"), 470);
1763
+ def setConvertImagesToJpeg(images)
1764
+ unless /(?i)^(none|opaque|all)$/.match(images)
1765
+ raise Error.new(Pdfcrowd.create_invalid_value_message(images, "setConvertImagesToJpeg", "html-to-pdf", "Allowed values are none, opaque, all.", "set_convert_images_to_jpeg"), 470);
1632
1766
  end
1633
1767
 
1634
- @fields['convert_images_to_jpeg'] = convert_images_to_jpeg
1768
+ @fields['convert_images_to_jpeg'] = images
1635
1769
  self
1636
1770
  end
1637
1771
 
1638
1772
  # Set the DPI of images in PDF. A lower DPI may result in a smaller PDF file. If the specified DPI is higher than the actual image DPI, the original image DPI is retained (no upscaling is performed). Use 0 to leave the images unaltered.
1639
1773
  #
1640
- # * +image_dpi+ - The DPI value. Must be a positive integer number or 0.
1774
+ # * +dpi+ - The DPI value. Must be a positive integer number or 0.
1641
1775
  # * *Returns* - The converter object.
1642
- def setImageDpi(image_dpi)
1643
- if (!(Integer(image_dpi) >= 0))
1644
- raise Error.new(Pdfcrowd.create_invalid_value_message(image_dpi, "image_dpi", "html-to-pdf", "Must be a positive integer number or 0.", "set_image_dpi"), 470);
1776
+ def setImageDpi(dpi)
1777
+ if (!(Integer(dpi) >= 0))
1778
+ raise Error.new(Pdfcrowd.create_invalid_value_message(dpi, "setImageDpi", "html-to-pdf", "Must be a positive integer number or 0.", "set_image_dpi"), 470);
1645
1779
  end
1646
1780
 
1647
- @fields['image_dpi'] = image_dpi
1781
+ @fields['image_dpi'] = dpi
1648
1782
  self
1649
1783
  end
1650
1784
 
1651
1785
  # Create linearized PDF. This is also known as Fast Web View.
1652
1786
  #
1653
- # * +linearize+ - Set to true to create linearized PDF.
1787
+ # * +value+ - Set to true to create linearized PDF.
1654
1788
  # * *Returns* - The converter object.
1655
- def setLinearize(linearize)
1656
- @fields['linearize'] = linearize
1789
+ def setLinearize(value)
1790
+ @fields['linearize'] = value
1657
1791
  self
1658
1792
  end
1659
1793
 
1660
1794
  # Encrypt the PDF. This prevents search engines from indexing the contents.
1661
1795
  #
1662
- # * +encrypt+ - Set to true to enable PDF encryption.
1796
+ # * +value+ - Set to true to enable PDF encryption.
1663
1797
  # * *Returns* - The converter object.
1664
- def setEncrypt(encrypt)
1665
- @fields['encrypt'] = encrypt
1798
+ def setEncrypt(value)
1799
+ @fields['encrypt'] = value
1666
1800
  self
1667
1801
  end
1668
1802
 
1669
1803
  # Protect the PDF with a user password. When a PDF has a user password, it must be supplied in order to view the document and to perform operations allowed by the access permissions.
1670
1804
  #
1671
- # * +user_password+ - The user password.
1805
+ # * +password+ - The user password.
1672
1806
  # * *Returns* - The converter object.
1673
- def setUserPassword(user_password)
1674
- @fields['user_password'] = user_password
1807
+ def setUserPassword(password)
1808
+ @fields['user_password'] = password
1675
1809
  self
1676
1810
  end
1677
1811
 
1678
1812
  # Protect the PDF with an owner password. Supplying an owner password grants unlimited access to the PDF including changing the passwords and access permissions.
1679
1813
  #
1680
- # * +owner_password+ - The owner password.
1814
+ # * +password+ - The owner password.
1681
1815
  # * *Returns* - The converter object.
1682
- def setOwnerPassword(owner_password)
1683
- @fields['owner_password'] = owner_password
1816
+ def setOwnerPassword(password)
1817
+ @fields['owner_password'] = password
1684
1818
  self
1685
1819
  end
1686
1820
 
1687
1821
  # Disallow printing of the output PDF.
1688
1822
  #
1689
- # * +no_print+ - Set to true to set the no-print flag in the output PDF.
1823
+ # * +value+ - Set to true to set the no-print flag in the output PDF.
1690
1824
  # * *Returns* - The converter object.
1691
- def setNoPrint(no_print)
1692
- @fields['no_print'] = no_print
1825
+ def setNoPrint(value)
1826
+ @fields['no_print'] = value
1693
1827
  self
1694
1828
  end
1695
1829
 
1696
- # Disallow modification of the ouput PDF.
1830
+ # Disallow modification of the output PDF.
1697
1831
  #
1698
- # * +no_modify+ - Set to true to set the read-only only flag in the output PDF.
1832
+ # * +value+ - Set to true to set the read-only only flag in the output PDF.
1699
1833
  # * *Returns* - The converter object.
1700
- def setNoModify(no_modify)
1701
- @fields['no_modify'] = no_modify
1834
+ def setNoModify(value)
1835
+ @fields['no_modify'] = value
1702
1836
  self
1703
1837
  end
1704
1838
 
1705
1839
  # Disallow text and graphics extraction from the output PDF.
1706
1840
  #
1707
- # * +no_copy+ - Set to true to set the no-copy flag in the output PDF.
1841
+ # * +value+ - Set to true to set the no-copy flag in the output PDF.
1708
1842
  # * *Returns* - The converter object.
1709
- def setNoCopy(no_copy)
1710
- @fields['no_copy'] = no_copy
1843
+ def setNoCopy(value)
1844
+ @fields['no_copy'] = value
1711
1845
  self
1712
1846
  end
1713
1847
 
@@ -1749,138 +1883,214 @@ module Pdfcrowd
1749
1883
 
1750
1884
  # Specify the page layout to be used when the document is opened.
1751
1885
  #
1752
- # * +page_layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
1886
+ # * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
1753
1887
  # * *Returns* - The converter object.
1754
- def setPageLayout(page_layout)
1755
- unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(page_layout)
1756
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_layout, "page_layout", "html-to-pdf", "Allowed values are single-page, one-column, two-column-left, two-column-right.", "set_page_layout"), 470);
1888
+ def setPageLayout(layout)
1889
+ unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout)
1890
+ raise Error.new(Pdfcrowd.create_invalid_value_message(layout, "setPageLayout", "html-to-pdf", "Allowed values are single-page, one-column, two-column-left, two-column-right.", "set_page_layout"), 470);
1757
1891
  end
1758
1892
 
1759
- @fields['page_layout'] = page_layout
1893
+ @fields['page_layout'] = layout
1760
1894
  self
1761
1895
  end
1762
1896
 
1763
1897
  # Specify how the document should be displayed when opened.
1764
1898
  #
1765
- # * +page_mode+ - Allowed values are full-screen, thumbnails, outlines.
1899
+ # * +mode+ - Allowed values are full-screen, thumbnails, outlines.
1766
1900
  # * *Returns* - The converter object.
1767
- def setPageMode(page_mode)
1768
- unless /(?i)^(full-screen|thumbnails|outlines)$/.match(page_mode)
1769
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_mode, "page_mode", "html-to-pdf", "Allowed values are full-screen, thumbnails, outlines.", "set_page_mode"), 470);
1901
+ def setPageMode(mode)
1902
+ unless /(?i)^(full-screen|thumbnails|outlines)$/.match(mode)
1903
+ raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setPageMode", "html-to-pdf", "Allowed values are full-screen, thumbnails, outlines.", "set_page_mode"), 470);
1770
1904
  end
1771
1905
 
1772
- @fields['page_mode'] = page_mode
1906
+ @fields['page_mode'] = mode
1773
1907
  self
1774
1908
  end
1775
1909
 
1776
1910
  # Specify how the page should be displayed when opened.
1777
1911
  #
1778
- # * +initial_zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
1912
+ # * +zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
1779
1913
  # * *Returns* - The converter object.
1780
- def setInitialZoomType(initial_zoom_type)
1781
- unless /(?i)^(fit-width|fit-height|fit-page)$/.match(initial_zoom_type)
1782
- raise Error.new(Pdfcrowd.create_invalid_value_message(initial_zoom_type, "initial_zoom_type", "html-to-pdf", "Allowed values are fit-width, fit-height, fit-page.", "set_initial_zoom_type"), 470);
1914
+ def setInitialZoomType(zoom_type)
1915
+ unless /(?i)^(fit-width|fit-height|fit-page)$/.match(zoom_type)
1916
+ raise Error.new(Pdfcrowd.create_invalid_value_message(zoom_type, "setInitialZoomType", "html-to-pdf", "Allowed values are fit-width, fit-height, fit-page.", "set_initial_zoom_type"), 470);
1783
1917
  end
1784
1918
 
1785
- @fields['initial_zoom_type'] = initial_zoom_type
1919
+ @fields['initial_zoom_type'] = zoom_type
1786
1920
  self
1787
1921
  end
1788
1922
 
1789
1923
  # Display the specified page when the document is opened.
1790
1924
  #
1791
- # * +initial_page+ - Must be a positive integer number.
1925
+ # * +page+ - Must be a positive integer number.
1792
1926
  # * *Returns* - The converter object.
1793
- def setInitialPage(initial_page)
1794
- if (!(Integer(initial_page) > 0))
1795
- raise Error.new(Pdfcrowd.create_invalid_value_message(initial_page, "initial_page", "html-to-pdf", "Must be a positive integer number.", "set_initial_page"), 470);
1927
+ def setInitialPage(page)
1928
+ if (!(Integer(page) > 0))
1929
+ raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "html-to-pdf", "Must be a positive integer number.", "set_initial_page"), 470);
1796
1930
  end
1797
1931
 
1798
- @fields['initial_page'] = initial_page
1932
+ @fields['initial_page'] = page
1799
1933
  self
1800
1934
  end
1801
1935
 
1802
1936
  # Specify the initial page zoom in percents when the document is opened.
1803
1937
  #
1804
- # * +initial_zoom+ - Must be a positive integer number.
1938
+ # * +zoom+ - Must be a positive integer number.
1805
1939
  # * *Returns* - The converter object.
1806
- def setInitialZoom(initial_zoom)
1807
- if (!(Integer(initial_zoom) > 0))
1808
- raise Error.new(Pdfcrowd.create_invalid_value_message(initial_zoom, "initial_zoom", "html-to-pdf", "Must be a positive integer number.", "set_initial_zoom"), 470);
1940
+ def setInitialZoom(zoom)
1941
+ if (!(Integer(zoom) > 0))
1942
+ raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "html-to-pdf", "Must be a positive integer number.", "set_initial_zoom"), 470);
1809
1943
  end
1810
1944
 
1811
- @fields['initial_zoom'] = initial_zoom
1945
+ @fields['initial_zoom'] = zoom
1812
1946
  self
1813
1947
  end
1814
1948
 
1815
1949
  # Specify whether to hide the viewer application's tool bars when the document is active.
1816
1950
  #
1817
- # * +hide_toolbar+ - Set to true to hide tool bars.
1951
+ # * +value+ - Set to true to hide tool bars.
1818
1952
  # * *Returns* - The converter object.
1819
- def setHideToolbar(hide_toolbar)
1820
- @fields['hide_toolbar'] = hide_toolbar
1953
+ def setHideToolbar(value)
1954
+ @fields['hide_toolbar'] = value
1821
1955
  self
1822
1956
  end
1823
1957
 
1824
1958
  # Specify whether to hide the viewer application's menu bar when the document is active.
1825
1959
  #
1826
- # * +hide_menubar+ - Set to true to hide the menu bar.
1960
+ # * +value+ - Set to true to hide the menu bar.
1827
1961
  # * *Returns* - The converter object.
1828
- def setHideMenubar(hide_menubar)
1829
- @fields['hide_menubar'] = hide_menubar
1962
+ def setHideMenubar(value)
1963
+ @fields['hide_menubar'] = value
1830
1964
  self
1831
1965
  end
1832
1966
 
1833
1967
  # Specify 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.
1834
1968
  #
1835
- # * +hide_window_ui+ - Set to true to hide ui elements.
1969
+ # * +value+ - Set to true to hide ui elements.
1836
1970
  # * *Returns* - The converter object.
1837
- def setHideWindowUi(hide_window_ui)
1838
- @fields['hide_window_ui'] = hide_window_ui
1971
+ def setHideWindowUi(value)
1972
+ @fields['hide_window_ui'] = value
1839
1973
  self
1840
1974
  end
1841
1975
 
1842
1976
  # Specify whether to resize the document's window to fit the size of the first displayed page.
1843
1977
  #
1844
- # * +fit_window+ - Set to true to resize the window.
1978
+ # * +value+ - Set to true to resize the window.
1845
1979
  # * *Returns* - The converter object.
1846
- def setFitWindow(fit_window)
1847
- @fields['fit_window'] = fit_window
1980
+ def setFitWindow(value)
1981
+ @fields['fit_window'] = value
1848
1982
  self
1849
1983
  end
1850
1984
 
1851
1985
  # Specify whether to position the document's window in the center of the screen.
1852
1986
  #
1853
- # * +center_window+ - Set to true to center the window.
1987
+ # * +value+ - Set to true to center the window.
1854
1988
  # * *Returns* - The converter object.
1855
- def setCenterWindow(center_window)
1856
- @fields['center_window'] = center_window
1989
+ def setCenterWindow(value)
1990
+ @fields['center_window'] = value
1857
1991
  self
1858
1992
  end
1859
1993
 
1860
1994
  # Specify whether the window's title bar should display the document title. If false , the title bar should instead display the name of the PDF file containing the document.
1861
1995
  #
1862
- # * +display_title+ - Set to true to display the title.
1996
+ # * +value+ - Set to true to display the title.
1863
1997
  # * *Returns* - The converter object.
1864
- def setDisplayTitle(display_title)
1865
- @fields['display_title'] = display_title
1998
+ def setDisplayTitle(value)
1999
+ @fields['display_title'] = value
1866
2000
  self
1867
2001
  end
1868
2002
 
1869
2003
  # Set the predominant reading order for text to right-to-left. This option has no direct effect on the document's contents or page numbering but can be used to determine the relative positioning of pages when displayed side by side or printed n-up
1870
2004
  #
1871
- # * +right_to_left+ - Set to true to set right-to-left reading order.
2005
+ # * +value+ - Set to true to set right-to-left reading order.
2006
+ # * *Returns* - The converter object.
2007
+ def setRightToLeft(value)
2008
+ @fields['right_to_left'] = value
2009
+ self
2010
+ end
2011
+
2012
+ # Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
2013
+ #
2014
+ # * +data_string+ - The input data string.
2015
+ # * *Returns* - The converter object.
2016
+ def setDataString(data_string)
2017
+ @fields['data_string'] = data_string
2018
+ self
2019
+ end
2020
+
2021
+ # Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
2022
+ #
2023
+ # * +data_file+ - The file path to a local file containing the input data.
2024
+ # * *Returns* - The converter object.
2025
+ def setDataFile(data_file)
2026
+ @files['data_file'] = data_file
2027
+ self
2028
+ end
2029
+
2030
+ # Specify the input data format.
2031
+ #
2032
+ # * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
2033
+ # * *Returns* - The converter object.
2034
+ def setDataFormat(data_format)
2035
+ unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
2036
+ raise Error.new(Pdfcrowd.create_invalid_value_message(data_format, "setDataFormat", "html-to-pdf", "Allowed values are auto, json, xml, yaml, csv.", "set_data_format"), 470);
2037
+ end
2038
+
2039
+ @fields['data_format'] = data_format
2040
+ self
2041
+ end
2042
+
2043
+ # Set the encoding of the data file set by setDataFile.
2044
+ #
2045
+ # * +encoding+ - The data file encoding.
2046
+ # * *Returns* - The converter object.
2047
+ def setDataEncoding(encoding)
2048
+ @fields['data_encoding'] = encoding
2049
+ self
2050
+ end
2051
+
2052
+ # Ignore undefined variables in the HTML template. The default mode is strict so any undefined variable causes the conversion to fail. You can use {% if variable is defined %} to check if the variable is defined.
2053
+ #
2054
+ # * +value+ - Set to true to ignore undefined variables.
2055
+ # * *Returns* - The converter object.
2056
+ def setDataIgnoreUndefined(value)
2057
+ @fields['data_ignore_undefined'] = value
2058
+ self
2059
+ end
2060
+
2061
+ # Auto escape HTML symbols in the input data before placing them into the output.
2062
+ #
2063
+ # * +value+ - Set to true to turn auto escaping on.
2064
+ # * *Returns* - The converter object.
2065
+ def setDataAutoEscape(value)
2066
+ @fields['data_auto_escape'] = value
2067
+ self
2068
+ end
2069
+
2070
+ # Auto trim whitespace around each template command block.
2071
+ #
2072
+ # * +value+ - Set to true to turn auto trimming on.
2073
+ # * *Returns* - The converter object.
2074
+ def setDataTrimBlocks(value)
2075
+ @fields['data_trim_blocks'] = value
2076
+ self
2077
+ end
2078
+
2079
+ # Set the advanced data options:csv_delimiter - The CSV data delimiter, the default is ,.xml_remove_root - Remove the root XML element from the input data.data_root - The name of the root element inserted into the input data without a root node (e.g. CSV), the default is data.
2080
+ #
2081
+ # * +options+ - Comma separated list of options.
1872
2082
  # * *Returns* - The converter object.
1873
- def setRightToLeft(right_to_left)
1874
- @fields['right_to_left'] = right_to_left
2083
+ def setDataOptions(options)
2084
+ @fields['data_options'] = options
1875
2085
  self
1876
2086
  end
1877
2087
 
1878
2088
  # Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.
1879
2089
  #
1880
- # * +debug_log+ - Set to true to enable the debug logging.
2090
+ # * +value+ - Set to true to enable the debug logging.
1881
2091
  # * *Returns* - The converter object.
1882
- def setDebugLog(debug_log)
1883
- @fields['debug_log'] = debug_log
2092
+ def setDebugLog(value)
2093
+ @fields['debug_log'] = value
1884
2094
  self
1885
2095
  end
1886
2096
 
@@ -1923,6 +2133,12 @@ module Pdfcrowd
1923
2133
  return @helper.getOutputSize()
1924
2134
  end
1925
2135
 
2136
+ # Get the version details.
2137
+ # * *Returns* - API version, converter version, and client version.
2138
+ def getVersion()
2139
+ return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
2140
+ end
2141
+
1926
2142
  # Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
1927
2143
  #
1928
2144
  # * +tag+ - A string with the custom tag.
@@ -1932,69 +2148,151 @@ module Pdfcrowd
1932
2148
  self
1933
2149
  end
1934
2150
 
1935
- # A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTP scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
2151
+ # A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTP scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
2152
+ #
2153
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2154
+ # * *Returns* - The converter object.
2155
+ def setHttpProxy(proxy)
2156
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
2157
+ raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "html-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
2158
+ end
2159
+
2160
+ @fields['http_proxy'] = proxy
2161
+ self
2162
+ end
2163
+
2164
+ # A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTPS scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
2165
+ #
2166
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2167
+ # * *Returns* - The converter object.
2168
+ def setHttpsProxy(proxy)
2169
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
2170
+ raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "html-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
2171
+ end
2172
+
2173
+ @fields['https_proxy'] = proxy
2174
+ self
2175
+ end
2176
+
2177
+ # A client certificate to authenticate Pdfcrowd converter on your web server. The certificate is used for two-way SSL/TLS authentication and adds extra security.
2178
+ #
2179
+ # * +certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
2180
+ # * *Returns* - The converter object.
2181
+ def setClientCertificate(certificate)
2182
+ if (!(File.file?(certificate) && !File.zero?(certificate)))
2183
+ raise Error.new(Pdfcrowd.create_invalid_value_message(certificate, "setClientCertificate", "html-to-pdf", "The file must exist and not be empty.", "set_client_certificate"), 470);
2184
+ end
2185
+
2186
+ @files['client_certificate'] = certificate
2187
+ self
2188
+ end
2189
+
2190
+ # A password for PKCS12 file with a client certificate if it is needed.
2191
+ #
2192
+ # * +password+ -
2193
+ # * *Returns* - The converter object.
2194
+ def setClientCertificatePassword(password)
2195
+ @fields['client_certificate_password'] = password
2196
+ self
2197
+ end
2198
+
2199
+ # Set the internal DPI resolution used for positioning of PDF contents. It can help in situations when there are small inaccuracies in the PDF. It is recommended to use values that are a multiple of 72, such as 288 or 360.
2200
+ #
2201
+ # * +dpi+ - The DPI value. The value must be in the range of 72-600.
2202
+ # * *Returns* - The converter object.
2203
+ def setLayoutDpi(dpi)
2204
+ if (!(Integer(dpi) >= 72 && Integer(dpi) <= 600))
2205
+ raise Error.new(Pdfcrowd.create_invalid_value_message(dpi, "setLayoutDpi", "html-to-pdf", "The value must be in the range of 72-600.", "set_layout_dpi"), 470);
2206
+ end
2207
+
2208
+ @fields['layout_dpi'] = dpi
2209
+ self
2210
+ end
2211
+
2212
+ # A 2D transformation matrix applied to the main contents on each page. The origin [0,0] is located at the top-left corner of the contents. The resolution is 72 dpi.
2213
+ #
2214
+ # * +matrix+ - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"
2215
+ # * *Returns* - The converter object.
2216
+ def setContentsMatrix(matrix)
2217
+ @fields['contents_matrix'] = matrix
2218
+ self
2219
+ end
2220
+
2221
+ # A 2D transformation matrix applied to the page header contents. The origin [0,0] is located at the top-left corner of the header. The resolution is 72 dpi.
2222
+ #
2223
+ # * +matrix+ - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"
2224
+ # * *Returns* - The converter object.
2225
+ def setHeaderMatrix(matrix)
2226
+ @fields['header_matrix'] = matrix
2227
+ self
2228
+ end
2229
+
2230
+ # A 2D transformation matrix applied to the page footer contents. The origin [0,0] is located at the top-left corner of the footer. The resolution is 72 dpi.
2231
+ #
2232
+ # * +matrix+ - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"
2233
+ # * *Returns* - The converter object.
2234
+ def setFooterMatrix(matrix)
2235
+ @fields['footer_matrix'] = matrix
2236
+ self
2237
+ end
2238
+
2239
+ # Disable automatic height adjustment that compensates for pixel to point rounding errors.
1936
2240
  #
1937
- # * +http_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2241
+ # * +value+ - Set to true to disable automatic height scale.
1938
2242
  # * *Returns* - The converter object.
1939
- def setHttpProxy(http_proxy)
1940
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(http_proxy)
1941
- raise Error.new(Pdfcrowd.create_invalid_value_message(http_proxy, "http_proxy", "html-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
1942
- end
1943
-
1944
- @fields['http_proxy'] = http_proxy
2243
+ def setDisablePageHeightOptimization(value)
2244
+ @fields['disable_page_height_optimization'] = value
1945
2245
  self
1946
2246
  end
1947
2247
 
1948
- # A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTPS scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
2248
+ # Add special CSS classes to the main document's body element. This allows applying custom styling based on these classes: pdfcrowd-page-X - where X is the current page number pdfcrowd-page-odd - odd page pdfcrowd-page-even - even page
2249
+ # Warning: If your custom styling affects the contents area size (e.g. by using different margins, padding, border width), the resulting PDF may contain duplicit contents or some contents may be missing.
1949
2250
  #
1950
- # * +https_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2251
+ # * +value+ - Set to true to add the special CSS classes.
1951
2252
  # * *Returns* - The converter object.
1952
- def setHttpsProxy(https_proxy)
1953
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(https_proxy)
1954
- raise Error.new(Pdfcrowd.create_invalid_value_message(https_proxy, "https_proxy", "html-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
1955
- end
1956
-
1957
- @fields['https_proxy'] = https_proxy
2253
+ def setMainDocumentCssAnnotation(value)
2254
+ @fields['main_document_css_annotation'] = value
1958
2255
  self
1959
2256
  end
1960
2257
 
1961
- # A client certificate to authenticate Pdfcrowd converter on your web server. The certificate is used for two-way SSL/TLS authentication and adds extra security.
2258
+ # Add special CSS classes to the header/footer's body element. This allows applying custom styling based on these classes: pdfcrowd-page-X - where X is the current page number pdfcrowd-page-count-X - where X is the total page count pdfcrowd-page-first - the first page pdfcrowd-page-last - the last page pdfcrowd-page-odd - odd page pdfcrowd-page-even - even page
1962
2259
  #
1963
- # * +client_certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
2260
+ # * +value+ - Set to true to add the special CSS classes.
1964
2261
  # * *Returns* - The converter object.
1965
- def setClientCertificate(client_certificate)
1966
- if (!(File.file?(client_certificate) && !File.zero?(client_certificate)))
1967
- raise Error.new(Pdfcrowd.create_invalid_value_message(client_certificate, "client_certificate", "html-to-pdf", "The file must exist and not be empty.", "set_client_certificate"), 470);
1968
- end
1969
-
1970
- @files['client_certificate'] = client_certificate
2262
+ def setHeaderFooterCssAnnotation(value)
2263
+ @fields['header_footer_css_annotation'] = value
1971
2264
  self
1972
2265
  end
1973
2266
 
1974
- # A password for PKCS12 file with a client certificate if it is needed.
2267
+ # Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
1975
2268
  #
1976
- # * +client_certificate_password+ -
2269
+ # * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
1977
2270
  # * *Returns* - The converter object.
1978
- def setClientCertificatePassword(client_certificate_password)
1979
- @fields['client_certificate_password'] = client_certificate_password
2271
+ def setConverterVersion(version)
2272
+ unless /(?i)^(latest|20.10|18.10)$/.match(version)
2273
+ raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "html-to-pdf", "Allowed values are latest, 20.10, 18.10.", "set_converter_version"), 470);
2274
+ end
2275
+
2276
+ @helper.setConverterVersion(version)
1980
2277
  self
1981
2278
  end
1982
2279
 
1983
2280
  # Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
2281
+ # Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
1984
2282
  #
1985
- # * +use_http+ - Set to true to use HTTP.
2283
+ # * +value+ - Set to true to use HTTP.
1986
2284
  # * *Returns* - The converter object.
1987
- def setUseHttp(use_http)
1988
- @helper.setUseHttp(use_http)
2285
+ def setUseHttp(value)
2286
+ @helper.setUseHttp(value)
1989
2287
  self
1990
2288
  end
1991
2289
 
1992
- # Set a custom user agent HTTP header. It can be usefull if you are behind some proxy or firewall.
2290
+ # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
1993
2291
  #
1994
- # * +user_agent+ - The user agent string.
2292
+ # * +agent+ - The user agent string.
1995
2293
  # * *Returns* - The converter object.
1996
- def setUserAgent(user_agent)
1997
- @helper.setUserAgent(user_agent)
2294
+ def setUserAgent(agent)
2295
+ @helper.setUserAgent(agent)
1998
2296
  self
1999
2297
  end
2000
2298
 
@@ -2012,10 +2310,10 @@ module Pdfcrowd
2012
2310
 
2013
2311
  # Specifies the number of retries when the 502 HTTP status code is received. The 502 status code indicates a temporary network issue. This feature can be disabled by setting to 0.
2014
2312
  #
2015
- # * +retry_count+ - Number of retries wanted.
2313
+ # * +count+ - Number of retries wanted.
2016
2314
  # * *Returns* - The converter object.
2017
- def setRetryCount(retry_count)
2018
- @helper.setRetryCount(retry_count)
2315
+ def setRetryCount(count)
2316
+ @helper.setRetryCount(count)
2019
2317
  self
2020
2318
  end
2021
2319
 
@@ -2044,7 +2342,7 @@ module Pdfcrowd
2044
2342
  # * *Returns* - The converter object.
2045
2343
  def setOutputFormat(output_format)
2046
2344
  unless /(?i)^(png|jpg|gif|tiff|bmp|ico|ppm|pgm|pbm|pnm|psb|pct|ras|tga|sgi|sun|webp)$/.match(output_format)
2047
- raise Error.new(Pdfcrowd.create_invalid_value_message(output_format, "output_format", "html-to-image", "Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.", "set_output_format"), 470);
2345
+ raise Error.new(Pdfcrowd.create_invalid_value_message(output_format, "setOutputFormat", "html-to-image", "Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.", "set_output_format"), 470);
2048
2346
  end
2049
2347
 
2050
2348
  @fields['output_format'] = output_format
@@ -2057,7 +2355,7 @@ module Pdfcrowd
2057
2355
  # * *Returns* - Byte array containing the conversion output.
2058
2356
  def convertUrl(url)
2059
2357
  unless /(?i)^https?:\/\/.*$/.match(url)
2060
- raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "html-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
2358
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "html-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
2061
2359
  end
2062
2360
 
2063
2361
  @fields['url'] = url
@@ -2070,7 +2368,7 @@ module Pdfcrowd
2070
2368
  # * +out_stream+ - The output stream that will contain the conversion output.
2071
2369
  def convertUrlToStream(url, out_stream)
2072
2370
  unless /(?i)^https?:\/\/.*$/.match(url)
2073
- raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "html-to-image", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
2371
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "html-to-image", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
2074
2372
  end
2075
2373
 
2076
2374
  @fields['url'] = url
@@ -2083,7 +2381,7 @@ module Pdfcrowd
2083
2381
  # * +file_path+ - The output file path. The string must not be empty.
2084
2382
  def convertUrlToFile(url, file_path)
2085
2383
  if (!(!file_path.nil? && !file_path.empty?))
2086
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-image", "The string must not be empty.", "convert_url_to_file"), 470);
2384
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "html-to-image", "The string must not be empty.", "convert_url_to_file"), 470);
2087
2385
  end
2088
2386
 
2089
2387
  output_file = open(file_path, "wb")
@@ -2103,7 +2401,7 @@ module Pdfcrowd
2103
2401
  # * *Returns* - Byte array containing the conversion output.
2104
2402
  def convertFile(file)
2105
2403
  if (!(File.file?(file) && !File.zero?(file)))
2106
- raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-image", "The file must exist and not be empty.", "convert_file"), 470);
2404
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "html-to-image", "The file must exist and not be empty.", "convert_file"), 470);
2107
2405
  end
2108
2406
 
2109
2407
  @files['file'] = file
@@ -2116,7 +2414,7 @@ module Pdfcrowd
2116
2414
  # * +out_stream+ - The output stream that will contain the conversion output.
2117
2415
  def convertFileToStream(file, out_stream)
2118
2416
  if (!(File.file?(file) && !File.zero?(file)))
2119
- raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-image", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
2417
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "html-to-image", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
2120
2418
  end
2121
2419
 
2122
2420
  @files['file'] = file
@@ -2129,7 +2427,7 @@ module Pdfcrowd
2129
2427
  # * +file_path+ - The output file path. The string must not be empty.
2130
2428
  def convertFileToFile(file, file_path)
2131
2429
  if (!(!file_path.nil? && !file_path.empty?))
2132
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-image", "The string must not be empty.", "convert_file_to_file"), 470);
2430
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "html-to-image", "The string must not be empty.", "convert_file_to_file"), 470);
2133
2431
  end
2134
2432
 
2135
2433
  output_file = open(file_path, "wb")
@@ -2149,7 +2447,7 @@ module Pdfcrowd
2149
2447
  # * *Returns* - Byte array containing the conversion output.
2150
2448
  def convertString(text)
2151
2449
  if (!(!text.nil? && !text.empty?))
2152
- raise Error.new(Pdfcrowd.create_invalid_value_message(text, "text", "html-to-image", "The string must not be empty.", "convert_string"), 470);
2450
+ raise Error.new(Pdfcrowd.create_invalid_value_message(text, "convertString", "html-to-image", "The string must not be empty.", "convert_string"), 470);
2153
2451
  end
2154
2452
 
2155
2453
  @fields['text'] = text
@@ -2162,7 +2460,7 @@ module Pdfcrowd
2162
2460
  # * +out_stream+ - The output stream that will contain the conversion output.
2163
2461
  def convertStringToStream(text, out_stream)
2164
2462
  if (!(!text.nil? && !text.empty?))
2165
- raise Error.new(Pdfcrowd.create_invalid_value_message(text, "text", "html-to-image", "The string must not be empty.", "convert_string_to_stream"), 470);
2463
+ raise Error.new(Pdfcrowd.create_invalid_value_message(text, "convertStringToStream::text", "html-to-image", "The string must not be empty.", "convert_string_to_stream"), 470);
2166
2464
  end
2167
2465
 
2168
2466
  @fields['text'] = text
@@ -2175,7 +2473,7 @@ module Pdfcrowd
2175
2473
  # * +file_path+ - The output file path. The string must not be empty.
2176
2474
  def convertStringToFile(text, file_path)
2177
2475
  if (!(!file_path.nil? && !file_path.empty?))
2178
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-image", "The string must not be empty.", "convert_string_to_file"), 470);
2476
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStringToFile::file_path", "html-to-image", "The string must not be empty.", "convert_string_to_file"), 470);
2179
2477
  end
2180
2478
 
2181
2479
  output_file = open(file_path, "wb")
@@ -2189,57 +2487,126 @@ module Pdfcrowd
2189
2487
  end
2190
2488
  end
2191
2489
 
2490
+ # Convert the contents of an input stream.
2491
+ #
2492
+ # * +in_stream+ - The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript).
2493
+ # * *Returns* - Byte array containing the conversion output.
2494
+ def convertStream(in_stream)
2495
+ @raw_data['stream'] = in_stream.read
2496
+ @helper.post(@fields, @files, @raw_data)
2497
+ end
2498
+
2499
+ # Convert the contents of an input stream and write the result to an output stream.
2500
+ #
2501
+ # * +in_stream+ - The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript).
2502
+ # * +out_stream+ - The output stream that will contain the conversion output.
2503
+ def convertStreamToStream(in_stream, out_stream)
2504
+ @raw_data['stream'] = in_stream.read
2505
+ @helper.post(@fields, @files, @raw_data, out_stream)
2506
+ end
2507
+
2508
+ # Convert the contents of an input stream and write the result to a local file.
2509
+ #
2510
+ # * +in_stream+ - The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript).
2511
+ # * +file_path+ - The output file path. The string must not be empty.
2512
+ def convertStreamToFile(in_stream, file_path)
2513
+ if (!(!file_path.nil? && !file_path.empty?))
2514
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "html-to-image", "The string must not be empty.", "convert_stream_to_file"), 470);
2515
+ end
2516
+
2517
+ output_file = open(file_path, "wb")
2518
+ begin
2519
+ convertStreamToStream(in_stream, output_file)
2520
+ output_file.close()
2521
+ rescue Error => why
2522
+ output_file.close()
2523
+ FileUtils.rm(file_path)
2524
+ raise
2525
+ end
2526
+ end
2527
+
2528
+ # Use the print version of the page if available (@media print).
2529
+ #
2530
+ # * +value+ - Set to true to use the print version of the page.
2531
+ # * *Returns* - The converter object.
2532
+ def setUsePrintMedia(value)
2533
+ @fields['use_print_media'] = value
2534
+ self
2535
+ end
2536
+
2192
2537
  # Do not print the background graphics.
2193
2538
  #
2194
- # * +no_background+ - Set to true to disable the background graphics.
2539
+ # * +value+ - Set to true to disable the background graphics.
2195
2540
  # * *Returns* - The converter object.
2196
- def setNoBackground(no_background)
2197
- @fields['no_background'] = no_background
2541
+ def setNoBackground(value)
2542
+ @fields['no_background'] = value
2198
2543
  self
2199
2544
  end
2200
2545
 
2201
2546
  # Do not execute JavaScript.
2202
2547
  #
2203
- # * +disable_javascript+ - Set to true to disable JavaScript in web pages.
2548
+ # * +value+ - Set to true to disable JavaScript in web pages.
2204
2549
  # * *Returns* - The converter object.
2205
- def setDisableJavascript(disable_javascript)
2206
- @fields['disable_javascript'] = disable_javascript
2550
+ def setDisableJavascript(value)
2551
+ @fields['disable_javascript'] = value
2207
2552
  self
2208
2553
  end
2209
2554
 
2210
2555
  # Do not load images.
2211
2556
  #
2212
- # * +disable_image_loading+ - Set to true to disable loading of images.
2557
+ # * +value+ - Set to true to disable loading of images.
2213
2558
  # * *Returns* - The converter object.
2214
- def setDisableImageLoading(disable_image_loading)
2215
- @fields['disable_image_loading'] = disable_image_loading
2559
+ def setDisableImageLoading(value)
2560
+ @fields['disable_image_loading'] = value
2216
2561
  self
2217
2562
  end
2218
2563
 
2219
2564
  # Disable loading fonts from remote sources.
2220
2565
  #
2221
- # * +disable_remote_fonts+ - Set to true disable loading remote fonts.
2566
+ # * +value+ - Set to true disable loading remote fonts.
2567
+ # * *Returns* - The converter object.
2568
+ def setDisableRemoteFonts(value)
2569
+ @fields['disable_remote_fonts'] = value
2570
+ self
2571
+ end
2572
+
2573
+ # Specifies how iframes are handled.
2574
+ #
2575
+ # * +iframes+ - Allowed values are all, same-origin, none.
2222
2576
  # * *Returns* - The converter object.
2223
- def setDisableRemoteFonts(disable_remote_fonts)
2224
- @fields['disable_remote_fonts'] = disable_remote_fonts
2577
+ def setLoadIframes(iframes)
2578
+ unless /(?i)^(all|same-origin|none)$/.match(iframes)
2579
+ raise Error.new(Pdfcrowd.create_invalid_value_message(iframes, "setLoadIframes", "html-to-image", "Allowed values are all, same-origin, none.", "set_load_iframes"), 470);
2580
+ end
2581
+
2582
+ @fields['load_iframes'] = iframes
2225
2583
  self
2226
2584
  end
2227
2585
 
2228
2586
  # Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
2229
2587
  #
2230
- # * +block_ads+ - Set to true to block ads in web pages.
2588
+ # * +value+ - Set to true to block ads in web pages.
2231
2589
  # * *Returns* - The converter object.
2232
- def setBlockAds(block_ads)
2233
- @fields['block_ads'] = block_ads
2590
+ def setBlockAds(value)
2591
+ @fields['block_ads'] = value
2234
2592
  self
2235
2593
  end
2236
2594
 
2237
2595
  # Set the default HTML content text encoding.
2238
2596
  #
2239
- # * +default_encoding+ - The text encoding of the HTML content.
2597
+ # * +encoding+ - The text encoding of the HTML content.
2598
+ # * *Returns* - The converter object.
2599
+ def setDefaultEncoding(encoding)
2600
+ @fields['default_encoding'] = encoding
2601
+ self
2602
+ end
2603
+
2604
+ # Set the locale for the conversion. This may affect the output format of dates, times and numbers.
2605
+ #
2606
+ # * +locale+ - The locale code according to ISO 639.
2240
2607
  # * *Returns* - The converter object.
2241
- def setDefaultEncoding(default_encoding)
2242
- @fields['default_encoding'] = default_encoding
2608
+ def setLocale(locale)
2609
+ @fields['locale'] = locale
2243
2610
  self
2244
2611
  end
2245
2612
 
@@ -2272,24 +2639,6 @@ module Pdfcrowd
2272
2639
  self
2273
2640
  end
2274
2641
 
2275
- # Use the print version of the page if available (@media print).
2276
- #
2277
- # * +use_print_media+ - Set to true to use the print version of the page.
2278
- # * *Returns* - The converter object.
2279
- def setUsePrintMedia(use_print_media)
2280
- @fields['use_print_media'] = use_print_media
2281
- self
2282
- end
2283
-
2284
- # Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
2285
- #
2286
- # * +no_xpdfcrowd_header+ - Set to true to disable sending X-Pdfcrowd HTTP header.
2287
- # * *Returns* - The converter object.
2288
- def setNoXpdfcrowdHeader(no_xpdfcrowd_header)
2289
- @fields['no_xpdfcrowd_header'] = no_xpdfcrowd_header
2290
- self
2291
- end
2292
-
2293
2642
  # Set cookies that are sent in Pdfcrowd HTTP requests.
2294
2643
  #
2295
2644
  # * +cookies+ - The cookie string.
@@ -2301,10 +2650,10 @@ module Pdfcrowd
2301
2650
 
2302
2651
  # Do not allow insecure HTTPS connections.
2303
2652
  #
2304
- # * +verify_ssl_certificates+ - Set to true to enable SSL certificate verification.
2653
+ # * +value+ - Set to true to enable SSL certificate verification.
2305
2654
  # * *Returns* - The converter object.
2306
- def setVerifySslCertificates(verify_ssl_certificates)
2307
- @fields['verify_ssl_certificates'] = verify_ssl_certificates
2655
+ def setVerifySslCertificates(value)
2656
+ @fields['verify_ssl_certificates'] = value
2308
2657
  self
2309
2658
  end
2310
2659
 
@@ -2326,55 +2675,64 @@ module Pdfcrowd
2326
2675
  self
2327
2676
  end
2328
2677
 
2678
+ # Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
2679
+ #
2680
+ # * +value+ - Set to true to disable sending X-Pdfcrowd HTTP header.
2681
+ # * *Returns* - The converter object.
2682
+ def setNoXpdfcrowdHeader(value)
2683
+ @fields['no_xpdfcrowd_header'] = value
2684
+ self
2685
+ end
2686
+
2329
2687
  # Run a custom JavaScript after the document is loaded and ready to print. The script is intended for post-load DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
2330
2688
  #
2331
- # * +custom_javascript+ - A string containing a JavaScript code. The string must not be empty.
2689
+ # * +javascript+ - A string containing a JavaScript code. The string must not be empty.
2332
2690
  # * *Returns* - The converter object.
2333
- def setCustomJavascript(custom_javascript)
2334
- if (!(!custom_javascript.nil? && !custom_javascript.empty?))
2335
- raise Error.new(Pdfcrowd.create_invalid_value_message(custom_javascript, "custom_javascript", "html-to-image", "The string must not be empty.", "set_custom_javascript"), 470);
2691
+ def setCustomJavascript(javascript)
2692
+ if (!(!javascript.nil? && !javascript.empty?))
2693
+ raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setCustomJavascript", "html-to-image", "The string must not be empty.", "set_custom_javascript"), 470);
2336
2694
  end
2337
2695
 
2338
- @fields['custom_javascript'] = custom_javascript
2696
+ @fields['custom_javascript'] = javascript
2339
2697
  self
2340
2698
  end
2341
2699
 
2342
2700
  # Run a custom JavaScript right after the document is loaded. The script is intended for early DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
2343
2701
  #
2344
- # * +on_load_javascript+ - A string containing a JavaScript code. The string must not be empty.
2702
+ # * +javascript+ - A string containing a JavaScript code. The string must not be empty.
2345
2703
  # * *Returns* - The converter object.
2346
- def setOnLoadJavascript(on_load_javascript)
2347
- if (!(!on_load_javascript.nil? && !on_load_javascript.empty?))
2348
- raise Error.new(Pdfcrowd.create_invalid_value_message(on_load_javascript, "on_load_javascript", "html-to-image", "The string must not be empty.", "set_on_load_javascript"), 470);
2704
+ def setOnLoadJavascript(javascript)
2705
+ if (!(!javascript.nil? && !javascript.empty?))
2706
+ raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setOnLoadJavascript", "html-to-image", "The string must not be empty.", "set_on_load_javascript"), 470);
2349
2707
  end
2350
2708
 
2351
- @fields['on_load_javascript'] = on_load_javascript
2709
+ @fields['on_load_javascript'] = javascript
2352
2710
  self
2353
2711
  end
2354
2712
 
2355
2713
  # Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
2356
2714
  #
2357
- # * +custom_http_header+ - A string containing the header name and value separated by a colon.
2715
+ # * +header+ - A string containing the header name and value separated by a colon.
2358
2716
  # * *Returns* - The converter object.
2359
- def setCustomHttpHeader(custom_http_header)
2360
- unless /^.+:.+$/.match(custom_http_header)
2361
- raise Error.new(Pdfcrowd.create_invalid_value_message(custom_http_header, "custom_http_header", "html-to-image", "A string containing the header name and value separated by a colon.", "set_custom_http_header"), 470);
2717
+ def setCustomHttpHeader(header)
2718
+ unless /^.+:.+$/.match(header)
2719
+ raise Error.new(Pdfcrowd.create_invalid_value_message(header, "setCustomHttpHeader", "html-to-image", "A string containing the header name and value separated by a colon.", "set_custom_http_header"), 470);
2362
2720
  end
2363
2721
 
2364
- @fields['custom_http_header'] = custom_http_header
2722
+ @fields['custom_http_header'] = header
2365
2723
  self
2366
2724
  end
2367
2725
 
2368
- # Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. The maximum value is determined by your API license.
2726
+ # Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. Your API license defines the maximum wait time by "Max Delay" parameter.
2369
2727
  #
2370
- # * +javascript_delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
2728
+ # * +delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
2371
2729
  # * *Returns* - The converter object.
2372
- def setJavascriptDelay(javascript_delay)
2373
- if (!(Integer(javascript_delay) >= 0))
2374
- raise Error.new(Pdfcrowd.create_invalid_value_message(javascript_delay, "javascript_delay", "html-to-image", "Must be a positive integer number or 0.", "set_javascript_delay"), 470);
2730
+ def setJavascriptDelay(delay)
2731
+ if (!(Integer(delay) >= 0))
2732
+ raise Error.new(Pdfcrowd.create_invalid_value_message(delay, "setJavascriptDelay", "html-to-image", "Must be a positive integer number or 0.", "set_javascript_delay"), 470);
2375
2733
  end
2376
2734
 
2377
- @fields['javascript_delay'] = javascript_delay
2735
+ @fields['javascript_delay'] = delay
2378
2736
  self
2379
2737
  end
2380
2738
 
@@ -2384,7 +2742,7 @@ module Pdfcrowd
2384
2742
  # * *Returns* - The converter object.
2385
2743
  def setElementToConvert(selectors)
2386
2744
  if (!(!selectors.nil? && !selectors.empty?))
2387
- raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "selectors", "html-to-image", "The string must not be empty.", "set_element_to_convert"), 470);
2745
+ raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setElementToConvert", "html-to-image", "The string must not be empty.", "set_element_to_convert"), 470);
2388
2746
  end
2389
2747
 
2390
2748
  @fields['element_to_convert'] = selectors
@@ -2397,7 +2755,7 @@ module Pdfcrowd
2397
2755
  # * *Returns* - The converter object.
2398
2756
  def setElementToConvertMode(mode)
2399
2757
  unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode)
2400
- raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "mode", "html-to-image", "Allowed values are cut-out, remove-siblings, hide-siblings.", "set_element_to_convert_mode"), 470);
2758
+ raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setElementToConvertMode", "html-to-image", "Allowed values are cut-out, remove-siblings, hide-siblings.", "set_element_to_convert_mode"), 470);
2401
2759
  end
2402
2760
 
2403
2761
  @fields['element_to_convert_mode'] = mode
@@ -2410,7 +2768,7 @@ module Pdfcrowd
2410
2768
  # * *Returns* - The converter object.
2411
2769
  def setWaitForElement(selectors)
2412
2770
  if (!(!selectors.nil? && !selectors.empty?))
2413
- raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "selectors", "html-to-image", "The string must not be empty.", "set_wait_for_element"), 470);
2771
+ raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setWaitForElement", "html-to-image", "The string must not be empty.", "set_wait_for_element"), 470);
2414
2772
  end
2415
2773
 
2416
2774
  @fields['wait_for_element'] = selectors
@@ -2419,49 +2777,138 @@ module Pdfcrowd
2419
2777
 
2420
2778
  # Set the output image width in pixels.
2421
2779
  #
2422
- # * +screenshot_width+ - The value must be in the range 96-65000.
2780
+ # * +width+ - The value must be in the range 96-65000.
2423
2781
  # * *Returns* - The converter object.
2424
- def setScreenshotWidth(screenshot_width)
2425
- if (!(Integer(screenshot_width) >= 96 && Integer(screenshot_width) <= 65000))
2426
- raise Error.new(Pdfcrowd.create_invalid_value_message(screenshot_width, "screenshot_width", "html-to-image", "The value must be in the range 96-65000.", "set_screenshot_width"), 470);
2782
+ def setScreenshotWidth(width)
2783
+ if (!(Integer(width) >= 96 && Integer(width) <= 65000))
2784
+ raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setScreenshotWidth", "html-to-image", "The value must be in the range 96-65000.", "set_screenshot_width"), 470);
2427
2785
  end
2428
2786
 
2429
- @fields['screenshot_width'] = screenshot_width
2787
+ @fields['screenshot_width'] = width
2430
2788
  self
2431
2789
  end
2432
2790
 
2433
2791
  # Set the output image height in pixels. If it is not specified, actual document height is used.
2434
2792
  #
2435
- # * +screenshot_height+ - Must be a positive integer number.
2793
+ # * +height+ - Must be a positive integer number.
2436
2794
  # * *Returns* - The converter object.
2437
- def setScreenshotHeight(screenshot_height)
2438
- if (!(Integer(screenshot_height) > 0))
2439
- raise Error.new(Pdfcrowd.create_invalid_value_message(screenshot_height, "screenshot_height", "html-to-image", "Must be a positive integer number.", "set_screenshot_height"), 470);
2795
+ def setScreenshotHeight(height)
2796
+ if (!(Integer(height) > 0))
2797
+ raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setScreenshotHeight", "html-to-image", "Must be a positive integer number.", "set_screenshot_height"), 470);
2440
2798
  end
2441
2799
 
2442
- @fields['screenshot_height'] = screenshot_height
2800
+ @fields['screenshot_height'] = height
2443
2801
  self
2444
2802
  end
2445
2803
 
2446
2804
  # Set the scaling factor (zoom) for the output image.
2447
2805
  #
2448
- # * +scale_factor+ - The percentage value. Must be a positive integer number.
2806
+ # * +factor+ - The percentage value. Must be a positive integer number.
2807
+ # * *Returns* - The converter object.
2808
+ def setScaleFactor(factor)
2809
+ if (!(Integer(factor) > 0))
2810
+ raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "html-to-image", "Must be a positive integer number.", "set_scale_factor"), 470);
2811
+ end
2812
+
2813
+ @fields['scale_factor'] = factor
2814
+ self
2815
+ end
2816
+
2817
+ # The output image background color.
2818
+ #
2819
+ # * +color+ - The value must be in RRGGBB or RRGGBBAA hexadecimal format.
2820
+ # * *Returns* - The converter object.
2821
+ def setBackgroundColor(color)
2822
+ unless /^[0-9a-fA-F]{6,8}$/.match(color)
2823
+ raise Error.new(Pdfcrowd.create_invalid_value_message(color, "setBackgroundColor", "html-to-image", "The value must be in RRGGBB or RRGGBBAA hexadecimal format.", "set_background_color"), 470);
2824
+ end
2825
+
2826
+ @fields['background_color'] = color
2827
+ self
2828
+ end
2829
+
2830
+ # Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
2831
+ #
2832
+ # * +data_string+ - The input data string.
2833
+ # * *Returns* - The converter object.
2834
+ def setDataString(data_string)
2835
+ @fields['data_string'] = data_string
2836
+ self
2837
+ end
2838
+
2839
+ # Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
2840
+ #
2841
+ # * +data_file+ - The file path to a local file containing the input data.
2449
2842
  # * *Returns* - The converter object.
2450
- def setScaleFactor(scale_factor)
2451
- if (!(Integer(scale_factor) > 0))
2452
- raise Error.new(Pdfcrowd.create_invalid_value_message(scale_factor, "scale_factor", "html-to-image", "Must be a positive integer number.", "set_scale_factor"), 470);
2843
+ def setDataFile(data_file)
2844
+ @files['data_file'] = data_file
2845
+ self
2846
+ end
2847
+
2848
+ # Specify the input data format.
2849
+ #
2850
+ # * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
2851
+ # * *Returns* - The converter object.
2852
+ def setDataFormat(data_format)
2853
+ unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
2854
+ raise Error.new(Pdfcrowd.create_invalid_value_message(data_format, "setDataFormat", "html-to-image", "Allowed values are auto, json, xml, yaml, csv.", "set_data_format"), 470);
2453
2855
  end
2454
2856
 
2455
- @fields['scale_factor'] = scale_factor
2857
+ @fields['data_format'] = data_format
2858
+ self
2859
+ end
2860
+
2861
+ # Set the encoding of the data file set by setDataFile.
2862
+ #
2863
+ # * +encoding+ - The data file encoding.
2864
+ # * *Returns* - The converter object.
2865
+ def setDataEncoding(encoding)
2866
+ @fields['data_encoding'] = encoding
2867
+ self
2868
+ end
2869
+
2870
+ # Ignore undefined variables in the HTML template. The default mode is strict so any undefined variable causes the conversion to fail. You can use {% if variable is defined %} to check if the variable is defined.
2871
+ #
2872
+ # * +value+ - Set to true to ignore undefined variables.
2873
+ # * *Returns* - The converter object.
2874
+ def setDataIgnoreUndefined(value)
2875
+ @fields['data_ignore_undefined'] = value
2876
+ self
2877
+ end
2878
+
2879
+ # Auto escape HTML symbols in the input data before placing them into the output.
2880
+ #
2881
+ # * +value+ - Set to true to turn auto escaping on.
2882
+ # * *Returns* - The converter object.
2883
+ def setDataAutoEscape(value)
2884
+ @fields['data_auto_escape'] = value
2885
+ self
2886
+ end
2887
+
2888
+ # Auto trim whitespace around each template command block.
2889
+ #
2890
+ # * +value+ - Set to true to turn auto trimming on.
2891
+ # * *Returns* - The converter object.
2892
+ def setDataTrimBlocks(value)
2893
+ @fields['data_trim_blocks'] = value
2894
+ self
2895
+ end
2896
+
2897
+ # Set the advanced data options:csv_delimiter - The CSV data delimiter, the default is ,.xml_remove_root - Remove the root XML element from the input data.data_root - The name of the root element inserted into the input data without a root node (e.g. CSV), the default is data.
2898
+ #
2899
+ # * +options+ - Comma separated list of options.
2900
+ # * *Returns* - The converter object.
2901
+ def setDataOptions(options)
2902
+ @fields['data_options'] = options
2456
2903
  self
2457
2904
  end
2458
2905
 
2459
2906
  # Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.
2460
2907
  #
2461
- # * +debug_log+ - Set to true to enable the debug logging.
2908
+ # * +value+ - Set to true to enable the debug logging.
2462
2909
  # * *Returns* - The converter object.
2463
- def setDebugLog(debug_log)
2464
- @fields['debug_log'] = debug_log
2910
+ def setDebugLog(value)
2911
+ @fields['debug_log'] = value
2465
2912
  self
2466
2913
  end
2467
2914
 
@@ -2498,6 +2945,12 @@ module Pdfcrowd
2498
2945
  return @helper.getOutputSize()
2499
2946
  end
2500
2947
 
2948
+ # Get the version details.
2949
+ # * *Returns* - API version, converter version, and client version.
2950
+ def getVersion()
2951
+ return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
2952
+ end
2953
+
2501
2954
  # Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
2502
2955
  #
2503
2956
  # * +tag+ - A string with the custom tag.
@@ -2509,67 +2962,81 @@ module Pdfcrowd
2509
2962
 
2510
2963
  # A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTP scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
2511
2964
  #
2512
- # * +http_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2965
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2513
2966
  # * *Returns* - The converter object.
2514
- def setHttpProxy(http_proxy)
2515
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(http_proxy)
2516
- raise Error.new(Pdfcrowd.create_invalid_value_message(http_proxy, "http_proxy", "html-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
2967
+ def setHttpProxy(proxy)
2968
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
2969
+ raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "html-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
2517
2970
  end
2518
2971
 
2519
- @fields['http_proxy'] = http_proxy
2972
+ @fields['http_proxy'] = proxy
2520
2973
  self
2521
2974
  end
2522
2975
 
2523
2976
  # A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTPS scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
2524
2977
  #
2525
- # * +https_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2978
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2526
2979
  # * *Returns* - The converter object.
2527
- def setHttpsProxy(https_proxy)
2528
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(https_proxy)
2529
- raise Error.new(Pdfcrowd.create_invalid_value_message(https_proxy, "https_proxy", "html-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
2980
+ def setHttpsProxy(proxy)
2981
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
2982
+ raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "html-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
2530
2983
  end
2531
2984
 
2532
- @fields['https_proxy'] = https_proxy
2985
+ @fields['https_proxy'] = proxy
2533
2986
  self
2534
2987
  end
2535
2988
 
2536
2989
  # A client certificate to authenticate Pdfcrowd converter on your web server. The certificate is used for two-way SSL/TLS authentication and adds extra security.
2537
2990
  #
2538
- # * +client_certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
2991
+ # * +certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
2539
2992
  # * *Returns* - The converter object.
2540
- def setClientCertificate(client_certificate)
2541
- if (!(File.file?(client_certificate) && !File.zero?(client_certificate)))
2542
- raise Error.new(Pdfcrowd.create_invalid_value_message(client_certificate, "client_certificate", "html-to-image", "The file must exist and not be empty.", "set_client_certificate"), 470);
2993
+ def setClientCertificate(certificate)
2994
+ if (!(File.file?(certificate) && !File.zero?(certificate)))
2995
+ raise Error.new(Pdfcrowd.create_invalid_value_message(certificate, "setClientCertificate", "html-to-image", "The file must exist and not be empty.", "set_client_certificate"), 470);
2543
2996
  end
2544
2997
 
2545
- @files['client_certificate'] = client_certificate
2998
+ @files['client_certificate'] = certificate
2546
2999
  self
2547
3000
  end
2548
3001
 
2549
3002
  # A password for PKCS12 file with a client certificate if it is needed.
2550
3003
  #
2551
- # * +client_certificate_password+ -
3004
+ # * +password+ -
2552
3005
  # * *Returns* - The converter object.
2553
- def setClientCertificatePassword(client_certificate_password)
2554
- @fields['client_certificate_password'] = client_certificate_password
3006
+ def setClientCertificatePassword(password)
3007
+ @fields['client_certificate_password'] = password
3008
+ self
3009
+ end
3010
+
3011
+ # Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
3012
+ #
3013
+ # * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
3014
+ # * *Returns* - The converter object.
3015
+ def setConverterVersion(version)
3016
+ unless /(?i)^(latest|20.10|18.10)$/.match(version)
3017
+ raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "html-to-image", "Allowed values are latest, 20.10, 18.10.", "set_converter_version"), 470);
3018
+ end
3019
+
3020
+ @helper.setConverterVersion(version)
2555
3021
  self
2556
3022
  end
2557
3023
 
2558
3024
  # Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
3025
+ # Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
2559
3026
  #
2560
- # * +use_http+ - Set to true to use HTTP.
3027
+ # * +value+ - Set to true to use HTTP.
2561
3028
  # * *Returns* - The converter object.
2562
- def setUseHttp(use_http)
2563
- @helper.setUseHttp(use_http)
3029
+ def setUseHttp(value)
3030
+ @helper.setUseHttp(value)
2564
3031
  self
2565
3032
  end
2566
3033
 
2567
- # Set a custom user agent HTTP header. It can be usefull if you are behind some proxy or firewall.
3034
+ # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
2568
3035
  #
2569
- # * +user_agent+ - The user agent string.
3036
+ # * +agent+ - The user agent string.
2570
3037
  # * *Returns* - The converter object.
2571
- def setUserAgent(user_agent)
2572
- @helper.setUserAgent(user_agent)
3038
+ def setUserAgent(agent)
3039
+ @helper.setUserAgent(agent)
2573
3040
  self
2574
3041
  end
2575
3042
 
@@ -2587,10 +3054,10 @@ module Pdfcrowd
2587
3054
 
2588
3055
  # Specifies the number of retries when the 502 HTTP status code is received. The 502 status code indicates a temporary network issue. This feature can be disabled by setting to 0.
2589
3056
  #
2590
- # * +retry_count+ - Number of retries wanted.
3057
+ # * +count+ - Number of retries wanted.
2591
3058
  # * *Returns* - The converter object.
2592
- def setRetryCount(retry_count)
2593
- @helper.setRetryCount(retry_count)
3059
+ def setRetryCount(count)
3060
+ @helper.setRetryCount(count)
2594
3061
  self
2595
3062
  end
2596
3063
 
@@ -2619,7 +3086,7 @@ module Pdfcrowd
2619
3086
  # * *Returns* - Byte array containing the conversion output.
2620
3087
  def convertUrl(url)
2621
3088
  unless /(?i)^https?:\/\/.*$/.match(url)
2622
- raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "image-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
3089
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
2623
3090
  end
2624
3091
 
2625
3092
  @fields['url'] = url
@@ -2632,7 +3099,7 @@ module Pdfcrowd
2632
3099
  # * +out_stream+ - The output stream that will contain the conversion output.
2633
3100
  def convertUrlToStream(url, out_stream)
2634
3101
  unless /(?i)^https?:\/\/.*$/.match(url)
2635
- raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "image-to-image", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
3102
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "image-to-image", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
2636
3103
  end
2637
3104
 
2638
3105
  @fields['url'] = url
@@ -2645,7 +3112,7 @@ module Pdfcrowd
2645
3112
  # * +file_path+ - The output file path. The string must not be empty.
2646
3113
  def convertUrlToFile(url, file_path)
2647
3114
  if (!(!file_path.nil? && !file_path.empty?))
2648
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "image-to-image", "The string must not be empty.", "convert_url_to_file"), 470);
3115
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "image-to-image", "The string must not be empty.", "convert_url_to_file"), 470);
2649
3116
  end
2650
3117
 
2651
3118
  output_file = open(file_path, "wb")
@@ -2661,11 +3128,11 @@ module Pdfcrowd
2661
3128
 
2662
3129
  # Convert a local file.
2663
3130
  #
2664
- # * +file+ - The path to a local file to convert. The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip). The file must exist and not be empty.
3131
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
2665
3132
  # * *Returns* - Byte array containing the conversion output.
2666
3133
  def convertFile(file)
2667
3134
  if (!(File.file?(file) && !File.zero?(file)))
2668
- raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "image-to-image", "The file must exist and not be empty.", "convert_file"), 470);
3135
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "image-to-image", "The file must exist and not be empty.", "convert_file"), 470);
2669
3136
  end
2670
3137
 
2671
3138
  @files['file'] = file
@@ -2674,11 +3141,11 @@ module Pdfcrowd
2674
3141
 
2675
3142
  # Convert a local file and write the result to an output stream.
2676
3143
  #
2677
- # * +file+ - The path to a local file to convert. The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip). The file must exist and not be empty.
3144
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
2678
3145
  # * +out_stream+ - The output stream that will contain the conversion output.
2679
3146
  def convertFileToStream(file, out_stream)
2680
3147
  if (!(File.file?(file) && !File.zero?(file)))
2681
- raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "image-to-image", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
3148
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "image-to-image", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
2682
3149
  end
2683
3150
 
2684
3151
  @files['file'] = file
@@ -2687,11 +3154,11 @@ module Pdfcrowd
2687
3154
 
2688
3155
  # Convert a local file and write the result to a local file.
2689
3156
  #
2690
- # * +file+ - The path to a local file to convert. The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip). The file must exist and not be empty.
3157
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
2691
3158
  # * +file_path+ - The output file path. The string must not be empty.
2692
3159
  def convertFileToFile(file, file_path)
2693
3160
  if (!(!file_path.nil? && !file_path.empty?))
2694
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "image-to-image", "The string must not be empty.", "convert_file_to_file"), 470);
3161
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "image-to-image", "The string must not be empty.", "convert_file_to_file"), 470);
2695
3162
  end
2696
3163
 
2697
3164
  output_file = open(file_path, "wb")
@@ -2729,7 +3196,7 @@ module Pdfcrowd
2729
3196
  # * +file_path+ - The output file path. The string must not be empty.
2730
3197
  def convertRawDataToFile(data, file_path)
2731
3198
  if (!(!file_path.nil? && !file_path.empty?))
2732
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "image-to-image", "The string must not be empty.", "convert_raw_data_to_file"), 470);
3199
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertRawDataToFile::file_path", "image-to-image", "The string must not be empty.", "convert_raw_data_to_file"), 470);
2733
3200
  end
2734
3201
 
2735
3202
  output_file = open(file_path, "wb")
@@ -2743,13 +3210,51 @@ module Pdfcrowd
2743
3210
  end
2744
3211
  end
2745
3212
 
3213
+ # Convert the contents of an input stream.
3214
+ #
3215
+ # * +in_stream+ - The input stream with source data.
3216
+ # * *Returns* - Byte array containing the conversion output.
3217
+ def convertStream(in_stream)
3218
+ @raw_data['stream'] = in_stream.read
3219
+ @helper.post(@fields, @files, @raw_data)
3220
+ end
3221
+
3222
+ # Convert the contents of an input stream and write the result to an output stream.
3223
+ #
3224
+ # * +in_stream+ - The input stream with source data.
3225
+ # * +out_stream+ - The output stream that will contain the conversion output.
3226
+ def convertStreamToStream(in_stream, out_stream)
3227
+ @raw_data['stream'] = in_stream.read
3228
+ @helper.post(@fields, @files, @raw_data, out_stream)
3229
+ end
3230
+
3231
+ # Convert the contents of an input stream and write the result to a local file.
3232
+ #
3233
+ # * +in_stream+ - The input stream with source data.
3234
+ # * +file_path+ - The output file path. The string must not be empty.
3235
+ def convertStreamToFile(in_stream, file_path)
3236
+ if (!(!file_path.nil? && !file_path.empty?))
3237
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "image-to-image", "The string must not be empty.", "convert_stream_to_file"), 470);
3238
+ end
3239
+
3240
+ output_file = open(file_path, "wb")
3241
+ begin
3242
+ convertStreamToStream(in_stream, output_file)
3243
+ output_file.close()
3244
+ rescue Error => why
3245
+ output_file.close()
3246
+ FileUtils.rm(file_path)
3247
+ raise
3248
+ end
3249
+ end
3250
+
2746
3251
  # The format of the output file.
2747
3252
  #
2748
3253
  # * +output_format+ - Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.
2749
3254
  # * *Returns* - The converter object.
2750
3255
  def setOutputFormat(output_format)
2751
3256
  unless /(?i)^(png|jpg|gif|tiff|bmp|ico|ppm|pgm|pbm|pnm|psb|pct|ras|tga|sgi|sun|webp)$/.match(output_format)
2752
- raise Error.new(Pdfcrowd.create_invalid_value_message(output_format, "output_format", "image-to-image", "Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.", "set_output_format"), 470);
3257
+ raise Error.new(Pdfcrowd.create_invalid_value_message(output_format, "setOutputFormat", "image-to-image", "Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.", "set_output_format"), 470);
2753
3258
  end
2754
3259
 
2755
3260
  @fields['output_format'] = output_format
@@ -2776,10 +3281,10 @@ module Pdfcrowd
2776
3281
 
2777
3282
  # Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.
2778
3283
  #
2779
- # * +debug_log+ - Set to true to enable the debug logging.
3284
+ # * +value+ - Set to true to enable the debug logging.
2780
3285
  # * *Returns* - The converter object.
2781
- def setDebugLog(debug_log)
2782
- @fields['debug_log'] = debug_log
3286
+ def setDebugLog(value)
3287
+ @fields['debug_log'] = value
2783
3288
  self
2784
3289
  end
2785
3290
 
@@ -2816,6 +3321,12 @@ module Pdfcrowd
2816
3321
  return @helper.getOutputSize()
2817
3322
  end
2818
3323
 
3324
+ # Get the version details.
3325
+ # * *Returns* - API version, converter version, and client version.
3326
+ def getVersion()
3327
+ return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
3328
+ end
3329
+
2819
3330
  # Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
2820
3331
  #
2821
3332
  # * +tag+ - A string with the custom tag.
@@ -2827,45 +3338,59 @@ module Pdfcrowd
2827
3338
 
2828
3339
  # A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTP scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
2829
3340
  #
2830
- # * +http_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
3341
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2831
3342
  # * *Returns* - The converter object.
2832
- def setHttpProxy(http_proxy)
2833
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(http_proxy)
2834
- raise Error.new(Pdfcrowd.create_invalid_value_message(http_proxy, "http_proxy", "image-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
3343
+ def setHttpProxy(proxy)
3344
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
3345
+ raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "image-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
2835
3346
  end
2836
3347
 
2837
- @fields['http_proxy'] = http_proxy
3348
+ @fields['http_proxy'] = proxy
2838
3349
  self
2839
3350
  end
2840
3351
 
2841
3352
  # A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTPS scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
2842
3353
  #
2843
- # * +https_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
3354
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
3355
+ # * *Returns* - The converter object.
3356
+ def setHttpsProxy(proxy)
3357
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
3358
+ raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "image-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
3359
+ end
3360
+
3361
+ @fields['https_proxy'] = proxy
3362
+ self
3363
+ end
3364
+
3365
+ # Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
3366
+ #
3367
+ # * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
2844
3368
  # * *Returns* - The converter object.
2845
- def setHttpsProxy(https_proxy)
2846
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(https_proxy)
2847
- raise Error.new(Pdfcrowd.create_invalid_value_message(https_proxy, "https_proxy", "image-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
3369
+ def setConverterVersion(version)
3370
+ unless /(?i)^(latest|20.10|18.10)$/.match(version)
3371
+ raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "image-to-image", "Allowed values are latest, 20.10, 18.10.", "set_converter_version"), 470);
2848
3372
  end
2849
3373
 
2850
- @fields['https_proxy'] = https_proxy
3374
+ @helper.setConverterVersion(version)
2851
3375
  self
2852
3376
  end
2853
3377
 
2854
3378
  # Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
3379
+ # Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
2855
3380
  #
2856
- # * +use_http+ - Set to true to use HTTP.
3381
+ # * +value+ - Set to true to use HTTP.
2857
3382
  # * *Returns* - The converter object.
2858
- def setUseHttp(use_http)
2859
- @helper.setUseHttp(use_http)
3383
+ def setUseHttp(value)
3384
+ @helper.setUseHttp(value)
2860
3385
  self
2861
3386
  end
2862
3387
 
2863
- # Set a custom user agent HTTP header. It can be usefull if you are behind some proxy or firewall.
3388
+ # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
2864
3389
  #
2865
- # * +user_agent+ - The user agent string.
3390
+ # * +agent+ - The user agent string.
2866
3391
  # * *Returns* - The converter object.
2867
- def setUserAgent(user_agent)
2868
- @helper.setUserAgent(user_agent)
3392
+ def setUserAgent(agent)
3393
+ @helper.setUserAgent(agent)
2869
3394
  self
2870
3395
  end
2871
3396
 
@@ -2883,10 +3408,10 @@ module Pdfcrowd
2883
3408
 
2884
3409
  # Specifies the number of retries when the 502 HTTP status code is received. The 502 status code indicates a temporary network issue. This feature can be disabled by setting to 0.
2885
3410
  #
2886
- # * +retry_count+ - Number of retries wanted.
3411
+ # * +count+ - Number of retries wanted.
2887
3412
  # * *Returns* - The converter object.
2888
- def setRetryCount(retry_count)
2889
- @helper.setRetryCount(retry_count)
3413
+ def setRetryCount(count)
3414
+ @helper.setRetryCount(count)
2890
3415
  self
2891
3416
  end
2892
3417
 
@@ -2915,7 +3440,7 @@ module Pdfcrowd
2915
3440
  # * *Returns* - The converter object.
2916
3441
  def setAction(action)
2917
3442
  unless /(?i)^(join|shuffle)$/.match(action)
2918
- raise Error.new(Pdfcrowd.create_invalid_value_message(action, "action", "pdf-to-pdf", "Allowed values are join, shuffle.", "set_action"), 470);
3443
+ raise Error.new(Pdfcrowd.create_invalid_value_message(action, "setAction", "pdf-to-pdf", "Allowed values are join, shuffle.", "set_action"), 470);
2919
3444
  end
2920
3445
 
2921
3446
  @fields['action'] = action
@@ -2940,7 +3465,7 @@ module Pdfcrowd
2940
3465
  # * +file_path+ - The output file path. The string must not be empty.
2941
3466
  def convertToFile(file_path)
2942
3467
  if (!(!file_path.nil? && !file_path.empty?))
2943
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "pdf-to-pdf", "The string must not be empty.", "convert_to_file"), 470);
3468
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertToFile", "pdf-to-pdf", "The string must not be empty.", "convert_to_file"), 470);
2944
3469
  end
2945
3470
 
2946
3471
  output_file = open(file_path, "wb")
@@ -2954,7 +3479,7 @@ module Pdfcrowd
2954
3479
  # * *Returns* - The converter object.
2955
3480
  def addPdfFile(file_path)
2956
3481
  if (!(File.file?(file_path) && !File.zero?(file_path)))
2957
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "pdf-to-pdf", "The file must exist and not be empty.", "add_pdf_file"), 470);
3482
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "addPdfFile", "pdf-to-pdf", "The file must exist and not be empty.", "add_pdf_file"), 470);
2958
3483
  end
2959
3484
 
2960
3485
  @files['f_%s' % @file_id] = file_path
@@ -2964,267 +3489,319 @@ module Pdfcrowd
2964
3489
 
2965
3490
  # Add in-memory raw PDF data to the list of the input PDFs.Typical usage is for adding PDF created by another Pdfcrowd converter. Example in PHP: $clientPdf2Pdf->addPdfRawData($clientHtml2Pdf->convertUrl('http://www.example.com'));
2966
3491
  #
2967
- # * +pdf_raw_data+ - The raw PDF data. The input data must be PDF content.
3492
+ # * +data+ - The raw PDF data. The input data must be PDF content.
2968
3493
  # * *Returns* - The converter object.
2969
- def addPdfRawData(pdf_raw_data)
2970
- if (!(!pdf_raw_data.nil? && pdf_raw_data.length > 300 and pdf_raw_data[0...4] == '%PDF'))
2971
- raise Error.new(Pdfcrowd.create_invalid_value_message("raw PDF data", "pdf_raw_data", "pdf-to-pdf", "The input data must be PDF content.", "add_pdf_raw_data"), 470);
3494
+ def addPdfRawData(data)
3495
+ if (!(!data.nil? && data.length > 300 and data[0...4] == '%PDF'))
3496
+ raise Error.new(Pdfcrowd.create_invalid_value_message("raw PDF data", "addPdfRawData", "pdf-to-pdf", "The input data must be PDF content.", "add_pdf_raw_data"), 470);
2972
3497
  end
2973
3498
 
2974
- @raw_data['f_%s' % @file_id] = pdf_raw_data
3499
+ @raw_data['f_%s' % @file_id] = data
2975
3500
  @file_id += 1
2976
3501
  self
2977
3502
  end
2978
3503
 
2979
3504
  # Apply the first page of the watermark PDF to every page of the output PDF.
2980
3505
  #
2981
- # * +page_watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
3506
+ # * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
3507
+ # * *Returns* - The converter object.
3508
+ def setPageWatermark(watermark)
3509
+ if (!(File.file?(watermark) && !File.zero?(watermark)))
3510
+ raise Error.new(Pdfcrowd.create_invalid_value_message(watermark, "setPageWatermark", "pdf-to-pdf", "The file must exist and not be empty.", "set_page_watermark"), 470);
3511
+ end
3512
+
3513
+ @files['page_watermark'] = watermark
3514
+ self
3515
+ end
3516
+
3517
+ # Load a watermark PDF from the specified URL and apply the first page of the watermark PDF to every page of the output PDF.
3518
+ #
3519
+ # * +url+ - The supported protocols are http:// and https://.
2982
3520
  # * *Returns* - The converter object.
2983
- def setPageWatermark(page_watermark)
2984
- if (!(File.file?(page_watermark) && !File.zero?(page_watermark)))
2985
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_watermark, "page_watermark", "pdf-to-pdf", "The file must exist and not be empty.", "set_page_watermark"), 470);
3521
+ def setPageWatermarkUrl(url)
3522
+ unless /(?i)^https?:\/\/.*$/.match(url)
3523
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageWatermarkUrl", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_page_watermark_url"), 470);
2986
3524
  end
2987
3525
 
2988
- @files['page_watermark'] = page_watermark
3526
+ @fields['page_watermark_url'] = url
2989
3527
  self
2990
3528
  end
2991
3529
 
2992
3530
  # Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
2993
3531
  #
2994
- # * +multipage_watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
3532
+ # * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
3533
+ # * *Returns* - The converter object.
3534
+ def setMultipageWatermark(watermark)
3535
+ if (!(File.file?(watermark) && !File.zero?(watermark)))
3536
+ raise Error.new(Pdfcrowd.create_invalid_value_message(watermark, "setMultipageWatermark", "pdf-to-pdf", "The file must exist and not be empty.", "set_multipage_watermark"), 470);
3537
+ end
3538
+
3539
+ @files['multipage_watermark'] = watermark
3540
+ self
3541
+ end
3542
+
3543
+ # Load a watermark PDF from the specified URL and apply each page of the specified watermark PDF to the corresponding page of the output PDF.
3544
+ #
3545
+ # * +url+ - The supported protocols are http:// and https://.
2995
3546
  # * *Returns* - The converter object.
2996
- def setMultipageWatermark(multipage_watermark)
2997
- if (!(File.file?(multipage_watermark) && !File.zero?(multipage_watermark)))
2998
- raise Error.new(Pdfcrowd.create_invalid_value_message(multipage_watermark, "multipage_watermark", "pdf-to-pdf", "The file must exist and not be empty.", "set_multipage_watermark"), 470);
3547
+ def setMultipageWatermarkUrl(url)
3548
+ unless /(?i)^https?:\/\/.*$/.match(url)
3549
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageWatermarkUrl", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_watermark_url"), 470);
2999
3550
  end
3000
3551
 
3001
- @files['multipage_watermark'] = multipage_watermark
3552
+ @fields['multipage_watermark_url'] = url
3002
3553
  self
3003
3554
  end
3004
3555
 
3005
3556
  # Apply the first page of the specified PDF to the background of every page of the output PDF.
3006
3557
  #
3007
- # * +page_background+ - The file path to a local background PDF file. The file must exist and not be empty.
3558
+ # * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
3559
+ # * *Returns* - The converter object.
3560
+ def setPageBackground(background)
3561
+ if (!(File.file?(background) && !File.zero?(background)))
3562
+ raise Error.new(Pdfcrowd.create_invalid_value_message(background, "setPageBackground", "pdf-to-pdf", "The file must exist and not be empty.", "set_page_background"), 470);
3563
+ end
3564
+
3565
+ @files['page_background'] = background
3566
+ self
3567
+ end
3568
+
3569
+ # Load a background PDF from the specified URL and apply the first page of the background PDF to every page of the output PDF.
3570
+ #
3571
+ # * +url+ - The supported protocols are http:// and https://.
3008
3572
  # * *Returns* - The converter object.
3009
- def setPageBackground(page_background)
3010
- if (!(File.file?(page_background) && !File.zero?(page_background)))
3011
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_background, "page_background", "pdf-to-pdf", "The file must exist and not be empty.", "set_page_background"), 470);
3573
+ def setPageBackgroundUrl(url)
3574
+ unless /(?i)^https?:\/\/.*$/.match(url)
3575
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageBackgroundUrl", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_page_background_url"), 470);
3012
3576
  end
3013
3577
 
3014
- @files['page_background'] = page_background
3578
+ @fields['page_background_url'] = url
3015
3579
  self
3016
3580
  end
3017
3581
 
3018
3582
  # Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
3019
3583
  #
3020
- # * +multipage_background+ - The file path to a local background PDF file. The file must exist and not be empty.
3584
+ # * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
3585
+ # * *Returns* - The converter object.
3586
+ def setMultipageBackground(background)
3587
+ if (!(File.file?(background) && !File.zero?(background)))
3588
+ raise Error.new(Pdfcrowd.create_invalid_value_message(background, "setMultipageBackground", "pdf-to-pdf", "The file must exist and not be empty.", "set_multipage_background"), 470);
3589
+ end
3590
+
3591
+ @files['multipage_background'] = background
3592
+ self
3593
+ end
3594
+
3595
+ # Load a background PDF from the specified URL and apply each page of the specified background PDF to the corresponding page of the output PDF.
3596
+ #
3597
+ # * +url+ - The supported protocols are http:// and https://.
3021
3598
  # * *Returns* - The converter object.
3022
- def setMultipageBackground(multipage_background)
3023
- if (!(File.file?(multipage_background) && !File.zero?(multipage_background)))
3024
- raise Error.new(Pdfcrowd.create_invalid_value_message(multipage_background, "multipage_background", "pdf-to-pdf", "The file must exist and not be empty.", "set_multipage_background"), 470);
3599
+ def setMultipageBackgroundUrl(url)
3600
+ unless /(?i)^https?:\/\/.*$/.match(url)
3601
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageBackgroundUrl", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_background_url"), 470);
3025
3602
  end
3026
3603
 
3027
- @files['multipage_background'] = multipage_background
3604
+ @fields['multipage_background_url'] = url
3028
3605
  self
3029
3606
  end
3030
3607
 
3031
3608
  # Create linearized PDF. This is also known as Fast Web View.
3032
3609
  #
3033
- # * +linearize+ - Set to true to create linearized PDF.
3610
+ # * +value+ - Set to true to create linearized PDF.
3034
3611
  # * *Returns* - The converter object.
3035
- def setLinearize(linearize)
3036
- @fields['linearize'] = linearize
3612
+ def setLinearize(value)
3613
+ @fields['linearize'] = value
3037
3614
  self
3038
3615
  end
3039
3616
 
3040
3617
  # Encrypt the PDF. This prevents search engines from indexing the contents.
3041
3618
  #
3042
- # * +encrypt+ - Set to true to enable PDF encryption.
3619
+ # * +value+ - Set to true to enable PDF encryption.
3043
3620
  # * *Returns* - The converter object.
3044
- def setEncrypt(encrypt)
3045
- @fields['encrypt'] = encrypt
3621
+ def setEncrypt(value)
3622
+ @fields['encrypt'] = value
3046
3623
  self
3047
3624
  end
3048
3625
 
3049
3626
  # Protect the PDF with a user password. When a PDF has a user password, it must be supplied in order to view the document and to perform operations allowed by the access permissions.
3050
3627
  #
3051
- # * +user_password+ - The user password.
3628
+ # * +password+ - The user password.
3052
3629
  # * *Returns* - The converter object.
3053
- def setUserPassword(user_password)
3054
- @fields['user_password'] = user_password
3630
+ def setUserPassword(password)
3631
+ @fields['user_password'] = password
3055
3632
  self
3056
3633
  end
3057
3634
 
3058
3635
  # Protect the PDF with an owner password. Supplying an owner password grants unlimited access to the PDF including changing the passwords and access permissions.
3059
3636
  #
3060
- # * +owner_password+ - The owner password.
3637
+ # * +password+ - The owner password.
3061
3638
  # * *Returns* - The converter object.
3062
- def setOwnerPassword(owner_password)
3063
- @fields['owner_password'] = owner_password
3639
+ def setOwnerPassword(password)
3640
+ @fields['owner_password'] = password
3064
3641
  self
3065
3642
  end
3066
3643
 
3067
3644
  # Disallow printing of the output PDF.
3068
3645
  #
3069
- # * +no_print+ - Set to true to set the no-print flag in the output PDF.
3646
+ # * +value+ - Set to true to set the no-print flag in the output PDF.
3070
3647
  # * *Returns* - The converter object.
3071
- def setNoPrint(no_print)
3072
- @fields['no_print'] = no_print
3648
+ def setNoPrint(value)
3649
+ @fields['no_print'] = value
3073
3650
  self
3074
3651
  end
3075
3652
 
3076
- # Disallow modification of the ouput PDF.
3653
+ # Disallow modification of the output PDF.
3077
3654
  #
3078
- # * +no_modify+ - Set to true to set the read-only only flag in the output PDF.
3655
+ # * +value+ - Set to true to set the read-only only flag in the output PDF.
3079
3656
  # * *Returns* - The converter object.
3080
- def setNoModify(no_modify)
3081
- @fields['no_modify'] = no_modify
3657
+ def setNoModify(value)
3658
+ @fields['no_modify'] = value
3082
3659
  self
3083
3660
  end
3084
3661
 
3085
3662
  # Disallow text and graphics extraction from the output PDF.
3086
3663
  #
3087
- # * +no_copy+ - Set to true to set the no-copy flag in the output PDF.
3664
+ # * +value+ - Set to true to set the no-copy flag in the output PDF.
3088
3665
  # * *Returns* - The converter object.
3089
- def setNoCopy(no_copy)
3090
- @fields['no_copy'] = no_copy
3666
+ def setNoCopy(value)
3667
+ @fields['no_copy'] = value
3091
3668
  self
3092
3669
  end
3093
3670
 
3094
3671
  # Specify the page layout to be used when the document is opened.
3095
3672
  #
3096
- # * +page_layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
3673
+ # * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
3097
3674
  # * *Returns* - The converter object.
3098
- def setPageLayout(page_layout)
3099
- unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(page_layout)
3100
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_layout, "page_layout", "pdf-to-pdf", "Allowed values are single-page, one-column, two-column-left, two-column-right.", "set_page_layout"), 470);
3675
+ def setPageLayout(layout)
3676
+ unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout)
3677
+ raise Error.new(Pdfcrowd.create_invalid_value_message(layout, "setPageLayout", "pdf-to-pdf", "Allowed values are single-page, one-column, two-column-left, two-column-right.", "set_page_layout"), 470);
3101
3678
  end
3102
3679
 
3103
- @fields['page_layout'] = page_layout
3680
+ @fields['page_layout'] = layout
3104
3681
  self
3105
3682
  end
3106
3683
 
3107
3684
  # Specify how the document should be displayed when opened.
3108
3685
  #
3109
- # * +page_mode+ - Allowed values are full-screen, thumbnails, outlines.
3686
+ # * +mode+ - Allowed values are full-screen, thumbnails, outlines.
3110
3687
  # * *Returns* - The converter object.
3111
- def setPageMode(page_mode)
3112
- unless /(?i)^(full-screen|thumbnails|outlines)$/.match(page_mode)
3113
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_mode, "page_mode", "pdf-to-pdf", "Allowed values are full-screen, thumbnails, outlines.", "set_page_mode"), 470);
3688
+ def setPageMode(mode)
3689
+ unless /(?i)^(full-screen|thumbnails|outlines)$/.match(mode)
3690
+ raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setPageMode", "pdf-to-pdf", "Allowed values are full-screen, thumbnails, outlines.", "set_page_mode"), 470);
3114
3691
  end
3115
3692
 
3116
- @fields['page_mode'] = page_mode
3693
+ @fields['page_mode'] = mode
3117
3694
  self
3118
3695
  end
3119
3696
 
3120
3697
  # Specify how the page should be displayed when opened.
3121
3698
  #
3122
- # * +initial_zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
3699
+ # * +zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
3123
3700
  # * *Returns* - The converter object.
3124
- def setInitialZoomType(initial_zoom_type)
3125
- unless /(?i)^(fit-width|fit-height|fit-page)$/.match(initial_zoom_type)
3126
- raise Error.new(Pdfcrowd.create_invalid_value_message(initial_zoom_type, "initial_zoom_type", "pdf-to-pdf", "Allowed values are fit-width, fit-height, fit-page.", "set_initial_zoom_type"), 470);
3701
+ def setInitialZoomType(zoom_type)
3702
+ unless /(?i)^(fit-width|fit-height|fit-page)$/.match(zoom_type)
3703
+ raise Error.new(Pdfcrowd.create_invalid_value_message(zoom_type, "setInitialZoomType", "pdf-to-pdf", "Allowed values are fit-width, fit-height, fit-page.", "set_initial_zoom_type"), 470);
3127
3704
  end
3128
3705
 
3129
- @fields['initial_zoom_type'] = initial_zoom_type
3706
+ @fields['initial_zoom_type'] = zoom_type
3130
3707
  self
3131
3708
  end
3132
3709
 
3133
3710
  # Display the specified page when the document is opened.
3134
3711
  #
3135
- # * +initial_page+ - Must be a positive integer number.
3712
+ # * +page+ - Must be a positive integer number.
3136
3713
  # * *Returns* - The converter object.
3137
- def setInitialPage(initial_page)
3138
- if (!(Integer(initial_page) > 0))
3139
- raise Error.new(Pdfcrowd.create_invalid_value_message(initial_page, "initial_page", "pdf-to-pdf", "Must be a positive integer number.", "set_initial_page"), 470);
3714
+ def setInitialPage(page)
3715
+ if (!(Integer(page) > 0))
3716
+ raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "pdf-to-pdf", "Must be a positive integer number.", "set_initial_page"), 470);
3140
3717
  end
3141
3718
 
3142
- @fields['initial_page'] = initial_page
3719
+ @fields['initial_page'] = page
3143
3720
  self
3144
3721
  end
3145
3722
 
3146
3723
  # Specify the initial page zoom in percents when the document is opened.
3147
3724
  #
3148
- # * +initial_zoom+ - Must be a positive integer number.
3725
+ # * +zoom+ - Must be a positive integer number.
3149
3726
  # * *Returns* - The converter object.
3150
- def setInitialZoom(initial_zoom)
3151
- if (!(Integer(initial_zoom) > 0))
3152
- raise Error.new(Pdfcrowd.create_invalid_value_message(initial_zoom, "initial_zoom", "pdf-to-pdf", "Must be a positive integer number.", "set_initial_zoom"), 470);
3727
+ def setInitialZoom(zoom)
3728
+ if (!(Integer(zoom) > 0))
3729
+ raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "pdf-to-pdf", "Must be a positive integer number.", "set_initial_zoom"), 470);
3153
3730
  end
3154
3731
 
3155
- @fields['initial_zoom'] = initial_zoom
3732
+ @fields['initial_zoom'] = zoom
3156
3733
  self
3157
3734
  end
3158
3735
 
3159
3736
  # Specify whether to hide the viewer application's tool bars when the document is active.
3160
3737
  #
3161
- # * +hide_toolbar+ - Set to true to hide tool bars.
3738
+ # * +value+ - Set to true to hide tool bars.
3162
3739
  # * *Returns* - The converter object.
3163
- def setHideToolbar(hide_toolbar)
3164
- @fields['hide_toolbar'] = hide_toolbar
3740
+ def setHideToolbar(value)
3741
+ @fields['hide_toolbar'] = value
3165
3742
  self
3166
3743
  end
3167
3744
 
3168
3745
  # Specify whether to hide the viewer application's menu bar when the document is active.
3169
3746
  #
3170
- # * +hide_menubar+ - Set to true to hide the menu bar.
3747
+ # * +value+ - Set to true to hide the menu bar.
3171
3748
  # * *Returns* - The converter object.
3172
- def setHideMenubar(hide_menubar)
3173
- @fields['hide_menubar'] = hide_menubar
3749
+ def setHideMenubar(value)
3750
+ @fields['hide_menubar'] = value
3174
3751
  self
3175
3752
  end
3176
3753
 
3177
3754
  # Specify 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.
3178
3755
  #
3179
- # * +hide_window_ui+ - Set to true to hide ui elements.
3756
+ # * +value+ - Set to true to hide ui elements.
3180
3757
  # * *Returns* - The converter object.
3181
- def setHideWindowUi(hide_window_ui)
3182
- @fields['hide_window_ui'] = hide_window_ui
3758
+ def setHideWindowUi(value)
3759
+ @fields['hide_window_ui'] = value
3183
3760
  self
3184
3761
  end
3185
3762
 
3186
3763
  # Specify whether to resize the document's window to fit the size of the first displayed page.
3187
3764
  #
3188
- # * +fit_window+ - Set to true to resize the window.
3765
+ # * +value+ - Set to true to resize the window.
3189
3766
  # * *Returns* - The converter object.
3190
- def setFitWindow(fit_window)
3191
- @fields['fit_window'] = fit_window
3767
+ def setFitWindow(value)
3768
+ @fields['fit_window'] = value
3192
3769
  self
3193
3770
  end
3194
3771
 
3195
3772
  # Specify whether to position the document's window in the center of the screen.
3196
3773
  #
3197
- # * +center_window+ - Set to true to center the window.
3774
+ # * +value+ - Set to true to center the window.
3198
3775
  # * *Returns* - The converter object.
3199
- def setCenterWindow(center_window)
3200
- @fields['center_window'] = center_window
3776
+ def setCenterWindow(value)
3777
+ @fields['center_window'] = value
3201
3778
  self
3202
3779
  end
3203
3780
 
3204
3781
  # Specify whether the window's title bar should display the document title. If false , the title bar should instead display the name of the PDF file containing the document.
3205
3782
  #
3206
- # * +display_title+ - Set to true to display the title.
3783
+ # * +value+ - Set to true to display the title.
3207
3784
  # * *Returns* - The converter object.
3208
- def setDisplayTitle(display_title)
3209
- @fields['display_title'] = display_title
3785
+ def setDisplayTitle(value)
3786
+ @fields['display_title'] = value
3210
3787
  self
3211
3788
  end
3212
3789
 
3213
3790
  # Set the predominant reading order for text to right-to-left. This option has no direct effect on the document's contents or page numbering but can be used to determine the relative positioning of pages when displayed side by side or printed n-up
3214
3791
  #
3215
- # * +right_to_left+ - Set to true to set right-to-left reading order.
3792
+ # * +value+ - Set to true to set right-to-left reading order.
3216
3793
  # * *Returns* - The converter object.
3217
- def setRightToLeft(right_to_left)
3218
- @fields['right_to_left'] = right_to_left
3794
+ def setRightToLeft(value)
3795
+ @fields['right_to_left'] = value
3219
3796
  self
3220
3797
  end
3221
3798
 
3222
3799
  # Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.
3223
3800
  #
3224
- # * +debug_log+ - Set to true to enable the debug logging.
3801
+ # * +value+ - Set to true to enable the debug logging.
3225
3802
  # * *Returns* - The converter object.
3226
- def setDebugLog(debug_log)
3227
- @fields['debug_log'] = debug_log
3803
+ def setDebugLog(value)
3804
+ @fields['debug_log'] = value
3228
3805
  self
3229
3806
  end
3230
3807
 
@@ -3267,6 +3844,12 @@ module Pdfcrowd
3267
3844
  return @helper.getOutputSize()
3268
3845
  end
3269
3846
 
3847
+ # Get the version details.
3848
+ # * *Returns* - API version, converter version, and client version.
3849
+ def getVersion()
3850
+ return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
3851
+ end
3852
+
3270
3853
  # Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
3271
3854
  #
3272
3855
  # * +tag+ - A string with the custom tag.
@@ -3276,21 +3859,35 @@ module Pdfcrowd
3276
3859
  self
3277
3860
  end
3278
3861
 
3862
+ # Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
3863
+ #
3864
+ # * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
3865
+ # * *Returns* - The converter object.
3866
+ def setConverterVersion(version)
3867
+ unless /(?i)^(latest|20.10|18.10)$/.match(version)
3868
+ raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "pdf-to-pdf", "Allowed values are latest, 20.10, 18.10.", "set_converter_version"), 470);
3869
+ end
3870
+
3871
+ @helper.setConverterVersion(version)
3872
+ self
3873
+ end
3874
+
3279
3875
  # Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
3876
+ # Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
3280
3877
  #
3281
- # * +use_http+ - Set to true to use HTTP.
3878
+ # * +value+ - Set to true to use HTTP.
3282
3879
  # * *Returns* - The converter object.
3283
- def setUseHttp(use_http)
3284
- @helper.setUseHttp(use_http)
3880
+ def setUseHttp(value)
3881
+ @helper.setUseHttp(value)
3285
3882
  self
3286
3883
  end
3287
3884
 
3288
- # Set a custom user agent HTTP header. It can be usefull if you are behind some proxy or firewall.
3885
+ # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
3289
3886
  #
3290
- # * +user_agent+ - The user agent string.
3887
+ # * +agent+ - The user agent string.
3291
3888
  # * *Returns* - The converter object.
3292
- def setUserAgent(user_agent)
3293
- @helper.setUserAgent(user_agent)
3889
+ def setUserAgent(agent)
3890
+ @helper.setUserAgent(agent)
3294
3891
  self
3295
3892
  end
3296
3893
 
@@ -3308,10 +3905,10 @@ module Pdfcrowd
3308
3905
 
3309
3906
  # Specifies the number of retries when the 502 HTTP status code is received. The 502 status code indicates a temporary network issue. This feature can be disabled by setting to 0.
3310
3907
  #
3311
- # * +retry_count+ - Number of retries wanted.
3908
+ # * +count+ - Number of retries wanted.
3312
3909
  # * *Returns* - The converter object.
3313
- def setRetryCount(retry_count)
3314
- @helper.setRetryCount(retry_count)
3910
+ def setRetryCount(count)
3911
+ @helper.setRetryCount(count)
3315
3912
  self
3316
3913
  end
3317
3914
 
@@ -3340,7 +3937,7 @@ module Pdfcrowd
3340
3937
  # * *Returns* - Byte array containing the conversion output.
3341
3938
  def convertUrl(url)
3342
3939
  unless /(?i)^https?:\/\/.*$/.match(url)
3343
- raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "image-to-pdf", "The supported protocols are http:// and https://.", "convert_url"), 470);
3940
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-pdf", "The supported protocols are http:// and https://.", "convert_url"), 470);
3344
3941
  end
3345
3942
 
3346
3943
  @fields['url'] = url
@@ -3353,7 +3950,7 @@ module Pdfcrowd
3353
3950
  # * +out_stream+ - The output stream that will contain the conversion output.
3354
3951
  def convertUrlToStream(url, out_stream)
3355
3952
  unless /(?i)^https?:\/\/.*$/.match(url)
3356
- raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "image-to-pdf", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
3953
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "image-to-pdf", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
3357
3954
  end
3358
3955
 
3359
3956
  @fields['url'] = url
@@ -3366,7 +3963,7 @@ module Pdfcrowd
3366
3963
  # * +file_path+ - The output file path. The string must not be empty.
3367
3964
  def convertUrlToFile(url, file_path)
3368
3965
  if (!(!file_path.nil? && !file_path.empty?))
3369
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "image-to-pdf", "The string must not be empty.", "convert_url_to_file"), 470);
3966
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "image-to-pdf", "The string must not be empty.", "convert_url_to_file"), 470);
3370
3967
  end
3371
3968
 
3372
3969
  output_file = open(file_path, "wb")
@@ -3382,11 +3979,11 @@ module Pdfcrowd
3382
3979
 
3383
3980
  # Convert a local file.
3384
3981
  #
3385
- # * +file+ - The path to a local file to convert. The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip). The file must exist and not be empty.
3982
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
3386
3983
  # * *Returns* - Byte array containing the conversion output.
3387
3984
  def convertFile(file)
3388
3985
  if (!(File.file?(file) && !File.zero?(file)))
3389
- raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "image-to-pdf", "The file must exist and not be empty.", "convert_file"), 470);
3986
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "image-to-pdf", "The file must exist and not be empty.", "convert_file"), 470);
3390
3987
  end
3391
3988
 
3392
3989
  @files['file'] = file
@@ -3395,11 +3992,11 @@ module Pdfcrowd
3395
3992
 
3396
3993
  # Convert a local file and write the result to an output stream.
3397
3994
  #
3398
- # * +file+ - The path to a local file to convert. The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip). The file must exist and not be empty.
3995
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
3399
3996
  # * +out_stream+ - The output stream that will contain the conversion output.
3400
3997
  def convertFileToStream(file, out_stream)
3401
3998
  if (!(File.file?(file) && !File.zero?(file)))
3402
- raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "image-to-pdf", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
3999
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "image-to-pdf", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
3403
4000
  end
3404
4001
 
3405
4002
  @files['file'] = file
@@ -3408,11 +4005,11 @@ module Pdfcrowd
3408
4005
 
3409
4006
  # Convert a local file and write the result to a local file.
3410
4007
  #
3411
- # * +file+ - The path to a local file to convert. The file can be either a single file or an archive (.tar.gz, .tar.bz2, or .zip). The file must exist and not be empty.
4008
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
3412
4009
  # * +file_path+ - The output file path. The string must not be empty.
3413
4010
  def convertFileToFile(file, file_path)
3414
4011
  if (!(!file_path.nil? && !file_path.empty?))
3415
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "image-to-pdf", "The string must not be empty.", "convert_file_to_file"), 470);
4012
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "image-to-pdf", "The string must not be empty.", "convert_file_to_file"), 470);
3416
4013
  end
3417
4014
 
3418
4015
  output_file = open(file_path, "wb")
@@ -3450,7 +4047,7 @@ module Pdfcrowd
3450
4047
  # * +file_path+ - The output file path. The string must not be empty.
3451
4048
  def convertRawDataToFile(data, file_path)
3452
4049
  if (!(!file_path.nil? && !file_path.empty?))
3453
- raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "image-to-pdf", "The string must not be empty.", "convert_raw_data_to_file"), 470);
4050
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertRawDataToFile::file_path", "image-to-pdf", "The string must not be empty.", "convert_raw_data_to_file"), 470);
3454
4051
  end
3455
4052
 
3456
4053
  output_file = open(file_path, "wb")
@@ -3464,6 +4061,44 @@ module Pdfcrowd
3464
4061
  end
3465
4062
  end
3466
4063
 
4064
+ # Convert the contents of an input stream.
4065
+ #
4066
+ # * +in_stream+ - The input stream with source data.
4067
+ # * *Returns* - Byte array containing the conversion output.
4068
+ def convertStream(in_stream)
4069
+ @raw_data['stream'] = in_stream.read
4070
+ @helper.post(@fields, @files, @raw_data)
4071
+ end
4072
+
4073
+ # Convert the contents of an input stream and write the result to an output stream.
4074
+ #
4075
+ # * +in_stream+ - The input stream with source data.
4076
+ # * +out_stream+ - The output stream that will contain the conversion output.
4077
+ def convertStreamToStream(in_stream, out_stream)
4078
+ @raw_data['stream'] = in_stream.read
4079
+ @helper.post(@fields, @files, @raw_data, out_stream)
4080
+ end
4081
+
4082
+ # Convert the contents of an input stream and write the result to a local file.
4083
+ #
4084
+ # * +in_stream+ - The input stream with source data.
4085
+ # * +file_path+ - The output file path. The string must not be empty.
4086
+ def convertStreamToFile(in_stream, file_path)
4087
+ if (!(!file_path.nil? && !file_path.empty?))
4088
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "image-to-pdf", "The string must not be empty.", "convert_stream_to_file"), 470);
4089
+ end
4090
+
4091
+ output_file = open(file_path, "wb")
4092
+ begin
4093
+ convertStreamToStream(in_stream, output_file)
4094
+ output_file.close()
4095
+ rescue Error => why
4096
+ output_file.close()
4097
+ FileUtils.rm(file_path)
4098
+ raise
4099
+ end
4100
+ end
4101
+
3467
4102
  # Resize the image.
3468
4103
  #
3469
4104
  # * +resize+ - The resize percentage or new image dimensions.
@@ -3484,10 +4119,10 @@ module Pdfcrowd
3484
4119
 
3485
4120
  # Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.
3486
4121
  #
3487
- # * +debug_log+ - Set to true to enable the debug logging.
4122
+ # * +value+ - Set to true to enable the debug logging.
3488
4123
  # * *Returns* - The converter object.
3489
- def setDebugLog(debug_log)
3490
- @fields['debug_log'] = debug_log
4124
+ def setDebugLog(value)
4125
+ @fields['debug_log'] = value
3491
4126
  self
3492
4127
  end
3493
4128
 
@@ -3524,6 +4159,12 @@ module Pdfcrowd
3524
4159
  return @helper.getOutputSize()
3525
4160
  end
3526
4161
 
4162
+ # Get the version details.
4163
+ # * *Returns* - API version, converter version, and client version.
4164
+ def getVersion()
4165
+ return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
4166
+ end
4167
+
3527
4168
  # Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
3528
4169
  #
3529
4170
  # * +tag+ - A string with the custom tag.
@@ -3535,45 +4176,59 @@ module Pdfcrowd
3535
4176
 
3536
4177
  # A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTP scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
3537
4178
  #
3538
- # * +http_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
4179
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
3539
4180
  # * *Returns* - The converter object.
3540
- def setHttpProxy(http_proxy)
3541
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(http_proxy)
3542
- raise Error.new(Pdfcrowd.create_invalid_value_message(http_proxy, "http_proxy", "image-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
4181
+ def setHttpProxy(proxy)
4182
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
4183
+ raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "image-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
3543
4184
  end
3544
4185
 
3545
- @fields['http_proxy'] = http_proxy
4186
+ @fields['http_proxy'] = proxy
3546
4187
  self
3547
4188
  end
3548
4189
 
3549
4190
  # A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTPS scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
3550
4191
  #
3551
- # * +https_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
4192
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
4193
+ # * *Returns* - The converter object.
4194
+ def setHttpsProxy(proxy)
4195
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
4196
+ raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "image-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
4197
+ end
4198
+
4199
+ @fields['https_proxy'] = proxy
4200
+ self
4201
+ end
4202
+
4203
+ # Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
4204
+ #
4205
+ # * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
3552
4206
  # * *Returns* - The converter object.
3553
- def setHttpsProxy(https_proxy)
3554
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(https_proxy)
3555
- raise Error.new(Pdfcrowd.create_invalid_value_message(https_proxy, "https_proxy", "image-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
4207
+ def setConverterVersion(version)
4208
+ unless /(?i)^(latest|20.10|18.10)$/.match(version)
4209
+ raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "image-to-pdf", "Allowed values are latest, 20.10, 18.10.", "set_converter_version"), 470);
3556
4210
  end
3557
4211
 
3558
- @fields['https_proxy'] = https_proxy
4212
+ @helper.setConverterVersion(version)
3559
4213
  self
3560
4214
  end
3561
4215
 
3562
4216
  # Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
4217
+ # Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
3563
4218
  #
3564
- # * +use_http+ - Set to true to use HTTP.
4219
+ # * +value+ - Set to true to use HTTP.
3565
4220
  # * *Returns* - The converter object.
3566
- def setUseHttp(use_http)
3567
- @helper.setUseHttp(use_http)
4221
+ def setUseHttp(value)
4222
+ @helper.setUseHttp(value)
3568
4223
  self
3569
4224
  end
3570
4225
 
3571
- # Set a custom user agent HTTP header. It can be usefull if you are behind some proxy or firewall.
4226
+ # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
3572
4227
  #
3573
- # * +user_agent+ - The user agent string.
4228
+ # * +agent+ - The user agent string.
3574
4229
  # * *Returns* - The converter object.
3575
- def setUserAgent(user_agent)
3576
- @helper.setUserAgent(user_agent)
4230
+ def setUserAgent(agent)
4231
+ @helper.setUserAgent(agent)
3577
4232
  self
3578
4233
  end
3579
4234
 
@@ -3591,10 +4246,10 @@ module Pdfcrowd
3591
4246
 
3592
4247
  # Specifies the number of retries when the 502 HTTP status code is received. The 502 status code indicates a temporary network issue. This feature can be disabled by setting to 0.
3593
4248
  #
3594
- # * +retry_count+ - Number of retries wanted.
4249
+ # * +count+ - Number of retries wanted.
3595
4250
  # * *Returns* - The converter object.
3596
- def setRetryCount(retry_count)
3597
- @helper.setRetryCount(retry_count)
4251
+ def setRetryCount(count)
4252
+ @helper.setRetryCount(count)
3598
4253
  self
3599
4254
  end
3600
4255