pdfcrowd 4.8.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/pdfcrowd.rb +1349 -618
- 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)
|
@@ -683,6 +692,7 @@ module Pdfcrowd
|
|
683
692
|
|
684
693
|
begin
|
685
694
|
http.start {|conn|
|
695
|
+
conn.read_timeout = 300
|
686
696
|
conn.request(request) {|response|
|
687
697
|
@debug_log_url = response["X-Pdfcrowd-Debug-Log"] || ''
|
688
698
|
@credits = (response["X-Pdfcrowd-Remaining-Credits"] || 999999).to_i
|
@@ -723,7 +733,7 @@ module Pdfcrowd
|
|
723
733
|
end
|
724
734
|
|
725
735
|
def self.create_invalid_value_message(value, field, converter, hint, id)
|
726
|
-
message = "Invalid value '%s' for
|
736
|
+
message = "Invalid value '%s' for %s." % [value, field]
|
727
737
|
message += " " + hint if hint
|
728
738
|
return message + " " + "Details: https://www.pdfcrowd.com/doc/api/%s/ruby/#%s" % [converter, id]
|
729
739
|
end
|
@@ -753,7 +763,7 @@ module Pdfcrowd
|
|
753
763
|
# * *Returns* - Byte array containing the conversion output.
|
754
764
|
def convertUrl(url)
|
755
765
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
756
|
-
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);
|
757
767
|
end
|
758
768
|
|
759
769
|
@fields['url'] = url
|
@@ -766,7 +776,7 @@ module Pdfcrowd
|
|
766
776
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
767
777
|
def convertUrlToStream(url, out_stream)
|
768
778
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
769
|
-
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);
|
770
780
|
end
|
771
781
|
|
772
782
|
@fields['url'] = url
|
@@ -779,7 +789,7 @@ module Pdfcrowd
|
|
779
789
|
# * +file_path+ - The output file path. The string must not be empty.
|
780
790
|
def convertUrlToFile(url, file_path)
|
781
791
|
if (!(!file_path.nil? && !file_path.empty?))
|
782
|
-
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);
|
783
793
|
end
|
784
794
|
|
785
795
|
output_file = open(file_path, "wb")
|
@@ -799,11 +809,7 @@ module Pdfcrowd
|
|
799
809
|
# * *Returns* - Byte array containing the conversion output.
|
800
810
|
def convertFile(file)
|
801
811
|
if (!(File.file?(file) && !File.zero?(file)))
|
802
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "
|
803
|
-
end
|
804
|
-
|
805
|
-
if (!(File.file?(file) && !File.zero?(file)))
|
806
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-pdf", "The file name must have a valid extension.", "convert_file"), 470);
|
812
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "html-to-pdf", "The file must exist and not be empty.", "convert_file"), 470);
|
807
813
|
end
|
808
814
|
|
809
815
|
@files['file'] = file
|
@@ -816,11 +822,7 @@ module Pdfcrowd
|
|
816
822
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
817
823
|
def convertFileToStream(file, out_stream)
|
818
824
|
if (!(File.file?(file) && !File.zero?(file)))
|
819
|
-
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);
|
820
|
-
end
|
821
|
-
|
822
|
-
if (!(File.file?(file) && !File.zero?(file)))
|
823
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-pdf", "The file name must have a valid extension.", "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);
|
824
826
|
end
|
825
827
|
|
826
828
|
@files['file'] = file
|
@@ -833,7 +835,7 @@ module Pdfcrowd
|
|
833
835
|
# * +file_path+ - The output file path. The string must not be empty.
|
834
836
|
def convertFileToFile(file, file_path)
|
835
837
|
if (!(!file_path.nil? && !file_path.empty?))
|
836
|
-
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);
|
837
839
|
end
|
838
840
|
|
839
841
|
output_file = open(file_path, "wb")
|
@@ -853,7 +855,7 @@ module Pdfcrowd
|
|
853
855
|
# * *Returns* - Byte array containing the conversion output.
|
854
856
|
def convertString(text)
|
855
857
|
if (!(!text.nil? && !text.empty?))
|
856
|
-
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);
|
857
859
|
end
|
858
860
|
|
859
861
|
@fields['text'] = text
|
@@ -866,7 +868,7 @@ module Pdfcrowd
|
|
866
868
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
867
869
|
def convertStringToStream(text, out_stream)
|
868
870
|
if (!(!text.nil? && !text.empty?))
|
869
|
-
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);
|
870
872
|
end
|
871
873
|
|
872
874
|
@fields['text'] = text
|
@@ -879,7 +881,7 @@ module Pdfcrowd
|
|
879
881
|
# * +file_path+ - The output file path. The string must not be empty.
|
880
882
|
def convertStringToFile(text, file_path)
|
881
883
|
if (!(!file_path.nil? && !file_path.empty?))
|
882
|
-
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);
|
883
885
|
end
|
884
886
|
|
885
887
|
output_file = open(file_path, "wb")
|
@@ -895,40 +897,40 @@ module Pdfcrowd
|
|
895
897
|
|
896
898
|
# Set the output page size.
|
897
899
|
#
|
898
|
-
# * +
|
900
|
+
# * +size+ - Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.
|
899
901
|
# * *Returns* - The converter object.
|
900
|
-
def setPageSize(
|
901
|
-
unless /(?i)^(A2|A3|A4|A5|A6|Letter)$/.match(
|
902
|
-
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);
|
903
905
|
end
|
904
906
|
|
905
|
-
@fields['page_size'] =
|
907
|
+
@fields['page_size'] = size
|
906
908
|
self
|
907
909
|
end
|
908
910
|
|
909
911
|
# Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
|
910
912
|
#
|
911
|
-
# * +
|
913
|
+
# * +width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
912
914
|
# * *Returns* - The converter object.
|
913
|
-
def setPageWidth(
|
914
|
-
unless /(?i)^[0-9]
|
915
|
-
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);
|
916
918
|
end
|
917
919
|
|
918
|
-
@fields['page_width'] =
|
920
|
+
@fields['page_width'] = width
|
919
921
|
self
|
920
922
|
end
|
921
923
|
|
922
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.
|
923
925
|
#
|
924
|
-
# * +
|
926
|
+
# * +height+ - Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
925
927
|
# * *Returns* - The converter object.
|
926
|
-
def setPageHeight(
|
927
|
-
unless /(?i)
|
928
|
-
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);
|
929
931
|
end
|
930
932
|
|
931
|
-
@fields['page_height'] =
|
933
|
+
@fields['page_height'] = height
|
932
934
|
self
|
933
935
|
end
|
934
936
|
|
@@ -949,7 +951,7 @@ module Pdfcrowd
|
|
949
951
|
# * *Returns* - The converter object.
|
950
952
|
def setOrientation(orientation)
|
951
953
|
unless /(?i)^(landscape|portrait)$/.match(orientation)
|
952
|
-
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);
|
953
955
|
end
|
954
956
|
|
955
957
|
@fields['orientation'] = orientation
|
@@ -958,62 +960,62 @@ module Pdfcrowd
|
|
958
960
|
|
959
961
|
# Set the output page top margin.
|
960
962
|
#
|
961
|
-
# * +
|
963
|
+
# * +top+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
962
964
|
# * *Returns* - The converter object.
|
963
|
-
def setMarginTop(
|
964
|
-
unless /(?i)^[0-9]
|
965
|
-
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);
|
966
968
|
end
|
967
969
|
|
968
|
-
@fields['margin_top'] =
|
970
|
+
@fields['margin_top'] = top
|
969
971
|
self
|
970
972
|
end
|
971
973
|
|
972
974
|
# Set the output page right margin.
|
973
975
|
#
|
974
|
-
# * +
|
976
|
+
# * +right+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
975
977
|
# * *Returns* - The converter object.
|
976
|
-
def setMarginRight(
|
977
|
-
unless /(?i)^[0-9]
|
978
|
-
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);
|
979
981
|
end
|
980
982
|
|
981
|
-
@fields['margin_right'] =
|
983
|
+
@fields['margin_right'] = right
|
982
984
|
self
|
983
985
|
end
|
984
986
|
|
985
987
|
# Set the output page bottom margin.
|
986
988
|
#
|
987
|
-
# * +
|
989
|
+
# * +bottom+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
988
990
|
# * *Returns* - The converter object.
|
989
|
-
def setMarginBottom(
|
990
|
-
unless /(?i)^[0-9]
|
991
|
-
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);
|
992
994
|
end
|
993
995
|
|
994
|
-
@fields['margin_bottom'] =
|
996
|
+
@fields['margin_bottom'] = bottom
|
995
997
|
self
|
996
998
|
end
|
997
999
|
|
998
1000
|
# Set the output page left margin.
|
999
1001
|
#
|
1000
|
-
# * +
|
1002
|
+
# * +left+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1001
1003
|
# * *Returns* - The converter object.
|
1002
|
-
def setMarginLeft(
|
1003
|
-
unless /(?i)^[0-9]
|
1004
|
-
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);
|
1005
1007
|
end
|
1006
1008
|
|
1007
|
-
@fields['margin_left'] =
|
1009
|
+
@fields['margin_left'] = left
|
1008
1010
|
self
|
1009
1011
|
end
|
1010
1012
|
|
1011
|
-
# Disable margins.
|
1013
|
+
# Disable page margins.
|
1012
1014
|
#
|
1013
|
-
# * +
|
1015
|
+
# * +value+ - Set to true to disable margins.
|
1014
1016
|
# * *Returns* - The converter object.
|
1015
|
-
def setNoMargins(
|
1016
|
-
@fields['no_margins'] =
|
1017
|
+
def setNoMargins(value)
|
1018
|
+
@fields['no_margins'] = value
|
1017
1019
|
self
|
1018
1020
|
end
|
1019
1021
|
|
@@ -1034,313 +1036,494 @@ module Pdfcrowd
|
|
1034
1036
|
|
1035
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>
|
1036
1038
|
#
|
1037
|
-
# * +
|
1039
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1038
1040
|
# * *Returns* - The converter object.
|
1039
|
-
def setHeaderUrl(
|
1040
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
1041
|
-
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);
|
1042
1044
|
end
|
1043
1045
|
|
1044
|
-
@fields['header_url'] =
|
1046
|
+
@fields['header_url'] = url
|
1045
1047
|
self
|
1046
1048
|
end
|
1047
1049
|
|
1048
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>
|
1049
1051
|
#
|
1050
|
-
# * +
|
1052
|
+
# * +html+ - The string must not be empty.
|
1051
1053
|
# * *Returns* - The converter object.
|
1052
|
-
def setHeaderHtml(
|
1053
|
-
if (!(!
|
1054
|
-
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);
|
1055
1057
|
end
|
1056
1058
|
|
1057
|
-
@fields['header_html'] =
|
1059
|
+
@fields['header_html'] = html
|
1058
1060
|
self
|
1059
1061
|
end
|
1060
1062
|
|
1061
1063
|
# Set the header height.
|
1062
1064
|
#
|
1063
|
-
# * +
|
1065
|
+
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1064
1066
|
# * *Returns* - The converter object.
|
1065
|
-
def setHeaderHeight(
|
1066
|
-
unless /(?i)^[0-9]
|
1067
|
-
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);
|
1068
1070
|
end
|
1069
1071
|
|
1070
|
-
@fields['header_height'] =
|
1072
|
+
@fields['header_height'] = height
|
1071
1073
|
self
|
1072
1074
|
end
|
1073
1075
|
|
1074
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>
|
1075
1077
|
#
|
1076
|
-
# * +
|
1078
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1077
1079
|
# * *Returns* - The converter object.
|
1078
|
-
def setFooterUrl(
|
1079
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
1080
|
-
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);
|
1081
1083
|
end
|
1082
1084
|
|
1083
|
-
@fields['footer_url'] =
|
1085
|
+
@fields['footer_url'] = url
|
1084
1086
|
self
|
1085
1087
|
end
|
1086
1088
|
|
1087
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>
|
1088
1090
|
#
|
1089
|
-
# * +
|
1091
|
+
# * +html+ - The string must not be empty.
|
1090
1092
|
# * *Returns* - The converter object.
|
1091
|
-
def setFooterHtml(
|
1092
|
-
if (!(!
|
1093
|
-
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);
|
1094
1096
|
end
|
1095
1097
|
|
1096
|
-
@fields['footer_html'] =
|
1098
|
+
@fields['footer_html'] = html
|
1097
1099
|
self
|
1098
1100
|
end
|
1099
1101
|
|
1100
1102
|
# Set the footer height.
|
1101
1103
|
#
|
1102
|
-
# * +
|
1104
|
+
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1103
1105
|
# * *Returns* - The converter object.
|
1104
|
-
def setFooterHeight(
|
1105
|
-
unless /(?i)^[0-9]
|
1106
|
-
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);
|
1107
1109
|
end
|
1108
1110
|
|
1109
|
-
@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
|
1110
1121
|
self
|
1111
1122
|
end
|
1112
1123
|
|
1113
1124
|
# Set the page range to print.
|
1114
1125
|
#
|
1115
|
-
# * +pages+ - A comma
|
1126
|
+
# * +pages+ - A comma separated list of page numbers or ranges.
|
1116
1127
|
# * *Returns* - The converter object.
|
1117
1128
|
def setPrintPageRange(pages)
|
1118
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)
|
1119
|
-
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);
|
1120
1131
|
end
|
1121
1132
|
|
1122
1133
|
@fields['print_page_range'] = pages
|
1123
1134
|
self
|
1124
1135
|
end
|
1125
1136
|
|
1126
|
-
# The page
|
1137
|
+
# The page header is not printed on the specified pages.
|
1127
1138
|
#
|
1128
|
-
# * +
|
1139
|
+
# * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma separated list of page numbers.
|
1129
1140
|
# * *Returns* - The converter object.
|
1130
|
-
def
|
1131
|
-
unless /^
|
1132
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1141
|
+
def setExcludeHeaderOnPages(pages)
|
1142
|
+
unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(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);
|
1133
1144
|
end
|
1134
1145
|
|
1135
|
-
@fields['
|
1146
|
+
@fields['exclude_header_on_pages'] = pages
|
1136
1147
|
self
|
1137
1148
|
end
|
1138
1149
|
|
1139
|
-
#
|
1150
|
+
# The page footer is not printed on the specified pages.
|
1140
1151
|
#
|
1141
|
-
# * +
|
1152
|
+
# * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma separated list of page numbers.
|
1142
1153
|
# * *Returns* - The converter object.
|
1143
|
-
def
|
1144
|
-
|
1145
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1154
|
+
def setExcludeFooterOnPages(pages)
|
1155
|
+
unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(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);
|
1146
1157
|
end
|
1147
1158
|
|
1148
|
-
@
|
1159
|
+
@fields['exclude_footer_on_pages'] = pages
|
1149
1160
|
self
|
1150
1161
|
end
|
1151
1162
|
|
1152
|
-
#
|
1163
|
+
# Set an offset between physical and logical page numbers.
|
1164
|
+
#
|
1165
|
+
# * +offset+ - Integer specifying page offset.
|
1166
|
+
# * *Returns* - The converter object.
|
1167
|
+
def setPageNumberingOffset(offset)
|
1168
|
+
@fields['page_numbering_offset'] = offset
|
1169
|
+
self
|
1170
|
+
end
|
1171
|
+
|
1172
|
+
# Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
|
1153
1173
|
#
|
1154
|
-
# * +
|
1174
|
+
# * +x+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
|
1155
1175
|
# * *Returns* - The converter object.
|
1156
|
-
def
|
1157
|
-
|
1158
|
-
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);
|
1159
1179
|
end
|
1160
1180
|
|
1161
|
-
@
|
1181
|
+
@fields['content_area_x'] = x
|
1162
1182
|
self
|
1163
1183
|
end
|
1164
1184
|
|
1165
|
-
#
|
1185
|
+
# Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
|
1166
1186
|
#
|
1167
|
-
# * +
|
1187
|
+
# * +y+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
|
1168
1188
|
# * *Returns* - The converter object.
|
1169
|
-
def
|
1170
|
-
|
1171
|
-
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);
|
1172
1192
|
end
|
1173
1193
|
|
1174
|
-
@
|
1194
|
+
@fields['content_area_y'] = y
|
1175
1195
|
self
|
1176
1196
|
end
|
1177
1197
|
|
1178
|
-
#
|
1198
|
+
# Set the width of the content area. It should be at least 1 inch.
|
1179
1199
|
#
|
1180
|
-
# * +
|
1200
|
+
# * +width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1181
1201
|
# * *Returns* - The converter object.
|
1182
|
-
def
|
1183
|
-
|
1184
|
-
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);
|
1185
1205
|
end
|
1186
1206
|
|
1187
|
-
@
|
1207
|
+
@fields['content_area_width'] = width
|
1188
1208
|
self
|
1189
1209
|
end
|
1190
1210
|
|
1191
|
-
#
|
1211
|
+
# Set the height of the content area. It should be at least 1 inch.
|
1192
1212
|
#
|
1193
|
-
# * +
|
1213
|
+
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1194
1214
|
# * *Returns* - The converter object.
|
1195
|
-
def
|
1196
|
-
unless
|
1197
|
-
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);
|
1198
1218
|
end
|
1199
1219
|
|
1200
|
-
@fields['
|
1220
|
+
@fields['content_area_height'] = height
|
1201
1221
|
self
|
1202
1222
|
end
|
1203
1223
|
|
1204
|
-
# The
|
1224
|
+
# Set the content area position and size. The content area enables to specify a web page area to be converted.
|
1225
|
+
#
|
1226
|
+
# * +x+ - Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
|
1227
|
+
# * +y+ - Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
|
1228
|
+
# * +width+ - Set the width of the content area. It should be at least 1 inch. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1229
|
+
# * +height+ - Set the height of the content area. It should be at least 1 inch. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1230
|
+
# * *Returns* - The converter object.
|
1231
|
+
def setContentArea(x, y, width, height)
|
1232
|
+
setContentAreaX(x)
|
1233
|
+
setContentAreaY(y)
|
1234
|
+
setContentAreaWidth(width)
|
1235
|
+
setContentAreaHeight(height)
|
1236
|
+
self
|
1237
|
+
end
|
1238
|
+
|
1239
|
+
# Specifies behavior in presence of CSS @page rules. It may affect the page size, margins and orientation.
|
1205
1240
|
#
|
1206
|
-
# * +
|
1241
|
+
# * +mode+ - The page rule mode. Allowed values are default, mode1, mode2.
|
1207
1242
|
# * *Returns* - The converter object.
|
1208
|
-
def
|
1209
|
-
unless
|
1210
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
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);
|
1211
1246
|
end
|
1212
1247
|
|
1213
|
-
@fields['
|
1248
|
+
@fields['css_page_rule_mode'] = mode
|
1214
1249
|
self
|
1215
1250
|
end
|
1216
1251
|
|
1217
|
-
# Set
|
1252
|
+
# Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
|
1218
1253
|
#
|
1219
|
-
# * +
|
1254
|
+
# * +data_string+ - The input data string.
|
1220
1255
|
# * *Returns* - The converter object.
|
1221
|
-
def
|
1222
|
-
@fields['
|
1256
|
+
def setDataString(data_string)
|
1257
|
+
@fields['data_string'] = data_string
|
1258
|
+
self
|
1259
|
+
end
|
1260
|
+
|
1261
|
+
# Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
|
1262
|
+
#
|
1263
|
+
# * +data_file+ - The file path to a local file containing the input data.
|
1264
|
+
# * *Returns* - The converter object.
|
1265
|
+
def setDataFile(data_file)
|
1266
|
+
@files['data_file'] = data_file
|
1267
|
+
self
|
1268
|
+
end
|
1269
|
+
|
1270
|
+
# Specify the input data format.
|
1271
|
+
#
|
1272
|
+
# * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
|
1273
|
+
# * *Returns* - The converter object.
|
1274
|
+
def setDataFormat(data_format)
|
1275
|
+
unless /(?i)^(auto|json|xml|yaml|csv)$/.match(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);
|
1277
|
+
end
|
1278
|
+
|
1279
|
+
@fields['data_format'] = data_format
|
1280
|
+
self
|
1281
|
+
end
|
1282
|
+
|
1283
|
+
# Set the encoding of the data file set by setDataFile.
|
1284
|
+
#
|
1285
|
+
# * +encoding+ - The data file encoding.
|
1286
|
+
# * *Returns* - The converter object.
|
1287
|
+
def setDataEncoding(encoding)
|
1288
|
+
@fields['data_encoding'] = encoding
|
1289
|
+
self
|
1290
|
+
end
|
1291
|
+
|
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.
|
1293
|
+
#
|
1294
|
+
# * +value+ - Set to true to ignore undefined variables.
|
1295
|
+
# * *Returns* - The converter object.
|
1296
|
+
def setDataIgnoreUndefined(value)
|
1297
|
+
@fields['data_ignore_undefined'] = value
|
1298
|
+
self
|
1299
|
+
end
|
1300
|
+
|
1301
|
+
# Auto escape HTML symbols in the input data before placing them into the output.
|
1302
|
+
#
|
1303
|
+
# * +value+ - Set to true to turn auto escaping on.
|
1304
|
+
# * *Returns* - The converter object.
|
1305
|
+
def setDataAutoEscape(value)
|
1306
|
+
@fields['data_auto_escape'] = value
|
1307
|
+
self
|
1308
|
+
end
|
1309
|
+
|
1310
|
+
# Auto trim whitespace around each template command block.
|
1311
|
+
#
|
1312
|
+
# * +value+ - Set to true to turn auto trimming on.
|
1313
|
+
# * *Returns* - The converter object.
|
1314
|
+
def setDataTrimBlocks(value)
|
1315
|
+
@fields['data_trim_blocks'] = value
|
1316
|
+
self
|
1317
|
+
end
|
1318
|
+
|
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.
|
1320
|
+
#
|
1321
|
+
# * +options+ - Comma separated list of options.
|
1322
|
+
# * *Returns* - The converter object.
|
1323
|
+
def setDataOptions(options)
|
1324
|
+
@fields['data_options'] = options
|
1223
1325
|
self
|
1224
1326
|
end
|
1225
1327
|
|
1226
|
-
#
|
1328
|
+
# Apply the first page of the watermark PDF to every page of the output PDF.
|
1227
1329
|
#
|
1228
|
-
# * +
|
1330
|
+
# * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
|
1229
1331
|
# * *Returns* - The converter object.
|
1230
|
-
def
|
1231
|
-
|
1232
|
-
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);
|
1233
1335
|
end
|
1234
1336
|
|
1235
|
-
@
|
1337
|
+
@files['page_watermark'] = watermark
|
1236
1338
|
self
|
1237
1339
|
end
|
1238
1340
|
|
1239
|
-
#
|
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.
|
1240
1342
|
#
|
1241
|
-
# * +
|
1343
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1242
1344
|
# * *Returns* - The converter object.
|
1243
|
-
def
|
1244
|
-
unless /(?i)
|
1245
|
-
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);
|
1246
1348
|
end
|
1247
1349
|
|
1248
|
-
@fields['
|
1350
|
+
@fields['page_watermark_url'] = url
|
1249
1351
|
self
|
1250
1352
|
end
|
1251
1353
|
|
1252
|
-
#
|
1354
|
+
# Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
|
1253
1355
|
#
|
1254
|
-
# * +
|
1356
|
+
# * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
|
1255
1357
|
# * *Returns* - The converter object.
|
1256
|
-
def
|
1257
|
-
|
1258
|
-
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);
|
1259
1361
|
end
|
1260
1362
|
|
1261
|
-
@
|
1363
|
+
@files['multipage_watermark'] = watermark
|
1262
1364
|
self
|
1263
1365
|
end
|
1264
1366
|
|
1265
|
-
#
|
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.
|
1266
1368
|
#
|
1267
|
-
# * +
|
1369
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1268
1370
|
# * *Returns* - The converter object.
|
1269
|
-
def
|
1270
|
-
unless /(?i)^
|
1271
|
-
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);
|
1272
1374
|
end
|
1273
1375
|
|
1274
|
-
@fields['
|
1376
|
+
@fields['multipage_watermark_url'] = url
|
1275
1377
|
self
|
1276
1378
|
end
|
1277
1379
|
|
1278
|
-
#
|
1380
|
+
# Apply the first page of the specified PDF to the background of every page of the output PDF.
|
1279
1381
|
#
|
1280
|
-
# * +
|
1281
|
-
# * +y+ - Set the top left Y coordinate of the content area. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
|
1282
|
-
# * +width+ - Set the width of the content area. It should be at least 1 inch. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1283
|
-
# * +height+ - Set the height of the content area. It should be at least 1 inch. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1382
|
+
# * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
|
1284
1383
|
# * *Returns* - The converter object.
|
1285
|
-
def
|
1286
|
-
|
1287
|
-
|
1288
|
-
|
1289
|
-
|
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);
|
1387
|
+
end
|
1388
|
+
|
1389
|
+
@files['page_background'] = background
|
1390
|
+
self
|
1391
|
+
end
|
1392
|
+
|
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.
|
1394
|
+
#
|
1395
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1396
|
+
# * *Returns* - The converter object.
|
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);
|
1400
|
+
end
|
1401
|
+
|
1402
|
+
@fields['page_background_url'] = url
|
1403
|
+
self
|
1404
|
+
end
|
1405
|
+
|
1406
|
+
# Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
|
1407
|
+
#
|
1408
|
+
# * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
|
1409
|
+
# * *Returns* - The converter object.
|
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);
|
1413
|
+
end
|
1414
|
+
|
1415
|
+
@files['multipage_background'] = background
|
1416
|
+
self
|
1417
|
+
end
|
1418
|
+
|
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.
|
1420
|
+
#
|
1421
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1422
|
+
# * *Returns* - The converter object.
|
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);
|
1426
|
+
end
|
1427
|
+
|
1428
|
+
@fields['multipage_background_url'] = url
|
1429
|
+
self
|
1430
|
+
end
|
1431
|
+
|
1432
|
+
# The page background color in RGB or RGBA hexadecimal format. The color fills the entire page regardless of the margins.
|
1433
|
+
#
|
1434
|
+
# * +color+ - The value must be in RRGGBB or RRGGBBAA hexadecimal format.
|
1435
|
+
# * *Returns* - The converter object.
|
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);
|
1439
|
+
end
|
1440
|
+
|
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
|
1290
1451
|
self
|
1291
1452
|
end
|
1292
1453
|
|
1293
1454
|
# Do not print the background graphics.
|
1294
1455
|
#
|
1295
|
-
# * +
|
1456
|
+
# * +value+ - Set to true to disable the background graphics.
|
1296
1457
|
# * *Returns* - The converter object.
|
1297
|
-
def setNoBackground(
|
1298
|
-
@fields['no_background'] =
|
1458
|
+
def setNoBackground(value)
|
1459
|
+
@fields['no_background'] = value
|
1299
1460
|
self
|
1300
1461
|
end
|
1301
1462
|
|
1302
1463
|
# Do not execute JavaScript.
|
1303
1464
|
#
|
1304
|
-
# * +
|
1465
|
+
# * +value+ - Set to true to disable JavaScript in web pages.
|
1305
1466
|
# * *Returns* - The converter object.
|
1306
|
-
def setDisableJavascript(
|
1307
|
-
@fields['disable_javascript'] =
|
1467
|
+
def setDisableJavascript(value)
|
1468
|
+
@fields['disable_javascript'] = value
|
1308
1469
|
self
|
1309
1470
|
end
|
1310
1471
|
|
1311
1472
|
# Do not load images.
|
1312
1473
|
#
|
1313
|
-
# * +
|
1474
|
+
# * +value+ - Set to true to disable loading of images.
|
1314
1475
|
# * *Returns* - The converter object.
|
1315
|
-
def setDisableImageLoading(
|
1316
|
-
@fields['disable_image_loading'] =
|
1476
|
+
def setDisableImageLoading(value)
|
1477
|
+
@fields['disable_image_loading'] = value
|
1317
1478
|
self
|
1318
1479
|
end
|
1319
1480
|
|
1320
1481
|
# Disable loading fonts from remote sources.
|
1321
1482
|
#
|
1322
|
-
# * +
|
1483
|
+
# * +value+ - Set to true disable loading remote fonts.
|
1484
|
+
# * *Returns* - The converter object.
|
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.
|
1323
1493
|
# * *Returns* - The converter object.
|
1324
|
-
def
|
1325
|
-
|
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
|
1326
1500
|
self
|
1327
1501
|
end
|
1328
1502
|
|
1329
1503
|
# Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
|
1330
1504
|
#
|
1331
|
-
# * +
|
1505
|
+
# * +value+ - Set to true to block ads in web pages.
|
1332
1506
|
# * *Returns* - The converter object.
|
1333
|
-
def setBlockAds(
|
1334
|
-
@fields['block_ads'] =
|
1507
|
+
def setBlockAds(value)
|
1508
|
+
@fields['block_ads'] = value
|
1335
1509
|
self
|
1336
1510
|
end
|
1337
1511
|
|
1338
1512
|
# Set the default HTML content text encoding.
|
1339
1513
|
#
|
1340
|
-
# * +
|
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.
|
1341
1524
|
# * *Returns* - The converter object.
|
1342
|
-
def
|
1343
|
-
@fields['
|
1525
|
+
def setLocale(locale)
|
1526
|
+
@fields['locale'] = locale
|
1344
1527
|
self
|
1345
1528
|
end
|
1346
1529
|
|
@@ -1373,24 +1556,6 @@ module Pdfcrowd
|
|
1373
1556
|
self
|
1374
1557
|
end
|
1375
1558
|
|
1376
|
-
# Use the print version of the page if available (@media print).
|
1377
|
-
#
|
1378
|
-
# * +use_print_media+ - Set to true to use the print version of the page.
|
1379
|
-
# * *Returns* - The converter object.
|
1380
|
-
def setUsePrintMedia(use_print_media)
|
1381
|
-
@fields['use_print_media'] = use_print_media
|
1382
|
-
self
|
1383
|
-
end
|
1384
|
-
|
1385
|
-
# Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
|
1386
|
-
#
|
1387
|
-
# * +no_xpdfcrowd_header+ - Set to true to disable sending X-Pdfcrowd HTTP header.
|
1388
|
-
# * *Returns* - The converter object.
|
1389
|
-
def setNoXpdfcrowdHeader(no_xpdfcrowd_header)
|
1390
|
-
@fields['no_xpdfcrowd_header'] = no_xpdfcrowd_header
|
1391
|
-
self
|
1392
|
-
end
|
1393
|
-
|
1394
1559
|
# Set cookies that are sent in Pdfcrowd HTTP requests.
|
1395
1560
|
#
|
1396
1561
|
# * +cookies+ - The cookie string.
|
@@ -1402,10 +1567,10 @@ module Pdfcrowd
|
|
1402
1567
|
|
1403
1568
|
# Do not allow insecure HTTPS connections.
|
1404
1569
|
#
|
1405
|
-
# * +
|
1570
|
+
# * +value+ - Set to true to enable SSL certificate verification.
|
1406
1571
|
# * *Returns* - The converter object.
|
1407
|
-
def setVerifySslCertificates(
|
1408
|
-
@fields['verify_ssl_certificates'] =
|
1572
|
+
def setVerifySslCertificates(value)
|
1573
|
+
@fields['verify_ssl_certificates'] = value
|
1409
1574
|
self
|
1410
1575
|
end
|
1411
1576
|
|
@@ -1427,55 +1592,64 @@ module Pdfcrowd
|
|
1427
1592
|
self
|
1428
1593
|
end
|
1429
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
|
+
|
1430
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.
|
1431
1605
|
#
|
1432
|
-
# * +
|
1606
|
+
# * +javascript+ - A string containing a JavaScript code. The string must not be empty.
|
1433
1607
|
# * *Returns* - The converter object.
|
1434
|
-
def setCustomJavascript(
|
1435
|
-
if (!(!
|
1436
|
-
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);
|
1437
1611
|
end
|
1438
1612
|
|
1439
|
-
@fields['custom_javascript'] =
|
1613
|
+
@fields['custom_javascript'] = javascript
|
1440
1614
|
self
|
1441
1615
|
end
|
1442
1616
|
|
1443
|
-
# Run a custom JavaScript right after the document is loaded. The script is intended for early DOM manipulation. In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
|
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.
|
1444
1618
|
#
|
1445
|
-
# * +
|
1619
|
+
# * +javascript+ - A string containing a JavaScript code. The string must not be empty.
|
1446
1620
|
# * *Returns* - The converter object.
|
1447
|
-
def setOnLoadJavascript(
|
1448
|
-
if (!(!
|
1449
|
-
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);
|
1450
1624
|
end
|
1451
1625
|
|
1452
|
-
@fields['on_load_javascript'] =
|
1626
|
+
@fields['on_load_javascript'] = javascript
|
1453
1627
|
self
|
1454
1628
|
end
|
1455
1629
|
|
1456
1630
|
# Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
|
1457
1631
|
#
|
1458
|
-
# * +
|
1632
|
+
# * +header+ - A string containing the header name and value separated by a colon.
|
1459
1633
|
# * *Returns* - The converter object.
|
1460
|
-
def setCustomHttpHeader(
|
1461
|
-
unless /^.+:.+$/.match(
|
1462
|
-
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);
|
1463
1637
|
end
|
1464
1638
|
|
1465
|
-
@fields['custom_http_header'] =
|
1639
|
+
@fields['custom_http_header'] = header
|
1466
1640
|
self
|
1467
1641
|
end
|
1468
1642
|
|
1469
|
-
# Wait the specified number of milliseconds to finish all JavaScript after the document is loaded.
|
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.
|
1470
1644
|
#
|
1471
|
-
# * +
|
1645
|
+
# * +delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
|
1472
1646
|
# * *Returns* - The converter object.
|
1473
|
-
def setJavascriptDelay(
|
1474
|
-
if (!(Integer(
|
1475
|
-
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);
|
1476
1650
|
end
|
1477
1651
|
|
1478
|
-
@fields['javascript_delay'] =
|
1652
|
+
@fields['javascript_delay'] = delay
|
1479
1653
|
self
|
1480
1654
|
end
|
1481
1655
|
|
@@ -1485,7 +1659,7 @@ module Pdfcrowd
|
|
1485
1659
|
# * *Returns* - The converter object.
|
1486
1660
|
def setElementToConvert(selectors)
|
1487
1661
|
if (!(!selectors.nil? && !selectors.empty?))
|
1488
|
-
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);
|
1489
1663
|
end
|
1490
1664
|
|
1491
1665
|
@fields['element_to_convert'] = selectors
|
@@ -1498,7 +1672,7 @@ module Pdfcrowd
|
|
1498
1672
|
# * *Returns* - The converter object.
|
1499
1673
|
def setElementToConvertMode(mode)
|
1500
1674
|
unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode)
|
1501
|
-
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);
|
1502
1676
|
end
|
1503
1677
|
|
1504
1678
|
@fields['element_to_convert_mode'] = mode
|
@@ -1511,7 +1685,7 @@ module Pdfcrowd
|
|
1511
1685
|
# * *Returns* - The converter object.
|
1512
1686
|
def setWaitForElement(selectors)
|
1513
1687
|
if (!(!selectors.nil? && !selectors.empty?))
|
1514
|
-
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);
|
1515
1689
|
end
|
1516
1690
|
|
1517
1691
|
@fields['wait_for_element'] = selectors
|
@@ -1520,33 +1694,33 @@ module Pdfcrowd
|
|
1520
1694
|
|
1521
1695
|
# Set the viewport width in pixels. The viewport is the user's visible area of the page.
|
1522
1696
|
#
|
1523
|
-
# * +
|
1697
|
+
# * +width+ - The value must be in the range 96-65000.
|
1524
1698
|
# * *Returns* - The converter object.
|
1525
|
-
def setViewportWidth(
|
1526
|
-
if (!(Integer(
|
1527
|
-
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);
|
1528
1702
|
end
|
1529
1703
|
|
1530
|
-
@fields['viewport_width'] =
|
1704
|
+
@fields['viewport_width'] = width
|
1531
1705
|
self
|
1532
1706
|
end
|
1533
1707
|
|
1534
1708
|
# Set the viewport height in pixels. The viewport is the user's visible area of the page.
|
1535
1709
|
#
|
1536
|
-
# * +
|
1710
|
+
# * +height+ - Must be a positive integer number.
|
1537
1711
|
# * *Returns* - The converter object.
|
1538
|
-
def setViewportHeight(
|
1539
|
-
if (!(Integer(
|
1540
|
-
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);
|
1541
1715
|
end
|
1542
1716
|
|
1543
|
-
@fields['viewport_height'] =
|
1717
|
+
@fields['viewport_height'] = height
|
1544
1718
|
self
|
1545
1719
|
end
|
1546
1720
|
|
1547
1721
|
# Set the viewport size. The viewport is the user's visible area of the page.
|
1548
1722
|
#
|
1549
|
-
# * +width+ - Set the viewport width in pixels. The viewport is the user's visible area of the page. The value must be in the range 96-
|
1723
|
+
# * +width+ - Set the viewport width in pixels. The viewport is the user's visible area of the page. The value must be in the range 96-65000.
|
1550
1724
|
# * +height+ - Set the viewport height in pixels. The viewport is the user's visible area of the page. Must be a positive integer number.
|
1551
1725
|
# * *Returns* - The converter object.
|
1552
1726
|
def setViewport(width, height)
|
@@ -1557,164 +1731,155 @@ module Pdfcrowd
|
|
1557
1731
|
|
1558
1732
|
# Set the rendering mode.
|
1559
1733
|
#
|
1560
|
-
# * +
|
1734
|
+
# * +mode+ - The rendering mode. Allowed values are default, viewport.
|
1561
1735
|
# * *Returns* - The converter object.
|
1562
|
-
def setRenderingMode(
|
1563
|
-
unless /(?i)^(default|viewport)$/.match(
|
1564
|
-
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);
|
1565
1739
|
end
|
1566
1740
|
|
1567
|
-
@fields['rendering_mode'] =
|
1741
|
+
@fields['rendering_mode'] = mode
|
1568
1742
|
self
|
1569
1743
|
end
|
1570
1744
|
|
1571
1745
|
# Specifies the scaling mode used for fitting the HTML contents to the print area.
|
1572
1746
|
#
|
1573
|
-
# * +
|
1747
|
+
# * +mode+ - The smart scaling mode. Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, mode1.
|
1574
1748
|
# * *Returns* - The converter object.
|
1575
|
-
def setSmartScalingMode(
|
1576
|
-
unless /(?i)^(default|disabled|viewport-fit|content-fit|single-page-fit)$/.match(
|
1577
|
-
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);
|
1578
1752
|
end
|
1579
1753
|
|
1580
|
-
@fields['smart_scaling_mode'] =
|
1754
|
+
@fields['smart_scaling_mode'] = mode
|
1581
1755
|
self
|
1582
1756
|
end
|
1583
1757
|
|
1584
1758
|
# Set the scaling factor (zoom) for the main page area.
|
1585
1759
|
#
|
1586
|
-
# * +
|
1760
|
+
# * +factor+ - The percentage value. The value must be in the range 10-500.
|
1587
1761
|
# * *Returns* - The converter object.
|
1588
|
-
def setScaleFactor(
|
1589
|
-
if (!(Integer(
|
1590
|
-
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);
|
1591
1765
|
end
|
1592
1766
|
|
1593
|
-
@fields['scale_factor'] =
|
1767
|
+
@fields['scale_factor'] = factor
|
1594
1768
|
self
|
1595
1769
|
end
|
1596
1770
|
|
1597
1771
|
# Set the scaling factor (zoom) for the header and footer.
|
1598
1772
|
#
|
1599
|
-
# * +
|
1773
|
+
# * +factor+ - The percentage value. The value must be in the range 10-500.
|
1600
1774
|
# * *Returns* - The converter object.
|
1601
|
-
def setHeaderFooterScaleFactor(
|
1602
|
-
if (!(Integer(
|
1603
|
-
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);
|
1604
1778
|
end
|
1605
1779
|
|
1606
|
-
@fields['header_footer_scale_factor'] =
|
1607
|
-
self
|
1608
|
-
end
|
1609
|
-
|
1610
|
-
# Disable the intelligent shrinking strategy that tries to optimally fit the HTML contents to a PDF page.
|
1611
|
-
#
|
1612
|
-
# * +disable_smart_shrinking+ - Set to true to disable the intelligent shrinking strategy.
|
1613
|
-
# * *Returns* - The converter object.
|
1614
|
-
def setDisableSmartShrinking(disable_smart_shrinking)
|
1615
|
-
@fields['disable_smart_shrinking'] = disable_smart_shrinking
|
1780
|
+
@fields['header_footer_scale_factor'] = factor
|
1616
1781
|
self
|
1617
1782
|
end
|
1618
1783
|
|
1619
1784
|
# Set the quality of embedded JPEG images. A lower quality results in a smaller PDF file but can lead to compression artifacts.
|
1620
1785
|
#
|
1621
|
-
# * +
|
1786
|
+
# * +quality+ - The percentage value. The value must be in the range 1-100.
|
1622
1787
|
# * *Returns* - The converter object.
|
1623
|
-
def setJpegQuality(
|
1624
|
-
if (!(Integer(
|
1625
|
-
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);
|
1626
1791
|
end
|
1627
1792
|
|
1628
|
-
@fields['jpeg_quality'] =
|
1793
|
+
@fields['jpeg_quality'] = quality
|
1629
1794
|
self
|
1630
1795
|
end
|
1631
1796
|
|
1632
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.
|
1633
1798
|
#
|
1634
|
-
# * +
|
1799
|
+
# * +images+ - The image category. Allowed values are none, opaque, all.
|
1635
1800
|
# * *Returns* - The converter object.
|
1636
|
-
def setConvertImagesToJpeg(
|
1637
|
-
unless /(?i)^(none|opaque|all)$/.match(
|
1638
|
-
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);
|
1639
1804
|
end
|
1640
1805
|
|
1641
|
-
@fields['convert_images_to_jpeg'] =
|
1806
|
+
@fields['convert_images_to_jpeg'] = images
|
1642
1807
|
self
|
1643
1808
|
end
|
1644
1809
|
|
1645
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.
|
1646
1811
|
#
|
1647
|
-
# * +
|
1812
|
+
# * +dpi+ - The DPI value. Must be a positive integer number or 0.
|
1648
1813
|
# * *Returns* - The converter object.
|
1649
|
-
def setImageDpi(
|
1650
|
-
if (!(Integer(
|
1651
|
-
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);
|
1652
1817
|
end
|
1653
1818
|
|
1654
|
-
@fields['image_dpi'] =
|
1819
|
+
@fields['image_dpi'] = dpi
|
1655
1820
|
self
|
1656
1821
|
end
|
1657
1822
|
|
1658
1823
|
# Create linearized PDF. This is also known as Fast Web View.
|
1659
1824
|
#
|
1660
|
-
# * +
|
1825
|
+
# * +value+ - Set to true to create linearized PDF.
|
1661
1826
|
# * *Returns* - The converter object.
|
1662
|
-
def setLinearize(
|
1663
|
-
@fields['linearize'] =
|
1827
|
+
def setLinearize(value)
|
1828
|
+
@fields['linearize'] = value
|
1664
1829
|
self
|
1665
1830
|
end
|
1666
1831
|
|
1667
1832
|
# Encrypt the PDF. This prevents search engines from indexing the contents.
|
1668
1833
|
#
|
1669
|
-
# * +
|
1834
|
+
# * +value+ - Set to true to enable PDF encryption.
|
1670
1835
|
# * *Returns* - The converter object.
|
1671
|
-
def setEncrypt(
|
1672
|
-
@fields['encrypt'] =
|
1836
|
+
def setEncrypt(value)
|
1837
|
+
@fields['encrypt'] = value
|
1673
1838
|
self
|
1674
1839
|
end
|
1675
1840
|
|
1676
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.
|
1677
1842
|
#
|
1678
|
-
# * +
|
1843
|
+
# * +password+ - The user password.
|
1679
1844
|
# * *Returns* - The converter object.
|
1680
|
-
def setUserPassword(
|
1681
|
-
@fields['user_password'] =
|
1845
|
+
def setUserPassword(password)
|
1846
|
+
@fields['user_password'] = password
|
1682
1847
|
self
|
1683
1848
|
end
|
1684
1849
|
|
1685
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.
|
1686
1851
|
#
|
1687
|
-
# * +
|
1852
|
+
# * +password+ - The owner password.
|
1688
1853
|
# * *Returns* - The converter object.
|
1689
|
-
def setOwnerPassword(
|
1690
|
-
@fields['owner_password'] =
|
1854
|
+
def setOwnerPassword(password)
|
1855
|
+
@fields['owner_password'] = password
|
1691
1856
|
self
|
1692
1857
|
end
|
1693
1858
|
|
1694
1859
|
# Disallow printing of the output PDF.
|
1695
1860
|
#
|
1696
|
-
# * +
|
1861
|
+
# * +value+ - Set to true to set the no-print flag in the output PDF.
|
1697
1862
|
# * *Returns* - The converter object.
|
1698
|
-
def setNoPrint(
|
1699
|
-
@fields['no_print'] =
|
1863
|
+
def setNoPrint(value)
|
1864
|
+
@fields['no_print'] = value
|
1700
1865
|
self
|
1701
1866
|
end
|
1702
1867
|
|
1703
|
-
# Disallow modification of the
|
1868
|
+
# Disallow modification of the output PDF.
|
1704
1869
|
#
|
1705
|
-
# * +
|
1870
|
+
# * +value+ - Set to true to set the read-only only flag in the output PDF.
|
1706
1871
|
# * *Returns* - The converter object.
|
1707
|
-
def setNoModify(
|
1708
|
-
@fields['no_modify'] =
|
1872
|
+
def setNoModify(value)
|
1873
|
+
@fields['no_modify'] = value
|
1709
1874
|
self
|
1710
1875
|
end
|
1711
1876
|
|
1712
1877
|
# Disallow text and graphics extraction from the output PDF.
|
1713
1878
|
#
|
1714
|
-
# * +
|
1879
|
+
# * +value+ - Set to true to set the no-copy flag in the output PDF.
|
1715
1880
|
# * *Returns* - The converter object.
|
1716
|
-
def setNoCopy(
|
1717
|
-
@fields['no_copy'] =
|
1881
|
+
def setNoCopy(value)
|
1882
|
+
@fields['no_copy'] = value
|
1718
1883
|
self
|
1719
1884
|
end
|
1720
1885
|
|
@@ -1756,138 +1921,138 @@ module Pdfcrowd
|
|
1756
1921
|
|
1757
1922
|
# Specify the page layout to be used when the document is opened.
|
1758
1923
|
#
|
1759
|
-
# * +
|
1924
|
+
# * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
|
1760
1925
|
# * *Returns* - The converter object.
|
1761
|
-
def setPageLayout(
|
1762
|
-
unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(
|
1763
|
-
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);
|
1764
1929
|
end
|
1765
1930
|
|
1766
|
-
@fields['page_layout'] =
|
1931
|
+
@fields['page_layout'] = layout
|
1767
1932
|
self
|
1768
1933
|
end
|
1769
1934
|
|
1770
1935
|
# Specify how the document should be displayed when opened.
|
1771
1936
|
#
|
1772
|
-
# * +
|
1937
|
+
# * +mode+ - Allowed values are full-screen, thumbnails, outlines.
|
1773
1938
|
# * *Returns* - The converter object.
|
1774
|
-
def setPageMode(
|
1775
|
-
unless /(?i)^(full-screen|thumbnails|outlines)$/.match(
|
1776
|
-
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);
|
1777
1942
|
end
|
1778
1943
|
|
1779
|
-
@fields['page_mode'] =
|
1944
|
+
@fields['page_mode'] = mode
|
1780
1945
|
self
|
1781
1946
|
end
|
1782
1947
|
|
1783
1948
|
# Specify how the page should be displayed when opened.
|
1784
1949
|
#
|
1785
|
-
# * +
|
1950
|
+
# * +zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
|
1786
1951
|
# * *Returns* - The converter object.
|
1787
|
-
def setInitialZoomType(
|
1788
|
-
unless /(?i)^(fit-width|fit-height|fit-page)$/.match(
|
1789
|
-
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);
|
1790
1955
|
end
|
1791
1956
|
|
1792
|
-
@fields['initial_zoom_type'] =
|
1957
|
+
@fields['initial_zoom_type'] = zoom_type
|
1793
1958
|
self
|
1794
1959
|
end
|
1795
1960
|
|
1796
1961
|
# Display the specified page when the document is opened.
|
1797
1962
|
#
|
1798
|
-
# * +
|
1963
|
+
# * +page+ - Must be a positive integer number.
|
1799
1964
|
# * *Returns* - The converter object.
|
1800
|
-
def setInitialPage(
|
1801
|
-
if (!(Integer(
|
1802
|
-
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);
|
1803
1968
|
end
|
1804
1969
|
|
1805
|
-
@fields['initial_page'] =
|
1970
|
+
@fields['initial_page'] = page
|
1806
1971
|
self
|
1807
1972
|
end
|
1808
1973
|
|
1809
1974
|
# Specify the initial page zoom in percents when the document is opened.
|
1810
1975
|
#
|
1811
|
-
# * +
|
1976
|
+
# * +zoom+ - Must be a positive integer number.
|
1812
1977
|
# * *Returns* - The converter object.
|
1813
|
-
def setInitialZoom(
|
1814
|
-
if (!(Integer(
|
1815
|
-
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);
|
1816
1981
|
end
|
1817
1982
|
|
1818
|
-
@fields['initial_zoom'] =
|
1983
|
+
@fields['initial_zoom'] = zoom
|
1819
1984
|
self
|
1820
1985
|
end
|
1821
1986
|
|
1822
1987
|
# Specify whether to hide the viewer application's tool bars when the document is active.
|
1823
1988
|
#
|
1824
|
-
# * +
|
1989
|
+
# * +value+ - Set to true to hide tool bars.
|
1825
1990
|
# * *Returns* - The converter object.
|
1826
|
-
def setHideToolbar(
|
1827
|
-
@fields['hide_toolbar'] =
|
1991
|
+
def setHideToolbar(value)
|
1992
|
+
@fields['hide_toolbar'] = value
|
1828
1993
|
self
|
1829
1994
|
end
|
1830
1995
|
|
1831
1996
|
# Specify whether to hide the viewer application's menu bar when the document is active.
|
1832
1997
|
#
|
1833
|
-
# * +
|
1998
|
+
# * +value+ - Set to true to hide the menu bar.
|
1834
1999
|
# * *Returns* - The converter object.
|
1835
|
-
def setHideMenubar(
|
1836
|
-
@fields['hide_menubar'] =
|
2000
|
+
def setHideMenubar(value)
|
2001
|
+
@fields['hide_menubar'] = value
|
1837
2002
|
self
|
1838
2003
|
end
|
1839
2004
|
|
1840
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.
|
1841
2006
|
#
|
1842
|
-
# * +
|
2007
|
+
# * +value+ - Set to true to hide ui elements.
|
1843
2008
|
# * *Returns* - The converter object.
|
1844
|
-
def setHideWindowUi(
|
1845
|
-
@fields['hide_window_ui'] =
|
2009
|
+
def setHideWindowUi(value)
|
2010
|
+
@fields['hide_window_ui'] = value
|
1846
2011
|
self
|
1847
2012
|
end
|
1848
2013
|
|
1849
2014
|
# Specify whether to resize the document's window to fit the size of the first displayed page.
|
1850
2015
|
#
|
1851
|
-
# * +
|
2016
|
+
# * +value+ - Set to true to resize the window.
|
1852
2017
|
# * *Returns* - The converter object.
|
1853
|
-
def setFitWindow(
|
1854
|
-
@fields['fit_window'] =
|
2018
|
+
def setFitWindow(value)
|
2019
|
+
@fields['fit_window'] = value
|
1855
2020
|
self
|
1856
2021
|
end
|
1857
2022
|
|
1858
2023
|
# Specify whether to position the document's window in the center of the screen.
|
1859
2024
|
#
|
1860
|
-
# * +
|
2025
|
+
# * +value+ - Set to true to center the window.
|
1861
2026
|
# * *Returns* - The converter object.
|
1862
|
-
def setCenterWindow(
|
1863
|
-
@fields['center_window'] =
|
2027
|
+
def setCenterWindow(value)
|
2028
|
+
@fields['center_window'] = value
|
1864
2029
|
self
|
1865
2030
|
end
|
1866
2031
|
|
1867
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.
|
1868
2033
|
#
|
1869
|
-
# * +
|
2034
|
+
# * +value+ - Set to true to display the title.
|
1870
2035
|
# * *Returns* - The converter object.
|
1871
|
-
def setDisplayTitle(
|
1872
|
-
@fields['display_title'] =
|
2036
|
+
def setDisplayTitle(value)
|
2037
|
+
@fields['display_title'] = value
|
1873
2038
|
self
|
1874
2039
|
end
|
1875
2040
|
|
1876
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
|
1877
2042
|
#
|
1878
|
-
# * +
|
2043
|
+
# * +value+ - Set to true to set right-to-left reading order.
|
1879
2044
|
# * *Returns* - The converter object.
|
1880
|
-
def setRightToLeft(
|
1881
|
-
@fields['right_to_left'] =
|
2045
|
+
def setRightToLeft(value)
|
2046
|
+
@fields['right_to_left'] = value
|
1882
2047
|
self
|
1883
2048
|
end
|
1884
2049
|
|
1885
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.
|
1886
2051
|
#
|
1887
|
-
# * +
|
2052
|
+
# * +value+ - Set to true to enable the debug logging.
|
1888
2053
|
# * *Returns* - The converter object.
|
1889
|
-
def setDebugLog(
|
1890
|
-
@fields['debug_log'] =
|
2054
|
+
def setDebugLog(value)
|
2055
|
+
@fields['debug_log'] = value
|
1891
2056
|
self
|
1892
2057
|
end
|
1893
2058
|
|
@@ -1930,6 +2095,12 @@ module Pdfcrowd
|
|
1930
2095
|
return @helper.getOutputSize()
|
1931
2096
|
end
|
1932
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
|
+
|
1933
2104
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
1934
2105
|
#
|
1935
2106
|
# * +tag+ - A string with the custom tag.
|
@@ -1941,67 +2112,149 @@ module Pdfcrowd
|
|
1941
2112
|
|
1942
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.
|
1943
2114
|
#
|
1944
|
-
# * +
|
2115
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
1945
2116
|
# * *Returns* - The converter object.
|
1946
|
-
def setHttpProxy(
|
1947
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
1948
|
-
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);
|
1949
2120
|
end
|
1950
2121
|
|
1951
|
-
@fields['http_proxy'] =
|
2122
|
+
@fields['http_proxy'] = proxy
|
1952
2123
|
self
|
1953
2124
|
end
|
1954
2125
|
|
1955
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.
|
1956
2127
|
#
|
1957
|
-
# * +
|
2128
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
1958
2129
|
# * *Returns* - The converter object.
|
1959
|
-
def setHttpsProxy(
|
1960
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
1961
|
-
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);
|
1962
2133
|
end
|
1963
2134
|
|
1964
|
-
@fields['https_proxy'] =
|
2135
|
+
@fields['https_proxy'] = proxy
|
1965
2136
|
self
|
1966
2137
|
end
|
1967
2138
|
|
1968
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.
|
1969
2140
|
#
|
1970
|
-
# * +
|
2141
|
+
# * +certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
|
2142
|
+
# * *Returns* - The converter object.
|
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);
|
2146
|
+
end
|
2147
|
+
|
2148
|
+
@files['client_certificate'] = certificate
|
2149
|
+
self
|
2150
|
+
end
|
2151
|
+
|
2152
|
+
# A password for PKCS12 file with a client certificate if it is needed.
|
2153
|
+
#
|
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.
|
1971
2164
|
# * *Returns* - The converter object.
|
1972
|
-
def
|
1973
|
-
if (!(
|
1974
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
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);
|
1975
2168
|
end
|
1976
2169
|
|
1977
|
-
@
|
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.
|
2204
|
+
# * *Returns* - The converter object.
|
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
|
1978
2217
|
self
|
1979
2218
|
end
|
1980
2219
|
|
1981
|
-
#
|
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
|
1982
2221
|
#
|
1983
|
-
# * +
|
2222
|
+
# * +value+ - Set to true to add the special CSS classes.
|
1984
2223
|
# * *Returns* - The converter object.
|
1985
|
-
def
|
1986
|
-
@fields['
|
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)
|
1987
2239
|
self
|
1988
2240
|
end
|
1989
2241
|
|
1990
2242
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
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.
|
1991
2244
|
#
|
1992
|
-
# * +
|
2245
|
+
# * +value+ - Set to true to use HTTP.
|
1993
2246
|
# * *Returns* - The converter object.
|
1994
|
-
def setUseHttp(
|
1995
|
-
@helper.setUseHttp(
|
2247
|
+
def setUseHttp(value)
|
2248
|
+
@helper.setUseHttp(value)
|
1996
2249
|
self
|
1997
2250
|
end
|
1998
2251
|
|
1999
|
-
# 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.
|
2000
2253
|
#
|
2001
|
-
# * +
|
2254
|
+
# * +agent+ - The user agent string.
|
2002
2255
|
# * *Returns* - The converter object.
|
2003
|
-
def setUserAgent(
|
2004
|
-
@helper.setUserAgent(
|
2256
|
+
def setUserAgent(agent)
|
2257
|
+
@helper.setUserAgent(agent)
|
2005
2258
|
self
|
2006
2259
|
end
|
2007
2260
|
|
@@ -2019,10 +2272,10 @@ module Pdfcrowd
|
|
2019
2272
|
|
2020
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.
|
2021
2274
|
#
|
2022
|
-
# * +
|
2275
|
+
# * +count+ - Number of retries wanted.
|
2023
2276
|
# * *Returns* - The converter object.
|
2024
|
-
def setRetryCount(
|
2025
|
-
@helper.setRetryCount(
|
2277
|
+
def setRetryCount(count)
|
2278
|
+
@helper.setRetryCount(count)
|
2026
2279
|
self
|
2027
2280
|
end
|
2028
2281
|
|
@@ -2051,7 +2304,7 @@ module Pdfcrowd
|
|
2051
2304
|
# * *Returns* - The converter object.
|
2052
2305
|
def setOutputFormat(output_format)
|
2053
2306
|
unless /(?i)^(png|jpg|gif|tiff|bmp|ico|ppm|pgm|pbm|pnm|psb|pct|ras|tga|sgi|sun|webp)$/.match(output_format)
|
2054
|
-
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);
|
2055
2308
|
end
|
2056
2309
|
|
2057
2310
|
@fields['output_format'] = output_format
|
@@ -2064,7 +2317,7 @@ module Pdfcrowd
|
|
2064
2317
|
# * *Returns* - Byte array containing the conversion output.
|
2065
2318
|
def convertUrl(url)
|
2066
2319
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
2067
|
-
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);
|
2068
2321
|
end
|
2069
2322
|
|
2070
2323
|
@fields['url'] = url
|
@@ -2077,7 +2330,7 @@ module Pdfcrowd
|
|
2077
2330
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2078
2331
|
def convertUrlToStream(url, out_stream)
|
2079
2332
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
2080
|
-
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);
|
2081
2334
|
end
|
2082
2335
|
|
2083
2336
|
@fields['url'] = url
|
@@ -2090,7 +2343,7 @@ module Pdfcrowd
|
|
2090
2343
|
# * +file_path+ - The output file path. The string must not be empty.
|
2091
2344
|
def convertUrlToFile(url, file_path)
|
2092
2345
|
if (!(!file_path.nil? && !file_path.empty?))
|
2093
|
-
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);
|
2094
2347
|
end
|
2095
2348
|
|
2096
2349
|
output_file = open(file_path, "wb")
|
@@ -2110,11 +2363,7 @@ module Pdfcrowd
|
|
2110
2363
|
# * *Returns* - Byte array containing the conversion output.
|
2111
2364
|
def convertFile(file)
|
2112
2365
|
if (!(File.file?(file) && !File.zero?(file)))
|
2113
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "
|
2114
|
-
end
|
2115
|
-
|
2116
|
-
if (!(File.file?(file) && !File.zero?(file)))
|
2117
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-image", "The file name must have a valid extension.", "convert_file"), 470);
|
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);
|
2118
2367
|
end
|
2119
2368
|
|
2120
2369
|
@files['file'] = file
|
@@ -2127,11 +2376,7 @@ module Pdfcrowd
|
|
2127
2376
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2128
2377
|
def convertFileToStream(file, out_stream)
|
2129
2378
|
if (!(File.file?(file) && !File.zero?(file)))
|
2130
|
-
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);
|
2131
|
-
end
|
2132
|
-
|
2133
|
-
if (!(File.file?(file) && !File.zero?(file)))
|
2134
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-image", "The file name must have a valid extension.", "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);
|
2135
2380
|
end
|
2136
2381
|
|
2137
2382
|
@files['file'] = file
|
@@ -2144,7 +2389,7 @@ module Pdfcrowd
|
|
2144
2389
|
# * +file_path+ - The output file path. The string must not be empty.
|
2145
2390
|
def convertFileToFile(file, file_path)
|
2146
2391
|
if (!(!file_path.nil? && !file_path.empty?))
|
2147
|
-
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);
|
2148
2393
|
end
|
2149
2394
|
|
2150
2395
|
output_file = open(file_path, "wb")
|
@@ -2164,7 +2409,7 @@ module Pdfcrowd
|
|
2164
2409
|
# * *Returns* - Byte array containing the conversion output.
|
2165
2410
|
def convertString(text)
|
2166
2411
|
if (!(!text.nil? && !text.empty?))
|
2167
|
-
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);
|
2168
2413
|
end
|
2169
2414
|
|
2170
2415
|
@fields['text'] = text
|
@@ -2177,7 +2422,7 @@ module Pdfcrowd
|
|
2177
2422
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2178
2423
|
def convertStringToStream(text, out_stream)
|
2179
2424
|
if (!(!text.nil? && !text.empty?))
|
2180
|
-
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);
|
2181
2426
|
end
|
2182
2427
|
|
2183
2428
|
@fields['text'] = text
|
@@ -2190,7 +2435,7 @@ module Pdfcrowd
|
|
2190
2435
|
# * +file_path+ - The output file path. The string must not be empty.
|
2191
2436
|
def convertStringToFile(text, file_path)
|
2192
2437
|
if (!(!file_path.nil? && !file_path.empty?))
|
2193
|
-
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);
|
2194
2439
|
end
|
2195
2440
|
|
2196
2441
|
output_file = open(file_path, "wb")
|
@@ -2204,57 +2449,164 @@ module Pdfcrowd
|
|
2204
2449
|
end
|
2205
2450
|
end
|
2206
2451
|
|
2207
|
-
#
|
2452
|
+
# Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
|
2208
2453
|
#
|
2209
|
-
# * +
|
2454
|
+
# * +data_string+ - The input data string.
|
2210
2455
|
# * *Returns* - The converter object.
|
2211
|
-
def
|
2212
|
-
@fields['
|
2456
|
+
def setDataString(data_string)
|
2457
|
+
@fields['data_string'] = data_string
|
2213
2458
|
self
|
2214
2459
|
end
|
2215
2460
|
|
2216
|
-
#
|
2461
|
+
# Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
|
2217
2462
|
#
|
2218
|
-
# * +
|
2463
|
+
# * +data_file+ - The file path to a local file containing the input data.
|
2219
2464
|
# * *Returns* - The converter object.
|
2220
|
-
def
|
2221
|
-
@
|
2465
|
+
def setDataFile(data_file)
|
2466
|
+
@files['data_file'] = data_file
|
2222
2467
|
self
|
2223
2468
|
end
|
2224
2469
|
|
2225
|
-
#
|
2470
|
+
# Specify the input data format.
|
2226
2471
|
#
|
2227
|
-
# * +
|
2472
|
+
# * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
|
2228
2473
|
# * *Returns* - The converter object.
|
2229
|
-
def
|
2230
|
-
|
2474
|
+
def setDataFormat(data_format)
|
2475
|
+
unless /(?i)^(auto|json|xml|yaml|csv)$/.match(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);
|
2477
|
+
end
|
2478
|
+
|
2479
|
+
@fields['data_format'] = data_format
|
2231
2480
|
self
|
2232
2481
|
end
|
2233
2482
|
|
2234
|
-
#
|
2483
|
+
# Set the encoding of the data file set by setDataFile.
|
2235
2484
|
#
|
2236
|
-
# * +
|
2485
|
+
# * +encoding+ - The data file encoding.
|
2237
2486
|
# * *Returns* - The converter object.
|
2238
|
-
def
|
2239
|
-
@fields['
|
2487
|
+
def setDataEncoding(encoding)
|
2488
|
+
@fields['data_encoding'] = encoding
|
2240
2489
|
self
|
2241
2490
|
end
|
2242
2491
|
|
2243
|
-
#
|
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.
|
2244
2493
|
#
|
2245
|
-
# * +
|
2494
|
+
# * +value+ - Set to true to ignore undefined variables.
|
2246
2495
|
# * *Returns* - The converter object.
|
2247
|
-
def
|
2248
|
-
@fields['
|
2496
|
+
def setDataIgnoreUndefined(value)
|
2497
|
+
@fields['data_ignore_undefined'] = value
|
2249
2498
|
self
|
2250
2499
|
end
|
2251
2500
|
|
2252
|
-
#
|
2501
|
+
# Auto escape HTML symbols in the input data before placing them into the output.
|
2253
2502
|
#
|
2254
|
-
# * +
|
2503
|
+
# * +value+ - Set to true to turn auto escaping on.
|
2255
2504
|
# * *Returns* - The converter object.
|
2256
|
-
def
|
2257
|
-
@fields['
|
2505
|
+
def setDataAutoEscape(value)
|
2506
|
+
@fields['data_auto_escape'] = value
|
2507
|
+
self
|
2508
|
+
end
|
2509
|
+
|
2510
|
+
# Auto trim whitespace around each template command block.
|
2511
|
+
#
|
2512
|
+
# * +value+ - Set to true to turn auto trimming on.
|
2513
|
+
# * *Returns* - The converter object.
|
2514
|
+
def setDataTrimBlocks(value)
|
2515
|
+
@fields['data_trim_blocks'] = value
|
2516
|
+
self
|
2517
|
+
end
|
2518
|
+
|
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.
|
2520
|
+
#
|
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.
|
2531
|
+
# * *Returns* - The converter object.
|
2532
|
+
def setUsePrintMedia(value)
|
2533
|
+
@fields['use_print_media'] = value
|
2534
|
+
self
|
2535
|
+
end
|
2536
|
+
|
2537
|
+
# Do not print the background graphics.
|
2538
|
+
#
|
2539
|
+
# * +value+ - Set to true to disable the background graphics.
|
2540
|
+
# * *Returns* - The converter object.
|
2541
|
+
def setNoBackground(value)
|
2542
|
+
@fields['no_background'] = value
|
2543
|
+
self
|
2544
|
+
end
|
2545
|
+
|
2546
|
+
# Do not execute JavaScript.
|
2547
|
+
#
|
2548
|
+
# * +value+ - Set to true to disable JavaScript in web pages.
|
2549
|
+
# * *Returns* - The converter object.
|
2550
|
+
def setDisableJavascript(value)
|
2551
|
+
@fields['disable_javascript'] = value
|
2552
|
+
self
|
2553
|
+
end
|
2554
|
+
|
2555
|
+
# Do not load images.
|
2556
|
+
#
|
2557
|
+
# * +value+ - Set to true to disable loading of images.
|
2558
|
+
# * *Returns* - The converter object.
|
2559
|
+
def setDisableImageLoading(value)
|
2560
|
+
@fields['disable_image_loading'] = value
|
2561
|
+
self
|
2562
|
+
end
|
2563
|
+
|
2564
|
+
# Disable loading fonts from remote sources.
|
2565
|
+
#
|
2566
|
+
# * +value+ - Set to true disable loading remote fonts.
|
2567
|
+
# * *Returns* - The converter object.
|
2568
|
+
def setDisableRemoteFonts(value)
|
2569
|
+
@fields['disable_remote_fonts'] = value
|
2570
|
+
self
|
2571
|
+
end
|
2572
|
+
|
2573
|
+
# Specifies how iframes are handled.
|
2574
|
+
#
|
2575
|
+
# * +iframes+ - Allowed values are all, same-origin, none.
|
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
|
2583
|
+
self
|
2584
|
+
end
|
2585
|
+
|
2586
|
+
# Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
|
2587
|
+
#
|
2588
|
+
# * +value+ - Set to true to block ads in web pages.
|
2589
|
+
# * *Returns* - The converter object.
|
2590
|
+
def setBlockAds(value)
|
2591
|
+
@fields['block_ads'] = value
|
2592
|
+
self
|
2593
|
+
end
|
2594
|
+
|
2595
|
+
# Set the default HTML content text encoding.
|
2596
|
+
#
|
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.
|
2607
|
+
# * *Returns* - The converter object.
|
2608
|
+
def setLocale(locale)
|
2609
|
+
@fields['locale'] = locale
|
2258
2610
|
self
|
2259
2611
|
end
|
2260
2612
|
|
@@ -2287,24 +2639,6 @@ module Pdfcrowd
|
|
2287
2639
|
self
|
2288
2640
|
end
|
2289
2641
|
|
2290
|
-
# Use the print version of the page if available (@media print).
|
2291
|
-
#
|
2292
|
-
# * +use_print_media+ - Set to true to use the print version of the page.
|
2293
|
-
# * *Returns* - The converter object.
|
2294
|
-
def setUsePrintMedia(use_print_media)
|
2295
|
-
@fields['use_print_media'] = use_print_media
|
2296
|
-
self
|
2297
|
-
end
|
2298
|
-
|
2299
|
-
# Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
|
2300
|
-
#
|
2301
|
-
# * +no_xpdfcrowd_header+ - Set to true to disable sending X-Pdfcrowd HTTP header.
|
2302
|
-
# * *Returns* - The converter object.
|
2303
|
-
def setNoXpdfcrowdHeader(no_xpdfcrowd_header)
|
2304
|
-
@fields['no_xpdfcrowd_header'] = no_xpdfcrowd_header
|
2305
|
-
self
|
2306
|
-
end
|
2307
|
-
|
2308
2642
|
# Set cookies that are sent in Pdfcrowd HTTP requests.
|
2309
2643
|
#
|
2310
2644
|
# * +cookies+ - The cookie string.
|
@@ -2316,10 +2650,10 @@ module Pdfcrowd
|
|
2316
2650
|
|
2317
2651
|
# Do not allow insecure HTTPS connections.
|
2318
2652
|
#
|
2319
|
-
# * +
|
2653
|
+
# * +value+ - Set to true to enable SSL certificate verification.
|
2320
2654
|
# * *Returns* - The converter object.
|
2321
|
-
def setVerifySslCertificates(
|
2322
|
-
@fields['verify_ssl_certificates'] =
|
2655
|
+
def setVerifySslCertificates(value)
|
2656
|
+
@fields['verify_ssl_certificates'] = value
|
2323
2657
|
self
|
2324
2658
|
end
|
2325
2659
|
|
@@ -2341,55 +2675,64 @@ module Pdfcrowd
|
|
2341
2675
|
self
|
2342
2676
|
end
|
2343
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
|
+
|
2344
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.
|
2345
2688
|
#
|
2346
|
-
# * +
|
2689
|
+
# * +javascript+ - A string containing a JavaScript code. The string must not be empty.
|
2347
2690
|
# * *Returns* - The converter object.
|
2348
|
-
def setCustomJavascript(
|
2349
|
-
if (!(!
|
2350
|
-
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);
|
2351
2694
|
end
|
2352
2695
|
|
2353
|
-
@fields['custom_javascript'] =
|
2696
|
+
@fields['custom_javascript'] = javascript
|
2354
2697
|
self
|
2355
2698
|
end
|
2356
2699
|
|
2357
|
-
# Run a custom JavaScript right after the document is loaded. The script is intended for early DOM manipulation. In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
|
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.
|
2358
2701
|
#
|
2359
|
-
# * +
|
2702
|
+
# * +javascript+ - A string containing a JavaScript code. The string must not be empty.
|
2360
2703
|
# * *Returns* - The converter object.
|
2361
|
-
def setOnLoadJavascript(
|
2362
|
-
if (!(!
|
2363
|
-
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);
|
2364
2707
|
end
|
2365
2708
|
|
2366
|
-
@fields['on_load_javascript'] =
|
2709
|
+
@fields['on_load_javascript'] = javascript
|
2367
2710
|
self
|
2368
2711
|
end
|
2369
2712
|
|
2370
2713
|
# Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
|
2371
2714
|
#
|
2372
|
-
# * +
|
2715
|
+
# * +header+ - A string containing the header name and value separated by a colon.
|
2373
2716
|
# * *Returns* - The converter object.
|
2374
|
-
def setCustomHttpHeader(
|
2375
|
-
unless /^.+:.+$/.match(
|
2376
|
-
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);
|
2377
2720
|
end
|
2378
2721
|
|
2379
|
-
@fields['custom_http_header'] =
|
2722
|
+
@fields['custom_http_header'] = header
|
2380
2723
|
self
|
2381
2724
|
end
|
2382
2725
|
|
2383
|
-
# Wait the specified number of milliseconds to finish all JavaScript after the document is loaded.
|
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.
|
2384
2727
|
#
|
2385
|
-
# * +
|
2728
|
+
# * +delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
|
2386
2729
|
# * *Returns* - The converter object.
|
2387
|
-
def setJavascriptDelay(
|
2388
|
-
if (!(Integer(
|
2389
|
-
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);
|
2390
2733
|
end
|
2391
2734
|
|
2392
|
-
@fields['javascript_delay'] =
|
2735
|
+
@fields['javascript_delay'] = delay
|
2393
2736
|
self
|
2394
2737
|
end
|
2395
2738
|
|
@@ -2399,7 +2742,7 @@ module Pdfcrowd
|
|
2399
2742
|
# * *Returns* - The converter object.
|
2400
2743
|
def setElementToConvert(selectors)
|
2401
2744
|
if (!(!selectors.nil? && !selectors.empty?))
|
2402
|
-
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);
|
2403
2746
|
end
|
2404
2747
|
|
2405
2748
|
@fields['element_to_convert'] = selectors
|
@@ -2412,7 +2755,7 @@ module Pdfcrowd
|
|
2412
2755
|
# * *Returns* - The converter object.
|
2413
2756
|
def setElementToConvertMode(mode)
|
2414
2757
|
unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode)
|
2415
|
-
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);
|
2416
2759
|
end
|
2417
2760
|
|
2418
2761
|
@fields['element_to_convert_mode'] = mode
|
@@ -2425,7 +2768,7 @@ module Pdfcrowd
|
|
2425
2768
|
# * *Returns* - The converter object.
|
2426
2769
|
def setWaitForElement(selectors)
|
2427
2770
|
if (!(!selectors.nil? && !selectors.empty?))
|
2428
|
-
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);
|
2429
2772
|
end
|
2430
2773
|
|
2431
2774
|
@fields['wait_for_element'] = selectors
|
@@ -2434,49 +2777,62 @@ module Pdfcrowd
|
|
2434
2777
|
|
2435
2778
|
# Set the output image width in pixels.
|
2436
2779
|
#
|
2437
|
-
# * +
|
2780
|
+
# * +width+ - The value must be in the range 96-65000.
|
2438
2781
|
# * *Returns* - The converter object.
|
2439
|
-
def setScreenshotWidth(
|
2440
|
-
if (!(Integer(
|
2441
|
-
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);
|
2442
2785
|
end
|
2443
2786
|
|
2444
|
-
@fields['screenshot_width'] =
|
2787
|
+
@fields['screenshot_width'] = width
|
2445
2788
|
self
|
2446
2789
|
end
|
2447
2790
|
|
2448
|
-
# Set the output image height in pixels. If it
|
2791
|
+
# Set the output image height in pixels. If it is not specified, actual document height is used.
|
2449
2792
|
#
|
2450
|
-
# * +
|
2793
|
+
# * +height+ - Must be a positive integer number.
|
2451
2794
|
# * *Returns* - The converter object.
|
2452
|
-
def setScreenshotHeight(
|
2453
|
-
if (!(Integer(
|
2454
|
-
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);
|
2455
2798
|
end
|
2456
2799
|
|
2457
|
-
@fields['screenshot_height'] =
|
2800
|
+
@fields['screenshot_height'] = height
|
2458
2801
|
self
|
2459
2802
|
end
|
2460
2803
|
|
2461
2804
|
# Set the scaling factor (zoom) for the output image.
|
2462
2805
|
#
|
2463
|
-
# * +
|
2806
|
+
# * +factor+ - The percentage value. Must be a positive integer number.
|
2464
2807
|
# * *Returns* - The converter object.
|
2465
|
-
def setScaleFactor(
|
2466
|
-
if (!(Integer(
|
2467
|
-
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);
|
2468
2811
|
end
|
2469
2812
|
|
2470
|
-
@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
|
2471
2827
|
self
|
2472
2828
|
end
|
2473
2829
|
|
2474
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.
|
2475
2831
|
#
|
2476
|
-
# * +
|
2832
|
+
# * +value+ - Set to true to enable the debug logging.
|
2477
2833
|
# * *Returns* - The converter object.
|
2478
|
-
def setDebugLog(
|
2479
|
-
@fields['debug_log'] =
|
2834
|
+
def setDebugLog(value)
|
2835
|
+
@fields['debug_log'] = value
|
2480
2836
|
self
|
2481
2837
|
end
|
2482
2838
|
|
@@ -2513,6 +2869,12 @@ module Pdfcrowd
|
|
2513
2869
|
return @helper.getOutputSize()
|
2514
2870
|
end
|
2515
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
|
+
|
2516
2878
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
2517
2879
|
#
|
2518
2880
|
# * +tag+ - A string with the custom tag.
|
@@ -2524,67 +2886,81 @@ module Pdfcrowd
|
|
2524
2886
|
|
2525
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.
|
2526
2888
|
#
|
2527
|
-
# * +
|
2889
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
2528
2890
|
# * *Returns* - The converter object.
|
2529
|
-
def setHttpProxy(
|
2530
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
2531
|
-
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);
|
2532
2894
|
end
|
2533
2895
|
|
2534
|
-
@fields['http_proxy'] =
|
2896
|
+
@fields['http_proxy'] = proxy
|
2535
2897
|
self
|
2536
2898
|
end
|
2537
2899
|
|
2538
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.
|
2539
2901
|
#
|
2540
|
-
# * +
|
2902
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
2541
2903
|
# * *Returns* - The converter object.
|
2542
|
-
def setHttpsProxy(
|
2543
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
2544
|
-
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);
|
2545
2907
|
end
|
2546
2908
|
|
2547
|
-
@fields['https_proxy'] =
|
2909
|
+
@fields['https_proxy'] = proxy
|
2548
2910
|
self
|
2549
2911
|
end
|
2550
2912
|
|
2551
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.
|
2552
2914
|
#
|
2553
|
-
# * +
|
2915
|
+
# * +certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
|
2554
2916
|
# * *Returns* - The converter object.
|
2555
|
-
def setClientCertificate(
|
2556
|
-
if (!(File.file?(
|
2557
|
-
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);
|
2558
2920
|
end
|
2559
2921
|
|
2560
|
-
@files['client_certificate'] =
|
2922
|
+
@files['client_certificate'] = certificate
|
2561
2923
|
self
|
2562
2924
|
end
|
2563
2925
|
|
2564
|
-
# A password for PKCS12 file with a client certificate if it
|
2926
|
+
# A password for PKCS12 file with a client certificate if it is needed.
|
2565
2927
|
#
|
2566
|
-
# * +
|
2928
|
+
# * +password+ -
|
2567
2929
|
# * *Returns* - The converter object.
|
2568
|
-
def setClientCertificatePassword(
|
2569
|
-
@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)
|
2570
2945
|
self
|
2571
2946
|
end
|
2572
2947
|
|
2573
2948
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
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.
|
2574
2950
|
#
|
2575
|
-
# * +
|
2951
|
+
# * +value+ - Set to true to use HTTP.
|
2576
2952
|
# * *Returns* - The converter object.
|
2577
|
-
def setUseHttp(
|
2578
|
-
@helper.setUseHttp(
|
2953
|
+
def setUseHttp(value)
|
2954
|
+
@helper.setUseHttp(value)
|
2579
2955
|
self
|
2580
2956
|
end
|
2581
2957
|
|
2582
|
-
# 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.
|
2583
2959
|
#
|
2584
|
-
# * +
|
2960
|
+
# * +agent+ - The user agent string.
|
2585
2961
|
# * *Returns* - The converter object.
|
2586
|
-
def setUserAgent(
|
2587
|
-
@helper.setUserAgent(
|
2962
|
+
def setUserAgent(agent)
|
2963
|
+
@helper.setUserAgent(agent)
|
2588
2964
|
self
|
2589
2965
|
end
|
2590
2966
|
|
@@ -2602,10 +2978,10 @@ module Pdfcrowd
|
|
2602
2978
|
|
2603
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.
|
2604
2980
|
#
|
2605
|
-
# * +
|
2981
|
+
# * +count+ - Number of retries wanted.
|
2606
2982
|
# * *Returns* - The converter object.
|
2607
|
-
def setRetryCount(
|
2608
|
-
@helper.setRetryCount(
|
2983
|
+
def setRetryCount(count)
|
2984
|
+
@helper.setRetryCount(count)
|
2609
2985
|
self
|
2610
2986
|
end
|
2611
2987
|
|
@@ -2634,7 +3010,7 @@ module Pdfcrowd
|
|
2634
3010
|
# * *Returns* - Byte array containing the conversion output.
|
2635
3011
|
def convertUrl(url)
|
2636
3012
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
2637
|
-
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);
|
2638
3014
|
end
|
2639
3015
|
|
2640
3016
|
@fields['url'] = url
|
@@ -2647,7 +3023,7 @@ module Pdfcrowd
|
|
2647
3023
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2648
3024
|
def convertUrlToStream(url, out_stream)
|
2649
3025
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
2650
|
-
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);
|
2651
3027
|
end
|
2652
3028
|
|
2653
3029
|
@fields['url'] = url
|
@@ -2660,7 +3036,7 @@ module Pdfcrowd
|
|
2660
3036
|
# * +file_path+ - The output file path. The string must not be empty.
|
2661
3037
|
def convertUrlToFile(url, file_path)
|
2662
3038
|
if (!(!file_path.nil? && !file_path.empty?))
|
2663
|
-
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);
|
2664
3040
|
end
|
2665
3041
|
|
2666
3042
|
output_file = open(file_path, "wb")
|
@@ -2676,11 +3052,11 @@ module Pdfcrowd
|
|
2676
3052
|
|
2677
3053
|
# Convert a local file.
|
2678
3054
|
#
|
2679
|
-
# * +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.
|
2680
3056
|
# * *Returns* - Byte array containing the conversion output.
|
2681
3057
|
def convertFile(file)
|
2682
3058
|
if (!(File.file?(file) && !File.zero?(file)))
|
2683
|
-
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);
|
2684
3060
|
end
|
2685
3061
|
|
2686
3062
|
@files['file'] = file
|
@@ -2689,11 +3065,11 @@ module Pdfcrowd
|
|
2689
3065
|
|
2690
3066
|
# Convert a local file and write the result to an output stream.
|
2691
3067
|
#
|
2692
|
-
# * +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.
|
2693
3069
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2694
3070
|
def convertFileToStream(file, out_stream)
|
2695
3071
|
if (!(File.file?(file) && !File.zero?(file)))
|
2696
|
-
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);
|
2697
3073
|
end
|
2698
3074
|
|
2699
3075
|
@files['file'] = file
|
@@ -2702,11 +3078,11 @@ module Pdfcrowd
|
|
2702
3078
|
|
2703
3079
|
# Convert a local file and write the result to a local file.
|
2704
3080
|
#
|
2705
|
-
# * +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.
|
2706
3082
|
# * +file_path+ - The output file path. The string must not be empty.
|
2707
3083
|
def convertFileToFile(file, file_path)
|
2708
3084
|
if (!(!file_path.nil? && !file_path.empty?))
|
2709
|
-
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);
|
2710
3086
|
end
|
2711
3087
|
|
2712
3088
|
output_file = open(file_path, "wb")
|
@@ -2744,7 +3120,7 @@ module Pdfcrowd
|
|
2744
3120
|
# * +file_path+ - The output file path. The string must not be empty.
|
2745
3121
|
def convertRawDataToFile(data, file_path)
|
2746
3122
|
if (!(!file_path.nil? && !file_path.empty?))
|
2747
|
-
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);
|
2748
3124
|
end
|
2749
3125
|
|
2750
3126
|
output_file = open(file_path, "wb")
|
@@ -2764,7 +3140,7 @@ module Pdfcrowd
|
|
2764
3140
|
# * *Returns* - The converter object.
|
2765
3141
|
def setOutputFormat(output_format)
|
2766
3142
|
unless /(?i)^(png|jpg|gif|tiff|bmp|ico|ppm|pgm|pbm|pnm|psb|pct|ras|tga|sgi|sun|webp)$/.match(output_format)
|
2767
|
-
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);
|
2768
3144
|
end
|
2769
3145
|
|
2770
3146
|
@fields['output_format'] = output_format
|
@@ -2791,10 +3167,10 @@ module Pdfcrowd
|
|
2791
3167
|
|
2792
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.
|
2793
3169
|
#
|
2794
|
-
# * +
|
3170
|
+
# * +value+ - Set to true to enable the debug logging.
|
2795
3171
|
# * *Returns* - The converter object.
|
2796
|
-
def setDebugLog(
|
2797
|
-
@fields['debug_log'] =
|
3172
|
+
def setDebugLog(value)
|
3173
|
+
@fields['debug_log'] = value
|
2798
3174
|
self
|
2799
3175
|
end
|
2800
3176
|
|
@@ -2831,6 +3207,12 @@ module Pdfcrowd
|
|
2831
3207
|
return @helper.getOutputSize()
|
2832
3208
|
end
|
2833
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
|
+
|
2834
3216
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
2835
3217
|
#
|
2836
3218
|
# * +tag+ - A string with the custom tag.
|
@@ -2842,45 +3224,59 @@ module Pdfcrowd
|
|
2842
3224
|
|
2843
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.
|
2844
3226
|
#
|
2845
|
-
# * +
|
3227
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
2846
3228
|
# * *Returns* - The converter object.
|
2847
|
-
def setHttpProxy(
|
2848
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
2849
|
-
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);
|
2850
3232
|
end
|
2851
3233
|
|
2852
|
-
@fields['http_proxy'] =
|
3234
|
+
@fields['http_proxy'] = proxy
|
2853
3235
|
self
|
2854
3236
|
end
|
2855
3237
|
|
2856
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.
|
2857
3239
|
#
|
2858
|
-
# * +
|
3240
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
3241
|
+
# * *Returns* - The converter object.
|
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);
|
3245
|
+
end
|
3246
|
+
|
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.
|
2859
3254
|
# * *Returns* - The converter object.
|
2860
|
-
def
|
2861
|
-
unless /(?i)^(
|
2862
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
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);
|
2863
3258
|
end
|
2864
3259
|
|
2865
|
-
@
|
3260
|
+
@helper.setConverterVersion(version)
|
2866
3261
|
self
|
2867
3262
|
end
|
2868
3263
|
|
2869
3264
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
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.
|
2870
3266
|
#
|
2871
|
-
# * +
|
3267
|
+
# * +value+ - Set to true to use HTTP.
|
2872
3268
|
# * *Returns* - The converter object.
|
2873
|
-
def setUseHttp(
|
2874
|
-
@helper.setUseHttp(
|
3269
|
+
def setUseHttp(value)
|
3270
|
+
@helper.setUseHttp(value)
|
2875
3271
|
self
|
2876
3272
|
end
|
2877
3273
|
|
2878
|
-
# 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.
|
2879
3275
|
#
|
2880
|
-
# * +
|
3276
|
+
# * +agent+ - The user agent string.
|
2881
3277
|
# * *Returns* - The converter object.
|
2882
|
-
def setUserAgent(
|
2883
|
-
@helper.setUserAgent(
|
3278
|
+
def setUserAgent(agent)
|
3279
|
+
@helper.setUserAgent(agent)
|
2884
3280
|
self
|
2885
3281
|
end
|
2886
3282
|
|
@@ -2898,10 +3294,10 @@ module Pdfcrowd
|
|
2898
3294
|
|
2899
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.
|
2900
3296
|
#
|
2901
|
-
# * +
|
3297
|
+
# * +count+ - Number of retries wanted.
|
2902
3298
|
# * *Returns* - The converter object.
|
2903
|
-
def setRetryCount(
|
2904
|
-
@helper.setRetryCount(
|
3299
|
+
def setRetryCount(count)
|
3300
|
+
@helper.setRetryCount(count)
|
2905
3301
|
self
|
2906
3302
|
end
|
2907
3303
|
|
@@ -2930,7 +3326,7 @@ module Pdfcrowd
|
|
2930
3326
|
# * *Returns* - The converter object.
|
2931
3327
|
def setAction(action)
|
2932
3328
|
unless /(?i)^(join|shuffle)$/.match(action)
|
2933
|
-
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);
|
2934
3330
|
end
|
2935
3331
|
|
2936
3332
|
@fields['action'] = action
|
@@ -2955,7 +3351,7 @@ module Pdfcrowd
|
|
2955
3351
|
# * +file_path+ - The output file path. The string must not be empty.
|
2956
3352
|
def convertToFile(file_path)
|
2957
3353
|
if (!(!file_path.nil? && !file_path.empty?))
|
2958
|
-
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);
|
2959
3355
|
end
|
2960
3356
|
|
2961
3357
|
output_file = open(file_path, "wb")
|
@@ -2969,7 +3365,7 @@ module Pdfcrowd
|
|
2969
3365
|
# * *Returns* - The converter object.
|
2970
3366
|
def addPdfFile(file_path)
|
2971
3367
|
if (!(File.file?(file_path) && !File.zero?(file_path)))
|
2972
|
-
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);
|
2973
3369
|
end
|
2974
3370
|
|
2975
3371
|
@files['f_%s' % @file_id] = file_path
|
@@ -2979,24 +3375,319 @@ module Pdfcrowd
|
|
2979
3375
|
|
2980
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'));
|
2981
3377
|
#
|
2982
|
-
# * +
|
3378
|
+
# * +data+ - The raw PDF data. The input data must be PDF content.
|
2983
3379
|
# * *Returns* - The converter object.
|
2984
|
-
def addPdfRawData(
|
2985
|
-
if (!(!
|
2986
|
-
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);
|
2987
3383
|
end
|
2988
3384
|
|
2989
|
-
@raw_data['f_%s' % @file_id] =
|
3385
|
+
@raw_data['f_%s' % @file_id] = data
|
2990
3386
|
@file_id += 1
|
2991
3387
|
self
|
2992
3388
|
end
|
2993
3389
|
|
3390
|
+
# Apply the first page of the watermark PDF to every page of the output PDF.
|
3391
|
+
#
|
3392
|
+
# * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
|
3393
|
+
# * *Returns* - The converter object.
|
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);
|
3397
|
+
end
|
3398
|
+
|
3399
|
+
@files['page_watermark'] = watermark
|
3400
|
+
self
|
3401
|
+
end
|
3402
|
+
|
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.
|
3404
|
+
#
|
3405
|
+
# * +url+ - The supported protocols are http:// and https://.
|
3406
|
+
# * *Returns* - The converter object.
|
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);
|
3410
|
+
end
|
3411
|
+
|
3412
|
+
@fields['page_watermark_url'] = url
|
3413
|
+
self
|
3414
|
+
end
|
3415
|
+
|
3416
|
+
# Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
|
3417
|
+
#
|
3418
|
+
# * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
|
3419
|
+
# * *Returns* - The converter object.
|
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);
|
3423
|
+
end
|
3424
|
+
|
3425
|
+
@files['multipage_watermark'] = watermark
|
3426
|
+
self
|
3427
|
+
end
|
3428
|
+
|
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.
|
3430
|
+
#
|
3431
|
+
# * +url+ - The supported protocols are http:// and https://.
|
3432
|
+
# * *Returns* - The converter object.
|
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);
|
3436
|
+
end
|
3437
|
+
|
3438
|
+
@fields['multipage_watermark_url'] = url
|
3439
|
+
self
|
3440
|
+
end
|
3441
|
+
|
3442
|
+
# Apply the first page of the specified PDF to the background of every page of the output PDF.
|
3443
|
+
#
|
3444
|
+
# * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
|
3445
|
+
# * *Returns* - The converter object.
|
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);
|
3449
|
+
end
|
3450
|
+
|
3451
|
+
@files['page_background'] = background
|
3452
|
+
self
|
3453
|
+
end
|
3454
|
+
|
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.
|
3456
|
+
#
|
3457
|
+
# * +url+ - The supported protocols are http:// and https://.
|
3458
|
+
# * *Returns* - The converter object.
|
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);
|
3462
|
+
end
|
3463
|
+
|
3464
|
+
@fields['page_background_url'] = url
|
3465
|
+
self
|
3466
|
+
end
|
3467
|
+
|
3468
|
+
# Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
|
3469
|
+
#
|
3470
|
+
# * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
|
3471
|
+
# * *Returns* - The converter object.
|
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);
|
3475
|
+
end
|
3476
|
+
|
3477
|
+
@files['multipage_background'] = background
|
3478
|
+
self
|
3479
|
+
end
|
3480
|
+
|
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.
|
3482
|
+
#
|
3483
|
+
# * +url+ - The supported protocols are http:// and https://.
|
3484
|
+
# * *Returns* - The converter object.
|
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);
|
3488
|
+
end
|
3489
|
+
|
3490
|
+
@fields['multipage_background_url'] = url
|
3491
|
+
self
|
3492
|
+
end
|
3493
|
+
|
3494
|
+
# Create linearized PDF. This is also known as Fast Web View.
|
3495
|
+
#
|
3496
|
+
# * +value+ - Set to true to create linearized PDF.
|
3497
|
+
# * *Returns* - The converter object.
|
3498
|
+
def setLinearize(value)
|
3499
|
+
@fields['linearize'] = value
|
3500
|
+
self
|
3501
|
+
end
|
3502
|
+
|
3503
|
+
# Encrypt the PDF. This prevents search engines from indexing the contents.
|
3504
|
+
#
|
3505
|
+
# * +value+ - Set to true to enable PDF encryption.
|
3506
|
+
# * *Returns* - The converter object.
|
3507
|
+
def setEncrypt(value)
|
3508
|
+
@fields['encrypt'] = value
|
3509
|
+
self
|
3510
|
+
end
|
3511
|
+
|
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.
|
3513
|
+
#
|
3514
|
+
# * +password+ - The user password.
|
3515
|
+
# * *Returns* - The converter object.
|
3516
|
+
def setUserPassword(password)
|
3517
|
+
@fields['user_password'] = password
|
3518
|
+
self
|
3519
|
+
end
|
3520
|
+
|
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.
|
3522
|
+
#
|
3523
|
+
# * +password+ - The owner password.
|
3524
|
+
# * *Returns* - The converter object.
|
3525
|
+
def setOwnerPassword(password)
|
3526
|
+
@fields['owner_password'] = password
|
3527
|
+
self
|
3528
|
+
end
|
3529
|
+
|
3530
|
+
# Disallow printing of the output PDF.
|
3531
|
+
#
|
3532
|
+
# * +value+ - Set to true to set the no-print flag in the output PDF.
|
3533
|
+
# * *Returns* - The converter object.
|
3534
|
+
def setNoPrint(value)
|
3535
|
+
@fields['no_print'] = value
|
3536
|
+
self
|
3537
|
+
end
|
3538
|
+
|
3539
|
+
# Disallow modification of the output PDF.
|
3540
|
+
#
|
3541
|
+
# * +value+ - Set to true to set the read-only only flag in the output PDF.
|
3542
|
+
# * *Returns* - The converter object.
|
3543
|
+
def setNoModify(value)
|
3544
|
+
@fields['no_modify'] = value
|
3545
|
+
self
|
3546
|
+
end
|
3547
|
+
|
3548
|
+
# Disallow text and graphics extraction from the output PDF.
|
3549
|
+
#
|
3550
|
+
# * +value+ - Set to true to set the no-copy flag in the output PDF.
|
3551
|
+
# * *Returns* - The converter object.
|
3552
|
+
def setNoCopy(value)
|
3553
|
+
@fields['no_copy'] = value
|
3554
|
+
self
|
3555
|
+
end
|
3556
|
+
|
3557
|
+
# Specify the page layout to be used when the document is opened.
|
3558
|
+
#
|
3559
|
+
# * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
|
3560
|
+
# * *Returns* - The converter object.
|
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);
|
3564
|
+
end
|
3565
|
+
|
3566
|
+
@fields['page_layout'] = layout
|
3567
|
+
self
|
3568
|
+
end
|
3569
|
+
|
3570
|
+
# Specify how the document should be displayed when opened.
|
3571
|
+
#
|
3572
|
+
# * +mode+ - Allowed values are full-screen, thumbnails, outlines.
|
3573
|
+
# * *Returns* - The converter object.
|
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);
|
3577
|
+
end
|
3578
|
+
|
3579
|
+
@fields['page_mode'] = mode
|
3580
|
+
self
|
3581
|
+
end
|
3582
|
+
|
3583
|
+
# Specify how the page should be displayed when opened.
|
3584
|
+
#
|
3585
|
+
# * +zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
|
3586
|
+
# * *Returns* - The converter object.
|
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);
|
3590
|
+
end
|
3591
|
+
|
3592
|
+
@fields['initial_zoom_type'] = zoom_type
|
3593
|
+
self
|
3594
|
+
end
|
3595
|
+
|
3596
|
+
# Display the specified page when the document is opened.
|
3597
|
+
#
|
3598
|
+
# * +page+ - Must be a positive integer number.
|
3599
|
+
# * *Returns* - The converter object.
|
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);
|
3603
|
+
end
|
3604
|
+
|
3605
|
+
@fields['initial_page'] = page
|
3606
|
+
self
|
3607
|
+
end
|
3608
|
+
|
3609
|
+
# Specify the initial page zoom in percents when the document is opened.
|
3610
|
+
#
|
3611
|
+
# * +zoom+ - Must be a positive integer number.
|
3612
|
+
# * *Returns* - The converter object.
|
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);
|
3616
|
+
end
|
3617
|
+
|
3618
|
+
@fields['initial_zoom'] = zoom
|
3619
|
+
self
|
3620
|
+
end
|
3621
|
+
|
3622
|
+
# Specify whether to hide the viewer application's tool bars when the document is active.
|
3623
|
+
#
|
3624
|
+
# * +value+ - Set to true to hide tool bars.
|
3625
|
+
# * *Returns* - The converter object.
|
3626
|
+
def setHideToolbar(value)
|
3627
|
+
@fields['hide_toolbar'] = value
|
3628
|
+
self
|
3629
|
+
end
|
3630
|
+
|
3631
|
+
# Specify whether to hide the viewer application's menu bar when the document is active.
|
3632
|
+
#
|
3633
|
+
# * +value+ - Set to true to hide the menu bar.
|
3634
|
+
# * *Returns* - The converter object.
|
3635
|
+
def setHideMenubar(value)
|
3636
|
+
@fields['hide_menubar'] = value
|
3637
|
+
self
|
3638
|
+
end
|
3639
|
+
|
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.
|
3641
|
+
#
|
3642
|
+
# * +value+ - Set to true to hide ui elements.
|
3643
|
+
# * *Returns* - The converter object.
|
3644
|
+
def setHideWindowUi(value)
|
3645
|
+
@fields['hide_window_ui'] = value
|
3646
|
+
self
|
3647
|
+
end
|
3648
|
+
|
3649
|
+
# Specify whether to resize the document's window to fit the size of the first displayed page.
|
3650
|
+
#
|
3651
|
+
# * +value+ - Set to true to resize the window.
|
3652
|
+
# * *Returns* - The converter object.
|
3653
|
+
def setFitWindow(value)
|
3654
|
+
@fields['fit_window'] = value
|
3655
|
+
self
|
3656
|
+
end
|
3657
|
+
|
3658
|
+
# Specify whether to position the document's window in the center of the screen.
|
3659
|
+
#
|
3660
|
+
# * +value+ - Set to true to center the window.
|
3661
|
+
# * *Returns* - The converter object.
|
3662
|
+
def setCenterWindow(value)
|
3663
|
+
@fields['center_window'] = value
|
3664
|
+
self
|
3665
|
+
end
|
3666
|
+
|
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.
|
3668
|
+
#
|
3669
|
+
# * +value+ - Set to true to display the title.
|
3670
|
+
# * *Returns* - The converter object.
|
3671
|
+
def setDisplayTitle(value)
|
3672
|
+
@fields['display_title'] = value
|
3673
|
+
self
|
3674
|
+
end
|
3675
|
+
|
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
|
3677
|
+
#
|
3678
|
+
# * +value+ - Set to true to set right-to-left reading order.
|
3679
|
+
# * *Returns* - The converter object.
|
3680
|
+
def setRightToLeft(value)
|
3681
|
+
@fields['right_to_left'] = value
|
3682
|
+
self
|
3683
|
+
end
|
3684
|
+
|
2994
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.
|
2995
3686
|
#
|
2996
|
-
# * +
|
3687
|
+
# * +value+ - Set to true to enable the debug logging.
|
2997
3688
|
# * *Returns* - The converter object.
|
2998
|
-
def setDebugLog(
|
2999
|
-
@fields['debug_log'] =
|
3689
|
+
def setDebugLog(value)
|
3690
|
+
@fields['debug_log'] = value
|
3000
3691
|
self
|
3001
3692
|
end
|
3002
3693
|
|
@@ -3039,6 +3730,12 @@ module Pdfcrowd
|
|
3039
3730
|
return @helper.getOutputSize()
|
3040
3731
|
end
|
3041
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
|
+
|
3042
3739
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
3043
3740
|
#
|
3044
3741
|
# * +tag+ - A string with the custom tag.
|
@@ -3048,21 +3745,35 @@ module Pdfcrowd
|
|
3048
3745
|
self
|
3049
3746
|
end
|
3050
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
|
+
|
3051
3761
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
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.
|
3052
3763
|
#
|
3053
|
-
# * +
|
3764
|
+
# * +value+ - Set to true to use HTTP.
|
3054
3765
|
# * *Returns* - The converter object.
|
3055
|
-
def setUseHttp(
|
3056
|
-
@helper.setUseHttp(
|
3766
|
+
def setUseHttp(value)
|
3767
|
+
@helper.setUseHttp(value)
|
3057
3768
|
self
|
3058
3769
|
end
|
3059
3770
|
|
3060
|
-
# 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.
|
3061
3772
|
#
|
3062
|
-
# * +
|
3773
|
+
# * +agent+ - The user agent string.
|
3063
3774
|
# * *Returns* - The converter object.
|
3064
|
-
def setUserAgent(
|
3065
|
-
@helper.setUserAgent(
|
3775
|
+
def setUserAgent(agent)
|
3776
|
+
@helper.setUserAgent(agent)
|
3066
3777
|
self
|
3067
3778
|
end
|
3068
3779
|
|
@@ -3080,10 +3791,10 @@ module Pdfcrowd
|
|
3080
3791
|
|
3081
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.
|
3082
3793
|
#
|
3083
|
-
# * +
|
3794
|
+
# * +count+ - Number of retries wanted.
|
3084
3795
|
# * *Returns* - The converter object.
|
3085
|
-
def setRetryCount(
|
3086
|
-
@helper.setRetryCount(
|
3796
|
+
def setRetryCount(count)
|
3797
|
+
@helper.setRetryCount(count)
|
3087
3798
|
self
|
3088
3799
|
end
|
3089
3800
|
|
@@ -3112,7 +3823,7 @@ module Pdfcrowd
|
|
3112
3823
|
# * *Returns* - Byte array containing the conversion output.
|
3113
3824
|
def convertUrl(url)
|
3114
3825
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
3115
|
-
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);
|
3116
3827
|
end
|
3117
3828
|
|
3118
3829
|
@fields['url'] = url
|
@@ -3125,7 +3836,7 @@ module Pdfcrowd
|
|
3125
3836
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
3126
3837
|
def convertUrlToStream(url, out_stream)
|
3127
3838
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
3128
|
-
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);
|
3129
3840
|
end
|
3130
3841
|
|
3131
3842
|
@fields['url'] = url
|
@@ -3138,7 +3849,7 @@ module Pdfcrowd
|
|
3138
3849
|
# * +file_path+ - The output file path. The string must not be empty.
|
3139
3850
|
def convertUrlToFile(url, file_path)
|
3140
3851
|
if (!(!file_path.nil? && !file_path.empty?))
|
3141
|
-
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);
|
3142
3853
|
end
|
3143
3854
|
|
3144
3855
|
output_file = open(file_path, "wb")
|
@@ -3154,11 +3865,11 @@ module Pdfcrowd
|
|
3154
3865
|
|
3155
3866
|
# Convert a local file.
|
3156
3867
|
#
|
3157
|
-
# * +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.
|
3158
3869
|
# * *Returns* - Byte array containing the conversion output.
|
3159
3870
|
def convertFile(file)
|
3160
3871
|
if (!(File.file?(file) && !File.zero?(file)))
|
3161
|
-
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);
|
3162
3873
|
end
|
3163
3874
|
|
3164
3875
|
@files['file'] = file
|
@@ -3167,11 +3878,11 @@ module Pdfcrowd
|
|
3167
3878
|
|
3168
3879
|
# Convert a local file and write the result to an output stream.
|
3169
3880
|
#
|
3170
|
-
# * +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.
|
3171
3882
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
3172
3883
|
def convertFileToStream(file, out_stream)
|
3173
3884
|
if (!(File.file?(file) && !File.zero?(file)))
|
3174
|
-
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);
|
3175
3886
|
end
|
3176
3887
|
|
3177
3888
|
@files['file'] = file
|
@@ -3180,11 +3891,11 @@ module Pdfcrowd
|
|
3180
3891
|
|
3181
3892
|
# Convert a local file and write the result to a local file.
|
3182
3893
|
#
|
3183
|
-
# * +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.
|
3184
3895
|
# * +file_path+ - The output file path. The string must not be empty.
|
3185
3896
|
def convertFileToFile(file, file_path)
|
3186
3897
|
if (!(!file_path.nil? && !file_path.empty?))
|
3187
|
-
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);
|
3188
3899
|
end
|
3189
3900
|
|
3190
3901
|
output_file = open(file_path, "wb")
|
@@ -3222,7 +3933,7 @@ module Pdfcrowd
|
|
3222
3933
|
# * +file_path+ - The output file path. The string must not be empty.
|
3223
3934
|
def convertRawDataToFile(data, file_path)
|
3224
3935
|
if (!(!file_path.nil? && !file_path.empty?))
|
3225
|
-
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);
|
3226
3937
|
end
|
3227
3938
|
|
3228
3939
|
output_file = open(file_path, "wb")
|
@@ -3256,10 +3967,10 @@ module Pdfcrowd
|
|
3256
3967
|
|
3257
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.
|
3258
3969
|
#
|
3259
|
-
# * +
|
3970
|
+
# * +value+ - Set to true to enable the debug logging.
|
3260
3971
|
# * *Returns* - The converter object.
|
3261
|
-
def setDebugLog(
|
3262
|
-
@fields['debug_log'] =
|
3972
|
+
def setDebugLog(value)
|
3973
|
+
@fields['debug_log'] = value
|
3263
3974
|
self
|
3264
3975
|
end
|
3265
3976
|
|
@@ -3296,6 +4007,12 @@ module Pdfcrowd
|
|
3296
4007
|
return @helper.getOutputSize()
|
3297
4008
|
end
|
3298
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
|
+
|
3299
4016
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
3300
4017
|
#
|
3301
4018
|
# * +tag+ - A string with the custom tag.
|
@@ -3307,45 +4024,59 @@ module Pdfcrowd
|
|
3307
4024
|
|
3308
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.
|
3309
4026
|
#
|
3310
|
-
# * +
|
4027
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
3311
4028
|
# * *Returns* - The converter object.
|
3312
|
-
def setHttpProxy(
|
3313
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
3314
|
-
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);
|
3315
4032
|
end
|
3316
4033
|
|
3317
|
-
@fields['http_proxy'] =
|
4034
|
+
@fields['http_proxy'] = proxy
|
3318
4035
|
self
|
3319
4036
|
end
|
3320
4037
|
|
3321
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.
|
3322
4039
|
#
|
3323
|
-
# * +
|
4040
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
3324
4041
|
# * *Returns* - The converter object.
|
3325
|
-
def setHttpsProxy(
|
3326
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
3327
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
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);
|
3328
4045
|
end
|
3329
4046
|
|
3330
|
-
@fields['https_proxy'] =
|
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.
|
4054
|
+
# * *Returns* - The converter object.
|
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);
|
4058
|
+
end
|
4059
|
+
|
4060
|
+
@helper.setConverterVersion(version)
|
3331
4061
|
self
|
3332
4062
|
end
|
3333
4063
|
|
3334
4064
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
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.
|
3335
4066
|
#
|
3336
|
-
# * +
|
4067
|
+
# * +value+ - Set to true to use HTTP.
|
3337
4068
|
# * *Returns* - The converter object.
|
3338
|
-
def setUseHttp(
|
3339
|
-
@helper.setUseHttp(
|
4069
|
+
def setUseHttp(value)
|
4070
|
+
@helper.setUseHttp(value)
|
3340
4071
|
self
|
3341
4072
|
end
|
3342
4073
|
|
3343
|
-
# 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.
|
3344
4075
|
#
|
3345
|
-
# * +
|
4076
|
+
# * +agent+ - The user agent string.
|
3346
4077
|
# * *Returns* - The converter object.
|
3347
|
-
def setUserAgent(
|
3348
|
-
@helper.setUserAgent(
|
4078
|
+
def setUserAgent(agent)
|
4079
|
+
@helper.setUserAgent(agent)
|
3349
4080
|
self
|
3350
4081
|
end
|
3351
4082
|
|
@@ -3363,10 +4094,10 @@ module Pdfcrowd
|
|
3363
4094
|
|
3364
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.
|
3365
4096
|
#
|
3366
|
-
# * +
|
4097
|
+
# * +count+ - Number of retries wanted.
|
3367
4098
|
# * *Returns* - The converter object.
|
3368
|
-
def setRetryCount(
|
3369
|
-
@helper.setRetryCount(
|
4099
|
+
def setRetryCount(count)
|
4100
|
+
@helper.setRetryCount(count)
|
3370
4101
|
self
|
3371
4102
|
end
|
3372
4103
|
|