pdfcrowd 4.12.0 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/pdfcrowd.rb +953 -711
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: cc58c568c0a12634d68d5dac7c41204f0f85700625b51ca8a88e71d4b6561cf7
|
4
|
+
data.tar.gz: a468401553b1ddaa4baf20d7941e0e5c62ed3f5a96b4a39dfb804186598454af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51baf77a8349fccdbd38959e3beca4d8db1640f28151ee58808c617679315a3b6aac98334e5a83549a9bd61d184391791bf5ecc210faf60195defc1dc05f7bbe
|
7
|
+
data.tar.gz: 5b0f93f5c60e5e7eba9406deeed8d1d13d2a215dc98b55082c399c7a5816b109840b92c527f8f55662c9b2a7893aaf4defe5a3bf7da2c9fb492b10849c6cc9e6
|
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 = '
|
533
|
+
CLIENT_VERSION = '5.0.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/
|
544
|
+
setUserAgent('pdfcrowd_ruby_client/5.0.0 (http://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 =
|
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
|
612
|
-
Net::HTTP::Post.new('/convert/')
|
620
|
+
def create_request()
|
621
|
+
Net::HTTP::Post.new('/convert/%s/' % @converter_version)
|
613
622
|
end
|
614
623
|
|
615
624
|
def self.add_file_field(name, file_name, data, body)
|
@@ -724,7 +733,7 @@ module Pdfcrowd
|
|
724
733
|
end
|
725
734
|
|
726
735
|
def self.create_invalid_value_message(value, field, converter, hint, id)
|
727
|
-
message = "Invalid value '%s' for
|
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, "
|
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, "
|
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, "
|
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")
|
@@ -888,40 +897,40 @@ module Pdfcrowd
|
|
888
897
|
|
889
898
|
# Set the output page size.
|
890
899
|
#
|
891
|
-
# * +
|
900
|
+
# * +size+ - Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.
|
892
901
|
# * *Returns* - The converter object.
|
893
|
-
def setPageSize(
|
894
|
-
unless /(?i)^(A2|A3|A4|A5|A6|Letter)$/.match(
|
895
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
902
|
+
def setPageSize(size)
|
903
|
+
unless /(?i)^(A0|A1|A2|A3|A4|A5|A6|Letter)$/.match(size)
|
904
|
+
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
905
|
end
|
897
906
|
|
898
|
-
@fields['page_size'] =
|
907
|
+
@fields['page_size'] = size
|
899
908
|
self
|
900
909
|
end
|
901
910
|
|
902
911
|
# Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
|
903
912
|
#
|
904
|
-
# * +
|
913
|
+
# * +width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
905
914
|
# * *Returns* - The converter object.
|
906
|
-
def setPageWidth(
|
907
|
-
unless /(?i)^[0-9]
|
908
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
915
|
+
def setPageWidth(width)
|
916
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
|
917
|
+
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
918
|
end
|
910
919
|
|
911
|
-
@fields['page_width'] =
|
920
|
+
@fields['page_width'] = width
|
912
921
|
self
|
913
922
|
end
|
914
923
|
|
915
924
|
# 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
925
|
#
|
917
|
-
# * +
|
926
|
+
# * +height+ - Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
918
927
|
# * *Returns* - The converter object.
|
919
|
-
def setPageHeight(
|
920
|
-
unless /(?i)
|
921
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
928
|
+
def setPageHeight(height)
|
929
|
+
unless /(?i)^0$|^\-1$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
930
|
+
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
931
|
end
|
923
932
|
|
924
|
-
@fields['page_height'] =
|
933
|
+
@fields['page_height'] = height
|
925
934
|
self
|
926
935
|
end
|
927
936
|
|
@@ -942,7 +951,7 @@ module Pdfcrowd
|
|
942
951
|
# * *Returns* - The converter object.
|
943
952
|
def setOrientation(orientation)
|
944
953
|
unless /(?i)^(landscape|portrait)$/.match(orientation)
|
945
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(orientation, "
|
954
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(orientation, "setOrientation", "html-to-pdf", "Allowed values are landscape, portrait.", "set_orientation"), 470);
|
946
955
|
end
|
947
956
|
|
948
957
|
@fields['orientation'] = orientation
|
@@ -951,62 +960,62 @@ module Pdfcrowd
|
|
951
960
|
|
952
961
|
# Set the output page top margin.
|
953
962
|
#
|
954
|
-
# * +
|
963
|
+
# * +top+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
955
964
|
# * *Returns* - The converter object.
|
956
|
-
def setMarginTop(
|
957
|
-
unless /(?i)^[0-9]
|
958
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
965
|
+
def setMarginTop(top)
|
966
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(top)
|
967
|
+
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
968
|
end
|
960
969
|
|
961
|
-
@fields['margin_top'] =
|
970
|
+
@fields['margin_top'] = top
|
962
971
|
self
|
963
972
|
end
|
964
973
|
|
965
974
|
# Set the output page right margin.
|
966
975
|
#
|
967
|
-
# * +
|
976
|
+
# * +right+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
968
977
|
# * *Returns* - The converter object.
|
969
|
-
def setMarginRight(
|
970
|
-
unless /(?i)^[0-9]
|
971
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
978
|
+
def setMarginRight(right)
|
979
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(right)
|
980
|
+
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
981
|
end
|
973
982
|
|
974
|
-
@fields['margin_right'] =
|
983
|
+
@fields['margin_right'] = right
|
975
984
|
self
|
976
985
|
end
|
977
986
|
|
978
987
|
# Set the output page bottom margin.
|
979
988
|
#
|
980
|
-
# * +
|
989
|
+
# * +bottom+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
981
990
|
# * *Returns* - The converter object.
|
982
|
-
def setMarginBottom(
|
983
|
-
unless /(?i)^[0-9]
|
984
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
991
|
+
def setMarginBottom(bottom)
|
992
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(bottom)
|
993
|
+
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
994
|
end
|
986
995
|
|
987
|
-
@fields['margin_bottom'] =
|
996
|
+
@fields['margin_bottom'] = bottom
|
988
997
|
self
|
989
998
|
end
|
990
999
|
|
991
1000
|
# Set the output page left margin.
|
992
1001
|
#
|
993
|
-
# * +
|
1002
|
+
# * +left+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
994
1003
|
# * *Returns* - The converter object.
|
995
|
-
def setMarginLeft(
|
996
|
-
unless /(?i)^[0-9]
|
997
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1004
|
+
def setMarginLeft(left)
|
1005
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(left)
|
1006
|
+
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
1007
|
end
|
999
1008
|
|
1000
|
-
@fields['margin_left'] =
|
1009
|
+
@fields['margin_left'] = left
|
1001
1010
|
self
|
1002
1011
|
end
|
1003
1012
|
|
1004
1013
|
# Disable page margins.
|
1005
1014
|
#
|
1006
|
-
# * +
|
1015
|
+
# * +value+ - Set to true to disable margins.
|
1007
1016
|
# * *Returns* - The converter object.
|
1008
|
-
def setNoMargins(
|
1009
|
-
@fields['no_margins'] =
|
1017
|
+
def setNoMargins(value)
|
1018
|
+
@fields['no_margins'] = value
|
1010
1019
|
self
|
1011
1020
|
end
|
1012
1021
|
|
@@ -1027,79 +1036,88 @@ module Pdfcrowd
|
|
1027
1036
|
|
1028
1037
|
# Load an HTML code from the specified URL and use it as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1029
1038
|
#
|
1030
|
-
# * +
|
1039
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1031
1040
|
# * *Returns* - The converter object.
|
1032
|
-
def setHeaderUrl(
|
1033
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
1034
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1041
|
+
def setHeaderUrl(url)
|
1042
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1043
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setHeaderUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_header_url"), 470);
|
1035
1044
|
end
|
1036
1045
|
|
1037
|
-
@fields['header_url'] =
|
1046
|
+
@fields['header_url'] = url
|
1038
1047
|
self
|
1039
1048
|
end
|
1040
1049
|
|
1041
1050
|
# Use the specified HTML code as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1042
1051
|
#
|
1043
|
-
# * +
|
1052
|
+
# * +html+ - The string must not be empty.
|
1044
1053
|
# * *Returns* - The converter object.
|
1045
|
-
def setHeaderHtml(
|
1046
|
-
if (!(!
|
1047
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1054
|
+
def setHeaderHtml(html)
|
1055
|
+
if (!(!html.nil? && !html.empty?))
|
1056
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setHeaderHtml", "html-to-pdf", "The string must not be empty.", "set_header_html"), 470);
|
1048
1057
|
end
|
1049
1058
|
|
1050
|
-
@fields['header_html'] =
|
1059
|
+
@fields['header_html'] = html
|
1051
1060
|
self
|
1052
1061
|
end
|
1053
1062
|
|
1054
1063
|
# Set the header height.
|
1055
1064
|
#
|
1056
|
-
# * +
|
1065
|
+
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1057
1066
|
# * *Returns* - The converter object.
|
1058
|
-
def setHeaderHeight(
|
1059
|
-
unless /(?i)^[0-9]
|
1060
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1067
|
+
def setHeaderHeight(height)
|
1068
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1069
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setHeaderHeight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_header_height"), 470);
|
1061
1070
|
end
|
1062
1071
|
|
1063
|
-
@fields['header_height'] =
|
1072
|
+
@fields['header_height'] = height
|
1064
1073
|
self
|
1065
1074
|
end
|
1066
1075
|
|
1067
1076
|
# Load an HTML code from the specified URL and use it as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1068
1077
|
#
|
1069
|
-
# * +
|
1078
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1070
1079
|
# * *Returns* - The converter object.
|
1071
|
-
def setFooterUrl(
|
1072
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
1073
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1080
|
+
def setFooterUrl(url)
|
1081
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1082
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setFooterUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_footer_url"), 470);
|
1074
1083
|
end
|
1075
1084
|
|
1076
|
-
@fields['footer_url'] =
|
1085
|
+
@fields['footer_url'] = url
|
1077
1086
|
self
|
1078
1087
|
end
|
1079
1088
|
|
1080
1089
|
# Use the specified HTML as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1081
1090
|
#
|
1082
|
-
# * +
|
1091
|
+
# * +html+ - The string must not be empty.
|
1083
1092
|
# * *Returns* - The converter object.
|
1084
|
-
def setFooterHtml(
|
1085
|
-
if (!(!
|
1086
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1093
|
+
def setFooterHtml(html)
|
1094
|
+
if (!(!html.nil? && !html.empty?))
|
1095
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setFooterHtml", "html-to-pdf", "The string must not be empty.", "set_footer_html"), 470);
|
1087
1096
|
end
|
1088
1097
|
|
1089
|
-
@fields['footer_html'] =
|
1098
|
+
@fields['footer_html'] = html
|
1090
1099
|
self
|
1091
1100
|
end
|
1092
1101
|
|
1093
1102
|
# Set the footer height.
|
1094
1103
|
#
|
1095
|
-
# * +
|
1104
|
+
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1096
1105
|
# * *Returns* - The converter object.
|
1097
|
-
def setFooterHeight(
|
1098
|
-
unless /(?i)^[0-9]
|
1099
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1106
|
+
def setFooterHeight(height)
|
1107
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1108
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setFooterHeight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_footer_height"), 470);
|
1100
1109
|
end
|
1101
1110
|
|
1102
|
-
@fields['footer_height'] =
|
1111
|
+
@fields['footer_height'] = height
|
1112
|
+
self
|
1113
|
+
end
|
1114
|
+
|
1115
|
+
# Disable horizontal page margins for header and footer. The header/footer contents width will be equal to the physical page width.
|
1116
|
+
#
|
1117
|
+
# * +value+ - Set to true to disable horizontal margins for header and footer.
|
1118
|
+
# * *Returns* - The converter object.
|
1119
|
+
def setNoHeaderFooterHorizontalMargins(value)
|
1120
|
+
@fields['no_header_footer_horizontal_margins'] = value
|
1103
1121
|
self
|
1104
1122
|
end
|
1105
1123
|
|
@@ -1109,7 +1127,7 @@ module Pdfcrowd
|
|
1109
1127
|
# * *Returns* - The converter object.
|
1110
1128
|
def setPrintPageRange(pages)
|
1111
1129
|
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, "
|
1130
|
+
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);
|
1113
1131
|
end
|
1114
1132
|
|
1115
1133
|
@fields['print_page_range'] = pages
|
@@ -1122,7 +1140,7 @@ module Pdfcrowd
|
|
1122
1140
|
# * *Returns* - The converter object.
|
1123
1141
|
def setExcludeHeaderOnPages(pages)
|
1124
1142
|
unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
|
1125
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "
|
1143
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setExcludeHeaderOnPages", "html-to-pdf", "A comma separated list of page numbers.", "set_exclude_header_on_pages"), 470);
|
1126
1144
|
end
|
1127
1145
|
|
1128
1146
|
@fields['exclude_header_on_pages'] = pages
|
@@ -1135,7 +1153,7 @@ module Pdfcrowd
|
|
1135
1153
|
# * *Returns* - The converter object.
|
1136
1154
|
def setExcludeFooterOnPages(pages)
|
1137
1155
|
unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
|
1138
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "
|
1156
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setExcludeFooterOnPages", "html-to-pdf", "A comma separated list of page numbers.", "set_exclude_footer_on_pages"), 470);
|
1139
1157
|
end
|
1140
1158
|
|
1141
1159
|
@fields['exclude_footer_on_pages'] = pages
|
@@ -1153,53 +1171,53 @@ module Pdfcrowd
|
|
1153
1171
|
|
1154
1172
|
# Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
|
1155
1173
|
#
|
1156
|
-
# * +
|
1174
|
+
# * +x+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
|
1157
1175
|
# * *Returns* - The converter object.
|
1158
|
-
def setContentAreaX(
|
1159
|
-
unless /(?i)
|
1160
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1176
|
+
def setContentAreaX(x)
|
1177
|
+
unless /(?i)^0$|^\-?[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(x)
|
1178
|
+
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);
|
1161
1179
|
end
|
1162
1180
|
|
1163
|
-
@fields['content_area_x'] =
|
1181
|
+
@fields['content_area_x'] = x
|
1164
1182
|
self
|
1165
1183
|
end
|
1166
1184
|
|
1167
1185
|
# Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
|
1168
1186
|
#
|
1169
|
-
# * +
|
1187
|
+
# * +y+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
|
1170
1188
|
# * *Returns* - The converter object.
|
1171
|
-
def setContentAreaY(
|
1172
|
-
unless /(?i)
|
1173
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1189
|
+
def setContentAreaY(y)
|
1190
|
+
unless /(?i)^0$|^\-?[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(y)
|
1191
|
+
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);
|
1174
1192
|
end
|
1175
1193
|
|
1176
|
-
@fields['content_area_y'] =
|
1194
|
+
@fields['content_area_y'] = y
|
1177
1195
|
self
|
1178
1196
|
end
|
1179
1197
|
|
1180
1198
|
# Set the width of the content area. It should be at least 1 inch.
|
1181
1199
|
#
|
1182
|
-
# * +
|
1200
|
+
# * +width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1183
1201
|
# * *Returns* - The converter object.
|
1184
|
-
def setContentAreaWidth(
|
1185
|
-
unless /(?i)^[0-9]
|
1186
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1202
|
+
def setContentAreaWidth(width)
|
1203
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
|
1204
|
+
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);
|
1187
1205
|
end
|
1188
1206
|
|
1189
|
-
@fields['content_area_width'] =
|
1207
|
+
@fields['content_area_width'] = width
|
1190
1208
|
self
|
1191
1209
|
end
|
1192
1210
|
|
1193
1211
|
# Set the height of the content area. It should be at least 1 inch.
|
1194
1212
|
#
|
1195
|
-
# * +
|
1213
|
+
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1196
1214
|
# * *Returns* - The converter object.
|
1197
|
-
def setContentAreaHeight(
|
1198
|
-
unless /(?i)^[0-9]
|
1199
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1215
|
+
def setContentAreaHeight(height)
|
1216
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1217
|
+
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);
|
1200
1218
|
end
|
1201
1219
|
|
1202
|
-
@fields['content_area_height'] =
|
1220
|
+
@fields['content_area_height'] = height
|
1203
1221
|
self
|
1204
1222
|
end
|
1205
1223
|
|
@@ -1218,6 +1236,19 @@ module Pdfcrowd
|
|
1218
1236
|
self
|
1219
1237
|
end
|
1220
1238
|
|
1239
|
+
# Specifies behavior in presence of CSS @page rules. It may affect the page size, margins and orientation.
|
1240
|
+
#
|
1241
|
+
# * +mode+ - The page rule mode. Allowed values are default, mode1, mode2.
|
1242
|
+
# * *Returns* - The converter object.
|
1243
|
+
def setCssPageRuleMode(mode)
|
1244
|
+
unless /(?i)^(default|mode1|mode2)$/.match(mode)
|
1245
|
+
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);
|
1246
|
+
end
|
1247
|
+
|
1248
|
+
@fields['css_page_rule_mode'] = mode
|
1249
|
+
self
|
1250
|
+
end
|
1251
|
+
|
1221
1252
|
# Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
|
1222
1253
|
#
|
1223
1254
|
# * +data_string+ - The input data string.
|
@@ -1242,7 +1273,7 @@ module Pdfcrowd
|
|
1242
1273
|
# * *Returns* - The converter object.
|
1243
1274
|
def setDataFormat(data_format)
|
1244
1275
|
unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
|
1245
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(data_format, "
|
1276
|
+
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);
|
1246
1277
|
end
|
1247
1278
|
|
1248
1279
|
@fields['data_format'] = data_format
|
@@ -1251,217 +1282,248 @@ module Pdfcrowd
|
|
1251
1282
|
|
1252
1283
|
# Set the encoding of the data file set by setDataFile.
|
1253
1284
|
#
|
1254
|
-
# * +
|
1285
|
+
# * +encoding+ - The data file encoding.
|
1255
1286
|
# * *Returns* - The converter object.
|
1256
|
-
def setDataEncoding(
|
1257
|
-
@fields['data_encoding'] =
|
1287
|
+
def setDataEncoding(encoding)
|
1288
|
+
@fields['data_encoding'] = encoding
|
1258
1289
|
self
|
1259
1290
|
end
|
1260
1291
|
|
1261
1292
|
# 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.
|
1262
1293
|
#
|
1263
|
-
# * +
|
1294
|
+
# * +value+ - Set to true to ignore undefined variables.
|
1264
1295
|
# * *Returns* - The converter object.
|
1265
|
-
def setDataIgnoreUndefined(
|
1266
|
-
@fields['data_ignore_undefined'] =
|
1296
|
+
def setDataIgnoreUndefined(value)
|
1297
|
+
@fields['data_ignore_undefined'] = value
|
1267
1298
|
self
|
1268
1299
|
end
|
1269
1300
|
|
1270
1301
|
# Auto escape HTML symbols in the input data before placing them into the output.
|
1271
1302
|
#
|
1272
|
-
# * +
|
1303
|
+
# * +value+ - Set to true to turn auto escaping on.
|
1273
1304
|
# * *Returns* - The converter object.
|
1274
|
-
def setDataAutoEscape(
|
1275
|
-
@fields['data_auto_escape'] =
|
1305
|
+
def setDataAutoEscape(value)
|
1306
|
+
@fields['data_auto_escape'] = value
|
1276
1307
|
self
|
1277
1308
|
end
|
1278
1309
|
|
1279
1310
|
# Auto trim whitespace around each template command block.
|
1280
1311
|
#
|
1281
|
-
# * +
|
1312
|
+
# * +value+ - Set to true to turn auto trimming on.
|
1282
1313
|
# * *Returns* - The converter object.
|
1283
|
-
def setDataTrimBlocks(
|
1284
|
-
@fields['data_trim_blocks'] =
|
1314
|
+
def setDataTrimBlocks(value)
|
1315
|
+
@fields['data_trim_blocks'] = value
|
1285
1316
|
self
|
1286
1317
|
end
|
1287
1318
|
|
1288
1319
|
# 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.
|
1289
1320
|
#
|
1290
|
-
# * +
|
1321
|
+
# * +options+ - Comma separated list of options.
|
1291
1322
|
# * *Returns* - The converter object.
|
1292
|
-
def setDataOptions(
|
1293
|
-
@fields['data_options'] =
|
1323
|
+
def setDataOptions(options)
|
1324
|
+
@fields['data_options'] = options
|
1294
1325
|
self
|
1295
1326
|
end
|
1296
1327
|
|
1297
1328
|
# Apply the first page of the watermark PDF to every page of the output PDF.
|
1298
1329
|
#
|
1299
|
-
# * +
|
1330
|
+
# * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
|
1300
1331
|
# * *Returns* - The converter object.
|
1301
|
-
def setPageWatermark(
|
1302
|
-
if (!(File.file?(
|
1303
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1332
|
+
def setPageWatermark(watermark)
|
1333
|
+
if (!(File.file?(watermark) && !File.zero?(watermark)))
|
1334
|
+
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
1335
|
end
|
1305
1336
|
|
1306
|
-
@files['page_watermark'] =
|
1337
|
+
@files['page_watermark'] = watermark
|
1307
1338
|
self
|
1308
1339
|
end
|
1309
1340
|
|
1310
1341
|
# 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
1342
|
#
|
1312
|
-
# * +
|
1343
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1313
1344
|
# * *Returns* - The converter object.
|
1314
|
-
def setPageWatermarkUrl(
|
1315
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
1316
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1345
|
+
def setPageWatermarkUrl(url)
|
1346
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1347
|
+
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
1348
|
end
|
1318
1349
|
|
1319
|
-
@fields['page_watermark_url'] =
|
1350
|
+
@fields['page_watermark_url'] = url
|
1320
1351
|
self
|
1321
1352
|
end
|
1322
1353
|
|
1323
1354
|
# Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
|
1324
1355
|
#
|
1325
|
-
# * +
|
1356
|
+
# * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
|
1326
1357
|
# * *Returns* - The converter object.
|
1327
|
-
def setMultipageWatermark(
|
1328
|
-
if (!(File.file?(
|
1329
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1358
|
+
def setMultipageWatermark(watermark)
|
1359
|
+
if (!(File.file?(watermark) && !File.zero?(watermark)))
|
1360
|
+
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
1361
|
end
|
1331
1362
|
|
1332
|
-
@files['multipage_watermark'] =
|
1363
|
+
@files['multipage_watermark'] = watermark
|
1333
1364
|
self
|
1334
1365
|
end
|
1335
1366
|
|
1336
1367
|
# 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
1368
|
#
|
1338
|
-
# * +
|
1369
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1339
1370
|
# * *Returns* - The converter object.
|
1340
|
-
def setMultipageWatermarkUrl(
|
1341
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
1342
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1371
|
+
def setMultipageWatermarkUrl(url)
|
1372
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1373
|
+
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
1374
|
end
|
1344
1375
|
|
1345
|
-
@fields['multipage_watermark_url'] =
|
1376
|
+
@fields['multipage_watermark_url'] = url
|
1346
1377
|
self
|
1347
1378
|
end
|
1348
1379
|
|
1349
1380
|
# Apply the first page of the specified PDF to the background of every page of the output PDF.
|
1350
1381
|
#
|
1351
|
-
# * +
|
1382
|
+
# * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
|
1352
1383
|
# * *Returns* - The converter object.
|
1353
|
-
def setPageBackground(
|
1354
|
-
if (!(File.file?(
|
1355
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1384
|
+
def setPageBackground(background)
|
1385
|
+
if (!(File.file?(background) && !File.zero?(background)))
|
1386
|
+
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
1387
|
end
|
1357
1388
|
|
1358
|
-
@files['page_background'] =
|
1389
|
+
@files['page_background'] = background
|
1359
1390
|
self
|
1360
1391
|
end
|
1361
1392
|
|
1362
1393
|
# 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
1394
|
#
|
1364
|
-
# * +
|
1395
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1365
1396
|
# * *Returns* - The converter object.
|
1366
|
-
def setPageBackgroundUrl(
|
1367
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
1368
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1397
|
+
def setPageBackgroundUrl(url)
|
1398
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1399
|
+
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
1400
|
end
|
1370
1401
|
|
1371
|
-
@fields['page_background_url'] =
|
1402
|
+
@fields['page_background_url'] = url
|
1372
1403
|
self
|
1373
1404
|
end
|
1374
1405
|
|
1375
1406
|
# Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
|
1376
1407
|
#
|
1377
|
-
# * +
|
1408
|
+
# * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
|
1378
1409
|
# * *Returns* - The converter object.
|
1379
|
-
def setMultipageBackground(
|
1380
|
-
if (!(File.file?(
|
1381
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1410
|
+
def setMultipageBackground(background)
|
1411
|
+
if (!(File.file?(background) && !File.zero?(background)))
|
1412
|
+
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
1413
|
end
|
1383
1414
|
|
1384
|
-
@files['multipage_background'] =
|
1415
|
+
@files['multipage_background'] = background
|
1385
1416
|
self
|
1386
1417
|
end
|
1387
1418
|
|
1388
1419
|
# 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
1420
|
#
|
1390
|
-
# * +
|
1421
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1391
1422
|
# * *Returns* - The converter object.
|
1392
|
-
def setMultipageBackgroundUrl(
|
1393
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
1394
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1423
|
+
def setMultipageBackgroundUrl(url)
|
1424
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1425
|
+
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
1426
|
end
|
1396
1427
|
|
1397
|
-
@fields['multipage_background_url'] =
|
1428
|
+
@fields['multipage_background_url'] = url
|
1398
1429
|
self
|
1399
1430
|
end
|
1400
1431
|
|
1401
1432
|
# The page background color in RGB or RGBA hexadecimal format. The color fills the entire page regardless of the margins.
|
1402
1433
|
#
|
1403
|
-
# * +
|
1434
|
+
# * +color+ - The value must be in RRGGBB or RRGGBBAA hexadecimal format.
|
1404
1435
|
# * *Returns* - The converter object.
|
1405
|
-
def setPageBackgroundColor(
|
1406
|
-
unless /^[0-9a-fA-F]{6,8}$/.match(
|
1407
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1436
|
+
def setPageBackgroundColor(color)
|
1437
|
+
unless /^[0-9a-fA-F]{6,8}$/.match(color)
|
1438
|
+
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
1439
|
end
|
1409
1440
|
|
1410
|
-
@fields['page_background_color'] =
|
1441
|
+
@fields['page_background_color'] = color
|
1442
|
+
self
|
1443
|
+
end
|
1444
|
+
|
1445
|
+
# Use the print version of the page if available (@media print).
|
1446
|
+
#
|
1447
|
+
# * +value+ - Set to true to use the print version of the page.
|
1448
|
+
# * *Returns* - The converter object.
|
1449
|
+
def setUsePrintMedia(value)
|
1450
|
+
@fields['use_print_media'] = value
|
1411
1451
|
self
|
1412
1452
|
end
|
1413
1453
|
|
1414
1454
|
# Do not print the background graphics.
|
1415
1455
|
#
|
1416
|
-
# * +
|
1456
|
+
# * +value+ - Set to true to disable the background graphics.
|
1417
1457
|
# * *Returns* - The converter object.
|
1418
|
-
def setNoBackground(
|
1419
|
-
@fields['no_background'] =
|
1458
|
+
def setNoBackground(value)
|
1459
|
+
@fields['no_background'] = value
|
1420
1460
|
self
|
1421
1461
|
end
|
1422
1462
|
|
1423
1463
|
# Do not execute JavaScript.
|
1424
1464
|
#
|
1425
|
-
# * +
|
1465
|
+
# * +value+ - Set to true to disable JavaScript in web pages.
|
1426
1466
|
# * *Returns* - The converter object.
|
1427
|
-
def setDisableJavascript(
|
1428
|
-
@fields['disable_javascript'] =
|
1467
|
+
def setDisableJavascript(value)
|
1468
|
+
@fields['disable_javascript'] = value
|
1429
1469
|
self
|
1430
1470
|
end
|
1431
1471
|
|
1432
1472
|
# Do not load images.
|
1433
1473
|
#
|
1434
|
-
# * +
|
1474
|
+
# * +value+ - Set to true to disable loading of images.
|
1435
1475
|
# * *Returns* - The converter object.
|
1436
|
-
def setDisableImageLoading(
|
1437
|
-
@fields['disable_image_loading'] =
|
1476
|
+
def setDisableImageLoading(value)
|
1477
|
+
@fields['disable_image_loading'] = value
|
1438
1478
|
self
|
1439
1479
|
end
|
1440
1480
|
|
1441
1481
|
# Disable loading fonts from remote sources.
|
1442
1482
|
#
|
1443
|
-
# * +
|
1483
|
+
# * +value+ - Set to true disable loading remote fonts.
|
1444
1484
|
# * *Returns* - The converter object.
|
1445
|
-
def setDisableRemoteFonts(
|
1446
|
-
@fields['disable_remote_fonts'] =
|
1485
|
+
def setDisableRemoteFonts(value)
|
1486
|
+
@fields['disable_remote_fonts'] = value
|
1487
|
+
self
|
1488
|
+
end
|
1489
|
+
|
1490
|
+
# Specifies how iframes are handled.
|
1491
|
+
#
|
1492
|
+
# * +iframes+ - Allowed values are all, same-origin, none.
|
1493
|
+
# * *Returns* - The converter object.
|
1494
|
+
def setLoadIframes(iframes)
|
1495
|
+
unless /(?i)^(all|same-origin|none)$/.match(iframes)
|
1496
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(iframes, "setLoadIframes", "html-to-pdf", "Allowed values are all, same-origin, none.", "set_load_iframes"), 470);
|
1497
|
+
end
|
1498
|
+
|
1499
|
+
@fields['load_iframes'] = iframes
|
1447
1500
|
self
|
1448
1501
|
end
|
1449
1502
|
|
1450
1503
|
# Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
|
1451
1504
|
#
|
1452
|
-
# * +
|
1505
|
+
# * +value+ - Set to true to block ads in web pages.
|
1453
1506
|
# * *Returns* - The converter object.
|
1454
|
-
def setBlockAds(
|
1455
|
-
@fields['block_ads'] =
|
1507
|
+
def setBlockAds(value)
|
1508
|
+
@fields['block_ads'] = value
|
1456
1509
|
self
|
1457
1510
|
end
|
1458
1511
|
|
1459
1512
|
# Set the default HTML content text encoding.
|
1460
1513
|
#
|
1461
|
-
# * +
|
1514
|
+
# * +encoding+ - The text encoding of the HTML content.
|
1515
|
+
# * *Returns* - The converter object.
|
1516
|
+
def setDefaultEncoding(encoding)
|
1517
|
+
@fields['default_encoding'] = encoding
|
1518
|
+
self
|
1519
|
+
end
|
1520
|
+
|
1521
|
+
# Set the locale for the conversion. This may affect the output format of dates, times and numbers.
|
1522
|
+
#
|
1523
|
+
# * +locale+ - The locale code according to ISO 639.
|
1462
1524
|
# * *Returns* - The converter object.
|
1463
|
-
def
|
1464
|
-
@fields['
|
1525
|
+
def setLocale(locale)
|
1526
|
+
@fields['locale'] = locale
|
1465
1527
|
self
|
1466
1528
|
end
|
1467
1529
|
|
@@ -1494,24 +1556,6 @@ module Pdfcrowd
|
|
1494
1556
|
self
|
1495
1557
|
end
|
1496
1558
|
|
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
1559
|
# Set cookies that are sent in Pdfcrowd HTTP requests.
|
1516
1560
|
#
|
1517
1561
|
# * +cookies+ - The cookie string.
|
@@ -1523,10 +1567,10 @@ module Pdfcrowd
|
|
1523
1567
|
|
1524
1568
|
# Do not allow insecure HTTPS connections.
|
1525
1569
|
#
|
1526
|
-
# * +
|
1570
|
+
# * +value+ - Set to true to enable SSL certificate verification.
|
1527
1571
|
# * *Returns* - The converter object.
|
1528
|
-
def setVerifySslCertificates(
|
1529
|
-
@fields['verify_ssl_certificates'] =
|
1572
|
+
def setVerifySslCertificates(value)
|
1573
|
+
@fields['verify_ssl_certificates'] = value
|
1530
1574
|
self
|
1531
1575
|
end
|
1532
1576
|
|
@@ -1548,55 +1592,64 @@ module Pdfcrowd
|
|
1548
1592
|
self
|
1549
1593
|
end
|
1550
1594
|
|
1595
|
+
# Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
|
1596
|
+
#
|
1597
|
+
# * +value+ - Set to true to disable sending X-Pdfcrowd HTTP header.
|
1598
|
+
# * *Returns* - The converter object.
|
1599
|
+
def setNoXpdfcrowdHeader(value)
|
1600
|
+
@fields['no_xpdfcrowd_header'] = value
|
1601
|
+
self
|
1602
|
+
end
|
1603
|
+
|
1551
1604
|
# 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
1605
|
#
|
1553
|
-
# * +
|
1606
|
+
# * +javascript+ - A string containing a JavaScript code. The string must not be empty.
|
1554
1607
|
# * *Returns* - The converter object.
|
1555
|
-
def setCustomJavascript(
|
1556
|
-
if (!(!
|
1557
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1608
|
+
def setCustomJavascript(javascript)
|
1609
|
+
if (!(!javascript.nil? && !javascript.empty?))
|
1610
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setCustomJavascript", "html-to-pdf", "The string must not be empty.", "set_custom_javascript"), 470);
|
1558
1611
|
end
|
1559
1612
|
|
1560
|
-
@fields['custom_javascript'] =
|
1613
|
+
@fields['custom_javascript'] = javascript
|
1561
1614
|
self
|
1562
1615
|
end
|
1563
1616
|
|
1564
1617
|
# 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
1618
|
#
|
1566
|
-
# * +
|
1619
|
+
# * +javascript+ - A string containing a JavaScript code. The string must not be empty.
|
1567
1620
|
# * *Returns* - The converter object.
|
1568
|
-
def setOnLoadJavascript(
|
1569
|
-
if (!(!
|
1570
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1621
|
+
def setOnLoadJavascript(javascript)
|
1622
|
+
if (!(!javascript.nil? && !javascript.empty?))
|
1623
|
+
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
1624
|
end
|
1572
1625
|
|
1573
|
-
@fields['on_load_javascript'] =
|
1626
|
+
@fields['on_load_javascript'] = javascript
|
1574
1627
|
self
|
1575
1628
|
end
|
1576
1629
|
|
1577
1630
|
# Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
|
1578
1631
|
#
|
1579
|
-
# * +
|
1632
|
+
# * +header+ - A string containing the header name and value separated by a colon.
|
1580
1633
|
# * *Returns* - The converter object.
|
1581
|
-
def setCustomHttpHeader(
|
1582
|
-
unless /^.+:.+$/.match(
|
1583
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1634
|
+
def setCustomHttpHeader(header)
|
1635
|
+
unless /^.+:.+$/.match(header)
|
1636
|
+
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
1637
|
end
|
1585
1638
|
|
1586
|
-
@fields['custom_http_header'] =
|
1639
|
+
@fields['custom_http_header'] = header
|
1587
1640
|
self
|
1588
1641
|
end
|
1589
1642
|
|
1590
1643
|
# 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
1644
|
#
|
1592
|
-
# * +
|
1645
|
+
# * +delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
|
1593
1646
|
# * *Returns* - The converter object.
|
1594
|
-
def setJavascriptDelay(
|
1595
|
-
if (!(Integer(
|
1596
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1647
|
+
def setJavascriptDelay(delay)
|
1648
|
+
if (!(Integer(delay) >= 0))
|
1649
|
+
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
1650
|
end
|
1598
1651
|
|
1599
|
-
@fields['javascript_delay'] =
|
1652
|
+
@fields['javascript_delay'] = delay
|
1600
1653
|
self
|
1601
1654
|
end
|
1602
1655
|
|
@@ -1606,7 +1659,7 @@ module Pdfcrowd
|
|
1606
1659
|
# * *Returns* - The converter object.
|
1607
1660
|
def setElementToConvert(selectors)
|
1608
1661
|
if (!(!selectors.nil? && !selectors.empty?))
|
1609
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "
|
1662
|
+
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
1663
|
end
|
1611
1664
|
|
1612
1665
|
@fields['element_to_convert'] = selectors
|
@@ -1619,7 +1672,7 @@ module Pdfcrowd
|
|
1619
1672
|
# * *Returns* - The converter object.
|
1620
1673
|
def setElementToConvertMode(mode)
|
1621
1674
|
unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode)
|
1622
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "
|
1675
|
+
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
1676
|
end
|
1624
1677
|
|
1625
1678
|
@fields['element_to_convert_mode'] = mode
|
@@ -1632,7 +1685,7 @@ module Pdfcrowd
|
|
1632
1685
|
# * *Returns* - The converter object.
|
1633
1686
|
def setWaitForElement(selectors)
|
1634
1687
|
if (!(!selectors.nil? && !selectors.empty?))
|
1635
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "
|
1688
|
+
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
1689
|
end
|
1637
1690
|
|
1638
1691
|
@fields['wait_for_element'] = selectors
|
@@ -1641,27 +1694,27 @@ module Pdfcrowd
|
|
1641
1694
|
|
1642
1695
|
# Set the viewport width in pixels. The viewport is the user's visible area of the page.
|
1643
1696
|
#
|
1644
|
-
# * +
|
1697
|
+
# * +width+ - The value must be in the range 96-65000.
|
1645
1698
|
# * *Returns* - The converter object.
|
1646
|
-
def setViewportWidth(
|
1647
|
-
if (!(Integer(
|
1648
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1699
|
+
def setViewportWidth(width)
|
1700
|
+
if (!(Integer(width) >= 96 && Integer(width) <= 65000))
|
1701
|
+
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
1702
|
end
|
1650
1703
|
|
1651
|
-
@fields['viewport_width'] =
|
1704
|
+
@fields['viewport_width'] = width
|
1652
1705
|
self
|
1653
1706
|
end
|
1654
1707
|
|
1655
1708
|
# Set the viewport height in pixels. The viewport is the user's visible area of the page.
|
1656
1709
|
#
|
1657
|
-
# * +
|
1710
|
+
# * +height+ - Must be a positive integer number.
|
1658
1711
|
# * *Returns* - The converter object.
|
1659
|
-
def setViewportHeight(
|
1660
|
-
if (!(Integer(
|
1661
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1712
|
+
def setViewportHeight(height)
|
1713
|
+
if (!(Integer(height) > 0))
|
1714
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setViewportHeight", "html-to-pdf", "Must be a positive integer number.", "set_viewport_height"), 470);
|
1662
1715
|
end
|
1663
1716
|
|
1664
|
-
@fields['viewport_height'] =
|
1717
|
+
@fields['viewport_height'] = height
|
1665
1718
|
self
|
1666
1719
|
end
|
1667
1720
|
|
@@ -1678,164 +1731,155 @@ module Pdfcrowd
|
|
1678
1731
|
|
1679
1732
|
# Set the rendering mode.
|
1680
1733
|
#
|
1681
|
-
# * +
|
1734
|
+
# * +mode+ - The rendering mode. Allowed values are default, viewport.
|
1682
1735
|
# * *Returns* - The converter object.
|
1683
|
-
def setRenderingMode(
|
1684
|
-
unless /(?i)^(default|viewport)$/.match(
|
1685
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1736
|
+
def setRenderingMode(mode)
|
1737
|
+
unless /(?i)^(default|viewport)$/.match(mode)
|
1738
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setRenderingMode", "html-to-pdf", "Allowed values are default, viewport.", "set_rendering_mode"), 470);
|
1686
1739
|
end
|
1687
1740
|
|
1688
|
-
@fields['rendering_mode'] =
|
1741
|
+
@fields['rendering_mode'] = mode
|
1689
1742
|
self
|
1690
1743
|
end
|
1691
1744
|
|
1692
1745
|
# Specifies the scaling mode used for fitting the HTML contents to the print area.
|
1693
1746
|
#
|
1694
|
-
# * +
|
1747
|
+
# * +mode+ - The smart scaling mode. Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, mode1.
|
1695
1748
|
# * *Returns* - The converter object.
|
1696
|
-
def setSmartScalingMode(
|
1697
|
-
unless /(?i)^(default|disabled|viewport-fit|content-fit|single-page-fit)$/.match(
|
1698
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1749
|
+
def setSmartScalingMode(mode)
|
1750
|
+
unless /(?i)^(default|disabled|viewport-fit|content-fit|single-page-fit|mode1)$/.match(mode)
|
1751
|
+
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
1752
|
end
|
1700
1753
|
|
1701
|
-
@fields['smart_scaling_mode'] =
|
1754
|
+
@fields['smart_scaling_mode'] = mode
|
1702
1755
|
self
|
1703
1756
|
end
|
1704
1757
|
|
1705
1758
|
# Set the scaling factor (zoom) for the main page area.
|
1706
1759
|
#
|
1707
|
-
# * +
|
1760
|
+
# * +factor+ - The percentage value. The value must be in the range 10-500.
|
1708
1761
|
# * *Returns* - The converter object.
|
1709
|
-
def setScaleFactor(
|
1710
|
-
if (!(Integer(
|
1711
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1762
|
+
def setScaleFactor(factor)
|
1763
|
+
if (!(Integer(factor) >= 10 && Integer(factor) <= 500))
|
1764
|
+
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);
|
1712
1765
|
end
|
1713
1766
|
|
1714
|
-
@fields['scale_factor'] =
|
1767
|
+
@fields['scale_factor'] = factor
|
1715
1768
|
self
|
1716
1769
|
end
|
1717
1770
|
|
1718
1771
|
# Set the scaling factor (zoom) for the header and footer.
|
1719
1772
|
#
|
1720
|
-
# * +
|
1773
|
+
# * +factor+ - The percentage value. The value must be in the range 10-500.
|
1721
1774
|
# * *Returns* - The converter object.
|
1722
|
-
def setHeaderFooterScaleFactor(
|
1723
|
-
if (!(Integer(
|
1724
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1775
|
+
def setHeaderFooterScaleFactor(factor)
|
1776
|
+
if (!(Integer(factor) >= 10 && Integer(factor) <= 500))
|
1777
|
+
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);
|
1725
1778
|
end
|
1726
1779
|
|
1727
|
-
@fields['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
|
1780
|
+
@fields['header_footer_scale_factor'] = factor
|
1737
1781
|
self
|
1738
1782
|
end
|
1739
1783
|
|
1740
1784
|
# Set the quality of embedded JPEG images. A lower quality results in a smaller PDF file but can lead to compression artifacts.
|
1741
1785
|
#
|
1742
|
-
# * +
|
1786
|
+
# * +quality+ - The percentage value. The value must be in the range 1-100.
|
1743
1787
|
# * *Returns* - The converter object.
|
1744
|
-
def setJpegQuality(
|
1745
|
-
if (!(Integer(
|
1746
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1788
|
+
def setJpegQuality(quality)
|
1789
|
+
if (!(Integer(quality) >= 1 && Integer(quality) <= 100))
|
1790
|
+
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
1791
|
end
|
1748
1792
|
|
1749
|
-
@fields['jpeg_quality'] =
|
1793
|
+
@fields['jpeg_quality'] = quality
|
1750
1794
|
self
|
1751
1795
|
end
|
1752
1796
|
|
1753
1797
|
# 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
1798
|
#
|
1755
|
-
# * +
|
1799
|
+
# * +images+ - The image category. Allowed values are none, opaque, all.
|
1756
1800
|
# * *Returns* - The converter object.
|
1757
|
-
def setConvertImagesToJpeg(
|
1758
|
-
unless /(?i)^(none|opaque|all)$/.match(
|
1759
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1801
|
+
def setConvertImagesToJpeg(images)
|
1802
|
+
unless /(?i)^(none|opaque|all)$/.match(images)
|
1803
|
+
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
1804
|
end
|
1761
1805
|
|
1762
|
-
@fields['convert_images_to_jpeg'] =
|
1806
|
+
@fields['convert_images_to_jpeg'] = images
|
1763
1807
|
self
|
1764
1808
|
end
|
1765
1809
|
|
1766
1810
|
# 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
1811
|
#
|
1768
|
-
# * +
|
1812
|
+
# * +dpi+ - The DPI value. Must be a positive integer number or 0.
|
1769
1813
|
# * *Returns* - The converter object.
|
1770
|
-
def setImageDpi(
|
1771
|
-
if (!(Integer(
|
1772
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1814
|
+
def setImageDpi(dpi)
|
1815
|
+
if (!(Integer(dpi) >= 0))
|
1816
|
+
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
1817
|
end
|
1774
1818
|
|
1775
|
-
@fields['image_dpi'] =
|
1819
|
+
@fields['image_dpi'] = dpi
|
1776
1820
|
self
|
1777
1821
|
end
|
1778
1822
|
|
1779
1823
|
# Create linearized PDF. This is also known as Fast Web View.
|
1780
1824
|
#
|
1781
|
-
# * +
|
1825
|
+
# * +value+ - Set to true to create linearized PDF.
|
1782
1826
|
# * *Returns* - The converter object.
|
1783
|
-
def setLinearize(
|
1784
|
-
@fields['linearize'] =
|
1827
|
+
def setLinearize(value)
|
1828
|
+
@fields['linearize'] = value
|
1785
1829
|
self
|
1786
1830
|
end
|
1787
1831
|
|
1788
1832
|
# Encrypt the PDF. This prevents search engines from indexing the contents.
|
1789
1833
|
#
|
1790
|
-
# * +
|
1834
|
+
# * +value+ - Set to true to enable PDF encryption.
|
1791
1835
|
# * *Returns* - The converter object.
|
1792
|
-
def setEncrypt(
|
1793
|
-
@fields['encrypt'] =
|
1836
|
+
def setEncrypt(value)
|
1837
|
+
@fields['encrypt'] = value
|
1794
1838
|
self
|
1795
1839
|
end
|
1796
1840
|
|
1797
1841
|
# 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
1842
|
#
|
1799
|
-
# * +
|
1843
|
+
# * +password+ - The user password.
|
1800
1844
|
# * *Returns* - The converter object.
|
1801
|
-
def setUserPassword(
|
1802
|
-
@fields['user_password'] =
|
1845
|
+
def setUserPassword(password)
|
1846
|
+
@fields['user_password'] = password
|
1803
1847
|
self
|
1804
1848
|
end
|
1805
1849
|
|
1806
1850
|
# 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
1851
|
#
|
1808
|
-
# * +
|
1852
|
+
# * +password+ - The owner password.
|
1809
1853
|
# * *Returns* - The converter object.
|
1810
|
-
def setOwnerPassword(
|
1811
|
-
@fields['owner_password'] =
|
1854
|
+
def setOwnerPassword(password)
|
1855
|
+
@fields['owner_password'] = password
|
1812
1856
|
self
|
1813
1857
|
end
|
1814
1858
|
|
1815
1859
|
# Disallow printing of the output PDF.
|
1816
1860
|
#
|
1817
|
-
# * +
|
1861
|
+
# * +value+ - Set to true to set the no-print flag in the output PDF.
|
1818
1862
|
# * *Returns* - The converter object.
|
1819
|
-
def setNoPrint(
|
1820
|
-
@fields['no_print'] =
|
1863
|
+
def setNoPrint(value)
|
1864
|
+
@fields['no_print'] = value
|
1821
1865
|
self
|
1822
1866
|
end
|
1823
1867
|
|
1824
1868
|
# Disallow modification of the output PDF.
|
1825
1869
|
#
|
1826
|
-
# * +
|
1870
|
+
# * +value+ - Set to true to set the read-only only flag in the output PDF.
|
1827
1871
|
# * *Returns* - The converter object.
|
1828
|
-
def setNoModify(
|
1829
|
-
@fields['no_modify'] =
|
1872
|
+
def setNoModify(value)
|
1873
|
+
@fields['no_modify'] = value
|
1830
1874
|
self
|
1831
1875
|
end
|
1832
1876
|
|
1833
1877
|
# Disallow text and graphics extraction from the output PDF.
|
1834
1878
|
#
|
1835
|
-
# * +
|
1879
|
+
# * +value+ - Set to true to set the no-copy flag in the output PDF.
|
1836
1880
|
# * *Returns* - The converter object.
|
1837
|
-
def setNoCopy(
|
1838
|
-
@fields['no_copy'] =
|
1881
|
+
def setNoCopy(value)
|
1882
|
+
@fields['no_copy'] = value
|
1839
1883
|
self
|
1840
1884
|
end
|
1841
1885
|
|
@@ -1877,138 +1921,138 @@ module Pdfcrowd
|
|
1877
1921
|
|
1878
1922
|
# Specify the page layout to be used when the document is opened.
|
1879
1923
|
#
|
1880
|
-
# * +
|
1924
|
+
# * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
|
1881
1925
|
# * *Returns* - The converter object.
|
1882
|
-
def setPageLayout(
|
1883
|
-
unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(
|
1884
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1926
|
+
def setPageLayout(layout)
|
1927
|
+
unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout)
|
1928
|
+
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
1929
|
end
|
1886
1930
|
|
1887
|
-
@fields['page_layout'] =
|
1931
|
+
@fields['page_layout'] = layout
|
1888
1932
|
self
|
1889
1933
|
end
|
1890
1934
|
|
1891
1935
|
# Specify how the document should be displayed when opened.
|
1892
1936
|
#
|
1893
|
-
# * +
|
1937
|
+
# * +mode+ - Allowed values are full-screen, thumbnails, outlines.
|
1894
1938
|
# * *Returns* - The converter object.
|
1895
|
-
def setPageMode(
|
1896
|
-
unless /(?i)^(full-screen|thumbnails|outlines)$/.match(
|
1897
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1939
|
+
def setPageMode(mode)
|
1940
|
+
unless /(?i)^(full-screen|thumbnails|outlines)$/.match(mode)
|
1941
|
+
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
1942
|
end
|
1899
1943
|
|
1900
|
-
@fields['page_mode'] =
|
1944
|
+
@fields['page_mode'] = mode
|
1901
1945
|
self
|
1902
1946
|
end
|
1903
1947
|
|
1904
1948
|
# Specify how the page should be displayed when opened.
|
1905
1949
|
#
|
1906
|
-
# * +
|
1950
|
+
# * +zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
|
1907
1951
|
# * *Returns* - The converter object.
|
1908
|
-
def setInitialZoomType(
|
1909
|
-
unless /(?i)^(fit-width|fit-height|fit-page)$/.match(
|
1910
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1952
|
+
def setInitialZoomType(zoom_type)
|
1953
|
+
unless /(?i)^(fit-width|fit-height|fit-page)$/.match(zoom_type)
|
1954
|
+
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
1955
|
end
|
1912
1956
|
|
1913
|
-
@fields['initial_zoom_type'] =
|
1957
|
+
@fields['initial_zoom_type'] = zoom_type
|
1914
1958
|
self
|
1915
1959
|
end
|
1916
1960
|
|
1917
1961
|
# Display the specified page when the document is opened.
|
1918
1962
|
#
|
1919
|
-
# * +
|
1963
|
+
# * +page+ - Must be a positive integer number.
|
1920
1964
|
# * *Returns* - The converter object.
|
1921
|
-
def setInitialPage(
|
1922
|
-
if (!(Integer(
|
1923
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1965
|
+
def setInitialPage(page)
|
1966
|
+
if (!(Integer(page) > 0))
|
1967
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "html-to-pdf", "Must be a positive integer number.", "set_initial_page"), 470);
|
1924
1968
|
end
|
1925
1969
|
|
1926
|
-
@fields['initial_page'] =
|
1970
|
+
@fields['initial_page'] = page
|
1927
1971
|
self
|
1928
1972
|
end
|
1929
1973
|
|
1930
1974
|
# Specify the initial page zoom in percents when the document is opened.
|
1931
1975
|
#
|
1932
|
-
# * +
|
1976
|
+
# * +zoom+ - Must be a positive integer number.
|
1933
1977
|
# * *Returns* - The converter object.
|
1934
|
-
def setInitialZoom(
|
1935
|
-
if (!(Integer(
|
1936
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1978
|
+
def setInitialZoom(zoom)
|
1979
|
+
if (!(Integer(zoom) > 0))
|
1980
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "html-to-pdf", "Must be a positive integer number.", "set_initial_zoom"), 470);
|
1937
1981
|
end
|
1938
1982
|
|
1939
|
-
@fields['initial_zoom'] =
|
1983
|
+
@fields['initial_zoom'] = zoom
|
1940
1984
|
self
|
1941
1985
|
end
|
1942
1986
|
|
1943
1987
|
# Specify whether to hide the viewer application's tool bars when the document is active.
|
1944
1988
|
#
|
1945
|
-
# * +
|
1989
|
+
# * +value+ - Set to true to hide tool bars.
|
1946
1990
|
# * *Returns* - The converter object.
|
1947
|
-
def setHideToolbar(
|
1948
|
-
@fields['hide_toolbar'] =
|
1991
|
+
def setHideToolbar(value)
|
1992
|
+
@fields['hide_toolbar'] = value
|
1949
1993
|
self
|
1950
1994
|
end
|
1951
1995
|
|
1952
1996
|
# Specify whether to hide the viewer application's menu bar when the document is active.
|
1953
1997
|
#
|
1954
|
-
# * +
|
1998
|
+
# * +value+ - Set to true to hide the menu bar.
|
1955
1999
|
# * *Returns* - The converter object.
|
1956
|
-
def setHideMenubar(
|
1957
|
-
@fields['hide_menubar'] =
|
2000
|
+
def setHideMenubar(value)
|
2001
|
+
@fields['hide_menubar'] = value
|
1958
2002
|
self
|
1959
2003
|
end
|
1960
2004
|
|
1961
2005
|
# 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
2006
|
#
|
1963
|
-
# * +
|
2007
|
+
# * +value+ - Set to true to hide ui elements.
|
1964
2008
|
# * *Returns* - The converter object.
|
1965
|
-
def setHideWindowUi(
|
1966
|
-
@fields['hide_window_ui'] =
|
2009
|
+
def setHideWindowUi(value)
|
2010
|
+
@fields['hide_window_ui'] = value
|
1967
2011
|
self
|
1968
2012
|
end
|
1969
2013
|
|
1970
2014
|
# Specify whether to resize the document's window to fit the size of the first displayed page.
|
1971
2015
|
#
|
1972
|
-
# * +
|
2016
|
+
# * +value+ - Set to true to resize the window.
|
1973
2017
|
# * *Returns* - The converter object.
|
1974
|
-
def setFitWindow(
|
1975
|
-
@fields['fit_window'] =
|
2018
|
+
def setFitWindow(value)
|
2019
|
+
@fields['fit_window'] = value
|
1976
2020
|
self
|
1977
2021
|
end
|
1978
2022
|
|
1979
2023
|
# Specify whether to position the document's window in the center of the screen.
|
1980
2024
|
#
|
1981
|
-
# * +
|
2025
|
+
# * +value+ - Set to true to center the window.
|
1982
2026
|
# * *Returns* - The converter object.
|
1983
|
-
def setCenterWindow(
|
1984
|
-
@fields['center_window'] =
|
2027
|
+
def setCenterWindow(value)
|
2028
|
+
@fields['center_window'] = value
|
1985
2029
|
self
|
1986
2030
|
end
|
1987
2031
|
|
1988
2032
|
# 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
2033
|
#
|
1990
|
-
# * +
|
2034
|
+
# * +value+ - Set to true to display the title.
|
1991
2035
|
# * *Returns* - The converter object.
|
1992
|
-
def setDisplayTitle(
|
1993
|
-
@fields['display_title'] =
|
2036
|
+
def setDisplayTitle(value)
|
2037
|
+
@fields['display_title'] = value
|
1994
2038
|
self
|
1995
2039
|
end
|
1996
2040
|
|
1997
2041
|
# 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
2042
|
#
|
1999
|
-
# * +
|
2043
|
+
# * +value+ - Set to true to set right-to-left reading order.
|
2000
2044
|
# * *Returns* - The converter object.
|
2001
|
-
def setRightToLeft(
|
2002
|
-
@fields['right_to_left'] =
|
2045
|
+
def setRightToLeft(value)
|
2046
|
+
@fields['right_to_left'] = value
|
2003
2047
|
self
|
2004
2048
|
end
|
2005
2049
|
|
2006
2050
|
# 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
2051
|
#
|
2008
|
-
# * +
|
2052
|
+
# * +value+ - Set to true to enable the debug logging.
|
2009
2053
|
# * *Returns* - The converter object.
|
2010
|
-
def setDebugLog(
|
2011
|
-
@fields['debug_log'] =
|
2054
|
+
def setDebugLog(value)
|
2055
|
+
@fields['debug_log'] = value
|
2012
2056
|
self
|
2013
2057
|
end
|
2014
2058
|
|
@@ -2051,6 +2095,12 @@ module Pdfcrowd
|
|
2051
2095
|
return @helper.getOutputSize()
|
2052
2096
|
end
|
2053
2097
|
|
2098
|
+
# Get the version details.
|
2099
|
+
# * *Returns* - API version, converter version, and client version.
|
2100
|
+
def getVersion()
|
2101
|
+
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
2102
|
+
end
|
2103
|
+
|
2054
2104
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
2055
2105
|
#
|
2056
2106
|
# * +tag+ - A string with the custom tag.
|
@@ -2062,68 +2112,149 @@ module Pdfcrowd
|
|
2062
2112
|
|
2063
2113
|
# 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
2114
|
#
|
2065
|
-
# * +
|
2115
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
2066
2116
|
# * *Returns* - The converter object.
|
2067
|
-
def setHttpProxy(
|
2068
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
2069
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2117
|
+
def setHttpProxy(proxy)
|
2118
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
2119
|
+
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
2120
|
end
|
2071
2121
|
|
2072
|
-
@fields['http_proxy'] =
|
2122
|
+
@fields['http_proxy'] = proxy
|
2073
2123
|
self
|
2074
2124
|
end
|
2075
2125
|
|
2076
2126
|
# 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
2127
|
#
|
2078
|
-
# * +
|
2128
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
2079
2129
|
# * *Returns* - The converter object.
|
2080
|
-
def setHttpsProxy(
|
2081
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
2082
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2130
|
+
def setHttpsProxy(proxy)
|
2131
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
2132
|
+
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
2133
|
end
|
2084
2134
|
|
2085
|
-
@fields['https_proxy'] =
|
2135
|
+
@fields['https_proxy'] = proxy
|
2086
2136
|
self
|
2087
2137
|
end
|
2088
2138
|
|
2089
2139
|
# 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
2140
|
#
|
2091
|
-
# * +
|
2141
|
+
# * +certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
|
2092
2142
|
# * *Returns* - The converter object.
|
2093
|
-
def setClientCertificate(
|
2094
|
-
if (!(File.file?(
|
2095
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2143
|
+
def setClientCertificate(certificate)
|
2144
|
+
if (!(File.file?(certificate) && !File.zero?(certificate)))
|
2145
|
+
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
2146
|
end
|
2097
2147
|
|
2098
|
-
@files['client_certificate'] =
|
2148
|
+
@files['client_certificate'] = certificate
|
2099
2149
|
self
|
2100
2150
|
end
|
2101
2151
|
|
2102
2152
|
# A password for PKCS12 file with a client certificate if it is needed.
|
2103
2153
|
#
|
2104
|
-
# * +
|
2154
|
+
# * +password+ -
|
2155
|
+
# * *Returns* - The converter object.
|
2156
|
+
def setClientCertificatePassword(password)
|
2157
|
+
@fields['client_certificate_password'] = password
|
2158
|
+
self
|
2159
|
+
end
|
2160
|
+
|
2161
|
+
# 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.
|
2162
|
+
#
|
2163
|
+
# * +dpi+ - The DPI value. The value must be in the range of 72-600.
|
2164
|
+
# * *Returns* - The converter object.
|
2165
|
+
def setLayoutDpi(dpi)
|
2166
|
+
if (!(Integer(dpi) >= 72 && Integer(dpi) <= 600))
|
2167
|
+
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);
|
2168
|
+
end
|
2169
|
+
|
2170
|
+
@fields['layout_dpi'] = dpi
|
2171
|
+
self
|
2172
|
+
end
|
2173
|
+
|
2174
|
+
# 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.
|
2175
|
+
#
|
2176
|
+
# * +matrix+ - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"
|
2177
|
+
# * *Returns* - The converter object.
|
2178
|
+
def setContentsMatrix(matrix)
|
2179
|
+
@fields['contents_matrix'] = matrix
|
2180
|
+
self
|
2181
|
+
end
|
2182
|
+
|
2183
|
+
# 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.
|
2184
|
+
#
|
2185
|
+
# * +matrix+ - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"
|
2186
|
+
# * *Returns* - The converter object.
|
2187
|
+
def setHeaderMatrix(matrix)
|
2188
|
+
@fields['header_matrix'] = matrix
|
2189
|
+
self
|
2190
|
+
end
|
2191
|
+
|
2192
|
+
# 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.
|
2193
|
+
#
|
2194
|
+
# * +matrix+ - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"
|
2195
|
+
# * *Returns* - The converter object.
|
2196
|
+
def setFooterMatrix(matrix)
|
2197
|
+
@fields['footer_matrix'] = matrix
|
2198
|
+
self
|
2199
|
+
end
|
2200
|
+
|
2201
|
+
# Disable automatic height adjustment that compensates for pixel to point rounding errors.
|
2202
|
+
#
|
2203
|
+
# * +value+ - Set to true to disable automatic height scale.
|
2105
2204
|
# * *Returns* - The converter object.
|
2106
|
-
def
|
2107
|
-
@fields['
|
2205
|
+
def setDisablePageHeightOptimization(value)
|
2206
|
+
@fields['disable_page_height_optimization'] = value
|
2207
|
+
self
|
2208
|
+
end
|
2209
|
+
|
2210
|
+
# 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
|
2211
|
+
# 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.
|
2212
|
+
#
|
2213
|
+
# * +value+ - Set to true to add the special CSS classes.
|
2214
|
+
# * *Returns* - The converter object.
|
2215
|
+
def setMainDocumentCssAnnotation(value)
|
2216
|
+
@fields['main_document_css_annotation'] = value
|
2217
|
+
self
|
2218
|
+
end
|
2219
|
+
|
2220
|
+
# 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
|
2221
|
+
#
|
2222
|
+
# * +value+ - Set to true to add the special CSS classes.
|
2223
|
+
# * *Returns* - The converter object.
|
2224
|
+
def setHeaderFooterCssAnnotation(value)
|
2225
|
+
@fields['header_footer_css_annotation'] = value
|
2226
|
+
self
|
2227
|
+
end
|
2228
|
+
|
2229
|
+
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
2230
|
+
#
|
2231
|
+
# * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
|
2232
|
+
# * *Returns* - The converter object.
|
2233
|
+
def setConverterVersion(version)
|
2234
|
+
unless /(?i)^(latest|20.10|18.10)$/.match(version)
|
2235
|
+
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);
|
2236
|
+
end
|
2237
|
+
|
2238
|
+
@helper.setConverterVersion(version)
|
2108
2239
|
self
|
2109
2240
|
end
|
2110
2241
|
|
2111
2242
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
2112
2243
|
# 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
2244
|
#
|
2114
|
-
# * +
|
2245
|
+
# * +value+ - Set to true to use HTTP.
|
2115
2246
|
# * *Returns* - The converter object.
|
2116
|
-
def setUseHttp(
|
2117
|
-
@helper.setUseHttp(
|
2247
|
+
def setUseHttp(value)
|
2248
|
+
@helper.setUseHttp(value)
|
2118
2249
|
self
|
2119
2250
|
end
|
2120
2251
|
|
2121
|
-
# Set a custom user agent HTTP header. It can be
|
2252
|
+
# Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
|
2122
2253
|
#
|
2123
|
-
# * +
|
2254
|
+
# * +agent+ - The user agent string.
|
2124
2255
|
# * *Returns* - The converter object.
|
2125
|
-
def setUserAgent(
|
2126
|
-
@helper.setUserAgent(
|
2256
|
+
def setUserAgent(agent)
|
2257
|
+
@helper.setUserAgent(agent)
|
2127
2258
|
self
|
2128
2259
|
end
|
2129
2260
|
|
@@ -2141,10 +2272,10 @@ module Pdfcrowd
|
|
2141
2272
|
|
2142
2273
|
# 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
2274
|
#
|
2144
|
-
# * +
|
2275
|
+
# * +count+ - Number of retries wanted.
|
2145
2276
|
# * *Returns* - The converter object.
|
2146
|
-
def setRetryCount(
|
2147
|
-
@helper.setRetryCount(
|
2277
|
+
def setRetryCount(count)
|
2278
|
+
@helper.setRetryCount(count)
|
2148
2279
|
self
|
2149
2280
|
end
|
2150
2281
|
|
@@ -2173,7 +2304,7 @@ module Pdfcrowd
|
|
2173
2304
|
# * *Returns* - The converter object.
|
2174
2305
|
def setOutputFormat(output_format)
|
2175
2306
|
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, "
|
2307
|
+
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
2308
|
end
|
2178
2309
|
|
2179
2310
|
@fields['output_format'] = output_format
|
@@ -2186,7 +2317,7 @@ module Pdfcrowd
|
|
2186
2317
|
# * *Returns* - Byte array containing the conversion output.
|
2187
2318
|
def convertUrl(url)
|
2188
2319
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
2189
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "
|
2320
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "html-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
|
2190
2321
|
end
|
2191
2322
|
|
2192
2323
|
@fields['url'] = url
|
@@ -2199,7 +2330,7 @@ module Pdfcrowd
|
|
2199
2330
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2200
2331
|
def convertUrlToStream(url, out_stream)
|
2201
2332
|
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);
|
2333
|
+
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
2334
|
end
|
2204
2335
|
|
2205
2336
|
@fields['url'] = url
|
@@ -2212,7 +2343,7 @@ module Pdfcrowd
|
|
2212
2343
|
# * +file_path+ - The output file path. The string must not be empty.
|
2213
2344
|
def convertUrlToFile(url, file_path)
|
2214
2345
|
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);
|
2346
|
+
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
2347
|
end
|
2217
2348
|
|
2218
2349
|
output_file = open(file_path, "wb")
|
@@ -2232,7 +2363,7 @@ module Pdfcrowd
|
|
2232
2363
|
# * *Returns* - Byte array containing the conversion output.
|
2233
2364
|
def convertFile(file)
|
2234
2365
|
if (!(File.file?(file) && !File.zero?(file)))
|
2235
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "
|
2366
|
+
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
2367
|
end
|
2237
2368
|
|
2238
2369
|
@files['file'] = file
|
@@ -2245,7 +2376,7 @@ module Pdfcrowd
|
|
2245
2376
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2246
2377
|
def convertFileToStream(file, out_stream)
|
2247
2378
|
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);
|
2379
|
+
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
2380
|
end
|
2250
2381
|
|
2251
2382
|
@files['file'] = file
|
@@ -2258,7 +2389,7 @@ module Pdfcrowd
|
|
2258
2389
|
# * +file_path+ - The output file path. The string must not be empty.
|
2259
2390
|
def convertFileToFile(file, file_path)
|
2260
2391
|
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);
|
2392
|
+
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
2393
|
end
|
2263
2394
|
|
2264
2395
|
output_file = open(file_path, "wb")
|
@@ -2278,7 +2409,7 @@ module Pdfcrowd
|
|
2278
2409
|
# * *Returns* - Byte array containing the conversion output.
|
2279
2410
|
def convertString(text)
|
2280
2411
|
if (!(!text.nil? && !text.empty?))
|
2281
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(text, "
|
2412
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(text, "convertString", "html-to-image", "The string must not be empty.", "convert_string"), 470);
|
2282
2413
|
end
|
2283
2414
|
|
2284
2415
|
@fields['text'] = text
|
@@ -2291,7 +2422,7 @@ module Pdfcrowd
|
|
2291
2422
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2292
2423
|
def convertStringToStream(text, out_stream)
|
2293
2424
|
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);
|
2425
|
+
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
2426
|
end
|
2296
2427
|
|
2297
2428
|
@fields['text'] = text
|
@@ -2304,7 +2435,7 @@ module Pdfcrowd
|
|
2304
2435
|
# * +file_path+ - The output file path. The string must not be empty.
|
2305
2436
|
def convertStringToFile(text, file_path)
|
2306
2437
|
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);
|
2438
|
+
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
2439
|
end
|
2309
2440
|
|
2310
2441
|
output_file = open(file_path, "wb")
|
@@ -2342,7 +2473,7 @@ module Pdfcrowd
|
|
2342
2473
|
# * *Returns* - The converter object.
|
2343
2474
|
def setDataFormat(data_format)
|
2344
2475
|
unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
|
2345
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(data_format, "
|
2476
|
+
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);
|
2346
2477
|
end
|
2347
2478
|
|
2348
2479
|
@fields['data_format'] = data_format
|
@@ -2351,100 +2482,131 @@ module Pdfcrowd
|
|
2351
2482
|
|
2352
2483
|
# Set the encoding of the data file set by setDataFile.
|
2353
2484
|
#
|
2354
|
-
# * +
|
2485
|
+
# * +encoding+ - The data file encoding.
|
2355
2486
|
# * *Returns* - The converter object.
|
2356
|
-
def setDataEncoding(
|
2357
|
-
@fields['data_encoding'] =
|
2487
|
+
def setDataEncoding(encoding)
|
2488
|
+
@fields['data_encoding'] = encoding
|
2358
2489
|
self
|
2359
2490
|
end
|
2360
2491
|
|
2361
2492
|
# 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.
|
2362
2493
|
#
|
2363
|
-
# * +
|
2494
|
+
# * +value+ - Set to true to ignore undefined variables.
|
2364
2495
|
# * *Returns* - The converter object.
|
2365
|
-
def setDataIgnoreUndefined(
|
2366
|
-
@fields['data_ignore_undefined'] =
|
2496
|
+
def setDataIgnoreUndefined(value)
|
2497
|
+
@fields['data_ignore_undefined'] = value
|
2367
2498
|
self
|
2368
2499
|
end
|
2369
2500
|
|
2370
2501
|
# Auto escape HTML symbols in the input data before placing them into the output.
|
2371
2502
|
#
|
2372
|
-
# * +
|
2503
|
+
# * +value+ - Set to true to turn auto escaping on.
|
2373
2504
|
# * *Returns* - The converter object.
|
2374
|
-
def setDataAutoEscape(
|
2375
|
-
@fields['data_auto_escape'] =
|
2505
|
+
def setDataAutoEscape(value)
|
2506
|
+
@fields['data_auto_escape'] = value
|
2376
2507
|
self
|
2377
2508
|
end
|
2378
2509
|
|
2379
2510
|
# Auto trim whitespace around each template command block.
|
2380
2511
|
#
|
2381
|
-
# * +
|
2512
|
+
# * +value+ - Set to true to turn auto trimming on.
|
2382
2513
|
# * *Returns* - The converter object.
|
2383
|
-
def setDataTrimBlocks(
|
2384
|
-
@fields['data_trim_blocks'] =
|
2514
|
+
def setDataTrimBlocks(value)
|
2515
|
+
@fields['data_trim_blocks'] = value
|
2385
2516
|
self
|
2386
2517
|
end
|
2387
2518
|
|
2388
2519
|
# 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.
|
2389
2520
|
#
|
2390
|
-
# * +
|
2521
|
+
# * +options+ - Comma separated list of options.
|
2522
|
+
# * *Returns* - The converter object.
|
2523
|
+
def setDataOptions(options)
|
2524
|
+
@fields['data_options'] = options
|
2525
|
+
self
|
2526
|
+
end
|
2527
|
+
|
2528
|
+
# Use the print version of the page if available (@media print).
|
2529
|
+
#
|
2530
|
+
# * +value+ - Set to true to use the print version of the page.
|
2391
2531
|
# * *Returns* - The converter object.
|
2392
|
-
def
|
2393
|
-
@fields['
|
2532
|
+
def setUsePrintMedia(value)
|
2533
|
+
@fields['use_print_media'] = value
|
2394
2534
|
self
|
2395
2535
|
end
|
2396
2536
|
|
2397
2537
|
# Do not print the background graphics.
|
2398
2538
|
#
|
2399
|
-
# * +
|
2539
|
+
# * +value+ - Set to true to disable the background graphics.
|
2400
2540
|
# * *Returns* - The converter object.
|
2401
|
-
def setNoBackground(
|
2402
|
-
@fields['no_background'] =
|
2541
|
+
def setNoBackground(value)
|
2542
|
+
@fields['no_background'] = value
|
2403
2543
|
self
|
2404
2544
|
end
|
2405
2545
|
|
2406
2546
|
# Do not execute JavaScript.
|
2407
2547
|
#
|
2408
|
-
# * +
|
2548
|
+
# * +value+ - Set to true to disable JavaScript in web pages.
|
2409
2549
|
# * *Returns* - The converter object.
|
2410
|
-
def setDisableJavascript(
|
2411
|
-
@fields['disable_javascript'] =
|
2550
|
+
def setDisableJavascript(value)
|
2551
|
+
@fields['disable_javascript'] = value
|
2412
2552
|
self
|
2413
2553
|
end
|
2414
2554
|
|
2415
2555
|
# Do not load images.
|
2416
2556
|
#
|
2417
|
-
# * +
|
2557
|
+
# * +value+ - Set to true to disable loading of images.
|
2418
2558
|
# * *Returns* - The converter object.
|
2419
|
-
def setDisableImageLoading(
|
2420
|
-
@fields['disable_image_loading'] =
|
2559
|
+
def setDisableImageLoading(value)
|
2560
|
+
@fields['disable_image_loading'] = value
|
2421
2561
|
self
|
2422
2562
|
end
|
2423
2563
|
|
2424
2564
|
# Disable loading fonts from remote sources.
|
2425
2565
|
#
|
2426
|
-
# * +
|
2566
|
+
# * +value+ - Set to true disable loading remote fonts.
|
2427
2567
|
# * *Returns* - The converter object.
|
2428
|
-
def setDisableRemoteFonts(
|
2429
|
-
@fields['disable_remote_fonts'] =
|
2568
|
+
def setDisableRemoteFonts(value)
|
2569
|
+
@fields['disable_remote_fonts'] = value
|
2570
|
+
self
|
2571
|
+
end
|
2572
|
+
|
2573
|
+
# Specifies how iframes are handled.
|
2574
|
+
#
|
2575
|
+
# * +iframes+ - Allowed values are all, same-origin, none.
|
2576
|
+
# * *Returns* - The converter object.
|
2577
|
+
def setLoadIframes(iframes)
|
2578
|
+
unless /(?i)^(all|same-origin|none)$/.match(iframes)
|
2579
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(iframes, "setLoadIframes", "html-to-image", "Allowed values are all, same-origin, none.", "set_load_iframes"), 470);
|
2580
|
+
end
|
2581
|
+
|
2582
|
+
@fields['load_iframes'] = iframes
|
2430
2583
|
self
|
2431
2584
|
end
|
2432
2585
|
|
2433
2586
|
# Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
|
2434
2587
|
#
|
2435
|
-
# * +
|
2588
|
+
# * +value+ - Set to true to block ads in web pages.
|
2436
2589
|
# * *Returns* - The converter object.
|
2437
|
-
def setBlockAds(
|
2438
|
-
@fields['block_ads'] =
|
2590
|
+
def setBlockAds(value)
|
2591
|
+
@fields['block_ads'] = value
|
2439
2592
|
self
|
2440
2593
|
end
|
2441
2594
|
|
2442
2595
|
# Set the default HTML content text encoding.
|
2443
2596
|
#
|
2444
|
-
# * +
|
2597
|
+
# * +encoding+ - The text encoding of the HTML content.
|
2598
|
+
# * *Returns* - The converter object.
|
2599
|
+
def setDefaultEncoding(encoding)
|
2600
|
+
@fields['default_encoding'] = encoding
|
2601
|
+
self
|
2602
|
+
end
|
2603
|
+
|
2604
|
+
# Set the locale for the conversion. This may affect the output format of dates, times and numbers.
|
2605
|
+
#
|
2606
|
+
# * +locale+ - The locale code according to ISO 639.
|
2445
2607
|
# * *Returns* - The converter object.
|
2446
|
-
def
|
2447
|
-
@fields['
|
2608
|
+
def setLocale(locale)
|
2609
|
+
@fields['locale'] = locale
|
2448
2610
|
self
|
2449
2611
|
end
|
2450
2612
|
|
@@ -2477,24 +2639,6 @@ module Pdfcrowd
|
|
2477
2639
|
self
|
2478
2640
|
end
|
2479
2641
|
|
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
2642
|
# Set cookies that are sent in Pdfcrowd HTTP requests.
|
2499
2643
|
#
|
2500
2644
|
# * +cookies+ - The cookie string.
|
@@ -2506,10 +2650,10 @@ module Pdfcrowd
|
|
2506
2650
|
|
2507
2651
|
# Do not allow insecure HTTPS connections.
|
2508
2652
|
#
|
2509
|
-
# * +
|
2653
|
+
# * +value+ - Set to true to enable SSL certificate verification.
|
2510
2654
|
# * *Returns* - The converter object.
|
2511
|
-
def setVerifySslCertificates(
|
2512
|
-
@fields['verify_ssl_certificates'] =
|
2655
|
+
def setVerifySslCertificates(value)
|
2656
|
+
@fields['verify_ssl_certificates'] = value
|
2513
2657
|
self
|
2514
2658
|
end
|
2515
2659
|
|
@@ -2531,55 +2675,64 @@ module Pdfcrowd
|
|
2531
2675
|
self
|
2532
2676
|
end
|
2533
2677
|
|
2678
|
+
# Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
|
2679
|
+
#
|
2680
|
+
# * +value+ - Set to true to disable sending X-Pdfcrowd HTTP header.
|
2681
|
+
# * *Returns* - The converter object.
|
2682
|
+
def setNoXpdfcrowdHeader(value)
|
2683
|
+
@fields['no_xpdfcrowd_header'] = value
|
2684
|
+
self
|
2685
|
+
end
|
2686
|
+
|
2534
2687
|
# Run a custom JavaScript after the document is loaded and ready to print. The script is intended for post-load DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
|
2535
2688
|
#
|
2536
|
-
# * +
|
2689
|
+
# * +javascript+ - A string containing a JavaScript code. The string must not be empty.
|
2537
2690
|
# * *Returns* - The converter object.
|
2538
|
-
def setCustomJavascript(
|
2539
|
-
if (!(!
|
2540
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2691
|
+
def setCustomJavascript(javascript)
|
2692
|
+
if (!(!javascript.nil? && !javascript.empty?))
|
2693
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setCustomJavascript", "html-to-image", "The string must not be empty.", "set_custom_javascript"), 470);
|
2541
2694
|
end
|
2542
2695
|
|
2543
|
-
@fields['custom_javascript'] =
|
2696
|
+
@fields['custom_javascript'] = javascript
|
2544
2697
|
self
|
2545
2698
|
end
|
2546
2699
|
|
2547
2700
|
# Run a custom JavaScript right after the document is loaded. The script is intended for early DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
|
2548
2701
|
#
|
2549
|
-
# * +
|
2702
|
+
# * +javascript+ - A string containing a JavaScript code. The string must not be empty.
|
2550
2703
|
# * *Returns* - The converter object.
|
2551
|
-
def setOnLoadJavascript(
|
2552
|
-
if (!(!
|
2553
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2704
|
+
def setOnLoadJavascript(javascript)
|
2705
|
+
if (!(!javascript.nil? && !javascript.empty?))
|
2706
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setOnLoadJavascript", "html-to-image", "The string must not be empty.", "set_on_load_javascript"), 470);
|
2554
2707
|
end
|
2555
2708
|
|
2556
|
-
@fields['on_load_javascript'] =
|
2709
|
+
@fields['on_load_javascript'] = javascript
|
2557
2710
|
self
|
2558
2711
|
end
|
2559
2712
|
|
2560
2713
|
# Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
|
2561
2714
|
#
|
2562
|
-
# * +
|
2715
|
+
# * +header+ - A string containing the header name and value separated by a colon.
|
2563
2716
|
# * *Returns* - The converter object.
|
2564
|
-
def setCustomHttpHeader(
|
2565
|
-
unless /^.+:.+$/.match(
|
2566
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2717
|
+
def setCustomHttpHeader(header)
|
2718
|
+
unless /^.+:.+$/.match(header)
|
2719
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(header, "setCustomHttpHeader", "html-to-image", "A string containing the header name and value separated by a colon.", "set_custom_http_header"), 470);
|
2567
2720
|
end
|
2568
2721
|
|
2569
|
-
@fields['custom_http_header'] =
|
2722
|
+
@fields['custom_http_header'] = header
|
2570
2723
|
self
|
2571
2724
|
end
|
2572
2725
|
|
2573
2726
|
# Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. Your API license defines the maximum wait time by "Max Delay" parameter.
|
2574
2727
|
#
|
2575
|
-
# * +
|
2728
|
+
# * +delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
|
2576
2729
|
# * *Returns* - The converter object.
|
2577
|
-
def setJavascriptDelay(
|
2578
|
-
if (!(Integer(
|
2579
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2730
|
+
def setJavascriptDelay(delay)
|
2731
|
+
if (!(Integer(delay) >= 0))
|
2732
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(delay, "setJavascriptDelay", "html-to-image", "Must be a positive integer number or 0.", "set_javascript_delay"), 470);
|
2580
2733
|
end
|
2581
2734
|
|
2582
|
-
@fields['javascript_delay'] =
|
2735
|
+
@fields['javascript_delay'] = delay
|
2583
2736
|
self
|
2584
2737
|
end
|
2585
2738
|
|
@@ -2589,7 +2742,7 @@ module Pdfcrowd
|
|
2589
2742
|
# * *Returns* - The converter object.
|
2590
2743
|
def setElementToConvert(selectors)
|
2591
2744
|
if (!(!selectors.nil? && !selectors.empty?))
|
2592
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "
|
2745
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setElementToConvert", "html-to-image", "The string must not be empty.", "set_element_to_convert"), 470);
|
2593
2746
|
end
|
2594
2747
|
|
2595
2748
|
@fields['element_to_convert'] = selectors
|
@@ -2602,7 +2755,7 @@ module Pdfcrowd
|
|
2602
2755
|
# * *Returns* - The converter object.
|
2603
2756
|
def setElementToConvertMode(mode)
|
2604
2757
|
unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode)
|
2605
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "
|
2758
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setElementToConvertMode", "html-to-image", "Allowed values are cut-out, remove-siblings, hide-siblings.", "set_element_to_convert_mode"), 470);
|
2606
2759
|
end
|
2607
2760
|
|
2608
2761
|
@fields['element_to_convert_mode'] = mode
|
@@ -2615,7 +2768,7 @@ module Pdfcrowd
|
|
2615
2768
|
# * *Returns* - The converter object.
|
2616
2769
|
def setWaitForElement(selectors)
|
2617
2770
|
if (!(!selectors.nil? && !selectors.empty?))
|
2618
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "
|
2771
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setWaitForElement", "html-to-image", "The string must not be empty.", "set_wait_for_element"), 470);
|
2619
2772
|
end
|
2620
2773
|
|
2621
2774
|
@fields['wait_for_element'] = selectors
|
@@ -2624,49 +2777,62 @@ module Pdfcrowd
|
|
2624
2777
|
|
2625
2778
|
# Set the output image width in pixels.
|
2626
2779
|
#
|
2627
|
-
# * +
|
2780
|
+
# * +width+ - The value must be in the range 96-65000.
|
2628
2781
|
# * *Returns* - The converter object.
|
2629
|
-
def setScreenshotWidth(
|
2630
|
-
if (!(Integer(
|
2631
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2782
|
+
def setScreenshotWidth(width)
|
2783
|
+
if (!(Integer(width) >= 96 && Integer(width) <= 65000))
|
2784
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setScreenshotWidth", "html-to-image", "The value must be in the range 96-65000.", "set_screenshot_width"), 470);
|
2632
2785
|
end
|
2633
2786
|
|
2634
|
-
@fields['screenshot_width'] =
|
2787
|
+
@fields['screenshot_width'] = width
|
2635
2788
|
self
|
2636
2789
|
end
|
2637
2790
|
|
2638
2791
|
# Set the output image height in pixels. If it is not specified, actual document height is used.
|
2639
2792
|
#
|
2640
|
-
# * +
|
2793
|
+
# * +height+ - Must be a positive integer number.
|
2641
2794
|
# * *Returns* - The converter object.
|
2642
|
-
def setScreenshotHeight(
|
2643
|
-
if (!(Integer(
|
2644
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2795
|
+
def setScreenshotHeight(height)
|
2796
|
+
if (!(Integer(height) > 0))
|
2797
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setScreenshotHeight", "html-to-image", "Must be a positive integer number.", "set_screenshot_height"), 470);
|
2645
2798
|
end
|
2646
2799
|
|
2647
|
-
@fields['screenshot_height'] =
|
2800
|
+
@fields['screenshot_height'] = height
|
2648
2801
|
self
|
2649
2802
|
end
|
2650
2803
|
|
2651
2804
|
# Set the scaling factor (zoom) for the output image.
|
2652
2805
|
#
|
2653
|
-
# * +
|
2806
|
+
# * +factor+ - The percentage value. Must be a positive integer number.
|
2654
2807
|
# * *Returns* - The converter object.
|
2655
|
-
def setScaleFactor(
|
2656
|
-
if (!(Integer(
|
2657
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2808
|
+
def setScaleFactor(factor)
|
2809
|
+
if (!(Integer(factor) > 0))
|
2810
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "html-to-image", "Must be a positive integer number.", "set_scale_factor"), 470);
|
2658
2811
|
end
|
2659
2812
|
|
2660
|
-
@fields['scale_factor'] =
|
2813
|
+
@fields['scale_factor'] = factor
|
2814
|
+
self
|
2815
|
+
end
|
2816
|
+
|
2817
|
+
# The output image background color.
|
2818
|
+
#
|
2819
|
+
# * +color+ - The value must be in RRGGBB or RRGGBBAA hexadecimal format.
|
2820
|
+
# * *Returns* - The converter object.
|
2821
|
+
def setBackgroundColor(color)
|
2822
|
+
unless /^[0-9a-fA-F]{6,8}$/.match(color)
|
2823
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(color, "setBackgroundColor", "html-to-image", "The value must be in RRGGBB or RRGGBBAA hexadecimal format.", "set_background_color"), 470);
|
2824
|
+
end
|
2825
|
+
|
2826
|
+
@fields['background_color'] = color
|
2661
2827
|
self
|
2662
2828
|
end
|
2663
2829
|
|
2664
2830
|
# 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
2831
|
#
|
2666
|
-
# * +
|
2832
|
+
# * +value+ - Set to true to enable the debug logging.
|
2667
2833
|
# * *Returns* - The converter object.
|
2668
|
-
def setDebugLog(
|
2669
|
-
@fields['debug_log'] =
|
2834
|
+
def setDebugLog(value)
|
2835
|
+
@fields['debug_log'] = value
|
2670
2836
|
self
|
2671
2837
|
end
|
2672
2838
|
|
@@ -2703,6 +2869,12 @@ module Pdfcrowd
|
|
2703
2869
|
return @helper.getOutputSize()
|
2704
2870
|
end
|
2705
2871
|
|
2872
|
+
# Get the version details.
|
2873
|
+
# * *Returns* - API version, converter version, and client version.
|
2874
|
+
def getVersion()
|
2875
|
+
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
2876
|
+
end
|
2877
|
+
|
2706
2878
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
2707
2879
|
#
|
2708
2880
|
# * +tag+ - A string with the custom tag.
|
@@ -2714,68 +2886,81 @@ module Pdfcrowd
|
|
2714
2886
|
|
2715
2887
|
# 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
2888
|
#
|
2717
|
-
# * +
|
2889
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
2718
2890
|
# * *Returns* - The converter object.
|
2719
|
-
def setHttpProxy(
|
2720
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
2721
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2891
|
+
def setHttpProxy(proxy)
|
2892
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
2893
|
+
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
2894
|
end
|
2723
2895
|
|
2724
|
-
@fields['http_proxy'] =
|
2896
|
+
@fields['http_proxy'] = proxy
|
2725
2897
|
self
|
2726
2898
|
end
|
2727
2899
|
|
2728
2900
|
# 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
2901
|
#
|
2730
|
-
# * +
|
2902
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
2731
2903
|
# * *Returns* - The converter object.
|
2732
|
-
def setHttpsProxy(
|
2733
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
2734
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2904
|
+
def setHttpsProxy(proxy)
|
2905
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
2906
|
+
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
2907
|
end
|
2736
2908
|
|
2737
|
-
@fields['https_proxy'] =
|
2909
|
+
@fields['https_proxy'] = proxy
|
2738
2910
|
self
|
2739
2911
|
end
|
2740
2912
|
|
2741
2913
|
# 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
2914
|
#
|
2743
|
-
# * +
|
2915
|
+
# * +certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
|
2744
2916
|
# * *Returns* - The converter object.
|
2745
|
-
def setClientCertificate(
|
2746
|
-
if (!(File.file?(
|
2747
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2917
|
+
def setClientCertificate(certificate)
|
2918
|
+
if (!(File.file?(certificate) && !File.zero?(certificate)))
|
2919
|
+
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
2920
|
end
|
2749
2921
|
|
2750
|
-
@files['client_certificate'] =
|
2922
|
+
@files['client_certificate'] = certificate
|
2751
2923
|
self
|
2752
2924
|
end
|
2753
2925
|
|
2754
2926
|
# A password for PKCS12 file with a client certificate if it is needed.
|
2755
2927
|
#
|
2756
|
-
# * +
|
2928
|
+
# * +password+ -
|
2757
2929
|
# * *Returns* - The converter object.
|
2758
|
-
def setClientCertificatePassword(
|
2759
|
-
@fields['client_certificate_password'] =
|
2930
|
+
def setClientCertificatePassword(password)
|
2931
|
+
@fields['client_certificate_password'] = password
|
2932
|
+
self
|
2933
|
+
end
|
2934
|
+
|
2935
|
+
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
2936
|
+
#
|
2937
|
+
# * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
|
2938
|
+
# * *Returns* - The converter object.
|
2939
|
+
def setConverterVersion(version)
|
2940
|
+
unless /(?i)^(latest|20.10|18.10)$/.match(version)
|
2941
|
+
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);
|
2942
|
+
end
|
2943
|
+
|
2944
|
+
@helper.setConverterVersion(version)
|
2760
2945
|
self
|
2761
2946
|
end
|
2762
2947
|
|
2763
2948
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
2764
2949
|
# 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
2950
|
#
|
2766
|
-
# * +
|
2951
|
+
# * +value+ - Set to true to use HTTP.
|
2767
2952
|
# * *Returns* - The converter object.
|
2768
|
-
def setUseHttp(
|
2769
|
-
@helper.setUseHttp(
|
2953
|
+
def setUseHttp(value)
|
2954
|
+
@helper.setUseHttp(value)
|
2770
2955
|
self
|
2771
2956
|
end
|
2772
2957
|
|
2773
|
-
# Set a custom user agent HTTP header. It can be
|
2958
|
+
# Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
|
2774
2959
|
#
|
2775
|
-
# * +
|
2960
|
+
# * +agent+ - The user agent string.
|
2776
2961
|
# * *Returns* - The converter object.
|
2777
|
-
def setUserAgent(
|
2778
|
-
@helper.setUserAgent(
|
2962
|
+
def setUserAgent(agent)
|
2963
|
+
@helper.setUserAgent(agent)
|
2779
2964
|
self
|
2780
2965
|
end
|
2781
2966
|
|
@@ -2793,10 +2978,10 @@ module Pdfcrowd
|
|
2793
2978
|
|
2794
2979
|
# 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
2980
|
#
|
2796
|
-
# * +
|
2981
|
+
# * +count+ - Number of retries wanted.
|
2797
2982
|
# * *Returns* - The converter object.
|
2798
|
-
def setRetryCount(
|
2799
|
-
@helper.setRetryCount(
|
2983
|
+
def setRetryCount(count)
|
2984
|
+
@helper.setRetryCount(count)
|
2800
2985
|
self
|
2801
2986
|
end
|
2802
2987
|
|
@@ -2825,7 +3010,7 @@ module Pdfcrowd
|
|
2825
3010
|
# * *Returns* - Byte array containing the conversion output.
|
2826
3011
|
def convertUrl(url)
|
2827
3012
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
2828
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "
|
3013
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
|
2829
3014
|
end
|
2830
3015
|
|
2831
3016
|
@fields['url'] = url
|
@@ -2838,7 +3023,7 @@ module Pdfcrowd
|
|
2838
3023
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2839
3024
|
def convertUrlToStream(url, out_stream)
|
2840
3025
|
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);
|
3026
|
+
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
3027
|
end
|
2843
3028
|
|
2844
3029
|
@fields['url'] = url
|
@@ -2851,7 +3036,7 @@ module Pdfcrowd
|
|
2851
3036
|
# * +file_path+ - The output file path. The string must not be empty.
|
2852
3037
|
def convertUrlToFile(url, file_path)
|
2853
3038
|
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);
|
3039
|
+
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
3040
|
end
|
2856
3041
|
|
2857
3042
|
output_file = open(file_path, "wb")
|
@@ -2867,11 +3052,11 @@ module Pdfcrowd
|
|
2867
3052
|
|
2868
3053
|
# Convert a local file.
|
2869
3054
|
#
|
2870
|
-
# * +file+ - The path to a local file to convert. The file
|
3055
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
2871
3056
|
# * *Returns* - Byte array containing the conversion output.
|
2872
3057
|
def convertFile(file)
|
2873
3058
|
if (!(File.file?(file) && !File.zero?(file)))
|
2874
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "
|
3059
|
+
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
3060
|
end
|
2876
3061
|
|
2877
3062
|
@files['file'] = file
|
@@ -2880,11 +3065,11 @@ module Pdfcrowd
|
|
2880
3065
|
|
2881
3066
|
# Convert a local file and write the result to an output stream.
|
2882
3067
|
#
|
2883
|
-
# * +file+ - The path to a local file to convert. The file
|
3068
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
2884
3069
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2885
3070
|
def convertFileToStream(file, out_stream)
|
2886
3071
|
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);
|
3072
|
+
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
3073
|
end
|
2889
3074
|
|
2890
3075
|
@files['file'] = file
|
@@ -2893,11 +3078,11 @@ module Pdfcrowd
|
|
2893
3078
|
|
2894
3079
|
# Convert a local file and write the result to a local file.
|
2895
3080
|
#
|
2896
|
-
# * +file+ - The path to a local file to convert. The file
|
3081
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
2897
3082
|
# * +file_path+ - The output file path. The string must not be empty.
|
2898
3083
|
def convertFileToFile(file, file_path)
|
2899
3084
|
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);
|
3085
|
+
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
3086
|
end
|
2902
3087
|
|
2903
3088
|
output_file = open(file_path, "wb")
|
@@ -2935,7 +3120,7 @@ module Pdfcrowd
|
|
2935
3120
|
# * +file_path+ - The output file path. The string must not be empty.
|
2936
3121
|
def convertRawDataToFile(data, file_path)
|
2937
3122
|
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);
|
3123
|
+
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
3124
|
end
|
2940
3125
|
|
2941
3126
|
output_file = open(file_path, "wb")
|
@@ -2955,7 +3140,7 @@ module Pdfcrowd
|
|
2955
3140
|
# * *Returns* - The converter object.
|
2956
3141
|
def setOutputFormat(output_format)
|
2957
3142
|
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, "
|
3143
|
+
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
3144
|
end
|
2960
3145
|
|
2961
3146
|
@fields['output_format'] = output_format
|
@@ -2982,10 +3167,10 @@ module Pdfcrowd
|
|
2982
3167
|
|
2983
3168
|
# 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
3169
|
#
|
2985
|
-
# * +
|
3170
|
+
# * +value+ - Set to true to enable the debug logging.
|
2986
3171
|
# * *Returns* - The converter object.
|
2987
|
-
def setDebugLog(
|
2988
|
-
@fields['debug_log'] =
|
3172
|
+
def setDebugLog(value)
|
3173
|
+
@fields['debug_log'] = value
|
2989
3174
|
self
|
2990
3175
|
end
|
2991
3176
|
|
@@ -3022,6 +3207,12 @@ module Pdfcrowd
|
|
3022
3207
|
return @helper.getOutputSize()
|
3023
3208
|
end
|
3024
3209
|
|
3210
|
+
# Get the version details.
|
3211
|
+
# * *Returns* - API version, converter version, and client version.
|
3212
|
+
def getVersion()
|
3213
|
+
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
3214
|
+
end
|
3215
|
+
|
3025
3216
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
3026
3217
|
#
|
3027
3218
|
# * +tag+ - A string with the custom tag.
|
@@ -3033,46 +3224,59 @@ module Pdfcrowd
|
|
3033
3224
|
|
3034
3225
|
# 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
3226
|
#
|
3036
|
-
# * +
|
3227
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
3037
3228
|
# * *Returns* - The converter object.
|
3038
|
-
def setHttpProxy(
|
3039
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
3040
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3229
|
+
def setHttpProxy(proxy)
|
3230
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
3231
|
+
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
3232
|
end
|
3042
3233
|
|
3043
|
-
@fields['http_proxy'] =
|
3234
|
+
@fields['http_proxy'] = proxy
|
3044
3235
|
self
|
3045
3236
|
end
|
3046
3237
|
|
3047
3238
|
# 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
3239
|
#
|
3049
|
-
# * +
|
3240
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
3050
3241
|
# * *Returns* - The converter object.
|
3051
|
-
def setHttpsProxy(
|
3052
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
3053
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3242
|
+
def setHttpsProxy(proxy)
|
3243
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
3244
|
+
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);
|
3054
3245
|
end
|
3055
3246
|
|
3056
|
-
@fields['https_proxy'] =
|
3247
|
+
@fields['https_proxy'] = proxy
|
3248
|
+
self
|
3249
|
+
end
|
3250
|
+
|
3251
|
+
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
3252
|
+
#
|
3253
|
+
# * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
|
3254
|
+
# * *Returns* - The converter object.
|
3255
|
+
def setConverterVersion(version)
|
3256
|
+
unless /(?i)^(latest|20.10|18.10)$/.match(version)
|
3257
|
+
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);
|
3258
|
+
end
|
3259
|
+
|
3260
|
+
@helper.setConverterVersion(version)
|
3057
3261
|
self
|
3058
3262
|
end
|
3059
3263
|
|
3060
3264
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
3061
3265
|
# 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
3266
|
#
|
3063
|
-
# * +
|
3267
|
+
# * +value+ - Set to true to use HTTP.
|
3064
3268
|
# * *Returns* - The converter object.
|
3065
|
-
def setUseHttp(
|
3066
|
-
@helper.setUseHttp(
|
3269
|
+
def setUseHttp(value)
|
3270
|
+
@helper.setUseHttp(value)
|
3067
3271
|
self
|
3068
3272
|
end
|
3069
3273
|
|
3070
|
-
# Set a custom user agent HTTP header. It can be
|
3274
|
+
# Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
|
3071
3275
|
#
|
3072
|
-
# * +
|
3276
|
+
# * +agent+ - The user agent string.
|
3073
3277
|
# * *Returns* - The converter object.
|
3074
|
-
def setUserAgent(
|
3075
|
-
@helper.setUserAgent(
|
3278
|
+
def setUserAgent(agent)
|
3279
|
+
@helper.setUserAgent(agent)
|
3076
3280
|
self
|
3077
3281
|
end
|
3078
3282
|
|
@@ -3090,10 +3294,10 @@ module Pdfcrowd
|
|
3090
3294
|
|
3091
3295
|
# 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
3296
|
#
|
3093
|
-
# * +
|
3297
|
+
# * +count+ - Number of retries wanted.
|
3094
3298
|
# * *Returns* - The converter object.
|
3095
|
-
def setRetryCount(
|
3096
|
-
@helper.setRetryCount(
|
3299
|
+
def setRetryCount(count)
|
3300
|
+
@helper.setRetryCount(count)
|
3097
3301
|
self
|
3098
3302
|
end
|
3099
3303
|
|
@@ -3122,7 +3326,7 @@ module Pdfcrowd
|
|
3122
3326
|
# * *Returns* - The converter object.
|
3123
3327
|
def setAction(action)
|
3124
3328
|
unless /(?i)^(join|shuffle)$/.match(action)
|
3125
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(action, "
|
3329
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(action, "setAction", "pdf-to-pdf", "Allowed values are join, shuffle.", "set_action"), 470);
|
3126
3330
|
end
|
3127
3331
|
|
3128
3332
|
@fields['action'] = action
|
@@ -3147,7 +3351,7 @@ module Pdfcrowd
|
|
3147
3351
|
# * +file_path+ - The output file path. The string must not be empty.
|
3148
3352
|
def convertToFile(file_path)
|
3149
3353
|
if (!(!file_path.nil? && !file_path.empty?))
|
3150
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "
|
3354
|
+
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
3355
|
end
|
3152
3356
|
|
3153
3357
|
output_file = open(file_path, "wb")
|
@@ -3161,7 +3365,7 @@ module Pdfcrowd
|
|
3161
3365
|
# * *Returns* - The converter object.
|
3162
3366
|
def addPdfFile(file_path)
|
3163
3367
|
if (!(File.file?(file_path) && !File.zero?(file_path)))
|
3164
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "
|
3368
|
+
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
3369
|
end
|
3166
3370
|
|
3167
3371
|
@files['f_%s' % @file_id] = file_path
|
@@ -3171,319 +3375,319 @@ module Pdfcrowd
|
|
3171
3375
|
|
3172
3376
|
# 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
3377
|
#
|
3174
|
-
# * +
|
3378
|
+
# * +data+ - The raw PDF data. The input data must be PDF content.
|
3175
3379
|
# * *Returns* - The converter object.
|
3176
|
-
def addPdfRawData(
|
3177
|
-
if (!(!
|
3178
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message("raw PDF data", "
|
3380
|
+
def addPdfRawData(data)
|
3381
|
+
if (!(!data.nil? && data.length > 300 and data[0...4] == '%PDF'))
|
3382
|
+
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
3383
|
end
|
3180
3384
|
|
3181
|
-
@raw_data['f_%s' % @file_id] =
|
3385
|
+
@raw_data['f_%s' % @file_id] = data
|
3182
3386
|
@file_id += 1
|
3183
3387
|
self
|
3184
3388
|
end
|
3185
3389
|
|
3186
3390
|
# Apply the first page of the watermark PDF to every page of the output PDF.
|
3187
3391
|
#
|
3188
|
-
# * +
|
3392
|
+
# * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
|
3189
3393
|
# * *Returns* - The converter object.
|
3190
|
-
def setPageWatermark(
|
3191
|
-
if (!(File.file?(
|
3192
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3394
|
+
def setPageWatermark(watermark)
|
3395
|
+
if (!(File.file?(watermark) && !File.zero?(watermark)))
|
3396
|
+
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
3397
|
end
|
3194
3398
|
|
3195
|
-
@files['page_watermark'] =
|
3399
|
+
@files['page_watermark'] = watermark
|
3196
3400
|
self
|
3197
3401
|
end
|
3198
3402
|
|
3199
3403
|
# 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
3404
|
#
|
3201
|
-
# * +
|
3405
|
+
# * +url+ - The supported protocols are http:// and https://.
|
3202
3406
|
# * *Returns* - The converter object.
|
3203
|
-
def setPageWatermarkUrl(
|
3204
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
3205
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3407
|
+
def setPageWatermarkUrl(url)
|
3408
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
3409
|
+
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
3410
|
end
|
3207
3411
|
|
3208
|
-
@fields['page_watermark_url'] =
|
3412
|
+
@fields['page_watermark_url'] = url
|
3209
3413
|
self
|
3210
3414
|
end
|
3211
3415
|
|
3212
3416
|
# Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
|
3213
3417
|
#
|
3214
|
-
# * +
|
3418
|
+
# * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
|
3215
3419
|
# * *Returns* - The converter object.
|
3216
|
-
def setMultipageWatermark(
|
3217
|
-
if (!(File.file?(
|
3218
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3420
|
+
def setMultipageWatermark(watermark)
|
3421
|
+
if (!(File.file?(watermark) && !File.zero?(watermark)))
|
3422
|
+
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
3423
|
end
|
3220
3424
|
|
3221
|
-
@files['multipage_watermark'] =
|
3425
|
+
@files['multipage_watermark'] = watermark
|
3222
3426
|
self
|
3223
3427
|
end
|
3224
3428
|
|
3225
3429
|
# 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
3430
|
#
|
3227
|
-
# * +
|
3431
|
+
# * +url+ - The supported protocols are http:// and https://.
|
3228
3432
|
# * *Returns* - The converter object.
|
3229
|
-
def setMultipageWatermarkUrl(
|
3230
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
3231
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3433
|
+
def setMultipageWatermarkUrl(url)
|
3434
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
3435
|
+
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
3436
|
end
|
3233
3437
|
|
3234
|
-
@fields['multipage_watermark_url'] =
|
3438
|
+
@fields['multipage_watermark_url'] = url
|
3235
3439
|
self
|
3236
3440
|
end
|
3237
3441
|
|
3238
3442
|
# Apply the first page of the specified PDF to the background of every page of the output PDF.
|
3239
3443
|
#
|
3240
|
-
# * +
|
3444
|
+
# * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
|
3241
3445
|
# * *Returns* - The converter object.
|
3242
|
-
def setPageBackground(
|
3243
|
-
if (!(File.file?(
|
3244
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3446
|
+
def setPageBackground(background)
|
3447
|
+
if (!(File.file?(background) && !File.zero?(background)))
|
3448
|
+
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
3449
|
end
|
3246
3450
|
|
3247
|
-
@files['page_background'] =
|
3451
|
+
@files['page_background'] = background
|
3248
3452
|
self
|
3249
3453
|
end
|
3250
3454
|
|
3251
3455
|
# 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
3456
|
#
|
3253
|
-
# * +
|
3457
|
+
# * +url+ - The supported protocols are http:// and https://.
|
3254
3458
|
# * *Returns* - The converter object.
|
3255
|
-
def setPageBackgroundUrl(
|
3256
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
3257
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3459
|
+
def setPageBackgroundUrl(url)
|
3460
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
3461
|
+
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
3462
|
end
|
3259
3463
|
|
3260
|
-
@fields['page_background_url'] =
|
3464
|
+
@fields['page_background_url'] = url
|
3261
3465
|
self
|
3262
3466
|
end
|
3263
3467
|
|
3264
3468
|
# Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
|
3265
3469
|
#
|
3266
|
-
# * +
|
3470
|
+
# * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
|
3267
3471
|
# * *Returns* - The converter object.
|
3268
|
-
def setMultipageBackground(
|
3269
|
-
if (!(File.file?(
|
3270
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3472
|
+
def setMultipageBackground(background)
|
3473
|
+
if (!(File.file?(background) && !File.zero?(background)))
|
3474
|
+
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
3475
|
end
|
3272
3476
|
|
3273
|
-
@files['multipage_background'] =
|
3477
|
+
@files['multipage_background'] = background
|
3274
3478
|
self
|
3275
3479
|
end
|
3276
3480
|
|
3277
3481
|
# 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
3482
|
#
|
3279
|
-
# * +
|
3483
|
+
# * +url+ - The supported protocols are http:// and https://.
|
3280
3484
|
# * *Returns* - The converter object.
|
3281
|
-
def setMultipageBackgroundUrl(
|
3282
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
3283
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3485
|
+
def setMultipageBackgroundUrl(url)
|
3486
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
3487
|
+
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
3488
|
end
|
3285
3489
|
|
3286
|
-
@fields['multipage_background_url'] =
|
3490
|
+
@fields['multipage_background_url'] = url
|
3287
3491
|
self
|
3288
3492
|
end
|
3289
3493
|
|
3290
3494
|
# Create linearized PDF. This is also known as Fast Web View.
|
3291
3495
|
#
|
3292
|
-
# * +
|
3496
|
+
# * +value+ - Set to true to create linearized PDF.
|
3293
3497
|
# * *Returns* - The converter object.
|
3294
|
-
def setLinearize(
|
3295
|
-
@fields['linearize'] =
|
3498
|
+
def setLinearize(value)
|
3499
|
+
@fields['linearize'] = value
|
3296
3500
|
self
|
3297
3501
|
end
|
3298
3502
|
|
3299
3503
|
# Encrypt the PDF. This prevents search engines from indexing the contents.
|
3300
3504
|
#
|
3301
|
-
# * +
|
3505
|
+
# * +value+ - Set to true to enable PDF encryption.
|
3302
3506
|
# * *Returns* - The converter object.
|
3303
|
-
def setEncrypt(
|
3304
|
-
@fields['encrypt'] =
|
3507
|
+
def setEncrypt(value)
|
3508
|
+
@fields['encrypt'] = value
|
3305
3509
|
self
|
3306
3510
|
end
|
3307
3511
|
|
3308
3512
|
# 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
3513
|
#
|
3310
|
-
# * +
|
3514
|
+
# * +password+ - The user password.
|
3311
3515
|
# * *Returns* - The converter object.
|
3312
|
-
def setUserPassword(
|
3313
|
-
@fields['user_password'] =
|
3516
|
+
def setUserPassword(password)
|
3517
|
+
@fields['user_password'] = password
|
3314
3518
|
self
|
3315
3519
|
end
|
3316
3520
|
|
3317
3521
|
# 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
3522
|
#
|
3319
|
-
# * +
|
3523
|
+
# * +password+ - The owner password.
|
3320
3524
|
# * *Returns* - The converter object.
|
3321
|
-
def setOwnerPassword(
|
3322
|
-
@fields['owner_password'] =
|
3525
|
+
def setOwnerPassword(password)
|
3526
|
+
@fields['owner_password'] = password
|
3323
3527
|
self
|
3324
3528
|
end
|
3325
3529
|
|
3326
3530
|
# Disallow printing of the output PDF.
|
3327
3531
|
#
|
3328
|
-
# * +
|
3532
|
+
# * +value+ - Set to true to set the no-print flag in the output PDF.
|
3329
3533
|
# * *Returns* - The converter object.
|
3330
|
-
def setNoPrint(
|
3331
|
-
@fields['no_print'] =
|
3534
|
+
def setNoPrint(value)
|
3535
|
+
@fields['no_print'] = value
|
3332
3536
|
self
|
3333
3537
|
end
|
3334
3538
|
|
3335
3539
|
# Disallow modification of the output PDF.
|
3336
3540
|
#
|
3337
|
-
# * +
|
3541
|
+
# * +value+ - Set to true to set the read-only only flag in the output PDF.
|
3338
3542
|
# * *Returns* - The converter object.
|
3339
|
-
def setNoModify(
|
3340
|
-
@fields['no_modify'] =
|
3543
|
+
def setNoModify(value)
|
3544
|
+
@fields['no_modify'] = value
|
3341
3545
|
self
|
3342
3546
|
end
|
3343
3547
|
|
3344
3548
|
# Disallow text and graphics extraction from the output PDF.
|
3345
3549
|
#
|
3346
|
-
# * +
|
3550
|
+
# * +value+ - Set to true to set the no-copy flag in the output PDF.
|
3347
3551
|
# * *Returns* - The converter object.
|
3348
|
-
def setNoCopy(
|
3349
|
-
@fields['no_copy'] =
|
3552
|
+
def setNoCopy(value)
|
3553
|
+
@fields['no_copy'] = value
|
3350
3554
|
self
|
3351
3555
|
end
|
3352
3556
|
|
3353
3557
|
# Specify the page layout to be used when the document is opened.
|
3354
3558
|
#
|
3355
|
-
# * +
|
3559
|
+
# * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
|
3356
3560
|
# * *Returns* - The converter object.
|
3357
|
-
def setPageLayout(
|
3358
|
-
unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(
|
3359
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3561
|
+
def setPageLayout(layout)
|
3562
|
+
unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout)
|
3563
|
+
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
3564
|
end
|
3361
3565
|
|
3362
|
-
@fields['page_layout'] =
|
3566
|
+
@fields['page_layout'] = layout
|
3363
3567
|
self
|
3364
3568
|
end
|
3365
3569
|
|
3366
3570
|
# Specify how the document should be displayed when opened.
|
3367
3571
|
#
|
3368
|
-
# * +
|
3572
|
+
# * +mode+ - Allowed values are full-screen, thumbnails, outlines.
|
3369
3573
|
# * *Returns* - The converter object.
|
3370
|
-
def setPageMode(
|
3371
|
-
unless /(?i)^(full-screen|thumbnails|outlines)$/.match(
|
3372
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3574
|
+
def setPageMode(mode)
|
3575
|
+
unless /(?i)^(full-screen|thumbnails|outlines)$/.match(mode)
|
3576
|
+
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
3577
|
end
|
3374
3578
|
|
3375
|
-
@fields['page_mode'] =
|
3579
|
+
@fields['page_mode'] = mode
|
3376
3580
|
self
|
3377
3581
|
end
|
3378
3582
|
|
3379
3583
|
# Specify how the page should be displayed when opened.
|
3380
3584
|
#
|
3381
|
-
# * +
|
3585
|
+
# * +zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
|
3382
3586
|
# * *Returns* - The converter object.
|
3383
|
-
def setInitialZoomType(
|
3384
|
-
unless /(?i)^(fit-width|fit-height|fit-page)$/.match(
|
3385
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3587
|
+
def setInitialZoomType(zoom_type)
|
3588
|
+
unless /(?i)^(fit-width|fit-height|fit-page)$/.match(zoom_type)
|
3589
|
+
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
3590
|
end
|
3387
3591
|
|
3388
|
-
@fields['initial_zoom_type'] =
|
3592
|
+
@fields['initial_zoom_type'] = zoom_type
|
3389
3593
|
self
|
3390
3594
|
end
|
3391
3595
|
|
3392
3596
|
# Display the specified page when the document is opened.
|
3393
3597
|
#
|
3394
|
-
# * +
|
3598
|
+
# * +page+ - Must be a positive integer number.
|
3395
3599
|
# * *Returns* - The converter object.
|
3396
|
-
def setInitialPage(
|
3397
|
-
if (!(Integer(
|
3398
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3600
|
+
def setInitialPage(page)
|
3601
|
+
if (!(Integer(page) > 0))
|
3602
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "pdf-to-pdf", "Must be a positive integer number.", "set_initial_page"), 470);
|
3399
3603
|
end
|
3400
3604
|
|
3401
|
-
@fields['initial_page'] =
|
3605
|
+
@fields['initial_page'] = page
|
3402
3606
|
self
|
3403
3607
|
end
|
3404
3608
|
|
3405
3609
|
# Specify the initial page zoom in percents when the document is opened.
|
3406
3610
|
#
|
3407
|
-
# * +
|
3611
|
+
# * +zoom+ - Must be a positive integer number.
|
3408
3612
|
# * *Returns* - The converter object.
|
3409
|
-
def setInitialZoom(
|
3410
|
-
if (!(Integer(
|
3411
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3613
|
+
def setInitialZoom(zoom)
|
3614
|
+
if (!(Integer(zoom) > 0))
|
3615
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "pdf-to-pdf", "Must be a positive integer number.", "set_initial_zoom"), 470);
|
3412
3616
|
end
|
3413
3617
|
|
3414
|
-
@fields['initial_zoom'] =
|
3618
|
+
@fields['initial_zoom'] = zoom
|
3415
3619
|
self
|
3416
3620
|
end
|
3417
3621
|
|
3418
3622
|
# Specify whether to hide the viewer application's tool bars when the document is active.
|
3419
3623
|
#
|
3420
|
-
# * +
|
3624
|
+
# * +value+ - Set to true to hide tool bars.
|
3421
3625
|
# * *Returns* - The converter object.
|
3422
|
-
def setHideToolbar(
|
3423
|
-
@fields['hide_toolbar'] =
|
3626
|
+
def setHideToolbar(value)
|
3627
|
+
@fields['hide_toolbar'] = value
|
3424
3628
|
self
|
3425
3629
|
end
|
3426
3630
|
|
3427
3631
|
# Specify whether to hide the viewer application's menu bar when the document is active.
|
3428
3632
|
#
|
3429
|
-
# * +
|
3633
|
+
# * +value+ - Set to true to hide the menu bar.
|
3430
3634
|
# * *Returns* - The converter object.
|
3431
|
-
def setHideMenubar(
|
3432
|
-
@fields['hide_menubar'] =
|
3635
|
+
def setHideMenubar(value)
|
3636
|
+
@fields['hide_menubar'] = value
|
3433
3637
|
self
|
3434
3638
|
end
|
3435
3639
|
|
3436
3640
|
# 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
3641
|
#
|
3438
|
-
# * +
|
3642
|
+
# * +value+ - Set to true to hide ui elements.
|
3439
3643
|
# * *Returns* - The converter object.
|
3440
|
-
def setHideWindowUi(
|
3441
|
-
@fields['hide_window_ui'] =
|
3644
|
+
def setHideWindowUi(value)
|
3645
|
+
@fields['hide_window_ui'] = value
|
3442
3646
|
self
|
3443
3647
|
end
|
3444
3648
|
|
3445
3649
|
# Specify whether to resize the document's window to fit the size of the first displayed page.
|
3446
3650
|
#
|
3447
|
-
# * +
|
3651
|
+
# * +value+ - Set to true to resize the window.
|
3448
3652
|
# * *Returns* - The converter object.
|
3449
|
-
def setFitWindow(
|
3450
|
-
@fields['fit_window'] =
|
3653
|
+
def setFitWindow(value)
|
3654
|
+
@fields['fit_window'] = value
|
3451
3655
|
self
|
3452
3656
|
end
|
3453
3657
|
|
3454
3658
|
# Specify whether to position the document's window in the center of the screen.
|
3455
3659
|
#
|
3456
|
-
# * +
|
3660
|
+
# * +value+ - Set to true to center the window.
|
3457
3661
|
# * *Returns* - The converter object.
|
3458
|
-
def setCenterWindow(
|
3459
|
-
@fields['center_window'] =
|
3662
|
+
def setCenterWindow(value)
|
3663
|
+
@fields['center_window'] = value
|
3460
3664
|
self
|
3461
3665
|
end
|
3462
3666
|
|
3463
3667
|
# 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
3668
|
#
|
3465
|
-
# * +
|
3669
|
+
# * +value+ - Set to true to display the title.
|
3466
3670
|
# * *Returns* - The converter object.
|
3467
|
-
def setDisplayTitle(
|
3468
|
-
@fields['display_title'] =
|
3671
|
+
def setDisplayTitle(value)
|
3672
|
+
@fields['display_title'] = value
|
3469
3673
|
self
|
3470
3674
|
end
|
3471
3675
|
|
3472
3676
|
# 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
3677
|
#
|
3474
|
-
# * +
|
3678
|
+
# * +value+ - Set to true to set right-to-left reading order.
|
3475
3679
|
# * *Returns* - The converter object.
|
3476
|
-
def setRightToLeft(
|
3477
|
-
@fields['right_to_left'] =
|
3680
|
+
def setRightToLeft(value)
|
3681
|
+
@fields['right_to_left'] = value
|
3478
3682
|
self
|
3479
3683
|
end
|
3480
3684
|
|
3481
3685
|
# 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
3686
|
#
|
3483
|
-
# * +
|
3687
|
+
# * +value+ - Set to true to enable the debug logging.
|
3484
3688
|
# * *Returns* - The converter object.
|
3485
|
-
def setDebugLog(
|
3486
|
-
@fields['debug_log'] =
|
3689
|
+
def setDebugLog(value)
|
3690
|
+
@fields['debug_log'] = value
|
3487
3691
|
self
|
3488
3692
|
end
|
3489
3693
|
|
@@ -3526,6 +3730,12 @@ module Pdfcrowd
|
|
3526
3730
|
return @helper.getOutputSize()
|
3527
3731
|
end
|
3528
3732
|
|
3733
|
+
# Get the version details.
|
3734
|
+
# * *Returns* - API version, converter version, and client version.
|
3735
|
+
def getVersion()
|
3736
|
+
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
3737
|
+
end
|
3738
|
+
|
3529
3739
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
3530
3740
|
#
|
3531
3741
|
# * +tag+ - A string with the custom tag.
|
@@ -3535,22 +3745,35 @@ module Pdfcrowd
|
|
3535
3745
|
self
|
3536
3746
|
end
|
3537
3747
|
|
3748
|
+
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
3749
|
+
#
|
3750
|
+
# * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
|
3751
|
+
# * *Returns* - The converter object.
|
3752
|
+
def setConverterVersion(version)
|
3753
|
+
unless /(?i)^(latest|20.10|18.10)$/.match(version)
|
3754
|
+
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);
|
3755
|
+
end
|
3756
|
+
|
3757
|
+
@helper.setConverterVersion(version)
|
3758
|
+
self
|
3759
|
+
end
|
3760
|
+
|
3538
3761
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
3539
3762
|
# 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
3763
|
#
|
3541
|
-
# * +
|
3764
|
+
# * +value+ - Set to true to use HTTP.
|
3542
3765
|
# * *Returns* - The converter object.
|
3543
|
-
def setUseHttp(
|
3544
|
-
@helper.setUseHttp(
|
3766
|
+
def setUseHttp(value)
|
3767
|
+
@helper.setUseHttp(value)
|
3545
3768
|
self
|
3546
3769
|
end
|
3547
3770
|
|
3548
|
-
# Set a custom user agent HTTP header. It can be
|
3771
|
+
# Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
|
3549
3772
|
#
|
3550
|
-
# * +
|
3773
|
+
# * +agent+ - The user agent string.
|
3551
3774
|
# * *Returns* - The converter object.
|
3552
|
-
def setUserAgent(
|
3553
|
-
@helper.setUserAgent(
|
3775
|
+
def setUserAgent(agent)
|
3776
|
+
@helper.setUserAgent(agent)
|
3554
3777
|
self
|
3555
3778
|
end
|
3556
3779
|
|
@@ -3568,10 +3791,10 @@ module Pdfcrowd
|
|
3568
3791
|
|
3569
3792
|
# 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
3793
|
#
|
3571
|
-
# * +
|
3794
|
+
# * +count+ - Number of retries wanted.
|
3572
3795
|
# * *Returns* - The converter object.
|
3573
|
-
def setRetryCount(
|
3574
|
-
@helper.setRetryCount(
|
3796
|
+
def setRetryCount(count)
|
3797
|
+
@helper.setRetryCount(count)
|
3575
3798
|
self
|
3576
3799
|
end
|
3577
3800
|
|
@@ -3600,7 +3823,7 @@ module Pdfcrowd
|
|
3600
3823
|
# * *Returns* - Byte array containing the conversion output.
|
3601
3824
|
def convertUrl(url)
|
3602
3825
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
3603
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "
|
3826
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-pdf", "The supported protocols are http:// and https://.", "convert_url"), 470);
|
3604
3827
|
end
|
3605
3828
|
|
3606
3829
|
@fields['url'] = url
|
@@ -3613,7 +3836,7 @@ module Pdfcrowd
|
|
3613
3836
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
3614
3837
|
def convertUrlToStream(url, out_stream)
|
3615
3838
|
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);
|
3839
|
+
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
3840
|
end
|
3618
3841
|
|
3619
3842
|
@fields['url'] = url
|
@@ -3626,7 +3849,7 @@ module Pdfcrowd
|
|
3626
3849
|
# * +file_path+ - The output file path. The string must not be empty.
|
3627
3850
|
def convertUrlToFile(url, file_path)
|
3628
3851
|
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);
|
3852
|
+
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
3853
|
end
|
3631
3854
|
|
3632
3855
|
output_file = open(file_path, "wb")
|
@@ -3642,11 +3865,11 @@ module Pdfcrowd
|
|
3642
3865
|
|
3643
3866
|
# Convert a local file.
|
3644
3867
|
#
|
3645
|
-
# * +file+ - The path to a local file to convert. The file
|
3868
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
3646
3869
|
# * *Returns* - Byte array containing the conversion output.
|
3647
3870
|
def convertFile(file)
|
3648
3871
|
if (!(File.file?(file) && !File.zero?(file)))
|
3649
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "
|
3872
|
+
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
3873
|
end
|
3651
3874
|
|
3652
3875
|
@files['file'] = file
|
@@ -3655,11 +3878,11 @@ module Pdfcrowd
|
|
3655
3878
|
|
3656
3879
|
# Convert a local file and write the result to an output stream.
|
3657
3880
|
#
|
3658
|
-
# * +file+ - The path to a local file to convert. The file
|
3881
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
3659
3882
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
3660
3883
|
def convertFileToStream(file, out_stream)
|
3661
3884
|
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);
|
3885
|
+
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
3886
|
end
|
3664
3887
|
|
3665
3888
|
@files['file'] = file
|
@@ -3668,11 +3891,11 @@ module Pdfcrowd
|
|
3668
3891
|
|
3669
3892
|
# Convert a local file and write the result to a local file.
|
3670
3893
|
#
|
3671
|
-
# * +file+ - The path to a local file to convert. The file
|
3894
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
3672
3895
|
# * +file_path+ - The output file path. The string must not be empty.
|
3673
3896
|
def convertFileToFile(file, file_path)
|
3674
3897
|
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);
|
3898
|
+
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
3899
|
end
|
3677
3900
|
|
3678
3901
|
output_file = open(file_path, "wb")
|
@@ -3710,7 +3933,7 @@ module Pdfcrowd
|
|
3710
3933
|
# * +file_path+ - The output file path. The string must not be empty.
|
3711
3934
|
def convertRawDataToFile(data, file_path)
|
3712
3935
|
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);
|
3936
|
+
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
3937
|
end
|
3715
3938
|
|
3716
3939
|
output_file = open(file_path, "wb")
|
@@ -3744,10 +3967,10 @@ module Pdfcrowd
|
|
3744
3967
|
|
3745
3968
|
# 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
3969
|
#
|
3747
|
-
# * +
|
3970
|
+
# * +value+ - Set to true to enable the debug logging.
|
3748
3971
|
# * *Returns* - The converter object.
|
3749
|
-
def setDebugLog(
|
3750
|
-
@fields['debug_log'] =
|
3972
|
+
def setDebugLog(value)
|
3973
|
+
@fields['debug_log'] = value
|
3751
3974
|
self
|
3752
3975
|
end
|
3753
3976
|
|
@@ -3784,6 +4007,12 @@ module Pdfcrowd
|
|
3784
4007
|
return @helper.getOutputSize()
|
3785
4008
|
end
|
3786
4009
|
|
4010
|
+
# Get the version details.
|
4011
|
+
# * *Returns* - API version, converter version, and client version.
|
4012
|
+
def getVersion()
|
4013
|
+
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
4014
|
+
end
|
4015
|
+
|
3787
4016
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
3788
4017
|
#
|
3789
4018
|
# * +tag+ - A string with the custom tag.
|
@@ -3795,46 +4024,59 @@ module Pdfcrowd
|
|
3795
4024
|
|
3796
4025
|
# 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
4026
|
#
|
3798
|
-
# * +
|
4027
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
3799
4028
|
# * *Returns* - The converter object.
|
3800
|
-
def setHttpProxy(
|
3801
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
3802
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
4029
|
+
def setHttpProxy(proxy)
|
4030
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
4031
|
+
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
4032
|
end
|
3804
4033
|
|
3805
|
-
@fields['http_proxy'] =
|
4034
|
+
@fields['http_proxy'] = proxy
|
3806
4035
|
self
|
3807
4036
|
end
|
3808
4037
|
|
3809
4038
|
# 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
4039
|
#
|
3811
|
-
# * +
|
4040
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
4041
|
+
# * *Returns* - The converter object.
|
4042
|
+
def setHttpsProxy(proxy)
|
4043
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
4044
|
+
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);
|
4045
|
+
end
|
4046
|
+
|
4047
|
+
@fields['https_proxy'] = proxy
|
4048
|
+
self
|
4049
|
+
end
|
4050
|
+
|
4051
|
+
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
4052
|
+
#
|
4053
|
+
# * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
|
3812
4054
|
# * *Returns* - The converter object.
|
3813
|
-
def
|
3814
|
-
unless /(?i)^(
|
3815
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
4055
|
+
def setConverterVersion(version)
|
4056
|
+
unless /(?i)^(latest|20.10|18.10)$/.match(version)
|
4057
|
+
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
4058
|
end
|
3817
4059
|
|
3818
|
-
@
|
4060
|
+
@helper.setConverterVersion(version)
|
3819
4061
|
self
|
3820
4062
|
end
|
3821
4063
|
|
3822
4064
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
3823
4065
|
# 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
4066
|
#
|
3825
|
-
# * +
|
4067
|
+
# * +value+ - Set to true to use HTTP.
|
3826
4068
|
# * *Returns* - The converter object.
|
3827
|
-
def setUseHttp(
|
3828
|
-
@helper.setUseHttp(
|
4069
|
+
def setUseHttp(value)
|
4070
|
+
@helper.setUseHttp(value)
|
3829
4071
|
self
|
3830
4072
|
end
|
3831
4073
|
|
3832
|
-
# Set a custom user agent HTTP header. It can be
|
4074
|
+
# Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
|
3833
4075
|
#
|
3834
|
-
# * +
|
4076
|
+
# * +agent+ - The user agent string.
|
3835
4077
|
# * *Returns* - The converter object.
|
3836
|
-
def setUserAgent(
|
3837
|
-
@helper.setUserAgent(
|
4078
|
+
def setUserAgent(agent)
|
4079
|
+
@helper.setUserAgent(agent)
|
3838
4080
|
self
|
3839
4081
|
end
|
3840
4082
|
|
@@ -3852,10 +4094,10 @@ module Pdfcrowd
|
|
3852
4094
|
|
3853
4095
|
# 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
4096
|
#
|
3855
|
-
# * +
|
4097
|
+
# * +count+ - Number of retries wanted.
|
3856
4098
|
# * *Returns* - The converter object.
|
3857
|
-
def setRetryCount(
|
3858
|
-
@helper.setRetryCount(
|
4099
|
+
def setRetryCount(count)
|
4100
|
+
@helper.setRetryCount(count)
|
3859
4101
|
self
|
3860
4102
|
end
|
3861
4103
|
|