pdfcrowd 4.12.0 → 5.2.0

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 +1323 -835
  3. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 831ab1316f51b02fcaac6c0f530631784c3ecc6c
4
- data.tar.gz: 3f2fb384a6abc373d1a9421b461bd7b4c573a38c
2
+ SHA256:
3
+ metadata.gz: ae09fe4d44318c3dab2a3804590c724cab4e92e0b4d96465741d01a3d3878e3d
4
+ data.tar.gz: 968307d08a48c39f21e290e5e0d1e18ec8b9284f90643617040b2c4ed525adef
5
5
  SHA512:
6
- metadata.gz: fd7873f02b1bf65df5430b0b457f13139399a79001e34e3fbc07700e2e0b48dd6d099c46c2a1bd8c31cbd134d60193c555dfa7ba690348593d7bd3747bf6b238
7
- data.tar.gz: 648468cfeab19ee85e491d7cd32d30f1e64c05f4bd816a3e39e38a3c2383eda0df700e53463fc36ff1df7b34e322018da605fc6168349761e1d1a3dabb768206
6
+ metadata.gz: 42bfe893fbf5c150376920d5550d387aac1214d62ee788a27df6429f05f91373e27ed16f4da33d6258ba5c1cc95e9b84b656cf3c02b7bf805fee4a2b62947cac
7
+ data.tar.gz: 4c6e63c4fa88abaa622701690a66b85ace7c3c62de2efed671d3098c3ee950efdd20fe6f0ac1224a201d172f98a18daeb5e065e5d5422c5b795b033eef557b15
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.12.0'
533
+ CLIENT_VERSION = '5.2.0'
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.12.0 (http://pdfcrowd.com)')
544
+ setUserAgent('pdfcrowd_ruby_client/5.2.0 (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)
@@ -617,7 +626,7 @@ module Pdfcrowd
617
626
  body << 'Content-Disposition: form-data; name="%s"; filename="%s"' % [name, file_name]
618
627
  body << 'Content-Type: application/octet-stream'
619
628
  body << ''
620
- body << data
629
+ body << data.force_encoding('UTF-8')
621
630
  end
622
631
 
623
632
  def self.encode_multipart_post_data(fields, files, raw_data)
@@ -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 the 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,89 @@ 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
+
936
+ # Set the file name of the main HTML document stored in the input archive. If not specified, the first HTML file in the archive is used for conversion. Use this method if the input archive contains multiple HTML documents.
937
+ #
938
+ # * +filename+ - The file name.
939
+ # * *Returns* - The converter object.
940
+ def setZipMainFilename(filename)
941
+ @fields['zip_main_filename'] = filename
942
+ self
943
+ end
944
+
889
945
  # Set the output page size.
890
946
  #
891
- # * +page_size+ - Allowed values are A2, A3, A4, A5, A6, Letter.
947
+ # * +size+ - Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.
892
948
  # * *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);
949
+ def setPageSize(size)
950
+ unless /(?i)^(A0|A1|A2|A3|A4|A5|A6|Letter)$/.match(size)
951
+ 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
952
  end
897
953
 
898
- @fields['page_size'] = page_size
954
+ @fields['page_size'] = size
899
955
  self
900
956
  end
901
957
 
902
958
  # Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
903
959
  #
904
- # * +page_width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
960
+ # * +width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
905
961
  # * *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);
962
+ def setPageWidth(width)
963
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
964
+ 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
965
  end
910
966
 
911
- @fields['page_width'] = page_width
967
+ @fields['page_width'] = width
912
968
  self
913
969
  end
914
970
 
915
971
  # 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
972
  #
917
- # * +page_height+ - Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
973
+ # * +height+ - Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
918
974
  # * *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);
975
+ def setPageHeight(height)
976
+ unless /(?i)^0$|^\-1$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
977
+ 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
978
  end
923
979
 
924
- @fields['page_height'] = page_height
980
+ @fields['page_height'] = height
925
981
  self
926
982
  end
927
983
 
@@ -942,7 +998,7 @@ module Pdfcrowd
942
998
  # * *Returns* - The converter object.
943
999
  def setOrientation(orientation)
944
1000
  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);
1001
+ raise Error.new(Pdfcrowd.create_invalid_value_message(orientation, "setOrientation", "html-to-pdf", "Allowed values are landscape, portrait.", "set_orientation"), 470);
946
1002
  end
947
1003
 
948
1004
  @fields['orientation'] = orientation
@@ -951,62 +1007,62 @@ module Pdfcrowd
951
1007
 
952
1008
  # Set the output page top margin.
953
1009
  #
954
- # * +margin_top+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1010
+ # * +top+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
955
1011
  # * *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);
1012
+ def setMarginTop(top)
1013
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(top)
1014
+ 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
1015
  end
960
1016
 
961
- @fields['margin_top'] = margin_top
1017
+ @fields['margin_top'] = top
962
1018
  self
963
1019
  end
964
1020
 
965
1021
  # Set the output page right margin.
966
1022
  #
967
- # * +margin_right+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1023
+ # * +right+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
968
1024
  # * *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);
1025
+ def setMarginRight(right)
1026
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(right)
1027
+ 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
1028
  end
973
1029
 
974
- @fields['margin_right'] = margin_right
1030
+ @fields['margin_right'] = right
975
1031
  self
976
1032
  end
977
1033
 
978
1034
  # Set the output page bottom margin.
979
1035
  #
980
- # * +margin_bottom+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1036
+ # * +bottom+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
981
1037
  # * *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);
1038
+ def setMarginBottom(bottom)
1039
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(bottom)
1040
+ 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
1041
  end
986
1042
 
987
- @fields['margin_bottom'] = margin_bottom
1043
+ @fields['margin_bottom'] = bottom
988
1044
  self
989
1045
  end
990
1046
 
991
1047
  # Set the output page left margin.
992
1048
  #
993
- # * +margin_left+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1049
+ # * +left+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
994
1050
  # * *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);
1051
+ def setMarginLeft(left)
1052
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(left)
1053
+ 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
1054
  end
999
1055
 
1000
- @fields['margin_left'] = margin_left
1056
+ @fields['margin_left'] = left
1001
1057
  self
1002
1058
  end
1003
1059
 
1004
1060
  # Disable page margins.
1005
1061
  #
1006
- # * +no_margins+ - Set to true to disable margins.
1062
+ # * +value+ - Set to true to disable margins.
1007
1063
  # * *Returns* - The converter object.
1008
- def setNoMargins(no_margins)
1009
- @fields['no_margins'] = no_margins
1064
+ def setNoMargins(value)
1065
+ @fields['no_margins'] = value
1010
1066
  self
1011
1067
  end
1012
1068
 
@@ -1025,443 +1081,451 @@ module Pdfcrowd
1025
1081
  self
1026
1082
  end
1027
1083
 
1028
- # 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>
1084
+ # Set the page range to print.
1029
1085
  #
1030
- # * +header_url+ - The supported protocols are http:// and https://.
1086
+ # * +pages+ - A comma separated list of page numbers or ranges.
1031
1087
  # * *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);
1088
+ def setPrintPageRange(pages)
1089
+ 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)
1090
+ 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);
1035
1091
  end
1036
1092
 
1037
- @fields['header_url'] = header_url
1093
+ @fields['print_page_range'] = pages
1038
1094
  self
1039
1095
  end
1040
1096
 
1041
- # 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>
1097
+ # Set an offset between physical and logical page numbers.
1042
1098
  #
1043
- # * +header_html+ - The string must not be empty.
1099
+ # * +offset+ - Integer specifying page offset.
1044
1100
  # * *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);
1048
- end
1049
-
1050
- @fields['header_html'] = header_html
1101
+ def setPageNumberingOffset(offset)
1102
+ @fields['page_numbering_offset'] = offset
1051
1103
  self
1052
1104
  end
1053
1105
 
1054
- # Set the header height.
1106
+ # Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
1055
1107
  #
1056
- # * +header_height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1108
+ # * +x+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
1057
1109
  # * *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);
1110
+ def setContentAreaX(x)
1111
+ unless /(?i)^0$|^\-?[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(x)
1112
+ 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);
1061
1113
  end
1062
1114
 
1063
- @fields['header_height'] = header_height
1115
+ @fields['content_area_x'] = x
1064
1116
  self
1065
1117
  end
1066
1118
 
1067
- # 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>
1119
+ # Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
1068
1120
  #
1069
- # * +footer_url+ - The supported protocols are http:// and https://.
1121
+ # * +y+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
1070
1122
  # * *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);
1123
+ def setContentAreaY(y)
1124
+ unless /(?i)^0$|^\-?[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(y)
1125
+ 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);
1074
1126
  end
1075
1127
 
1076
- @fields['footer_url'] = footer_url
1128
+ @fields['content_area_y'] = y
1077
1129
  self
1078
1130
  end
1079
1131
 
1080
- # 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>
1132
+ # Set the width of the content area. It should be at least 1 inch.
1081
1133
  #
1082
- # * +footer_html+ - The string must not be empty.
1134
+ # * +width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1083
1135
  # * *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);
1136
+ def setContentAreaWidth(width)
1137
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
1138
+ 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);
1087
1139
  end
1088
1140
 
1089
- @fields['footer_html'] = footer_html
1141
+ @fields['content_area_width'] = width
1090
1142
  self
1091
1143
  end
1092
1144
 
1093
- # Set the footer height.
1145
+ # Set the height of the content area. It should be at least 1 inch.
1094
1146
  #
1095
- # * +footer_height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1147
+ # * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1096
1148
  # * *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);
1149
+ def setContentAreaHeight(height)
1150
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
1151
+ 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);
1100
1152
  end
1101
1153
 
1102
- @fields['footer_height'] = footer_height
1154
+ @fields['content_area_height'] = height
1103
1155
  self
1104
1156
  end
1105
1157
 
1106
- # Set the page range to print.
1158
+ # Set the content area position and size. The content area enables to specify a web page area to be converted.
1107
1159
  #
1108
- # * +pages+ - A comma separated list of page numbers or ranges.
1160
+ # * +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.
1161
+ # * +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.
1162
+ # * +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).
1163
+ # * +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).
1109
1164
  # * *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 separated list of page numbers or ranges.", "set_print_page_range"), 470);
1113
- end
1114
-
1115
- @fields['print_page_range'] = pages
1165
+ def setContentArea(x, y, width, height)
1166
+ setContentAreaX(x)
1167
+ setContentAreaY(y)
1168
+ setContentAreaWidth(width)
1169
+ setContentAreaHeight(height)
1116
1170
  self
1117
1171
  end
1118
1172
 
1119
- # The page header is not printed on the specified pages.
1173
+ # Specifies behavior in presence of CSS @page rules. It may affect the page size, margins and orientation.
1120
1174
  #
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 separated list of page numbers.
1175
+ # * +mode+ - The page rule mode. Allowed values are default, mode1, mode2.
1122
1176
  # * *Returns* - The converter object.
1123
- def setExcludeHeaderOnPages(pages)
1124
- 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 separated list of page numbers.", "set_exclude_header_on_pages"), 470);
1177
+ def setCssPageRuleMode(mode)
1178
+ unless /(?i)^(default|mode1|mode2)$/.match(mode)
1179
+ 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);
1126
1180
  end
1127
1181
 
1128
- @fields['exclude_header_on_pages'] = pages
1182
+ @fields['css_page_rule_mode'] = mode
1129
1183
  self
1130
1184
  end
1131
1185
 
1132
- # The page footer is not printed on the specified pages.
1186
+ # 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. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. 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>
1133
1187
  #
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 separated list of page numbers.
1188
+ # * +url+ - The supported protocols are http:// and https://.
1135
1189
  # * *Returns* - The converter object.
1136
- def setExcludeFooterOnPages(pages)
1137
- 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 separated list of page numbers.", "set_exclude_footer_on_pages"), 470);
1190
+ def setHeaderUrl(url)
1191
+ unless /(?i)^https?:\/\/.*$/.match(url)
1192
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setHeaderUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_header_url"), 470);
1139
1193
  end
1140
1194
 
1141
- @fields['exclude_footer_on_pages'] = pages
1195
+ @fields['header_url'] = url
1142
1196
  self
1143
1197
  end
1144
1198
 
1145
- # Set an offset between physical and logical page numbers.
1146
- #
1147
- # * +offset+ - Integer specifying page offset.
1148
- # * *Returns* - The converter object.
1149
- def setPageNumberingOffset(offset)
1150
- @fields['page_numbering_offset'] = offset
1151
- self
1152
- end
1153
-
1154
- # Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
1199
+ # 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. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. 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>
1155
1200
  #
1156
- # * +content_area_x+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
1201
+ # * +html+ - The string must not be empty.
1157
1202
  # * *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);
1203
+ def setHeaderHtml(html)
1204
+ if (!(!html.nil? && !html.empty?))
1205
+ raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setHeaderHtml", "html-to-pdf", "The string must not be empty.", "set_header_html"), 470);
1161
1206
  end
1162
1207
 
1163
- @fields['content_area_x'] = content_area_x
1208
+ @fields['header_html'] = html
1164
1209
  self
1165
1210
  end
1166
1211
 
1167
- # Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
1212
+ # Set the header height.
1168
1213
  #
1169
- # * +content_area_y+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
1214
+ # * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1170
1215
  # * *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);
1216
+ def setHeaderHeight(height)
1217
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
1218
+ 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);
1174
1219
  end
1175
1220
 
1176
- @fields['content_area_y'] = content_area_y
1221
+ @fields['header_height'] = height
1177
1222
  self
1178
1223
  end
1179
1224
 
1180
- # Set the width of the content area. It should be at least 1 inch.
1225
+ # Set the file name of the header HTML document stored in the input archive. Use this method if the input archive contains multiple HTML documents.
1181
1226
  #
1182
- # * +content_area_width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1227
+ # * +filename+ - The file name.
1183
1228
  # * *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);
1187
- end
1188
-
1189
- @fields['content_area_width'] = content_area_width
1229
+ def setZipHeaderFilename(filename)
1230
+ @fields['zip_header_filename'] = filename
1190
1231
  self
1191
1232
  end
1192
1233
 
1193
- # Set the height of the content area. It should be at least 1 inch.
1234
+ # 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. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. 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>
1194
1235
  #
1195
- # * +content_area_height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1236
+ # * +url+ - The supported protocols are http:// and https://.
1196
1237
  # * *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);
1238
+ def setFooterUrl(url)
1239
+ unless /(?i)^https?:\/\/.*$/.match(url)
1240
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setFooterUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_footer_url"), 470);
1200
1241
  end
1201
1242
 
1202
- @fields['content_area_height'] = content_area_height
1203
- self
1204
- end
1205
-
1206
- # Set the content area position and size. The content area enables to specify a web page area to be converted.
1207
- #
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).
1212
- # * *Returns* - The converter object.
1213
- def setContentArea(x, y, width, height)
1214
- setContentAreaX(x)
1215
- setContentAreaY(y)
1216
- setContentAreaWidth(width)
1217
- setContentAreaHeight(height)
1243
+ @fields['footer_url'] = url
1218
1244
  self
1219
1245
  end
1220
1246
 
1221
- # Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
1247
+ # 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. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. 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>
1222
1248
  #
1223
- # * +data_string+ - The input data string.
1224
- # * *Returns* - The converter object.
1225
- def setDataString(data_string)
1226
- @fields['data_string'] = data_string
1227
- self
1228
- end
1229
-
1230
- # Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
1231
- #
1232
- # * +data_file+ - The file path to a local file containing the input data.
1249
+ # * +html+ - The string must not be empty.
1233
1250
  # * *Returns* - The converter object.
1234
- def setDataFile(data_file)
1235
- @files['data_file'] = data_file
1251
+ def setFooterHtml(html)
1252
+ if (!(!html.nil? && !html.empty?))
1253
+ raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setFooterHtml", "html-to-pdf", "The string must not be empty.", "set_footer_html"), 470);
1254
+ end
1255
+
1256
+ @fields['footer_html'] = html
1236
1257
  self
1237
1258
  end
1238
1259
 
1239
- # Specify the input data format.
1260
+ # Set the footer height.
1240
1261
  #
1241
- # * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
1262
+ # * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
1242
1263
  # * *Returns* - The converter object.
1243
- def setDataFormat(data_format)
1244
- unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
1245
- raise Error.new(Pdfcrowd.create_invalid_value_message(data_format, "data_format", "html-to-pdf", "Allowed values are auto, json, xml, yaml, csv.", "set_data_format"), 470);
1264
+ def setFooterHeight(height)
1265
+ unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
1266
+ 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);
1246
1267
  end
1247
1268
 
1248
- @fields['data_format'] = data_format
1269
+ @fields['footer_height'] = height
1249
1270
  self
1250
1271
  end
1251
1272
 
1252
- # Set the encoding of the data file set by setDataFile.
1273
+ # Set the file name of the footer HTML document stored in the input archive. Use this method if the input archive contains multiple HTML documents.
1253
1274
  #
1254
- # * +data_encoding+ - The data file encoding.
1275
+ # * +filename+ - The file name.
1255
1276
  # * *Returns* - The converter object.
1256
- def setDataEncoding(data_encoding)
1257
- @fields['data_encoding'] = data_encoding
1277
+ def setZipFooterFilename(filename)
1278
+ @fields['zip_footer_filename'] = filename
1258
1279
  self
1259
1280
  end
1260
1281
 
1261
- # 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.
1282
+ # Disable horizontal page margins for header and footer. The header/footer contents width will be equal to the physical page width.
1262
1283
  #
1263
- # * +data_ignore_undefined+ - Set to true to ignore undefined variables.
1284
+ # * +value+ - Set to true to disable horizontal margins for header and footer.
1264
1285
  # * *Returns* - The converter object.
1265
- def setDataIgnoreUndefined(data_ignore_undefined)
1266
- @fields['data_ignore_undefined'] = data_ignore_undefined
1286
+ def setNoHeaderFooterHorizontalMargins(value)
1287
+ @fields['no_header_footer_horizontal_margins'] = value
1267
1288
  self
1268
1289
  end
1269
1290
 
1270
- # Auto escape HTML symbols in the input data before placing them into the output.
1291
+ # The page header is not printed on the specified pages.
1271
1292
  #
1272
- # * +data_auto_escape+ - Set to true to turn auto escaping on.
1293
+ # * +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.
1273
1294
  # * *Returns* - The converter object.
1274
- def setDataAutoEscape(data_auto_escape)
1275
- @fields['data_auto_escape'] = data_auto_escape
1295
+ def setExcludeHeaderOnPages(pages)
1296
+ unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
1297
+ 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);
1298
+ end
1299
+
1300
+ @fields['exclude_header_on_pages'] = pages
1276
1301
  self
1277
1302
  end
1278
1303
 
1279
- # Auto trim whitespace around each template command block.
1304
+ # The page footer is not printed on the specified pages.
1280
1305
  #
1281
- # * +data_trim_blocks+ - Set to true to turn auto trimming on.
1306
+ # * +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.
1282
1307
  # * *Returns* - The converter object.
1283
- def setDataTrimBlocks(data_trim_blocks)
1284
- @fields['data_trim_blocks'] = data_trim_blocks
1308
+ def setExcludeFooterOnPages(pages)
1309
+ unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
1310
+ 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);
1311
+ end
1312
+
1313
+ @fields['exclude_footer_on_pages'] = pages
1285
1314
  self
1286
1315
  end
1287
1316
 
1288
- # 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.
1317
+ # Set the scaling factor (zoom) for the header and footer.
1289
1318
  #
1290
- # * +data_options+ - Comma separated list of options.
1319
+ # * +factor+ - The percentage value. The value must be in the range 10-500.
1291
1320
  # * *Returns* - The converter object.
1292
- def setDataOptions(data_options)
1293
- @fields['data_options'] = data_options
1321
+ def setHeaderFooterScaleFactor(factor)
1322
+ if (!(Integer(factor) >= 10 && Integer(factor) <= 500))
1323
+ 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);
1324
+ end
1325
+
1326
+ @fields['header_footer_scale_factor'] = factor
1294
1327
  self
1295
1328
  end
1296
1329
 
1297
1330
  # Apply the first page of the watermark PDF to every page of the output PDF.
1298
1331
  #
1299
- # * +page_watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
1332
+ # * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
1300
1333
  # * *Returns* - The converter object.
1301
- def setPageWatermark(page_watermark)
1302
- if (!(File.file?(page_watermark) && !File.zero?(page_watermark)))
1303
- 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);
1334
+ def setPageWatermark(watermark)
1335
+ if (!(File.file?(watermark) && !File.zero?(watermark)))
1336
+ 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);
1304
1337
  end
1305
1338
 
1306
- @files['page_watermark'] = page_watermark
1339
+ @files['page_watermark'] = watermark
1307
1340
  self
1308
1341
  end
1309
1342
 
1310
1343
  # Load a watermark PDF from the specified URL and apply the first page of the watermark PDF to every page of the output PDF.
1311
1344
  #
1312
- # * +page_watermark_url+ - The supported protocols are http:// and https://.
1345
+ # * +url+ - The supported protocols are http:// and https://.
1313
1346
  # * *Returns* - The converter object.
1314
- def setPageWatermarkUrl(page_watermark_url)
1315
- unless /(?i)^https?:\/\/.*$/.match(page_watermark_url)
1316
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_watermark_url, "page_watermark_url", "html-to-pdf", "The supported protocols are http:// and https://.", "set_page_watermark_url"), 470);
1347
+ def setPageWatermarkUrl(url)
1348
+ unless /(?i)^https?:\/\/.*$/.match(url)
1349
+ 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);
1317
1350
  end
1318
1351
 
1319
- @fields['page_watermark_url'] = page_watermark_url
1352
+ @fields['page_watermark_url'] = url
1320
1353
  self
1321
1354
  end
1322
1355
 
1323
1356
  # Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
1324
1357
  #
1325
- # * +multipage_watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
1358
+ # * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
1326
1359
  # * *Returns* - The converter object.
1327
- def setMultipageWatermark(multipage_watermark)
1328
- if (!(File.file?(multipage_watermark) && !File.zero?(multipage_watermark)))
1329
- 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);
1360
+ def setMultipageWatermark(watermark)
1361
+ if (!(File.file?(watermark) && !File.zero?(watermark)))
1362
+ 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);
1330
1363
  end
1331
1364
 
1332
- @files['multipage_watermark'] = multipage_watermark
1365
+ @files['multipage_watermark'] = watermark
1333
1366
  self
1334
1367
  end
1335
1368
 
1336
1369
  # 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.
1337
1370
  #
1338
- # * +multipage_watermark_url+ - The supported protocols are http:// and https://.
1371
+ # * +url+ - The supported protocols are http:// and https://.
1339
1372
  # * *Returns* - The converter object.
1340
- def setMultipageWatermarkUrl(multipage_watermark_url)
1341
- unless /(?i)^https?:\/\/.*$/.match(multipage_watermark_url)
1342
- raise Error.new(Pdfcrowd.create_invalid_value_message(multipage_watermark_url, "multipage_watermark_url", "html-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_watermark_url"), 470);
1373
+ def setMultipageWatermarkUrl(url)
1374
+ unless /(?i)^https?:\/\/.*$/.match(url)
1375
+ 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);
1343
1376
  end
1344
1377
 
1345
- @fields['multipage_watermark_url'] = multipage_watermark_url
1378
+ @fields['multipage_watermark_url'] = url
1346
1379
  self
1347
1380
  end
1348
1381
 
1349
1382
  # Apply the first page of the specified PDF to the background of every page of the output PDF.
1350
1383
  #
1351
- # * +page_background+ - The file path to a local background PDF file. The file must exist and not be empty.
1384
+ # * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
1352
1385
  # * *Returns* - The converter object.
1353
- def setPageBackground(page_background)
1354
- if (!(File.file?(page_background) && !File.zero?(page_background)))
1355
- 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);
1386
+ def setPageBackground(background)
1387
+ if (!(File.file?(background) && !File.zero?(background)))
1388
+ 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);
1356
1389
  end
1357
1390
 
1358
- @files['page_background'] = page_background
1391
+ @files['page_background'] = background
1359
1392
  self
1360
1393
  end
1361
1394
 
1362
1395
  # Load a background PDF from the specified URL and apply the first page of the background PDF to every page of the output PDF.
1363
1396
  #
1364
- # * +page_background_url+ - The supported protocols are http:// and https://.
1397
+ # * +url+ - The supported protocols are http:// and https://.
1365
1398
  # * *Returns* - The converter object.
1366
- def setPageBackgroundUrl(page_background_url)
1367
- unless /(?i)^https?:\/\/.*$/.match(page_background_url)
1368
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_background_url, "page_background_url", "html-to-pdf", "The supported protocols are http:// and https://.", "set_page_background_url"), 470);
1399
+ def setPageBackgroundUrl(url)
1400
+ unless /(?i)^https?:\/\/.*$/.match(url)
1401
+ 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);
1369
1402
  end
1370
1403
 
1371
- @fields['page_background_url'] = page_background_url
1404
+ @fields['page_background_url'] = url
1372
1405
  self
1373
1406
  end
1374
1407
 
1375
1408
  # Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
1376
1409
  #
1377
- # * +multipage_background+ - The file path to a local background PDF file. The file must exist and not be empty.
1410
+ # * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
1378
1411
  # * *Returns* - The converter object.
1379
- def setMultipageBackground(multipage_background)
1380
- if (!(File.file?(multipage_background) && !File.zero?(multipage_background)))
1381
- 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);
1412
+ def setMultipageBackground(background)
1413
+ if (!(File.file?(background) && !File.zero?(background)))
1414
+ 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);
1382
1415
  end
1383
1416
 
1384
- @files['multipage_background'] = multipage_background
1417
+ @files['multipage_background'] = background
1385
1418
  self
1386
1419
  end
1387
1420
 
1388
1421
  # 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.
1389
1422
  #
1390
- # * +multipage_background_url+ - The supported protocols are http:// and https://.
1423
+ # * +url+ - The supported protocols are http:// and https://.
1391
1424
  # * *Returns* - The converter object.
1392
- def setMultipageBackgroundUrl(multipage_background_url)
1393
- unless /(?i)^https?:\/\/.*$/.match(multipage_background_url)
1394
- raise Error.new(Pdfcrowd.create_invalid_value_message(multipage_background_url, "multipage_background_url", "html-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_background_url"), 470);
1425
+ def setMultipageBackgroundUrl(url)
1426
+ unless /(?i)^https?:\/\/.*$/.match(url)
1427
+ 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);
1395
1428
  end
1396
1429
 
1397
- @fields['multipage_background_url'] = multipage_background_url
1430
+ @fields['multipage_background_url'] = url
1398
1431
  self
1399
1432
  end
1400
1433
 
1401
1434
  # The page background color in RGB or RGBA hexadecimal format. The color fills the entire page regardless of the margins.
1402
1435
  #
1403
- # * +page_background_color+ - The value must be in RRGGBB or RRGGBBAA hexadecimal format.
1436
+ # * +color+ - The value must be in RRGGBB or RRGGBBAA hexadecimal format.
1404
1437
  # * *Returns* - The converter object.
1405
- def setPageBackgroundColor(page_background_color)
1406
- unless /^[0-9a-fA-F]{6,8}$/.match(page_background_color)
1407
- 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);
1438
+ def setPageBackgroundColor(color)
1439
+ unless /^[0-9a-fA-F]{6,8}$/.match(color)
1440
+ 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);
1408
1441
  end
1409
1442
 
1410
- @fields['page_background_color'] = page_background_color
1443
+ @fields['page_background_color'] = color
1444
+ self
1445
+ end
1446
+
1447
+ # Use the print version of the page if available (@media print).
1448
+ #
1449
+ # * +value+ - Set to true to use the print version of the page.
1450
+ # * *Returns* - The converter object.
1451
+ def setUsePrintMedia(value)
1452
+ @fields['use_print_media'] = value
1411
1453
  self
1412
1454
  end
1413
1455
 
1414
1456
  # Do not print the background graphics.
1415
1457
  #
1416
- # * +no_background+ - Set to true to disable the background graphics.
1458
+ # * +value+ - Set to true to disable the background graphics.
1417
1459
  # * *Returns* - The converter object.
1418
- def setNoBackground(no_background)
1419
- @fields['no_background'] = no_background
1460
+ def setNoBackground(value)
1461
+ @fields['no_background'] = value
1420
1462
  self
1421
1463
  end
1422
1464
 
1423
1465
  # Do not execute JavaScript.
1424
1466
  #
1425
- # * +disable_javascript+ - Set to true to disable JavaScript in web pages.
1467
+ # * +value+ - Set to true to disable JavaScript in web pages.
1426
1468
  # * *Returns* - The converter object.
1427
- def setDisableJavascript(disable_javascript)
1428
- @fields['disable_javascript'] = disable_javascript
1469
+ def setDisableJavascript(value)
1470
+ @fields['disable_javascript'] = value
1429
1471
  self
1430
1472
  end
1431
1473
 
1432
1474
  # Do not load images.
1433
1475
  #
1434
- # * +disable_image_loading+ - Set to true to disable loading of images.
1476
+ # * +value+ - Set to true to disable loading of images.
1435
1477
  # * *Returns* - The converter object.
1436
- def setDisableImageLoading(disable_image_loading)
1437
- @fields['disable_image_loading'] = disable_image_loading
1478
+ def setDisableImageLoading(value)
1479
+ @fields['disable_image_loading'] = value
1438
1480
  self
1439
1481
  end
1440
1482
 
1441
1483
  # Disable loading fonts from remote sources.
1442
1484
  #
1443
- # * +disable_remote_fonts+ - Set to true disable loading remote fonts.
1485
+ # * +value+ - Set to true disable loading remote fonts.
1486
+ # * *Returns* - The converter object.
1487
+ def setDisableRemoteFonts(value)
1488
+ @fields['disable_remote_fonts'] = value
1489
+ self
1490
+ end
1491
+
1492
+ # Specifies how iframes are handled.
1493
+ #
1494
+ # * +iframes+ - Allowed values are all, same-origin, none.
1444
1495
  # * *Returns* - The converter object.
1445
- def setDisableRemoteFonts(disable_remote_fonts)
1446
- @fields['disable_remote_fonts'] = disable_remote_fonts
1496
+ def setLoadIframes(iframes)
1497
+ unless /(?i)^(all|same-origin|none)$/.match(iframes)
1498
+ raise Error.new(Pdfcrowd.create_invalid_value_message(iframes, "setLoadIframes", "html-to-pdf", "Allowed values are all, same-origin, none.", "set_load_iframes"), 470);
1499
+ end
1500
+
1501
+ @fields['load_iframes'] = iframes
1447
1502
  self
1448
1503
  end
1449
1504
 
1450
1505
  # Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
1451
1506
  #
1452
- # * +block_ads+ - Set to true to block ads in web pages.
1507
+ # * +value+ - Set to true to block ads in web pages.
1453
1508
  # * *Returns* - The converter object.
1454
- def setBlockAds(block_ads)
1455
- @fields['block_ads'] = block_ads
1509
+ def setBlockAds(value)
1510
+ @fields['block_ads'] = value
1456
1511
  self
1457
1512
  end
1458
1513
 
1459
1514
  # Set the default HTML content text encoding.
1460
1515
  #
1461
- # * +default_encoding+ - The text encoding of the HTML content.
1516
+ # * +encoding+ - The text encoding of the HTML content.
1462
1517
  # * *Returns* - The converter object.
1463
- def setDefaultEncoding(default_encoding)
1464
- @fields['default_encoding'] = default_encoding
1518
+ def setDefaultEncoding(encoding)
1519
+ @fields['default_encoding'] = encoding
1520
+ self
1521
+ end
1522
+
1523
+ # Set the locale for the conversion. This may affect the output format of dates, times and numbers.
1524
+ #
1525
+ # * +locale+ - The locale code according to ISO 639.
1526
+ # * *Returns* - The converter object.
1527
+ def setLocale(locale)
1528
+ @fields['locale'] = locale
1465
1529
  self
1466
1530
  end
1467
1531
 
@@ -1494,24 +1558,6 @@ module Pdfcrowd
1494
1558
  self
1495
1559
  end
1496
1560
 
1497
- # Use the print version of the page if available (@media print).
1498
- #
1499
- # * +use_print_media+ - Set to true to use the print version of the page.
1500
- # * *Returns* - The converter object.
1501
- def setUsePrintMedia(use_print_media)
1502
- @fields['use_print_media'] = use_print_media
1503
- self
1504
- end
1505
-
1506
- # Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
1507
- #
1508
- # * +no_xpdfcrowd_header+ - Set to true to disable sending X-Pdfcrowd HTTP header.
1509
- # * *Returns* - The converter object.
1510
- def setNoXpdfcrowdHeader(no_xpdfcrowd_header)
1511
- @fields['no_xpdfcrowd_header'] = no_xpdfcrowd_header
1512
- self
1513
- end
1514
-
1515
1561
  # Set cookies that are sent in Pdfcrowd HTTP requests.
1516
1562
  #
1517
1563
  # * +cookies+ - The cookie string.
@@ -1523,10 +1569,10 @@ module Pdfcrowd
1523
1569
 
1524
1570
  # Do not allow insecure HTTPS connections.
1525
1571
  #
1526
- # * +verify_ssl_certificates+ - Set to true to enable SSL certificate verification.
1572
+ # * +value+ - Set to true to enable SSL certificate verification.
1527
1573
  # * *Returns* - The converter object.
1528
- def setVerifySslCertificates(verify_ssl_certificates)
1529
- @fields['verify_ssl_certificates'] = verify_ssl_certificates
1574
+ def setVerifySslCertificates(value)
1575
+ @fields['verify_ssl_certificates'] = value
1530
1576
  self
1531
1577
  end
1532
1578
 
@@ -1548,55 +1594,64 @@ module Pdfcrowd
1548
1594
  self
1549
1595
  end
1550
1596
 
1597
+ # Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
1598
+ #
1599
+ # * +value+ - Set to true to disable sending X-Pdfcrowd HTTP header.
1600
+ # * *Returns* - The converter object.
1601
+ def setNoXpdfcrowdHeader(value)
1602
+ @fields['no_xpdfcrowd_header'] = value
1603
+ self
1604
+ end
1605
+
1551
1606
  # 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.
1552
1607
  #
1553
- # * +custom_javascript+ - A string containing a JavaScript code. The string must not be empty.
1608
+ # * +javascript+ - A string containing a JavaScript code. The string must not be empty.
1554
1609
  # * *Returns* - The converter object.
1555
- def setCustomJavascript(custom_javascript)
1556
- if (!(!custom_javascript.nil? && !custom_javascript.empty?))
1557
- 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);
1610
+ def setCustomJavascript(javascript)
1611
+ if (!(!javascript.nil? && !javascript.empty?))
1612
+ raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setCustomJavascript", "html-to-pdf", "The string must not be empty.", "set_custom_javascript"), 470);
1558
1613
  end
1559
1614
 
1560
- @fields['custom_javascript'] = custom_javascript
1615
+ @fields['custom_javascript'] = javascript
1561
1616
  self
1562
1617
  end
1563
1618
 
1564
1619
  # 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.
1565
1620
  #
1566
- # * +on_load_javascript+ - A string containing a JavaScript code. The string must not be empty.
1621
+ # * +javascript+ - A string containing a JavaScript code. The string must not be empty.
1567
1622
  # * *Returns* - The converter object.
1568
- def setOnLoadJavascript(on_load_javascript)
1569
- if (!(!on_load_javascript.nil? && !on_load_javascript.empty?))
1570
- 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);
1623
+ def setOnLoadJavascript(javascript)
1624
+ if (!(!javascript.nil? && !javascript.empty?))
1625
+ raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setOnLoadJavascript", "html-to-pdf", "The string must not be empty.", "set_on_load_javascript"), 470);
1571
1626
  end
1572
1627
 
1573
- @fields['on_load_javascript'] = on_load_javascript
1628
+ @fields['on_load_javascript'] = javascript
1574
1629
  self
1575
1630
  end
1576
1631
 
1577
1632
  # Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
1578
1633
  #
1579
- # * +custom_http_header+ - A string containing the header name and value separated by a colon.
1634
+ # * +header+ - A string containing the header name and value separated by a colon.
1580
1635
  # * *Returns* - The converter object.
1581
- def setCustomHttpHeader(custom_http_header)
1582
- unless /^.+:.+$/.match(custom_http_header)
1583
- 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);
1636
+ def setCustomHttpHeader(header)
1637
+ unless /^.+:.+$/.match(header)
1638
+ 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);
1584
1639
  end
1585
1640
 
1586
- @fields['custom_http_header'] = custom_http_header
1641
+ @fields['custom_http_header'] = header
1587
1642
  self
1588
1643
  end
1589
1644
 
1590
1645
  # 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.
1591
1646
  #
1592
- # * +javascript_delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
1647
+ # * +delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
1593
1648
  # * *Returns* - The converter object.
1594
- def setJavascriptDelay(javascript_delay)
1595
- if (!(Integer(javascript_delay) >= 0))
1596
- 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);
1649
+ def setJavascriptDelay(delay)
1650
+ if (!(Integer(delay) >= 0))
1651
+ 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);
1597
1652
  end
1598
1653
 
1599
- @fields['javascript_delay'] = javascript_delay
1654
+ @fields['javascript_delay'] = delay
1600
1655
  self
1601
1656
  end
1602
1657
 
@@ -1606,20 +1661,20 @@ module Pdfcrowd
1606
1661
  # * *Returns* - The converter object.
1607
1662
  def setElementToConvert(selectors)
1608
1663
  if (!(!selectors.nil? && !selectors.empty?))
1609
- raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "selectors", "html-to-pdf", "The string must not be empty.", "set_element_to_convert"), 470);
1664
+ raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setElementToConvert", "html-to-pdf", "The string must not be empty.", "set_element_to_convert"), 470);
1610
1665
  end
1611
1666
 
1612
1667
  @fields['element_to_convert'] = selectors
1613
1668
  self
1614
1669
  end
1615
1670
 
1616
- # Specify the DOM handling when only a part of the document is converted.
1671
+ # Specify the DOM handling when only a part of the document is converted. This can affect the CSS rules used.
1617
1672
  #
1618
1673
  # * +mode+ - Allowed values are cut-out, remove-siblings, hide-siblings.
1619
1674
  # * *Returns* - The converter object.
1620
1675
  def setElementToConvertMode(mode)
1621
1676
  unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode)
1622
- 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);
1677
+ 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);
1623
1678
  end
1624
1679
 
1625
1680
  @fields['element_to_convert_mode'] = mode
@@ -1632,7 +1687,7 @@ module Pdfcrowd
1632
1687
  # * *Returns* - The converter object.
1633
1688
  def setWaitForElement(selectors)
1634
1689
  if (!(!selectors.nil? && !selectors.empty?))
1635
- raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "selectors", "html-to-pdf", "The string must not be empty.", "set_wait_for_element"), 470);
1690
+ raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setWaitForElement", "html-to-pdf", "The string must not be empty.", "set_wait_for_element"), 470);
1636
1691
  end
1637
1692
 
1638
1693
  @fields['wait_for_element'] = selectors
@@ -1641,27 +1696,27 @@ module Pdfcrowd
1641
1696
 
1642
1697
  # Set the viewport width in pixels. The viewport is the user's visible area of the page.
1643
1698
  #
1644
- # * +viewport_width+ - The value must be in the range 96-65000.
1699
+ # * +width+ - The value must be in the range 96-65000.
1645
1700
  # * *Returns* - The converter object.
1646
- def setViewportWidth(viewport_width)
1647
- if (!(Integer(viewport_width) >= 96 && Integer(viewport_width) <= 65000))
1648
- 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);
1701
+ def setViewportWidth(width)
1702
+ if (!(Integer(width) >= 96 && Integer(width) <= 65000))
1703
+ 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);
1649
1704
  end
1650
1705
 
1651
- @fields['viewport_width'] = viewport_width
1706
+ @fields['viewport_width'] = width
1652
1707
  self
1653
1708
  end
1654
1709
 
1655
1710
  # Set the viewport height in pixels. The viewport is the user's visible area of the page.
1656
1711
  #
1657
- # * +viewport_height+ - Must be a positive integer number.
1712
+ # * +height+ - Must be a positive integer number.
1658
1713
  # * *Returns* - The converter object.
1659
- def setViewportHeight(viewport_height)
1660
- if (!(Integer(viewport_height) > 0))
1661
- 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);
1714
+ def setViewportHeight(height)
1715
+ if (!(Integer(height) > 0))
1716
+ raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setViewportHeight", "html-to-pdf", "Must be a positive integer number.", "set_viewport_height"), 470);
1662
1717
  end
1663
1718
 
1664
- @fields['viewport_height'] = viewport_height
1719
+ @fields['viewport_height'] = height
1665
1720
  self
1666
1721
  end
1667
1722
 
@@ -1678,164 +1733,142 @@ module Pdfcrowd
1678
1733
 
1679
1734
  # Set the rendering mode.
1680
1735
  #
1681
- # * +rendering_mode+ - The rendering mode. Allowed values are default, viewport.
1736
+ # * +mode+ - The rendering mode. Allowed values are default, viewport.
1682
1737
  # * *Returns* - The converter object.
1683
- def setRenderingMode(rendering_mode)
1684
- unless /(?i)^(default|viewport)$/.match(rendering_mode)
1685
- raise Error.new(Pdfcrowd.create_invalid_value_message(rendering_mode, "rendering_mode", "html-to-pdf", "Allowed values are default, viewport.", "set_rendering_mode"), 470);
1738
+ def setRenderingMode(mode)
1739
+ unless /(?i)^(default|viewport)$/.match(mode)
1740
+ raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setRenderingMode", "html-to-pdf", "Allowed values are default, viewport.", "set_rendering_mode"), 470);
1686
1741
  end
1687
1742
 
1688
- @fields['rendering_mode'] = rendering_mode
1743
+ @fields['rendering_mode'] = mode
1689
1744
  self
1690
1745
  end
1691
1746
 
1692
1747
  # Specifies the scaling mode used for fitting the HTML contents to the print area.
1693
1748
  #
1694
- # * +smart_scaling_mode+ - The smart scaling mode. Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit.
1749
+ # * +mode+ - The smart scaling mode. Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, mode1.
1695
1750
  # * *Returns* - The converter object.
1696
- def setSmartScalingMode(smart_scaling_mode)
1697
- unless /(?i)^(default|disabled|viewport-fit|content-fit|single-page-fit)$/.match(smart_scaling_mode)
1698
- 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);
1751
+ def setSmartScalingMode(mode)
1752
+ unless /(?i)^(default|disabled|viewport-fit|content-fit|single-page-fit|mode1)$/.match(mode)
1753
+ 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);
1699
1754
  end
1700
1755
 
1701
- @fields['smart_scaling_mode'] = smart_scaling_mode
1756
+ @fields['smart_scaling_mode'] = mode
1702
1757
  self
1703
1758
  end
1704
1759
 
1705
1760
  # Set the scaling factor (zoom) for the main page area.
1706
1761
  #
1707
- # * +scale_factor+ - The percentage value. The value must be in the range 10-500.
1708
- # * *Returns* - The converter object.
1709
- def setScaleFactor(scale_factor)
1710
- if (!(Integer(scale_factor) >= 10 && Integer(scale_factor) <= 500))
1711
- 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);
1712
- end
1713
-
1714
- @fields['scale_factor'] = scale_factor
1715
- self
1716
- end
1717
-
1718
- # Set the scaling factor (zoom) for the header and footer.
1719
- #
1720
- # * +header_footer_scale_factor+ - The percentage value. The value must be in the range 10-500.
1762
+ # * +factor+ - The percentage value. The value must be in the range 10-500.
1721
1763
  # * *Returns* - The converter object.
1722
- def setHeaderFooterScaleFactor(header_footer_scale_factor)
1723
- if (!(Integer(header_footer_scale_factor) >= 10 && Integer(header_footer_scale_factor) <= 500))
1724
- 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);
1764
+ def setScaleFactor(factor)
1765
+ if (!(Integer(factor) >= 10 && Integer(factor) <= 500))
1766
+ 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);
1725
1767
  end
1726
1768
 
1727
- @fields['header_footer_scale_factor'] = header_footer_scale_factor
1728
- self
1729
- end
1730
-
1731
- # Disable the intelligent shrinking strategy that tries to optimally fit the HTML contents to a PDF page.
1732
- #
1733
- # * +disable_smart_shrinking+ - Set to true to disable the intelligent shrinking strategy.
1734
- # * *Returns* - The converter object.
1735
- def setDisableSmartShrinking(disable_smart_shrinking)
1736
- @fields['disable_smart_shrinking'] = disable_smart_shrinking
1769
+ @fields['scale_factor'] = factor
1737
1770
  self
1738
1771
  end
1739
1772
 
1740
1773
  # Set the quality of embedded JPEG images. A lower quality results in a smaller PDF file but can lead to compression artifacts.
1741
1774
  #
1742
- # * +jpeg_quality+ - The percentage value. The value must be in the range 1-100.
1775
+ # * +quality+ - The percentage value. The value must be in the range 1-100.
1743
1776
  # * *Returns* - The converter object.
1744
- def setJpegQuality(jpeg_quality)
1745
- if (!(Integer(jpeg_quality) >= 1 && Integer(jpeg_quality) <= 100))
1746
- 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);
1777
+ def setJpegQuality(quality)
1778
+ if (!(Integer(quality) >= 1 && Integer(quality) <= 100))
1779
+ 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);
1747
1780
  end
1748
1781
 
1749
- @fields['jpeg_quality'] = jpeg_quality
1782
+ @fields['jpeg_quality'] = quality
1750
1783
  self
1751
1784
  end
1752
1785
 
1753
1786
  # 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.
1754
1787
  #
1755
- # * +convert_images_to_jpeg+ - The image category. Allowed values are none, opaque, all.
1788
+ # * +images+ - The image category. Allowed values are none, opaque, all.
1756
1789
  # * *Returns* - The converter object.
1757
- def setConvertImagesToJpeg(convert_images_to_jpeg)
1758
- unless /(?i)^(none|opaque|all)$/.match(convert_images_to_jpeg)
1759
- 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);
1790
+ def setConvertImagesToJpeg(images)
1791
+ unless /(?i)^(none|opaque|all)$/.match(images)
1792
+ 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);
1760
1793
  end
1761
1794
 
1762
- @fields['convert_images_to_jpeg'] = convert_images_to_jpeg
1795
+ @fields['convert_images_to_jpeg'] = images
1763
1796
  self
1764
1797
  end
1765
1798
 
1766
1799
  # 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.
1767
1800
  #
1768
- # * +image_dpi+ - The DPI value. Must be a positive integer number or 0.
1801
+ # * +dpi+ - The DPI value. Must be a positive integer number or 0.
1769
1802
  # * *Returns* - The converter object.
1770
- def setImageDpi(image_dpi)
1771
- if (!(Integer(image_dpi) >= 0))
1772
- 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);
1803
+ def setImageDpi(dpi)
1804
+ if (!(Integer(dpi) >= 0))
1805
+ 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);
1773
1806
  end
1774
1807
 
1775
- @fields['image_dpi'] = image_dpi
1808
+ @fields['image_dpi'] = dpi
1776
1809
  self
1777
1810
  end
1778
1811
 
1779
1812
  # Create linearized PDF. This is also known as Fast Web View.
1780
1813
  #
1781
- # * +linearize+ - Set to true to create linearized PDF.
1814
+ # * +value+ - Set to true to create linearized PDF.
1782
1815
  # * *Returns* - The converter object.
1783
- def setLinearize(linearize)
1784
- @fields['linearize'] = linearize
1816
+ def setLinearize(value)
1817
+ @fields['linearize'] = value
1785
1818
  self
1786
1819
  end
1787
1820
 
1788
1821
  # Encrypt the PDF. This prevents search engines from indexing the contents.
1789
1822
  #
1790
- # * +encrypt+ - Set to true to enable PDF encryption.
1823
+ # * +value+ - Set to true to enable PDF encryption.
1791
1824
  # * *Returns* - The converter object.
1792
- def setEncrypt(encrypt)
1793
- @fields['encrypt'] = encrypt
1825
+ def setEncrypt(value)
1826
+ @fields['encrypt'] = value
1794
1827
  self
1795
1828
  end
1796
1829
 
1797
1830
  # 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.
1798
1831
  #
1799
- # * +user_password+ - The user password.
1832
+ # * +password+ - The user password.
1800
1833
  # * *Returns* - The converter object.
1801
- def setUserPassword(user_password)
1802
- @fields['user_password'] = user_password
1834
+ def setUserPassword(password)
1835
+ @fields['user_password'] = password
1803
1836
  self
1804
1837
  end
1805
1838
 
1806
1839
  # Protect the PDF with an owner password. Supplying an owner password grants unlimited access to the PDF including changing the passwords and access permissions.
1807
1840
  #
1808
- # * +owner_password+ - The owner password.
1841
+ # * +password+ - The owner password.
1809
1842
  # * *Returns* - The converter object.
1810
- def setOwnerPassword(owner_password)
1811
- @fields['owner_password'] = owner_password
1843
+ def setOwnerPassword(password)
1844
+ @fields['owner_password'] = password
1812
1845
  self
1813
1846
  end
1814
1847
 
1815
1848
  # Disallow printing of the output PDF.
1816
1849
  #
1817
- # * +no_print+ - Set to true to set the no-print flag in the output PDF.
1850
+ # * +value+ - Set to true to set the no-print flag in the output PDF.
1818
1851
  # * *Returns* - The converter object.
1819
- def setNoPrint(no_print)
1820
- @fields['no_print'] = no_print
1852
+ def setNoPrint(value)
1853
+ @fields['no_print'] = value
1821
1854
  self
1822
1855
  end
1823
1856
 
1824
1857
  # Disallow modification of the output PDF.
1825
1858
  #
1826
- # * +no_modify+ - Set to true to set the read-only only flag in the output PDF.
1859
+ # * +value+ - Set to true to set the read-only only flag in the output PDF.
1827
1860
  # * *Returns* - The converter object.
1828
- def setNoModify(no_modify)
1829
- @fields['no_modify'] = no_modify
1861
+ def setNoModify(value)
1862
+ @fields['no_modify'] = value
1830
1863
  self
1831
1864
  end
1832
1865
 
1833
1866
  # Disallow text and graphics extraction from the output PDF.
1834
1867
  #
1835
- # * +no_copy+ - Set to true to set the no-copy flag in the output PDF.
1868
+ # * +value+ - Set to true to set the no-copy flag in the output PDF.
1836
1869
  # * *Returns* - The converter object.
1837
- def setNoCopy(no_copy)
1838
- @fields['no_copy'] = no_copy
1870
+ def setNoCopy(value)
1871
+ @fields['no_copy'] = value
1839
1872
  self
1840
1873
  end
1841
1874
 
@@ -1875,140 +1908,225 @@ module Pdfcrowd
1875
1908
  self
1876
1909
  end
1877
1910
 
1911
+ # Extract meta tags (author, keywords and description) from the input HTML and use them in the output PDF.
1912
+ #
1913
+ # * +value+ - Set to true to extract meta tags.
1914
+ # * *Returns* - The converter object.
1915
+ def setExtractMetaTags(value)
1916
+ @fields['extract_meta_tags'] = value
1917
+ self
1918
+ end
1919
+
1878
1920
  # Specify the page layout to be used when the document is opened.
1879
1921
  #
1880
- # * +page_layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
1922
+ # * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
1881
1923
  # * *Returns* - The converter object.
1882
- def setPageLayout(page_layout)
1883
- unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(page_layout)
1884
- 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);
1924
+ def setPageLayout(layout)
1925
+ unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout)
1926
+ 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);
1885
1927
  end
1886
1928
 
1887
- @fields['page_layout'] = page_layout
1929
+ @fields['page_layout'] = layout
1888
1930
  self
1889
1931
  end
1890
1932
 
1891
1933
  # Specify how the document should be displayed when opened.
1892
1934
  #
1893
- # * +page_mode+ - Allowed values are full-screen, thumbnails, outlines.
1935
+ # * +mode+ - Allowed values are full-screen, thumbnails, outlines.
1894
1936
  # * *Returns* - The converter object.
1895
- def setPageMode(page_mode)
1896
- unless /(?i)^(full-screen|thumbnails|outlines)$/.match(page_mode)
1897
- 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);
1937
+ def setPageMode(mode)
1938
+ unless /(?i)^(full-screen|thumbnails|outlines)$/.match(mode)
1939
+ raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setPageMode", "html-to-pdf", "Allowed values are full-screen, thumbnails, outlines.", "set_page_mode"), 470);
1898
1940
  end
1899
1941
 
1900
- @fields['page_mode'] = page_mode
1942
+ @fields['page_mode'] = mode
1901
1943
  self
1902
1944
  end
1903
1945
 
1904
1946
  # Specify how the page should be displayed when opened.
1905
1947
  #
1906
- # * +initial_zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
1948
+ # * +zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
1907
1949
  # * *Returns* - The converter object.
1908
- def setInitialZoomType(initial_zoom_type)
1909
- unless /(?i)^(fit-width|fit-height|fit-page)$/.match(initial_zoom_type)
1910
- 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);
1950
+ def setInitialZoomType(zoom_type)
1951
+ unless /(?i)^(fit-width|fit-height|fit-page)$/.match(zoom_type)
1952
+ 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);
1911
1953
  end
1912
1954
 
1913
- @fields['initial_zoom_type'] = initial_zoom_type
1955
+ @fields['initial_zoom_type'] = zoom_type
1914
1956
  self
1915
1957
  end
1916
1958
 
1917
1959
  # Display the specified page when the document is opened.
1918
1960
  #
1919
- # * +initial_page+ - Must be a positive integer number.
1961
+ # * +page+ - Must be a positive integer number.
1920
1962
  # * *Returns* - The converter object.
1921
- def setInitialPage(initial_page)
1922
- if (!(Integer(initial_page) > 0))
1923
- 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);
1963
+ def setInitialPage(page)
1964
+ if (!(Integer(page) > 0))
1965
+ raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "html-to-pdf", "Must be a positive integer number.", "set_initial_page"), 470);
1924
1966
  end
1925
1967
 
1926
- @fields['initial_page'] = initial_page
1968
+ @fields['initial_page'] = page
1927
1969
  self
1928
1970
  end
1929
1971
 
1930
1972
  # Specify the initial page zoom in percents when the document is opened.
1931
1973
  #
1932
- # * +initial_zoom+ - Must be a positive integer number.
1974
+ # * +zoom+ - Must be a positive integer number.
1933
1975
  # * *Returns* - The converter object.
1934
- def setInitialZoom(initial_zoom)
1935
- if (!(Integer(initial_zoom) > 0))
1936
- 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);
1976
+ def setInitialZoom(zoom)
1977
+ if (!(Integer(zoom) > 0))
1978
+ raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "html-to-pdf", "Must be a positive integer number.", "set_initial_zoom"), 470);
1937
1979
  end
1938
1980
 
1939
- @fields['initial_zoom'] = initial_zoom
1981
+ @fields['initial_zoom'] = zoom
1940
1982
  self
1941
1983
  end
1942
1984
 
1943
1985
  # Specify whether to hide the viewer application's tool bars when the document is active.
1944
1986
  #
1945
- # * +hide_toolbar+ - Set to true to hide tool bars.
1987
+ # * +value+ - Set to true to hide tool bars.
1946
1988
  # * *Returns* - The converter object.
1947
- def setHideToolbar(hide_toolbar)
1948
- @fields['hide_toolbar'] = hide_toolbar
1989
+ def setHideToolbar(value)
1990
+ @fields['hide_toolbar'] = value
1949
1991
  self
1950
1992
  end
1951
1993
 
1952
1994
  # Specify whether to hide the viewer application's menu bar when the document is active.
1953
1995
  #
1954
- # * +hide_menubar+ - Set to true to hide the menu bar.
1996
+ # * +value+ - Set to true to hide the menu bar.
1955
1997
  # * *Returns* - The converter object.
1956
- def setHideMenubar(hide_menubar)
1957
- @fields['hide_menubar'] = hide_menubar
1998
+ def setHideMenubar(value)
1999
+ @fields['hide_menubar'] = value
1958
2000
  self
1959
2001
  end
1960
2002
 
1961
2003
  # 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.
1962
2004
  #
1963
- # * +hide_window_ui+ - Set to true to hide ui elements.
2005
+ # * +value+ - Set to true to hide ui elements.
1964
2006
  # * *Returns* - The converter object.
1965
- def setHideWindowUi(hide_window_ui)
1966
- @fields['hide_window_ui'] = hide_window_ui
2007
+ def setHideWindowUi(value)
2008
+ @fields['hide_window_ui'] = value
1967
2009
  self
1968
2010
  end
1969
2011
 
1970
2012
  # Specify whether to resize the document's window to fit the size of the first displayed page.
1971
2013
  #
1972
- # * +fit_window+ - Set to true to resize the window.
2014
+ # * +value+ - Set to true to resize the window.
1973
2015
  # * *Returns* - The converter object.
1974
- def setFitWindow(fit_window)
1975
- @fields['fit_window'] = fit_window
2016
+ def setFitWindow(value)
2017
+ @fields['fit_window'] = value
1976
2018
  self
1977
2019
  end
1978
2020
 
1979
2021
  # Specify whether to position the document's window in the center of the screen.
1980
2022
  #
1981
- # * +center_window+ - Set to true to center the window.
2023
+ # * +value+ - Set to true to center the window.
1982
2024
  # * *Returns* - The converter object.
1983
- def setCenterWindow(center_window)
1984
- @fields['center_window'] = center_window
2025
+ def setCenterWindow(value)
2026
+ @fields['center_window'] = value
1985
2027
  self
1986
2028
  end
1987
2029
 
1988
2030
  # 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.
1989
2031
  #
1990
- # * +display_title+ - Set to true to display the title.
2032
+ # * +value+ - Set to true to display the title.
1991
2033
  # * *Returns* - The converter object.
1992
- def setDisplayTitle(display_title)
1993
- @fields['display_title'] = display_title
2034
+ def setDisplayTitle(value)
2035
+ @fields['display_title'] = value
1994
2036
  self
1995
2037
  end
1996
2038
 
1997
2039
  # 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
1998
2040
  #
1999
- # * +right_to_left+ - Set to true to set right-to-left reading order.
2041
+ # * +value+ - Set to true to set right-to-left reading order.
2042
+ # * *Returns* - The converter object.
2043
+ def setRightToLeft(value)
2044
+ @fields['right_to_left'] = value
2045
+ self
2046
+ end
2047
+
2048
+ # Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
2049
+ #
2050
+ # * +data_string+ - The input data string.
2051
+ # * *Returns* - The converter object.
2052
+ def setDataString(data_string)
2053
+ @fields['data_string'] = data_string
2054
+ self
2055
+ end
2056
+
2057
+ # Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
2058
+ #
2059
+ # * +data_file+ - The file path to a local file containing the input data.
2060
+ # * *Returns* - The converter object.
2061
+ def setDataFile(data_file)
2062
+ @files['data_file'] = data_file
2063
+ self
2064
+ end
2065
+
2066
+ # Specify the input data format.
2067
+ #
2068
+ # * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
2069
+ # * *Returns* - The converter object.
2070
+ def setDataFormat(data_format)
2071
+ unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
2072
+ 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);
2073
+ end
2074
+
2075
+ @fields['data_format'] = data_format
2076
+ self
2077
+ end
2078
+
2079
+ # Set the encoding of the data file set by setDataFile.
2080
+ #
2081
+ # * +encoding+ - The data file encoding.
2082
+ # * *Returns* - The converter object.
2083
+ def setDataEncoding(encoding)
2084
+ @fields['data_encoding'] = encoding
2085
+ self
2086
+ end
2087
+
2088
+ # 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.
2089
+ #
2090
+ # * +value+ - Set to true to ignore undefined variables.
2091
+ # * *Returns* - The converter object.
2092
+ def setDataIgnoreUndefined(value)
2093
+ @fields['data_ignore_undefined'] = value
2094
+ self
2095
+ end
2096
+
2097
+ # Auto escape HTML symbols in the input data before placing them into the output.
2098
+ #
2099
+ # * +value+ - Set to true to turn auto escaping on.
2100
+ # * *Returns* - The converter object.
2101
+ def setDataAutoEscape(value)
2102
+ @fields['data_auto_escape'] = value
2103
+ self
2104
+ end
2105
+
2106
+ # Auto trim whitespace around each template command block.
2107
+ #
2108
+ # * +value+ - Set to true to turn auto trimming on.
2000
2109
  # * *Returns* - The converter object.
2001
- def setRightToLeft(right_to_left)
2002
- @fields['right_to_left'] = right_to_left
2110
+ def setDataTrimBlocks(value)
2111
+ @fields['data_trim_blocks'] = value
2112
+ self
2113
+ end
2114
+
2115
+ # 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.
2116
+ #
2117
+ # * +options+ - Comma separated list of options.
2118
+ # * *Returns* - The converter object.
2119
+ def setDataOptions(options)
2120
+ @fields['data_options'] = options
2003
2121
  self
2004
2122
  end
2005
2123
 
2006
2124
  # 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.
2007
2125
  #
2008
- # * +debug_log+ - Set to true to enable the debug logging.
2126
+ # * +value+ - Set to true to enable the debug logging.
2009
2127
  # * *Returns* - The converter object.
2010
- def setDebugLog(debug_log)
2011
- @fields['debug_log'] = debug_log
2128
+ def setDebugLog(value)
2129
+ @fields['debug_log'] = value
2012
2130
  self
2013
2131
  end
2014
2132
 
@@ -2051,6 +2169,12 @@ module Pdfcrowd
2051
2169
  return @helper.getOutputSize()
2052
2170
  end
2053
2171
 
2172
+ # Get the version details.
2173
+ # * *Returns* - API version, converter version, and client version.
2174
+ def getVersion()
2175
+ return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
2176
+ end
2177
+
2054
2178
  # Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
2055
2179
  #
2056
2180
  # * +tag+ - A string with the custom tag.
@@ -2062,68 +2186,149 @@ module Pdfcrowd
2062
2186
 
2063
2187
  # 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.
2064
2188
  #
2065
- # * +http_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2189
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2066
2190
  # * *Returns* - The converter object.
2067
- def setHttpProxy(http_proxy)
2068
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(http_proxy)
2069
- 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);
2191
+ def setHttpProxy(proxy)
2192
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
2193
+ 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);
2070
2194
  end
2071
2195
 
2072
- @fields['http_proxy'] = http_proxy
2196
+ @fields['http_proxy'] = proxy
2073
2197
  self
2074
2198
  end
2075
2199
 
2076
2200
  # 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.
2077
2201
  #
2078
- # * +https_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2202
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2079
2203
  # * *Returns* - The converter object.
2080
- def setHttpsProxy(https_proxy)
2081
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(https_proxy)
2082
- 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);
2204
+ def setHttpsProxy(proxy)
2205
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
2206
+ 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);
2083
2207
  end
2084
2208
 
2085
- @fields['https_proxy'] = https_proxy
2209
+ @fields['https_proxy'] = proxy
2086
2210
  self
2087
2211
  end
2088
2212
 
2089
2213
  # 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.
2090
2214
  #
2091
- # * +client_certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
2215
+ # * +certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
2092
2216
  # * *Returns* - The converter object.
2093
- def setClientCertificate(client_certificate)
2094
- if (!(File.file?(client_certificate) && !File.zero?(client_certificate)))
2095
- 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);
2217
+ def setClientCertificate(certificate)
2218
+ if (!(File.file?(certificate) && !File.zero?(certificate)))
2219
+ 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);
2096
2220
  end
2097
2221
 
2098
- @files['client_certificate'] = client_certificate
2222
+ @files['client_certificate'] = certificate
2099
2223
  self
2100
2224
  end
2101
2225
 
2102
2226
  # A password for PKCS12 file with a client certificate if it is needed.
2103
2227
  #
2104
- # * +client_certificate_password+ -
2228
+ # * +password+ -
2229
+ # * *Returns* - The converter object.
2230
+ def setClientCertificatePassword(password)
2231
+ @fields['client_certificate_password'] = password
2232
+ self
2233
+ end
2234
+
2235
+ # 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.
2236
+ #
2237
+ # * +dpi+ - The DPI value. The value must be in the range of 72-600.
2238
+ # * *Returns* - The converter object.
2239
+ def setLayoutDpi(dpi)
2240
+ if (!(Integer(dpi) >= 72 && Integer(dpi) <= 600))
2241
+ 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);
2242
+ end
2243
+
2244
+ @fields['layout_dpi'] = dpi
2245
+ self
2246
+ end
2247
+
2248
+ # 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.
2249
+ #
2250
+ # * +matrix+ - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"
2251
+ # * *Returns* - The converter object.
2252
+ def setContentsMatrix(matrix)
2253
+ @fields['contents_matrix'] = matrix
2254
+ self
2255
+ end
2256
+
2257
+ # 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.
2258
+ #
2259
+ # * +matrix+ - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"
2260
+ # * *Returns* - The converter object.
2261
+ def setHeaderMatrix(matrix)
2262
+ @fields['header_matrix'] = matrix
2263
+ self
2264
+ end
2265
+
2266
+ # 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.
2267
+ #
2268
+ # * +matrix+ - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"
2269
+ # * *Returns* - The converter object.
2270
+ def setFooterMatrix(matrix)
2271
+ @fields['footer_matrix'] = matrix
2272
+ self
2273
+ end
2274
+
2275
+ # Disable automatic height adjustment that compensates for pixel to point rounding errors.
2276
+ #
2277
+ # * +value+ - Set to true to disable automatic height scale.
2278
+ # * *Returns* - The converter object.
2279
+ def setDisablePageHeightOptimization(value)
2280
+ @fields['disable_page_height_optimization'] = value
2281
+ self
2282
+ end
2283
+
2284
+ # 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
2285
+ # 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.
2286
+ #
2287
+ # * +value+ - Set to true to add the special CSS classes.
2288
+ # * *Returns* - The converter object.
2289
+ def setMainDocumentCssAnnotation(value)
2290
+ @fields['main_document_css_annotation'] = value
2291
+ self
2292
+ end
2293
+
2294
+ # 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
2295
+ #
2296
+ # * +value+ - Set to true to add the special CSS classes.
2105
2297
  # * *Returns* - The converter object.
2106
- def setClientCertificatePassword(client_certificate_password)
2107
- @fields['client_certificate_password'] = client_certificate_password
2298
+ def setHeaderFooterCssAnnotation(value)
2299
+ @fields['header_footer_css_annotation'] = value
2300
+ self
2301
+ end
2302
+
2303
+ # Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
2304
+ #
2305
+ # * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
2306
+ # * *Returns* - The converter object.
2307
+ def setConverterVersion(version)
2308
+ unless /(?i)^(latest|20.10|18.10)$/.match(version)
2309
+ 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);
2310
+ end
2311
+
2312
+ @helper.setConverterVersion(version)
2108
2313
  self
2109
2314
  end
2110
2315
 
2111
2316
  # Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
2112
2317
  # Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
2113
2318
  #
2114
- # * +use_http+ - Set to true to use HTTP.
2319
+ # * +value+ - Set to true to use HTTP.
2115
2320
  # * *Returns* - The converter object.
2116
- def setUseHttp(use_http)
2117
- @helper.setUseHttp(use_http)
2321
+ def setUseHttp(value)
2322
+ @helper.setUseHttp(value)
2118
2323
  self
2119
2324
  end
2120
2325
 
2121
- # Set a custom user agent HTTP header. It can be usefull if you are behind some proxy or firewall.
2326
+ # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
2122
2327
  #
2123
- # * +user_agent+ - The user agent string.
2328
+ # * +agent+ - The user agent string.
2124
2329
  # * *Returns* - The converter object.
2125
- def setUserAgent(user_agent)
2126
- @helper.setUserAgent(user_agent)
2330
+ def setUserAgent(agent)
2331
+ @helper.setUserAgent(agent)
2127
2332
  self
2128
2333
  end
2129
2334
 
@@ -2141,10 +2346,10 @@ module Pdfcrowd
2141
2346
 
2142
2347
  # 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.
2143
2348
  #
2144
- # * +retry_count+ - Number of retries wanted.
2349
+ # * +count+ - Number of retries wanted.
2145
2350
  # * *Returns* - The converter object.
2146
- def setRetryCount(retry_count)
2147
- @helper.setRetryCount(retry_count)
2351
+ def setRetryCount(count)
2352
+ @helper.setRetryCount(count)
2148
2353
  self
2149
2354
  end
2150
2355
 
@@ -2173,7 +2378,7 @@ module Pdfcrowd
2173
2378
  # * *Returns* - The converter object.
2174
2379
  def setOutputFormat(output_format)
2175
2380
  unless /(?i)^(png|jpg|gif|tiff|bmp|ico|ppm|pgm|pbm|pnm|psb|pct|ras|tga|sgi|sun|webp)$/.match(output_format)
2176
- 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);
2381
+ 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);
2177
2382
  end
2178
2383
 
2179
2384
  @fields['output_format'] = output_format
@@ -2186,7 +2391,7 @@ module Pdfcrowd
2186
2391
  # * *Returns* - Byte array containing the conversion output.
2187
2392
  def convertUrl(url)
2188
2393
  unless /(?i)^https?:\/\/.*$/.match(url)
2189
- raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "html-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
2394
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "html-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
2190
2395
  end
2191
2396
 
2192
2397
  @fields['url'] = url
@@ -2199,7 +2404,7 @@ module Pdfcrowd
2199
2404
  # * +out_stream+ - The output stream that will contain the conversion output.
2200
2405
  def convertUrlToStream(url, out_stream)
2201
2406
  unless /(?i)^https?:\/\/.*$/.match(url)
2202
- 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);
2407
+ 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);
2203
2408
  end
2204
2409
 
2205
2410
  @fields['url'] = url
@@ -2212,7 +2417,7 @@ module Pdfcrowd
2212
2417
  # * +file_path+ - The output file path. The string must not be empty.
2213
2418
  def convertUrlToFile(url, file_path)
2214
2419
  if (!(!file_path.nil? && !file_path.empty?))
2215
- 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);
2420
+ 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);
2216
2421
  end
2217
2422
 
2218
2423
  output_file = open(file_path, "wb")
@@ -2232,7 +2437,7 @@ module Pdfcrowd
2232
2437
  # * *Returns* - Byte array containing the conversion output.
2233
2438
  def convertFile(file)
2234
2439
  if (!(File.file?(file) && !File.zero?(file)))
2235
- raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-image", "The file must exist and not be empty.", "convert_file"), 470);
2440
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "html-to-image", "The file must exist and not be empty.", "convert_file"), 470);
2236
2441
  end
2237
2442
 
2238
2443
  @files['file'] = file
@@ -2245,7 +2450,7 @@ module Pdfcrowd
2245
2450
  # * +out_stream+ - The output stream that will contain the conversion output.
2246
2451
  def convertFileToStream(file, out_stream)
2247
2452
  if (!(File.file?(file) && !File.zero?(file)))
2248
- 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);
2453
+ 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);
2249
2454
  end
2250
2455
 
2251
2456
  @files['file'] = file
@@ -2258,7 +2463,7 @@ module Pdfcrowd
2258
2463
  # * +file_path+ - The output file path. The string must not be empty.
2259
2464
  def convertFileToFile(file, file_path)
2260
2465
  if (!(!file_path.nil? && !file_path.empty?))
2261
- 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);
2466
+ 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);
2262
2467
  end
2263
2468
 
2264
2469
  output_file = open(file_path, "wb")
@@ -2278,7 +2483,7 @@ module Pdfcrowd
2278
2483
  # * *Returns* - Byte array containing the conversion output.
2279
2484
  def convertString(text)
2280
2485
  if (!(!text.nil? && !text.empty?))
2281
- raise Error.new(Pdfcrowd.create_invalid_value_message(text, "text", "html-to-image", "The string must not be empty.", "convert_string"), 470);
2486
+ raise Error.new(Pdfcrowd.create_invalid_value_message(text, "convertString", "html-to-image", "The string must not be empty.", "convert_string"), 470);
2282
2487
  end
2283
2488
 
2284
2489
  @fields['text'] = text
@@ -2291,7 +2496,7 @@ module Pdfcrowd
2291
2496
  # * +out_stream+ - The output stream that will contain the conversion output.
2292
2497
  def convertStringToStream(text, out_stream)
2293
2498
  if (!(!text.nil? && !text.empty?))
2294
- raise Error.new(Pdfcrowd.create_invalid_value_message(text, "text", "html-to-image", "The string must not be empty.", "convert_string_to_stream"), 470);
2499
+ 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);
2295
2500
  end
2296
2501
 
2297
2502
  @fields['text'] = text
@@ -2304,7 +2509,7 @@ module Pdfcrowd
2304
2509
  # * +file_path+ - The output file path. The string must not be empty.
2305
2510
  def convertStringToFile(text, file_path)
2306
2511
  if (!(!file_path.nil? && !file_path.empty?))
2307
- 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);
2512
+ 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);
2308
2513
  end
2309
2514
 
2310
2515
  output_file = open(file_path, "wb")
@@ -2318,133 +2523,135 @@ module Pdfcrowd
2318
2523
  end
2319
2524
  end
2320
2525
 
2321
- # Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
2526
+ # Convert the contents of an input stream.
2322
2527
  #
2323
- # * +data_string+ - The input data string.
2324
- # * *Returns* - The converter object.
2325
- def setDataString(data_string)
2326
- @fields['data_string'] = data_string
2327
- self
2528
+ # * +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).
2529
+ # * *Returns* - Byte array containing the conversion output.
2530
+ def convertStream(in_stream)
2531
+ @raw_data['stream'] = in_stream.read
2532
+ @helper.post(@fields, @files, @raw_data)
2328
2533
  end
2329
2534
 
2330
- # Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
2535
+ # Convert the contents of an input stream and write the result to an output stream.
2331
2536
  #
2332
- # * +data_file+ - The file path to a local file containing the input data.
2333
- # * *Returns* - The converter object.
2334
- def setDataFile(data_file)
2335
- @files['data_file'] = data_file
2336
- self
2537
+ # * +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).
2538
+ # * +out_stream+ - The output stream that will contain the conversion output.
2539
+ def convertStreamToStream(in_stream, out_stream)
2540
+ @raw_data['stream'] = in_stream.read
2541
+ @helper.post(@fields, @files, @raw_data, out_stream)
2337
2542
  end
2338
2543
 
2339
- # Specify the input data format.
2544
+ # Convert the contents of an input stream and write the result to a local file.
2340
2545
  #
2341
- # * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
2342
- # * *Returns* - The converter object.
2343
- def setDataFormat(data_format)
2344
- unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
2345
- raise Error.new(Pdfcrowd.create_invalid_value_message(data_format, "data_format", "html-to-image", "Allowed values are auto, json, xml, yaml, csv.", "set_data_format"), 470);
2546
+ # * +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).
2547
+ # * +file_path+ - The output file path. The string must not be empty.
2548
+ def convertStreamToFile(in_stream, file_path)
2549
+ if (!(!file_path.nil? && !file_path.empty?))
2550
+ 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);
2346
2551
  end
2347
2552
 
2348
- @fields['data_format'] = data_format
2349
- self
2350
- end
2351
-
2352
- # Set the encoding of the data file set by setDataFile.
2353
- #
2354
- # * +data_encoding+ - The data file encoding.
2355
- # * *Returns* - The converter object.
2356
- def setDataEncoding(data_encoding)
2357
- @fields['data_encoding'] = data_encoding
2358
- self
2553
+ output_file = open(file_path, "wb")
2554
+ begin
2555
+ convertStreamToStream(in_stream, output_file)
2556
+ output_file.close()
2557
+ rescue Error => why
2558
+ output_file.close()
2559
+ FileUtils.rm(file_path)
2560
+ raise
2561
+ end
2359
2562
  end
2360
2563
 
2361
- # 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.
2564
+ # Set the file name of the main HTML document stored in the input archive. If not specified, the first HTML file in the archive is used for conversion. Use this method if the input archive contains multiple HTML documents.
2362
2565
  #
2363
- # * +data_ignore_undefined+ - Set to true to ignore undefined variables.
2566
+ # * +filename+ - The file name.
2364
2567
  # * *Returns* - The converter object.
2365
- def setDataIgnoreUndefined(data_ignore_undefined)
2366
- @fields['data_ignore_undefined'] = data_ignore_undefined
2568
+ def setZipMainFilename(filename)
2569
+ @fields['zip_main_filename'] = filename
2367
2570
  self
2368
2571
  end
2369
2572
 
2370
- # Auto escape HTML symbols in the input data before placing them into the output.
2573
+ # Use the print version of the page if available (@media print).
2371
2574
  #
2372
- # * +data_auto_escape+ - Set to true to turn auto escaping on.
2575
+ # * +value+ - Set to true to use the print version of the page.
2373
2576
  # * *Returns* - The converter object.
2374
- def setDataAutoEscape(data_auto_escape)
2375
- @fields['data_auto_escape'] = data_auto_escape
2577
+ def setUsePrintMedia(value)
2578
+ @fields['use_print_media'] = value
2376
2579
  self
2377
2580
  end
2378
2581
 
2379
- # Auto trim whitespace around each template command block.
2582
+ # Do not print the background graphics.
2380
2583
  #
2381
- # * +data_trim_blocks+ - Set to true to turn auto trimming on.
2584
+ # * +value+ - Set to true to disable the background graphics.
2382
2585
  # * *Returns* - The converter object.
2383
- def setDataTrimBlocks(data_trim_blocks)
2384
- @fields['data_trim_blocks'] = data_trim_blocks
2586
+ def setNoBackground(value)
2587
+ @fields['no_background'] = value
2385
2588
  self
2386
2589
  end
2387
2590
 
2388
- # 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.
2591
+ # Do not execute JavaScript.
2389
2592
  #
2390
- # * +data_options+ - Comma separated list of options.
2593
+ # * +value+ - Set to true to disable JavaScript in web pages.
2391
2594
  # * *Returns* - The converter object.
2392
- def setDataOptions(data_options)
2393
- @fields['data_options'] = data_options
2595
+ def setDisableJavascript(value)
2596
+ @fields['disable_javascript'] = value
2394
2597
  self
2395
2598
  end
2396
2599
 
2397
- # Do not print the background graphics.
2600
+ # Do not load images.
2398
2601
  #
2399
- # * +no_background+ - Set to true to disable the background graphics.
2602
+ # * +value+ - Set to true to disable loading of images.
2400
2603
  # * *Returns* - The converter object.
2401
- def setNoBackground(no_background)
2402
- @fields['no_background'] = no_background
2604
+ def setDisableImageLoading(value)
2605
+ @fields['disable_image_loading'] = value
2403
2606
  self
2404
2607
  end
2405
2608
 
2406
- # Do not execute JavaScript.
2609
+ # Disable loading fonts from remote sources.
2407
2610
  #
2408
- # * +disable_javascript+ - Set to true to disable JavaScript in web pages.
2611
+ # * +value+ - Set to true disable loading remote fonts.
2409
2612
  # * *Returns* - The converter object.
2410
- def setDisableJavascript(disable_javascript)
2411
- @fields['disable_javascript'] = disable_javascript
2613
+ def setDisableRemoteFonts(value)
2614
+ @fields['disable_remote_fonts'] = value
2412
2615
  self
2413
2616
  end
2414
2617
 
2415
- # Do not load images.
2618
+ # Specifies how iframes are handled.
2416
2619
  #
2417
- # * +disable_image_loading+ - Set to true to disable loading of images.
2620
+ # * +iframes+ - Allowed values are all, same-origin, none.
2418
2621
  # * *Returns* - The converter object.
2419
- def setDisableImageLoading(disable_image_loading)
2420
- @fields['disable_image_loading'] = disable_image_loading
2622
+ def setLoadIframes(iframes)
2623
+ unless /(?i)^(all|same-origin|none)$/.match(iframes)
2624
+ raise Error.new(Pdfcrowd.create_invalid_value_message(iframes, "setLoadIframes", "html-to-image", "Allowed values are all, same-origin, none.", "set_load_iframes"), 470);
2625
+ end
2626
+
2627
+ @fields['load_iframes'] = iframes
2421
2628
  self
2422
2629
  end
2423
2630
 
2424
- # Disable loading fonts from remote sources.
2631
+ # Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
2425
2632
  #
2426
- # * +disable_remote_fonts+ - Set to true disable loading remote fonts.
2633
+ # * +value+ - Set to true to block ads in web pages.
2427
2634
  # * *Returns* - The converter object.
2428
- def setDisableRemoteFonts(disable_remote_fonts)
2429
- @fields['disable_remote_fonts'] = disable_remote_fonts
2635
+ def setBlockAds(value)
2636
+ @fields['block_ads'] = value
2430
2637
  self
2431
2638
  end
2432
2639
 
2433
- # Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
2640
+ # Set the default HTML content text encoding.
2434
2641
  #
2435
- # * +block_ads+ - Set to true to block ads in web pages.
2642
+ # * +encoding+ - The text encoding of the HTML content.
2436
2643
  # * *Returns* - The converter object.
2437
- def setBlockAds(block_ads)
2438
- @fields['block_ads'] = block_ads
2644
+ def setDefaultEncoding(encoding)
2645
+ @fields['default_encoding'] = encoding
2439
2646
  self
2440
2647
  end
2441
2648
 
2442
- # Set the default HTML content text encoding.
2649
+ # Set the locale for the conversion. This may affect the output format of dates, times and numbers.
2443
2650
  #
2444
- # * +default_encoding+ - The text encoding of the HTML content.
2651
+ # * +locale+ - The locale code according to ISO 639.
2445
2652
  # * *Returns* - The converter object.
2446
- def setDefaultEncoding(default_encoding)
2447
- @fields['default_encoding'] = default_encoding
2653
+ def setLocale(locale)
2654
+ @fields['locale'] = locale
2448
2655
  self
2449
2656
  end
2450
2657
 
@@ -2477,24 +2684,6 @@ module Pdfcrowd
2477
2684
  self
2478
2685
  end
2479
2686
 
2480
- # Use the print version of the page if available (@media print).
2481
- #
2482
- # * +use_print_media+ - Set to true to use the print version of the page.
2483
- # * *Returns* - The converter object.
2484
- def setUsePrintMedia(use_print_media)
2485
- @fields['use_print_media'] = use_print_media
2486
- self
2487
- end
2488
-
2489
- # Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
2490
- #
2491
- # * +no_xpdfcrowd_header+ - Set to true to disable sending X-Pdfcrowd HTTP header.
2492
- # * *Returns* - The converter object.
2493
- def setNoXpdfcrowdHeader(no_xpdfcrowd_header)
2494
- @fields['no_xpdfcrowd_header'] = no_xpdfcrowd_header
2495
- self
2496
- end
2497
-
2498
2687
  # Set cookies that are sent in Pdfcrowd HTTP requests.
2499
2688
  #
2500
2689
  # * +cookies+ - The cookie string.
@@ -2506,10 +2695,10 @@ module Pdfcrowd
2506
2695
 
2507
2696
  # Do not allow insecure HTTPS connections.
2508
2697
  #
2509
- # * +verify_ssl_certificates+ - Set to true to enable SSL certificate verification.
2698
+ # * +value+ - Set to true to enable SSL certificate verification.
2510
2699
  # * *Returns* - The converter object.
2511
- def setVerifySslCertificates(verify_ssl_certificates)
2512
- @fields['verify_ssl_certificates'] = verify_ssl_certificates
2700
+ def setVerifySslCertificates(value)
2701
+ @fields['verify_ssl_certificates'] = value
2513
2702
  self
2514
2703
  end
2515
2704
 
@@ -2531,55 +2720,64 @@ module Pdfcrowd
2531
2720
  self
2532
2721
  end
2533
2722
 
2723
+ # Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
2724
+ #
2725
+ # * +value+ - Set to true to disable sending X-Pdfcrowd HTTP header.
2726
+ # * *Returns* - The converter object.
2727
+ def setNoXpdfcrowdHeader(value)
2728
+ @fields['no_xpdfcrowd_header'] = value
2729
+ self
2730
+ end
2731
+
2534
2732
  # 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.
2535
2733
  #
2536
- # * +custom_javascript+ - A string containing a JavaScript code. The string must not be empty.
2734
+ # * +javascript+ - A string containing a JavaScript code. The string must not be empty.
2537
2735
  # * *Returns* - The converter object.
2538
- def setCustomJavascript(custom_javascript)
2539
- if (!(!custom_javascript.nil? && !custom_javascript.empty?))
2540
- 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);
2736
+ def setCustomJavascript(javascript)
2737
+ if (!(!javascript.nil? && !javascript.empty?))
2738
+ raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setCustomJavascript", "html-to-image", "The string must not be empty.", "set_custom_javascript"), 470);
2541
2739
  end
2542
2740
 
2543
- @fields['custom_javascript'] = custom_javascript
2741
+ @fields['custom_javascript'] = javascript
2544
2742
  self
2545
2743
  end
2546
2744
 
2547
2745
  # 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.
2548
2746
  #
2549
- # * +on_load_javascript+ - A string containing a JavaScript code. The string must not be empty.
2747
+ # * +javascript+ - A string containing a JavaScript code. The string must not be empty.
2550
2748
  # * *Returns* - The converter object.
2551
- def setOnLoadJavascript(on_load_javascript)
2552
- if (!(!on_load_javascript.nil? && !on_load_javascript.empty?))
2553
- 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);
2749
+ def setOnLoadJavascript(javascript)
2750
+ if (!(!javascript.nil? && !javascript.empty?))
2751
+ raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setOnLoadJavascript", "html-to-image", "The string must not be empty.", "set_on_load_javascript"), 470);
2554
2752
  end
2555
2753
 
2556
- @fields['on_load_javascript'] = on_load_javascript
2754
+ @fields['on_load_javascript'] = javascript
2557
2755
  self
2558
2756
  end
2559
2757
 
2560
2758
  # Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
2561
2759
  #
2562
- # * +custom_http_header+ - A string containing the header name and value separated by a colon.
2760
+ # * +header+ - A string containing the header name and value separated by a colon.
2563
2761
  # * *Returns* - The converter object.
2564
- def setCustomHttpHeader(custom_http_header)
2565
- unless /^.+:.+$/.match(custom_http_header)
2566
- 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);
2762
+ def setCustomHttpHeader(header)
2763
+ unless /^.+:.+$/.match(header)
2764
+ 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);
2567
2765
  end
2568
2766
 
2569
- @fields['custom_http_header'] = custom_http_header
2767
+ @fields['custom_http_header'] = header
2570
2768
  self
2571
2769
  end
2572
2770
 
2573
2771
  # 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.
2574
2772
  #
2575
- # * +javascript_delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
2773
+ # * +delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
2576
2774
  # * *Returns* - The converter object.
2577
- def setJavascriptDelay(javascript_delay)
2578
- if (!(Integer(javascript_delay) >= 0))
2579
- 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);
2775
+ def setJavascriptDelay(delay)
2776
+ if (!(Integer(delay) >= 0))
2777
+ 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);
2580
2778
  end
2581
2779
 
2582
- @fields['javascript_delay'] = javascript_delay
2780
+ @fields['javascript_delay'] = delay
2583
2781
  self
2584
2782
  end
2585
2783
 
@@ -2589,20 +2787,20 @@ module Pdfcrowd
2589
2787
  # * *Returns* - The converter object.
2590
2788
  def setElementToConvert(selectors)
2591
2789
  if (!(!selectors.nil? && !selectors.empty?))
2592
- raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "selectors", "html-to-image", "The string must not be empty.", "set_element_to_convert"), 470);
2790
+ raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setElementToConvert", "html-to-image", "The string must not be empty.", "set_element_to_convert"), 470);
2593
2791
  end
2594
2792
 
2595
2793
  @fields['element_to_convert'] = selectors
2596
2794
  self
2597
2795
  end
2598
2796
 
2599
- # Specify the DOM handling when only a part of the document is converted.
2797
+ # Specify the DOM handling when only a part of the document is converted. This can affect the CSS rules used.
2600
2798
  #
2601
2799
  # * +mode+ - Allowed values are cut-out, remove-siblings, hide-siblings.
2602
2800
  # * *Returns* - The converter object.
2603
2801
  def setElementToConvertMode(mode)
2604
2802
  unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode)
2605
- 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);
2803
+ 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);
2606
2804
  end
2607
2805
 
2608
2806
  @fields['element_to_convert_mode'] = mode
@@ -2615,7 +2813,7 @@ module Pdfcrowd
2615
2813
  # * *Returns* - The converter object.
2616
2814
  def setWaitForElement(selectors)
2617
2815
  if (!(!selectors.nil? && !selectors.empty?))
2618
- raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "selectors", "html-to-image", "The string must not be empty.", "set_wait_for_element"), 470);
2816
+ raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setWaitForElement", "html-to-image", "The string must not be empty.", "set_wait_for_element"), 470);
2619
2817
  end
2620
2818
 
2621
2819
  @fields['wait_for_element'] = selectors
@@ -2624,49 +2822,138 @@ module Pdfcrowd
2624
2822
 
2625
2823
  # Set the output image width in pixels.
2626
2824
  #
2627
- # * +screenshot_width+ - The value must be in the range 96-65000.
2825
+ # * +width+ - The value must be in the range 96-65000.
2628
2826
  # * *Returns* - The converter object.
2629
- def setScreenshotWidth(screenshot_width)
2630
- if (!(Integer(screenshot_width) >= 96 && Integer(screenshot_width) <= 65000))
2631
- 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);
2827
+ def setScreenshotWidth(width)
2828
+ if (!(Integer(width) >= 96 && Integer(width) <= 65000))
2829
+ 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);
2632
2830
  end
2633
2831
 
2634
- @fields['screenshot_width'] = screenshot_width
2832
+ @fields['screenshot_width'] = width
2635
2833
  self
2636
2834
  end
2637
2835
 
2638
2836
  # Set the output image height in pixels. If it is not specified, actual document height is used.
2639
2837
  #
2640
- # * +screenshot_height+ - Must be a positive integer number.
2838
+ # * +height+ - Must be a positive integer number.
2641
2839
  # * *Returns* - The converter object.
2642
- def setScreenshotHeight(screenshot_height)
2643
- if (!(Integer(screenshot_height) > 0))
2644
- 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);
2840
+ def setScreenshotHeight(height)
2841
+ if (!(Integer(height) > 0))
2842
+ raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setScreenshotHeight", "html-to-image", "Must be a positive integer number.", "set_screenshot_height"), 470);
2645
2843
  end
2646
2844
 
2647
- @fields['screenshot_height'] = screenshot_height
2845
+ @fields['screenshot_height'] = height
2648
2846
  self
2649
2847
  end
2650
2848
 
2651
2849
  # Set the scaling factor (zoom) for the output image.
2652
2850
  #
2653
- # * +scale_factor+ - The percentage value. Must be a positive integer number.
2851
+ # * +factor+ - The percentage value. Must be a positive integer number.
2852
+ # * *Returns* - The converter object.
2853
+ def setScaleFactor(factor)
2854
+ if (!(Integer(factor) > 0))
2855
+ raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "html-to-image", "Must be a positive integer number.", "set_scale_factor"), 470);
2856
+ end
2857
+
2858
+ @fields['scale_factor'] = factor
2859
+ self
2860
+ end
2861
+
2862
+ # The output image background color.
2863
+ #
2864
+ # * +color+ - The value must be in RRGGBB or RRGGBBAA hexadecimal format.
2865
+ # * *Returns* - The converter object.
2866
+ def setBackgroundColor(color)
2867
+ unless /^[0-9a-fA-F]{6,8}$/.match(color)
2868
+ 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);
2869
+ end
2870
+
2871
+ @fields['background_color'] = color
2872
+ self
2873
+ end
2874
+
2875
+ # Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
2876
+ #
2877
+ # * +data_string+ - The input data string.
2878
+ # * *Returns* - The converter object.
2879
+ def setDataString(data_string)
2880
+ @fields['data_string'] = data_string
2881
+ self
2882
+ end
2883
+
2884
+ # Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
2885
+ #
2886
+ # * +data_file+ - The file path to a local file containing the input data.
2887
+ # * *Returns* - The converter object.
2888
+ def setDataFile(data_file)
2889
+ @files['data_file'] = data_file
2890
+ self
2891
+ end
2892
+
2893
+ # Specify the input data format.
2894
+ #
2895
+ # * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
2654
2896
  # * *Returns* - The converter object.
2655
- def setScaleFactor(scale_factor)
2656
- if (!(Integer(scale_factor) > 0))
2657
- 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);
2897
+ def setDataFormat(data_format)
2898
+ unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
2899
+ 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);
2658
2900
  end
2659
2901
 
2660
- @fields['scale_factor'] = scale_factor
2902
+ @fields['data_format'] = data_format
2903
+ self
2904
+ end
2905
+
2906
+ # Set the encoding of the data file set by setDataFile.
2907
+ #
2908
+ # * +encoding+ - The data file encoding.
2909
+ # * *Returns* - The converter object.
2910
+ def setDataEncoding(encoding)
2911
+ @fields['data_encoding'] = encoding
2912
+ self
2913
+ end
2914
+
2915
+ # 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.
2916
+ #
2917
+ # * +value+ - Set to true to ignore undefined variables.
2918
+ # * *Returns* - The converter object.
2919
+ def setDataIgnoreUndefined(value)
2920
+ @fields['data_ignore_undefined'] = value
2921
+ self
2922
+ end
2923
+
2924
+ # Auto escape HTML symbols in the input data before placing them into the output.
2925
+ #
2926
+ # * +value+ - Set to true to turn auto escaping on.
2927
+ # * *Returns* - The converter object.
2928
+ def setDataAutoEscape(value)
2929
+ @fields['data_auto_escape'] = value
2930
+ self
2931
+ end
2932
+
2933
+ # Auto trim whitespace around each template command block.
2934
+ #
2935
+ # * +value+ - Set to true to turn auto trimming on.
2936
+ # * *Returns* - The converter object.
2937
+ def setDataTrimBlocks(value)
2938
+ @fields['data_trim_blocks'] = value
2939
+ self
2940
+ end
2941
+
2942
+ # 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.
2943
+ #
2944
+ # * +options+ - Comma separated list of options.
2945
+ # * *Returns* - The converter object.
2946
+ def setDataOptions(options)
2947
+ @fields['data_options'] = options
2661
2948
  self
2662
2949
  end
2663
2950
 
2664
2951
  # 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.
2665
2952
  #
2666
- # * +debug_log+ - Set to true to enable the debug logging.
2953
+ # * +value+ - Set to true to enable the debug logging.
2667
2954
  # * *Returns* - The converter object.
2668
- def setDebugLog(debug_log)
2669
- @fields['debug_log'] = debug_log
2955
+ def setDebugLog(value)
2956
+ @fields['debug_log'] = value
2670
2957
  self
2671
2958
  end
2672
2959
 
@@ -2703,6 +2990,12 @@ module Pdfcrowd
2703
2990
  return @helper.getOutputSize()
2704
2991
  end
2705
2992
 
2993
+ # Get the version details.
2994
+ # * *Returns* - API version, converter version, and client version.
2995
+ def getVersion()
2996
+ return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
2997
+ end
2998
+
2706
2999
  # Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
2707
3000
  #
2708
3001
  # * +tag+ - A string with the custom tag.
@@ -2714,68 +3007,81 @@ module Pdfcrowd
2714
3007
 
2715
3008
  # 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.
2716
3009
  #
2717
- # * +http_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
3010
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2718
3011
  # * *Returns* - The converter object.
2719
- def setHttpProxy(http_proxy)
2720
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(http_proxy)
2721
- 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);
3012
+ def setHttpProxy(proxy)
3013
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
3014
+ 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);
2722
3015
  end
2723
3016
 
2724
- @fields['http_proxy'] = http_proxy
3017
+ @fields['http_proxy'] = proxy
2725
3018
  self
2726
3019
  end
2727
3020
 
2728
3021
  # 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.
2729
3022
  #
2730
- # * +https_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
3023
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
2731
3024
  # * *Returns* - The converter object.
2732
- def setHttpsProxy(https_proxy)
2733
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(https_proxy)
2734
- 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);
3025
+ def setHttpsProxy(proxy)
3026
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
3027
+ 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);
2735
3028
  end
2736
3029
 
2737
- @fields['https_proxy'] = https_proxy
3030
+ @fields['https_proxy'] = proxy
2738
3031
  self
2739
3032
  end
2740
3033
 
2741
3034
  # 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.
2742
3035
  #
2743
- # * +client_certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
3036
+ # * +certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
2744
3037
  # * *Returns* - The converter object.
2745
- def setClientCertificate(client_certificate)
2746
- if (!(File.file?(client_certificate) && !File.zero?(client_certificate)))
2747
- 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);
3038
+ def setClientCertificate(certificate)
3039
+ if (!(File.file?(certificate) && !File.zero?(certificate)))
3040
+ 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);
2748
3041
  end
2749
3042
 
2750
- @files['client_certificate'] = client_certificate
3043
+ @files['client_certificate'] = certificate
2751
3044
  self
2752
3045
  end
2753
3046
 
2754
3047
  # A password for PKCS12 file with a client certificate if it is needed.
2755
3048
  #
2756
- # * +client_certificate_password+ -
3049
+ # * +password+ -
3050
+ # * *Returns* - The converter object.
3051
+ def setClientCertificatePassword(password)
3052
+ @fields['client_certificate_password'] = password
3053
+ self
3054
+ end
3055
+
3056
+ # Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
3057
+ #
3058
+ # * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
2757
3059
  # * *Returns* - The converter object.
2758
- def setClientCertificatePassword(client_certificate_password)
2759
- @fields['client_certificate_password'] = client_certificate_password
3060
+ def setConverterVersion(version)
3061
+ unless /(?i)^(latest|20.10|18.10)$/.match(version)
3062
+ 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);
3063
+ end
3064
+
3065
+ @helper.setConverterVersion(version)
2760
3066
  self
2761
3067
  end
2762
3068
 
2763
3069
  # Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
2764
3070
  # Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
2765
3071
  #
2766
- # * +use_http+ - Set to true to use HTTP.
3072
+ # * +value+ - Set to true to use HTTP.
2767
3073
  # * *Returns* - The converter object.
2768
- def setUseHttp(use_http)
2769
- @helper.setUseHttp(use_http)
3074
+ def setUseHttp(value)
3075
+ @helper.setUseHttp(value)
2770
3076
  self
2771
3077
  end
2772
3078
 
2773
- # Set a custom user agent HTTP header. It can be usefull if you are behind some proxy or firewall.
3079
+ # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
2774
3080
  #
2775
- # * +user_agent+ - The user agent string.
3081
+ # * +agent+ - The user agent string.
2776
3082
  # * *Returns* - The converter object.
2777
- def setUserAgent(user_agent)
2778
- @helper.setUserAgent(user_agent)
3083
+ def setUserAgent(agent)
3084
+ @helper.setUserAgent(agent)
2779
3085
  self
2780
3086
  end
2781
3087
 
@@ -2793,10 +3099,10 @@ module Pdfcrowd
2793
3099
 
2794
3100
  # 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.
2795
3101
  #
2796
- # * +retry_count+ - Number of retries wanted.
3102
+ # * +count+ - Number of retries wanted.
2797
3103
  # * *Returns* - The converter object.
2798
- def setRetryCount(retry_count)
2799
- @helper.setRetryCount(retry_count)
3104
+ def setRetryCount(count)
3105
+ @helper.setRetryCount(count)
2800
3106
  self
2801
3107
  end
2802
3108
 
@@ -2825,7 +3131,7 @@ module Pdfcrowd
2825
3131
  # * *Returns* - Byte array containing the conversion output.
2826
3132
  def convertUrl(url)
2827
3133
  unless /(?i)^https?:\/\/.*$/.match(url)
2828
- raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "image-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
3134
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
2829
3135
  end
2830
3136
 
2831
3137
  @fields['url'] = url
@@ -2838,7 +3144,7 @@ module Pdfcrowd
2838
3144
  # * +out_stream+ - The output stream that will contain the conversion output.
2839
3145
  def convertUrlToStream(url, out_stream)
2840
3146
  unless /(?i)^https?:\/\/.*$/.match(url)
2841
- 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);
3147
+ 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);
2842
3148
  end
2843
3149
 
2844
3150
  @fields['url'] = url
@@ -2851,7 +3157,7 @@ module Pdfcrowd
2851
3157
  # * +file_path+ - The output file path. The string must not be empty.
2852
3158
  def convertUrlToFile(url, file_path)
2853
3159
  if (!(!file_path.nil? && !file_path.empty?))
2854
- 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);
3160
+ 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);
2855
3161
  end
2856
3162
 
2857
3163
  output_file = open(file_path, "wb")
@@ -2867,11 +3173,11 @@ module Pdfcrowd
2867
3173
 
2868
3174
  # Convert a local file.
2869
3175
  #
2870
- # * +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.
3176
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
2871
3177
  # * *Returns* - Byte array containing the conversion output.
2872
3178
  def convertFile(file)
2873
3179
  if (!(File.file?(file) && !File.zero?(file)))
2874
- raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "image-to-image", "The file must exist and not be empty.", "convert_file"), 470);
3180
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "image-to-image", "The file must exist and not be empty.", "convert_file"), 470);
2875
3181
  end
2876
3182
 
2877
3183
  @files['file'] = file
@@ -2880,11 +3186,11 @@ module Pdfcrowd
2880
3186
 
2881
3187
  # Convert a local file and write the result to an output stream.
2882
3188
  #
2883
- # * +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.
3189
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
2884
3190
  # * +out_stream+ - The output stream that will contain the conversion output.
2885
3191
  def convertFileToStream(file, out_stream)
2886
3192
  if (!(File.file?(file) && !File.zero?(file)))
2887
- 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);
3193
+ 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);
2888
3194
  end
2889
3195
 
2890
3196
  @files['file'] = file
@@ -2893,11 +3199,11 @@ module Pdfcrowd
2893
3199
 
2894
3200
  # Convert a local file and write the result to a local file.
2895
3201
  #
2896
- # * +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.
3202
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
2897
3203
  # * +file_path+ - The output file path. The string must not be empty.
2898
3204
  def convertFileToFile(file, file_path)
2899
3205
  if (!(!file_path.nil? && !file_path.empty?))
2900
- 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);
3206
+ 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);
2901
3207
  end
2902
3208
 
2903
3209
  output_file = open(file_path, "wb")
@@ -2935,7 +3241,7 @@ module Pdfcrowd
2935
3241
  # * +file_path+ - The output file path. The string must not be empty.
2936
3242
  def convertRawDataToFile(data, file_path)
2937
3243
  if (!(!file_path.nil? && !file_path.empty?))
2938
- 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);
3244
+ 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);
2939
3245
  end
2940
3246
 
2941
3247
  output_file = open(file_path, "wb")
@@ -2949,13 +3255,51 @@ module Pdfcrowd
2949
3255
  end
2950
3256
  end
2951
3257
 
3258
+ # Convert the contents of an input stream.
3259
+ #
3260
+ # * +in_stream+ - The input stream with source data.
3261
+ # * *Returns* - Byte array containing the conversion output.
3262
+ def convertStream(in_stream)
3263
+ @raw_data['stream'] = in_stream.read
3264
+ @helper.post(@fields, @files, @raw_data)
3265
+ end
3266
+
3267
+ # Convert the contents of an input stream and write the result to an output stream.
3268
+ #
3269
+ # * +in_stream+ - The input stream with source data.
3270
+ # * +out_stream+ - The output stream that will contain the conversion output.
3271
+ def convertStreamToStream(in_stream, out_stream)
3272
+ @raw_data['stream'] = in_stream.read
3273
+ @helper.post(@fields, @files, @raw_data, out_stream)
3274
+ end
3275
+
3276
+ # Convert the contents of an input stream and write the result to a local file.
3277
+ #
3278
+ # * +in_stream+ - The input stream with source data.
3279
+ # * +file_path+ - The output file path. The string must not be empty.
3280
+ def convertStreamToFile(in_stream, file_path)
3281
+ if (!(!file_path.nil? && !file_path.empty?))
3282
+ 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);
3283
+ end
3284
+
3285
+ output_file = open(file_path, "wb")
3286
+ begin
3287
+ convertStreamToStream(in_stream, output_file)
3288
+ output_file.close()
3289
+ rescue Error => why
3290
+ output_file.close()
3291
+ FileUtils.rm(file_path)
3292
+ raise
3293
+ end
3294
+ end
3295
+
2952
3296
  # The format of the output file.
2953
3297
  #
2954
3298
  # * +output_format+ - Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.
2955
3299
  # * *Returns* - The converter object.
2956
3300
  def setOutputFormat(output_format)
2957
3301
  unless /(?i)^(png|jpg|gif|tiff|bmp|ico|ppm|pgm|pbm|pnm|psb|pct|ras|tga|sgi|sun|webp)$/.match(output_format)
2958
- 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);
3302
+ 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);
2959
3303
  end
2960
3304
 
2961
3305
  @fields['output_format'] = output_format
@@ -2982,10 +3326,10 @@ module Pdfcrowd
2982
3326
 
2983
3327
  # 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.
2984
3328
  #
2985
- # * +debug_log+ - Set to true to enable the debug logging.
3329
+ # * +value+ - Set to true to enable the debug logging.
2986
3330
  # * *Returns* - The converter object.
2987
- def setDebugLog(debug_log)
2988
- @fields['debug_log'] = debug_log
3331
+ def setDebugLog(value)
3332
+ @fields['debug_log'] = value
2989
3333
  self
2990
3334
  end
2991
3335
 
@@ -3022,6 +3366,12 @@ module Pdfcrowd
3022
3366
  return @helper.getOutputSize()
3023
3367
  end
3024
3368
 
3369
+ # Get the version details.
3370
+ # * *Returns* - API version, converter version, and client version.
3371
+ def getVersion()
3372
+ return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
3373
+ end
3374
+
3025
3375
  # Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
3026
3376
  #
3027
3377
  # * +tag+ - A string with the custom tag.
@@ -3033,46 +3383,59 @@ module Pdfcrowd
3033
3383
 
3034
3384
  # 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.
3035
3385
  #
3036
- # * +http_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
3386
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
3037
3387
  # * *Returns* - The converter object.
3038
- def setHttpProxy(http_proxy)
3039
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(http_proxy)
3040
- 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);
3388
+ def setHttpProxy(proxy)
3389
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
3390
+ 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);
3041
3391
  end
3042
3392
 
3043
- @fields['http_proxy'] = http_proxy
3393
+ @fields['http_proxy'] = proxy
3044
3394
  self
3045
3395
  end
3046
3396
 
3047
3397
  # 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.
3048
3398
  #
3049
- # * +https_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
3399
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
3400
+ # * *Returns* - The converter object.
3401
+ def setHttpsProxy(proxy)
3402
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
3403
+ 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);
3404
+ end
3405
+
3406
+ @fields['https_proxy'] = proxy
3407
+ self
3408
+ end
3409
+
3410
+ # Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
3411
+ #
3412
+ # * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
3050
3413
  # * *Returns* - The converter object.
3051
- def setHttpsProxy(https_proxy)
3052
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(https_proxy)
3053
- 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);
3414
+ def setConverterVersion(version)
3415
+ unless /(?i)^(latest|20.10|18.10)$/.match(version)
3416
+ 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);
3054
3417
  end
3055
3418
 
3056
- @fields['https_proxy'] = https_proxy
3419
+ @helper.setConverterVersion(version)
3057
3420
  self
3058
3421
  end
3059
3422
 
3060
3423
  # Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
3061
3424
  # Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
3062
3425
  #
3063
- # * +use_http+ - Set to true to use HTTP.
3426
+ # * +value+ - Set to true to use HTTP.
3064
3427
  # * *Returns* - The converter object.
3065
- def setUseHttp(use_http)
3066
- @helper.setUseHttp(use_http)
3428
+ def setUseHttp(value)
3429
+ @helper.setUseHttp(value)
3067
3430
  self
3068
3431
  end
3069
3432
 
3070
- # Set a custom user agent HTTP header. It can be usefull if you are behind some proxy or firewall.
3433
+ # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
3071
3434
  #
3072
- # * +user_agent+ - The user agent string.
3435
+ # * +agent+ - The user agent string.
3073
3436
  # * *Returns* - The converter object.
3074
- def setUserAgent(user_agent)
3075
- @helper.setUserAgent(user_agent)
3437
+ def setUserAgent(agent)
3438
+ @helper.setUserAgent(agent)
3076
3439
  self
3077
3440
  end
3078
3441
 
@@ -3090,10 +3453,10 @@ module Pdfcrowd
3090
3453
 
3091
3454
  # 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.
3092
3455
  #
3093
- # * +retry_count+ - Number of retries wanted.
3456
+ # * +count+ - Number of retries wanted.
3094
3457
  # * *Returns* - The converter object.
3095
- def setRetryCount(retry_count)
3096
- @helper.setRetryCount(retry_count)
3458
+ def setRetryCount(count)
3459
+ @helper.setRetryCount(count)
3097
3460
  self
3098
3461
  end
3099
3462
 
@@ -3122,7 +3485,7 @@ module Pdfcrowd
3122
3485
  # * *Returns* - The converter object.
3123
3486
  def setAction(action)
3124
3487
  unless /(?i)^(join|shuffle)$/.match(action)
3125
- raise Error.new(Pdfcrowd.create_invalid_value_message(action, "action", "pdf-to-pdf", "Allowed values are join, shuffle.", "set_action"), 470);
3488
+ raise Error.new(Pdfcrowd.create_invalid_value_message(action, "setAction", "pdf-to-pdf", "Allowed values are join, shuffle.", "set_action"), 470);
3126
3489
  end
3127
3490
 
3128
3491
  @fields['action'] = action
@@ -3147,7 +3510,7 @@ module Pdfcrowd
3147
3510
  # * +file_path+ - The output file path. The string must not be empty.
3148
3511
  def convertToFile(file_path)
3149
3512
  if (!(!file_path.nil? && !file_path.empty?))
3150
- 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);
3513
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertToFile", "pdf-to-pdf", "The string must not be empty.", "convert_to_file"), 470);
3151
3514
  end
3152
3515
 
3153
3516
  output_file = open(file_path, "wb")
@@ -3161,7 +3524,7 @@ module Pdfcrowd
3161
3524
  # * *Returns* - The converter object.
3162
3525
  def addPdfFile(file_path)
3163
3526
  if (!(File.file?(file_path) && !File.zero?(file_path)))
3164
- 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);
3527
+ 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);
3165
3528
  end
3166
3529
 
3167
3530
  @files['f_%s' % @file_id] = file_path
@@ -3171,319 +3534,368 @@ module Pdfcrowd
3171
3534
 
3172
3535
  # 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'));
3173
3536
  #
3174
- # * +pdf_raw_data+ - The raw PDF data. The input data must be PDF content.
3537
+ # * +data+ - The raw PDF data. The input data must be PDF content.
3175
3538
  # * *Returns* - The converter object.
3176
- def addPdfRawData(pdf_raw_data)
3177
- if (!(!pdf_raw_data.nil? && pdf_raw_data.length > 300 and pdf_raw_data[0...4] == '%PDF'))
3178
- 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);
3539
+ def addPdfRawData(data)
3540
+ if (!(!data.nil? && data.length > 300 and data[0...4] == '%PDF'))
3541
+ 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);
3179
3542
  end
3180
3543
 
3181
- @raw_data['f_%s' % @file_id] = pdf_raw_data
3544
+ @raw_data['f_%s' % @file_id] = data
3182
3545
  @file_id += 1
3183
3546
  self
3184
3547
  end
3185
3548
 
3186
3549
  # Apply the first page of the watermark PDF to every page of the output PDF.
3187
3550
  #
3188
- # * +page_watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
3551
+ # * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
3189
3552
  # * *Returns* - The converter object.
3190
- def setPageWatermark(page_watermark)
3191
- if (!(File.file?(page_watermark) && !File.zero?(page_watermark)))
3192
- 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);
3553
+ def setPageWatermark(watermark)
3554
+ if (!(File.file?(watermark) && !File.zero?(watermark)))
3555
+ 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);
3193
3556
  end
3194
3557
 
3195
- @files['page_watermark'] = page_watermark
3558
+ @files['page_watermark'] = watermark
3196
3559
  self
3197
3560
  end
3198
3561
 
3199
3562
  # Load a watermark PDF from the specified URL and apply the first page of the watermark PDF to every page of the output PDF.
3200
3563
  #
3201
- # * +page_watermark_url+ - The supported protocols are http:// and https://.
3564
+ # * +url+ - The supported protocols are http:// and https://.
3202
3565
  # * *Returns* - The converter object.
3203
- def setPageWatermarkUrl(page_watermark_url)
3204
- unless /(?i)^https?:\/\/.*$/.match(page_watermark_url)
3205
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_watermark_url, "page_watermark_url", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_page_watermark_url"), 470);
3566
+ def setPageWatermarkUrl(url)
3567
+ unless /(?i)^https?:\/\/.*$/.match(url)
3568
+ 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);
3206
3569
  end
3207
3570
 
3208
- @fields['page_watermark_url'] = page_watermark_url
3571
+ @fields['page_watermark_url'] = url
3209
3572
  self
3210
3573
  end
3211
3574
 
3212
3575
  # Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
3213
3576
  #
3214
- # * +multipage_watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
3577
+ # * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
3215
3578
  # * *Returns* - The converter object.
3216
- def setMultipageWatermark(multipage_watermark)
3217
- if (!(File.file?(multipage_watermark) && !File.zero?(multipage_watermark)))
3218
- 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);
3579
+ def setMultipageWatermark(watermark)
3580
+ if (!(File.file?(watermark) && !File.zero?(watermark)))
3581
+ 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);
3219
3582
  end
3220
3583
 
3221
- @files['multipage_watermark'] = multipage_watermark
3584
+ @files['multipage_watermark'] = watermark
3222
3585
  self
3223
3586
  end
3224
3587
 
3225
3588
  # 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.
3226
3589
  #
3227
- # * +multipage_watermark_url+ - The supported protocols are http:// and https://.
3590
+ # * +url+ - The supported protocols are http:// and https://.
3228
3591
  # * *Returns* - The converter object.
3229
- def setMultipageWatermarkUrl(multipage_watermark_url)
3230
- unless /(?i)^https?:\/\/.*$/.match(multipage_watermark_url)
3231
- raise Error.new(Pdfcrowd.create_invalid_value_message(multipage_watermark_url, "multipage_watermark_url", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_watermark_url"), 470);
3592
+ def setMultipageWatermarkUrl(url)
3593
+ unless /(?i)^https?:\/\/.*$/.match(url)
3594
+ 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);
3232
3595
  end
3233
3596
 
3234
- @fields['multipage_watermark_url'] = multipage_watermark_url
3597
+ @fields['multipage_watermark_url'] = url
3235
3598
  self
3236
3599
  end
3237
3600
 
3238
3601
  # Apply the first page of the specified PDF to the background of every page of the output PDF.
3239
3602
  #
3240
- # * +page_background+ - The file path to a local background PDF file. The file must exist and not be empty.
3603
+ # * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
3241
3604
  # * *Returns* - The converter object.
3242
- def setPageBackground(page_background)
3243
- if (!(File.file?(page_background) && !File.zero?(page_background)))
3244
- 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);
3605
+ def setPageBackground(background)
3606
+ if (!(File.file?(background) && !File.zero?(background)))
3607
+ 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);
3245
3608
  end
3246
3609
 
3247
- @files['page_background'] = page_background
3610
+ @files['page_background'] = background
3248
3611
  self
3249
3612
  end
3250
3613
 
3251
3614
  # Load a background PDF from the specified URL and apply the first page of the background PDF to every page of the output PDF.
3252
3615
  #
3253
- # * +page_background_url+ - The supported protocols are http:// and https://.
3616
+ # * +url+ - The supported protocols are http:// and https://.
3254
3617
  # * *Returns* - The converter object.
3255
- def setPageBackgroundUrl(page_background_url)
3256
- unless /(?i)^https?:\/\/.*$/.match(page_background_url)
3257
- raise Error.new(Pdfcrowd.create_invalid_value_message(page_background_url, "page_background_url", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_page_background_url"), 470);
3618
+ def setPageBackgroundUrl(url)
3619
+ unless /(?i)^https?:\/\/.*$/.match(url)
3620
+ 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);
3258
3621
  end
3259
3622
 
3260
- @fields['page_background_url'] = page_background_url
3623
+ @fields['page_background_url'] = url
3261
3624
  self
3262
3625
  end
3263
3626
 
3264
3627
  # Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
3265
3628
  #
3266
- # * +multipage_background+ - The file path to a local background PDF file. The file must exist and not be empty.
3629
+ # * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
3267
3630
  # * *Returns* - The converter object.
3268
- def setMultipageBackground(multipage_background)
3269
- if (!(File.file?(multipage_background) && !File.zero?(multipage_background)))
3270
- 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);
3631
+ def setMultipageBackground(background)
3632
+ if (!(File.file?(background) && !File.zero?(background)))
3633
+ 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);
3271
3634
  end
3272
3635
 
3273
- @files['multipage_background'] = multipage_background
3636
+ @files['multipage_background'] = background
3274
3637
  self
3275
3638
  end
3276
3639
 
3277
3640
  # 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.
3278
3641
  #
3279
- # * +multipage_background_url+ - The supported protocols are http:// and https://.
3642
+ # * +url+ - The supported protocols are http:// and https://.
3280
3643
  # * *Returns* - The converter object.
3281
- def setMultipageBackgroundUrl(multipage_background_url)
3282
- unless /(?i)^https?:\/\/.*$/.match(multipage_background_url)
3283
- raise Error.new(Pdfcrowd.create_invalid_value_message(multipage_background_url, "multipage_background_url", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_background_url"), 470);
3644
+ def setMultipageBackgroundUrl(url)
3645
+ unless /(?i)^https?:\/\/.*$/.match(url)
3646
+ 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);
3284
3647
  end
3285
3648
 
3286
- @fields['multipage_background_url'] = multipage_background_url
3649
+ @fields['multipage_background_url'] = url
3287
3650
  self
3288
3651
  end
3289
3652
 
3290
3653
  # Create linearized PDF. This is also known as Fast Web View.
3291
3654
  #
3292
- # * +linearize+ - Set to true to create linearized PDF.
3655
+ # * +value+ - Set to true to create linearized PDF.
3293
3656
  # * *Returns* - The converter object.
3294
- def setLinearize(linearize)
3295
- @fields['linearize'] = linearize
3657
+ def setLinearize(value)
3658
+ @fields['linearize'] = value
3296
3659
  self
3297
3660
  end
3298
3661
 
3299
3662
  # Encrypt the PDF. This prevents search engines from indexing the contents.
3300
3663
  #
3301
- # * +encrypt+ - Set to true to enable PDF encryption.
3664
+ # * +value+ - Set to true to enable PDF encryption.
3302
3665
  # * *Returns* - The converter object.
3303
- def setEncrypt(encrypt)
3304
- @fields['encrypt'] = encrypt
3666
+ def setEncrypt(value)
3667
+ @fields['encrypt'] = value
3305
3668
  self
3306
3669
  end
3307
3670
 
3308
3671
  # 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.
3309
3672
  #
3310
- # * +user_password+ - The user password.
3673
+ # * +password+ - The user password.
3311
3674
  # * *Returns* - The converter object.
3312
- def setUserPassword(user_password)
3313
- @fields['user_password'] = user_password
3675
+ def setUserPassword(password)
3676
+ @fields['user_password'] = password
3314
3677
  self
3315
3678
  end
3316
3679
 
3317
3680
  # Protect the PDF with an owner password. Supplying an owner password grants unlimited access to the PDF including changing the passwords and access permissions.
3318
3681
  #
3319
- # * +owner_password+ - The owner password.
3682
+ # * +password+ - The owner password.
3320
3683
  # * *Returns* - The converter object.
3321
- def setOwnerPassword(owner_password)
3322
- @fields['owner_password'] = owner_password
3684
+ def setOwnerPassword(password)
3685
+ @fields['owner_password'] = password
3323
3686
  self
3324
3687
  end
3325
3688
 
3326
3689
  # Disallow printing of the output PDF.
3327
3690
  #
3328
- # * +no_print+ - Set to true to set the no-print flag in the output PDF.
3691
+ # * +value+ - Set to true to set the no-print flag in the output PDF.
3329
3692
  # * *Returns* - The converter object.
3330
- def setNoPrint(no_print)
3331
- @fields['no_print'] = no_print
3693
+ def setNoPrint(value)
3694
+ @fields['no_print'] = value
3332
3695
  self
3333
3696
  end
3334
3697
 
3335
3698
  # Disallow modification of the output PDF.
3336
3699
  #
3337
- # * +no_modify+ - Set to true to set the read-only only flag in the output PDF.
3700
+ # * +value+ - Set to true to set the read-only only flag in the output PDF.
3338
3701
  # * *Returns* - The converter object.
3339
- def setNoModify(no_modify)
3340
- @fields['no_modify'] = no_modify
3702
+ def setNoModify(value)
3703
+ @fields['no_modify'] = value
3341
3704
  self
3342
3705
  end
3343
3706
 
3344
3707
  # Disallow text and graphics extraction from the output PDF.
3345
3708
  #
3346
- # * +no_copy+ - Set to true to set the no-copy flag in the output PDF.
3709
+ # * +value+ - Set to true to set the no-copy flag in the output PDF.
3710
+ # * *Returns* - The converter object.
3711
+ def setNoCopy(value)
3712
+ @fields['no_copy'] = value
3713
+ self
3714
+ end
3715
+
3716
+ # Set the title of the PDF.
3717
+ #
3718
+ # * +title+ - The title.
3719
+ # * *Returns* - The converter object.
3720
+ def setTitle(title)
3721
+ @fields['title'] = title
3722
+ self
3723
+ end
3724
+
3725
+ # Set the subject of the PDF.
3726
+ #
3727
+ # * +subject+ - The subject.
3728
+ # * *Returns* - The converter object.
3729
+ def setSubject(subject)
3730
+ @fields['subject'] = subject
3731
+ self
3732
+ end
3733
+
3734
+ # Set the author of the PDF.
3735
+ #
3736
+ # * +author+ - The author.
3737
+ # * *Returns* - The converter object.
3738
+ def setAuthor(author)
3739
+ @fields['author'] = author
3740
+ self
3741
+ end
3742
+
3743
+ # Associate keywords with the document.
3744
+ #
3745
+ # * +keywords+ - The string with the keywords.
3746
+ # * *Returns* - The converter object.
3747
+ def setKeywords(keywords)
3748
+ @fields['keywords'] = keywords
3749
+ self
3750
+ end
3751
+
3752
+ # Use metadata (title, subject, author and keywords) from the n-th input PDF.
3753
+ #
3754
+ # * +index+ - Set the index of the input PDF file from which to use the metadata. 0 means no metadata. Must be a positive integer number or 0.
3347
3755
  # * *Returns* - The converter object.
3348
- def setNoCopy(no_copy)
3349
- @fields['no_copy'] = no_copy
3756
+ def setUseMetadataFrom(index)
3757
+ if (!(Integer(index) >= 0))
3758
+ raise Error.new(Pdfcrowd.create_invalid_value_message(index, "setUseMetadataFrom", "pdf-to-pdf", "Must be a positive integer number or 0.", "set_use_metadata_from"), 470);
3759
+ end
3760
+
3761
+ @fields['use_metadata_from'] = index
3350
3762
  self
3351
3763
  end
3352
3764
 
3353
3765
  # Specify the page layout to be used when the document is opened.
3354
3766
  #
3355
- # * +page_layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
3767
+ # * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
3356
3768
  # * *Returns* - The converter object.
3357
- def setPageLayout(page_layout)
3358
- unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(page_layout)
3359
- 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);
3769
+ def setPageLayout(layout)
3770
+ unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout)
3771
+ 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);
3360
3772
  end
3361
3773
 
3362
- @fields['page_layout'] = page_layout
3774
+ @fields['page_layout'] = layout
3363
3775
  self
3364
3776
  end
3365
3777
 
3366
3778
  # Specify how the document should be displayed when opened.
3367
3779
  #
3368
- # * +page_mode+ - Allowed values are full-screen, thumbnails, outlines.
3780
+ # * +mode+ - Allowed values are full-screen, thumbnails, outlines.
3369
3781
  # * *Returns* - The converter object.
3370
- def setPageMode(page_mode)
3371
- unless /(?i)^(full-screen|thumbnails|outlines)$/.match(page_mode)
3372
- 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);
3782
+ def setPageMode(mode)
3783
+ unless /(?i)^(full-screen|thumbnails|outlines)$/.match(mode)
3784
+ raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setPageMode", "pdf-to-pdf", "Allowed values are full-screen, thumbnails, outlines.", "set_page_mode"), 470);
3373
3785
  end
3374
3786
 
3375
- @fields['page_mode'] = page_mode
3787
+ @fields['page_mode'] = mode
3376
3788
  self
3377
3789
  end
3378
3790
 
3379
3791
  # Specify how the page should be displayed when opened.
3380
3792
  #
3381
- # * +initial_zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
3793
+ # * +zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
3382
3794
  # * *Returns* - The converter object.
3383
- def setInitialZoomType(initial_zoom_type)
3384
- unless /(?i)^(fit-width|fit-height|fit-page)$/.match(initial_zoom_type)
3385
- 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);
3795
+ def setInitialZoomType(zoom_type)
3796
+ unless /(?i)^(fit-width|fit-height|fit-page)$/.match(zoom_type)
3797
+ 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);
3386
3798
  end
3387
3799
 
3388
- @fields['initial_zoom_type'] = initial_zoom_type
3800
+ @fields['initial_zoom_type'] = zoom_type
3389
3801
  self
3390
3802
  end
3391
3803
 
3392
3804
  # Display the specified page when the document is opened.
3393
3805
  #
3394
- # * +initial_page+ - Must be a positive integer number.
3806
+ # * +page+ - Must be a positive integer number.
3395
3807
  # * *Returns* - The converter object.
3396
- def setInitialPage(initial_page)
3397
- if (!(Integer(initial_page) > 0))
3398
- 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);
3808
+ def setInitialPage(page)
3809
+ if (!(Integer(page) > 0))
3810
+ raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "pdf-to-pdf", "Must be a positive integer number.", "set_initial_page"), 470);
3399
3811
  end
3400
3812
 
3401
- @fields['initial_page'] = initial_page
3813
+ @fields['initial_page'] = page
3402
3814
  self
3403
3815
  end
3404
3816
 
3405
3817
  # Specify the initial page zoom in percents when the document is opened.
3406
3818
  #
3407
- # * +initial_zoom+ - Must be a positive integer number.
3819
+ # * +zoom+ - Must be a positive integer number.
3408
3820
  # * *Returns* - The converter object.
3409
- def setInitialZoom(initial_zoom)
3410
- if (!(Integer(initial_zoom) > 0))
3411
- 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);
3821
+ def setInitialZoom(zoom)
3822
+ if (!(Integer(zoom) > 0))
3823
+ raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "pdf-to-pdf", "Must be a positive integer number.", "set_initial_zoom"), 470);
3412
3824
  end
3413
3825
 
3414
- @fields['initial_zoom'] = initial_zoom
3826
+ @fields['initial_zoom'] = zoom
3415
3827
  self
3416
3828
  end
3417
3829
 
3418
3830
  # Specify whether to hide the viewer application's tool bars when the document is active.
3419
3831
  #
3420
- # * +hide_toolbar+ - Set to true to hide tool bars.
3832
+ # * +value+ - Set to true to hide tool bars.
3421
3833
  # * *Returns* - The converter object.
3422
- def setHideToolbar(hide_toolbar)
3423
- @fields['hide_toolbar'] = hide_toolbar
3834
+ def setHideToolbar(value)
3835
+ @fields['hide_toolbar'] = value
3424
3836
  self
3425
3837
  end
3426
3838
 
3427
3839
  # Specify whether to hide the viewer application's menu bar when the document is active.
3428
3840
  #
3429
- # * +hide_menubar+ - Set to true to hide the menu bar.
3841
+ # * +value+ - Set to true to hide the menu bar.
3430
3842
  # * *Returns* - The converter object.
3431
- def setHideMenubar(hide_menubar)
3432
- @fields['hide_menubar'] = hide_menubar
3843
+ def setHideMenubar(value)
3844
+ @fields['hide_menubar'] = value
3433
3845
  self
3434
3846
  end
3435
3847
 
3436
3848
  # 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.
3437
3849
  #
3438
- # * +hide_window_ui+ - Set to true to hide ui elements.
3850
+ # * +value+ - Set to true to hide ui elements.
3439
3851
  # * *Returns* - The converter object.
3440
- def setHideWindowUi(hide_window_ui)
3441
- @fields['hide_window_ui'] = hide_window_ui
3852
+ def setHideWindowUi(value)
3853
+ @fields['hide_window_ui'] = value
3442
3854
  self
3443
3855
  end
3444
3856
 
3445
3857
  # Specify whether to resize the document's window to fit the size of the first displayed page.
3446
3858
  #
3447
- # * +fit_window+ - Set to true to resize the window.
3859
+ # * +value+ - Set to true to resize the window.
3448
3860
  # * *Returns* - The converter object.
3449
- def setFitWindow(fit_window)
3450
- @fields['fit_window'] = fit_window
3861
+ def setFitWindow(value)
3862
+ @fields['fit_window'] = value
3451
3863
  self
3452
3864
  end
3453
3865
 
3454
3866
  # Specify whether to position the document's window in the center of the screen.
3455
3867
  #
3456
- # * +center_window+ - Set to true to center the window.
3868
+ # * +value+ - Set to true to center the window.
3457
3869
  # * *Returns* - The converter object.
3458
- def setCenterWindow(center_window)
3459
- @fields['center_window'] = center_window
3870
+ def setCenterWindow(value)
3871
+ @fields['center_window'] = value
3460
3872
  self
3461
3873
  end
3462
3874
 
3463
3875
  # 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.
3464
3876
  #
3465
- # * +display_title+ - Set to true to display the title.
3877
+ # * +value+ - Set to true to display the title.
3466
3878
  # * *Returns* - The converter object.
3467
- def setDisplayTitle(display_title)
3468
- @fields['display_title'] = display_title
3879
+ def setDisplayTitle(value)
3880
+ @fields['display_title'] = value
3469
3881
  self
3470
3882
  end
3471
3883
 
3472
3884
  # 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
3473
3885
  #
3474
- # * +right_to_left+ - Set to true to set right-to-left reading order.
3886
+ # * +value+ - Set to true to set right-to-left reading order.
3475
3887
  # * *Returns* - The converter object.
3476
- def setRightToLeft(right_to_left)
3477
- @fields['right_to_left'] = right_to_left
3888
+ def setRightToLeft(value)
3889
+ @fields['right_to_left'] = value
3478
3890
  self
3479
3891
  end
3480
3892
 
3481
3893
  # 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.
3482
3894
  #
3483
- # * +debug_log+ - Set to true to enable the debug logging.
3895
+ # * +value+ - Set to true to enable the debug logging.
3484
3896
  # * *Returns* - The converter object.
3485
- def setDebugLog(debug_log)
3486
- @fields['debug_log'] = debug_log
3897
+ def setDebugLog(value)
3898
+ @fields['debug_log'] = value
3487
3899
  self
3488
3900
  end
3489
3901
 
@@ -3526,6 +3938,12 @@ module Pdfcrowd
3526
3938
  return @helper.getOutputSize()
3527
3939
  end
3528
3940
 
3941
+ # Get the version details.
3942
+ # * *Returns* - API version, converter version, and client version.
3943
+ def getVersion()
3944
+ return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
3945
+ end
3946
+
3529
3947
  # Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
3530
3948
  #
3531
3949
  # * +tag+ - A string with the custom tag.
@@ -3535,22 +3953,35 @@ module Pdfcrowd
3535
3953
  self
3536
3954
  end
3537
3955
 
3956
+ # Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
3957
+ #
3958
+ # * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
3959
+ # * *Returns* - The converter object.
3960
+ def setConverterVersion(version)
3961
+ unless /(?i)^(latest|20.10|18.10)$/.match(version)
3962
+ 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);
3963
+ end
3964
+
3965
+ @helper.setConverterVersion(version)
3966
+ self
3967
+ end
3968
+
3538
3969
  # Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
3539
3970
  # Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
3540
3971
  #
3541
- # * +use_http+ - Set to true to use HTTP.
3972
+ # * +value+ - Set to true to use HTTP.
3542
3973
  # * *Returns* - The converter object.
3543
- def setUseHttp(use_http)
3544
- @helper.setUseHttp(use_http)
3974
+ def setUseHttp(value)
3975
+ @helper.setUseHttp(value)
3545
3976
  self
3546
3977
  end
3547
3978
 
3548
- # Set a custom user agent HTTP header. It can be usefull if you are behind some proxy or firewall.
3979
+ # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
3549
3980
  #
3550
- # * +user_agent+ - The user agent string.
3981
+ # * +agent+ - The user agent string.
3551
3982
  # * *Returns* - The converter object.
3552
- def setUserAgent(user_agent)
3553
- @helper.setUserAgent(user_agent)
3983
+ def setUserAgent(agent)
3984
+ @helper.setUserAgent(agent)
3554
3985
  self
3555
3986
  end
3556
3987
 
@@ -3568,10 +3999,10 @@ module Pdfcrowd
3568
3999
 
3569
4000
  # 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.
3570
4001
  #
3571
- # * +retry_count+ - Number of retries wanted.
4002
+ # * +count+ - Number of retries wanted.
3572
4003
  # * *Returns* - The converter object.
3573
- def setRetryCount(retry_count)
3574
- @helper.setRetryCount(retry_count)
4004
+ def setRetryCount(count)
4005
+ @helper.setRetryCount(count)
3575
4006
  self
3576
4007
  end
3577
4008
 
@@ -3600,7 +4031,7 @@ module Pdfcrowd
3600
4031
  # * *Returns* - Byte array containing the conversion output.
3601
4032
  def convertUrl(url)
3602
4033
  unless /(?i)^https?:\/\/.*$/.match(url)
3603
- raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "image-to-pdf", "The supported protocols are http:// and https://.", "convert_url"), 470);
4034
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-pdf", "The supported protocols are http:// and https://.", "convert_url"), 470);
3604
4035
  end
3605
4036
 
3606
4037
  @fields['url'] = url
@@ -3613,7 +4044,7 @@ module Pdfcrowd
3613
4044
  # * +out_stream+ - The output stream that will contain the conversion output.
3614
4045
  def convertUrlToStream(url, out_stream)
3615
4046
  unless /(?i)^https?:\/\/.*$/.match(url)
3616
- 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);
4047
+ 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);
3617
4048
  end
3618
4049
 
3619
4050
  @fields['url'] = url
@@ -3626,7 +4057,7 @@ module Pdfcrowd
3626
4057
  # * +file_path+ - The output file path. The string must not be empty.
3627
4058
  def convertUrlToFile(url, file_path)
3628
4059
  if (!(!file_path.nil? && !file_path.empty?))
3629
- 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);
4060
+ 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);
3630
4061
  end
3631
4062
 
3632
4063
  output_file = open(file_path, "wb")
@@ -3642,11 +4073,11 @@ module Pdfcrowd
3642
4073
 
3643
4074
  # Convert a local file.
3644
4075
  #
3645
- # * +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.
4076
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
3646
4077
  # * *Returns* - Byte array containing the conversion output.
3647
4078
  def convertFile(file)
3648
4079
  if (!(File.file?(file) && !File.zero?(file)))
3649
- raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "image-to-pdf", "The file must exist and not be empty.", "convert_file"), 470);
4080
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "image-to-pdf", "The file must exist and not be empty.", "convert_file"), 470);
3650
4081
  end
3651
4082
 
3652
4083
  @files['file'] = file
@@ -3655,11 +4086,11 @@ module Pdfcrowd
3655
4086
 
3656
4087
  # Convert a local file and write the result to an output stream.
3657
4088
  #
3658
- # * +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.
4089
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
3659
4090
  # * +out_stream+ - The output stream that will contain the conversion output.
3660
4091
  def convertFileToStream(file, out_stream)
3661
4092
  if (!(File.file?(file) && !File.zero?(file)))
3662
- 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);
4093
+ 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);
3663
4094
  end
3664
4095
 
3665
4096
  @files['file'] = file
@@ -3668,11 +4099,11 @@ module Pdfcrowd
3668
4099
 
3669
4100
  # Convert a local file and write the result to a local file.
3670
4101
  #
3671
- # * +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.
4102
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
3672
4103
  # * +file_path+ - The output file path. The string must not be empty.
3673
4104
  def convertFileToFile(file, file_path)
3674
4105
  if (!(!file_path.nil? && !file_path.empty?))
3675
- 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);
4106
+ 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);
3676
4107
  end
3677
4108
 
3678
4109
  output_file = open(file_path, "wb")
@@ -3710,7 +4141,7 @@ module Pdfcrowd
3710
4141
  # * +file_path+ - The output file path. The string must not be empty.
3711
4142
  def convertRawDataToFile(data, file_path)
3712
4143
  if (!(!file_path.nil? && !file_path.empty?))
3713
- 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);
4144
+ 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);
3714
4145
  end
3715
4146
 
3716
4147
  output_file = open(file_path, "wb")
@@ -3724,6 +4155,44 @@ module Pdfcrowd
3724
4155
  end
3725
4156
  end
3726
4157
 
4158
+ # Convert the contents of an input stream.
4159
+ #
4160
+ # * +in_stream+ - The input stream with source data.
4161
+ # * *Returns* - Byte array containing the conversion output.
4162
+ def convertStream(in_stream)
4163
+ @raw_data['stream'] = in_stream.read
4164
+ @helper.post(@fields, @files, @raw_data)
4165
+ end
4166
+
4167
+ # Convert the contents of an input stream and write the result to an output stream.
4168
+ #
4169
+ # * +in_stream+ - The input stream with source data.
4170
+ # * +out_stream+ - The output stream that will contain the conversion output.
4171
+ def convertStreamToStream(in_stream, out_stream)
4172
+ @raw_data['stream'] = in_stream.read
4173
+ @helper.post(@fields, @files, @raw_data, out_stream)
4174
+ end
4175
+
4176
+ # Convert the contents of an input stream and write the result to a local file.
4177
+ #
4178
+ # * +in_stream+ - The input stream with source data.
4179
+ # * +file_path+ - The output file path. The string must not be empty.
4180
+ def convertStreamToFile(in_stream, file_path)
4181
+ if (!(!file_path.nil? && !file_path.empty?))
4182
+ 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);
4183
+ end
4184
+
4185
+ output_file = open(file_path, "wb")
4186
+ begin
4187
+ convertStreamToStream(in_stream, output_file)
4188
+ output_file.close()
4189
+ rescue Error => why
4190
+ output_file.close()
4191
+ FileUtils.rm(file_path)
4192
+ raise
4193
+ end
4194
+ end
4195
+
3727
4196
  # Resize the image.
3728
4197
  #
3729
4198
  # * +resize+ - The resize percentage or new image dimensions.
@@ -3744,10 +4213,10 @@ module Pdfcrowd
3744
4213
 
3745
4214
  # 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.
3746
4215
  #
3747
- # * +debug_log+ - Set to true to enable the debug logging.
4216
+ # * +value+ - Set to true to enable the debug logging.
3748
4217
  # * *Returns* - The converter object.
3749
- def setDebugLog(debug_log)
3750
- @fields['debug_log'] = debug_log
4218
+ def setDebugLog(value)
4219
+ @fields['debug_log'] = value
3751
4220
  self
3752
4221
  end
3753
4222
 
@@ -3784,6 +4253,12 @@ module Pdfcrowd
3784
4253
  return @helper.getOutputSize()
3785
4254
  end
3786
4255
 
4256
+ # Get the version details.
4257
+ # * *Returns* - API version, converter version, and client version.
4258
+ def getVersion()
4259
+ return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
4260
+ end
4261
+
3787
4262
  # Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
3788
4263
  #
3789
4264
  # * +tag+ - A string with the custom tag.
@@ -3795,46 +4270,59 @@ module Pdfcrowd
3795
4270
 
3796
4271
  # 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.
3797
4272
  #
3798
- # * +http_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
4273
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
3799
4274
  # * *Returns* - The converter object.
3800
- def setHttpProxy(http_proxy)
3801
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(http_proxy)
3802
- 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);
4275
+ def setHttpProxy(proxy)
4276
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
4277
+ 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);
3803
4278
  end
3804
4279
 
3805
- @fields['http_proxy'] = http_proxy
4280
+ @fields['http_proxy'] = proxy
3806
4281
  self
3807
4282
  end
3808
4283
 
3809
4284
  # 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.
3810
4285
  #
3811
- # * +https_proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
4286
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
4287
+ # * *Returns* - The converter object.
4288
+ def setHttpsProxy(proxy)
4289
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
4290
+ 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);
4291
+ end
4292
+
4293
+ @fields['https_proxy'] = proxy
4294
+ self
4295
+ end
4296
+
4297
+ # Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
4298
+ #
4299
+ # * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
3812
4300
  # * *Returns* - The converter object.
3813
- def setHttpsProxy(https_proxy)
3814
- unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(https_proxy)
3815
- 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);
4301
+ def setConverterVersion(version)
4302
+ unless /(?i)^(latest|20.10|18.10)$/.match(version)
4303
+ 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);
3816
4304
  end
3817
4305
 
3818
- @fields['https_proxy'] = https_proxy
4306
+ @helper.setConverterVersion(version)
3819
4307
  self
3820
4308
  end
3821
4309
 
3822
4310
  # Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
3823
4311
  # Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
3824
4312
  #
3825
- # * +use_http+ - Set to true to use HTTP.
4313
+ # * +value+ - Set to true to use HTTP.
3826
4314
  # * *Returns* - The converter object.
3827
- def setUseHttp(use_http)
3828
- @helper.setUseHttp(use_http)
4315
+ def setUseHttp(value)
4316
+ @helper.setUseHttp(value)
3829
4317
  self
3830
4318
  end
3831
4319
 
3832
- # Set a custom user agent HTTP header. It can be usefull if you are behind some proxy or firewall.
4320
+ # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
3833
4321
  #
3834
- # * +user_agent+ - The user agent string.
4322
+ # * +agent+ - The user agent string.
3835
4323
  # * *Returns* - The converter object.
3836
- def setUserAgent(user_agent)
3837
- @helper.setUserAgent(user_agent)
4324
+ def setUserAgent(agent)
4325
+ @helper.setUserAgent(agent)
3838
4326
  self
3839
4327
  end
3840
4328
 
@@ -3852,10 +4340,10 @@ module Pdfcrowd
3852
4340
 
3853
4341
  # 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.
3854
4342
  #
3855
- # * +retry_count+ - Number of retries wanted.
4343
+ # * +count+ - Number of retries wanted.
3856
4344
  # * *Returns* - The converter object.
3857
- def setRetryCount(retry_count)
3858
- @helper.setRetryCount(retry_count)
4345
+ def setRetryCount(count)
4346
+ @helper.setRetryCount(count)
3859
4347
  self
3860
4348
  end
3861
4349