pdfcrowd 6.3.0 → 6.5.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 +4 -4
- data/lib/pdfcrowd.rb +381 -263
- metadata +6 -6
data/lib/pdfcrowd.rb
CHANGED
@@ -44,24 +44,52 @@ module Pdfcrowd
|
|
44
44
|
# Thrown when an error occurs.
|
45
45
|
#
|
46
46
|
class Error < RuntimeError
|
47
|
-
attr_reader :http_code, :error
|
47
|
+
attr_reader :http_code, :error, :message, :doc_link, :reason_code
|
48
48
|
|
49
49
|
def initialize(error, http_code=nil)
|
50
50
|
super()
|
51
|
-
@http_code = http_code
|
52
51
|
@error = error
|
52
|
+
error_match = @error.match(/^(\d+)\.(\d+)\s+-\s+(.*?)(?:\s+Documentation link:\s+(.*))?$/) ||
|
53
|
+
@error.scan(/^(\d+)\.(\d+)\s+-\s+(.*?)(?:\s+Documentation link:\s+(.*))?$/m)
|
54
|
+
if error_match and error_match != []
|
55
|
+
@http_code = error_match[1]
|
56
|
+
@reason_code = error_match[2]
|
57
|
+
@message = error_match[3]
|
58
|
+
@doc_link = error_match[4] || ''
|
59
|
+
else
|
60
|
+
@http_code = http_code
|
61
|
+
@reason_code = -1
|
62
|
+
@message = @error
|
63
|
+
if @http_code
|
64
|
+
@error = "#{@http_code} - #{@error}"
|
65
|
+
end
|
66
|
+
@doc_link = ''
|
67
|
+
end
|
53
68
|
end
|
54
69
|
|
55
70
|
def to_s()
|
56
|
-
|
71
|
+
@error
|
57
72
|
end
|
58
73
|
|
59
74
|
def getCode()
|
75
|
+
warn "[DEPRECATION] `getCode` is obsolete and will be removed in future versions. Use `getStatusCode` instead."
|
60
76
|
@http_code
|
61
77
|
end
|
62
78
|
|
79
|
+
def getStatusCode()
|
80
|
+
@http_code
|
81
|
+
end
|
82
|
+
|
83
|
+
def getReasonCode()
|
84
|
+
@reason_code
|
85
|
+
end
|
86
|
+
|
63
87
|
def getMessage()
|
64
|
-
@
|
88
|
+
@message
|
89
|
+
end
|
90
|
+
|
91
|
+
def getDocumentationLink()
|
92
|
+
@doc_link
|
65
93
|
end
|
66
94
|
end
|
67
95
|
|
@@ -530,7 +558,7 @@ end
|
|
530
558
|
module Pdfcrowd
|
531
559
|
HOST = ENV["PDFCROWD_HOST"] || 'api.pdfcrowd.com'
|
532
560
|
MULTIPART_BOUNDARY = '----------ThIs_Is_tHe_bOUnDary_$'
|
533
|
-
CLIENT_VERSION = '6.
|
561
|
+
CLIENT_VERSION = '6.5.0'
|
534
562
|
|
535
563
|
class ConnectionHelper
|
536
564
|
def initialize(user_name, api_key)
|
@@ -541,7 +569,7 @@ module Pdfcrowd
|
|
541
569
|
|
542
570
|
setProxy(nil, nil, nil, nil)
|
543
571
|
setUseHttp(false)
|
544
|
-
setUserAgent('pdfcrowd_ruby_client/6.
|
572
|
+
setUserAgent('pdfcrowd_ruby_client/6.5.0 (https://pdfcrowd.com)')
|
545
573
|
|
546
574
|
@retry_count = 1
|
547
575
|
@converter_version = '24.04'
|
@@ -681,7 +709,7 @@ module Pdfcrowd
|
|
681
709
|
begin
|
682
710
|
return exec_request(request, out_stream)
|
683
711
|
rescue Error => err
|
684
|
-
if (err.
|
712
|
+
if (err.getStatusCode() == '502' or err.getStatusCode() == '503') and @retry_count > @retry
|
685
713
|
@retry += 1
|
686
714
|
sleep(@retry * 0.1)
|
687
715
|
else
|
@@ -726,18 +754,18 @@ module Pdfcrowd
|
|
726
754
|
rescue Timeout::Error => why
|
727
755
|
raise Error.new("Operation timed out\n")
|
728
756
|
rescue OpenSSL::SSL::SSLError => why
|
729
|
-
raise Error.new("There was a problem connecting to
|
730
|
-
"\nYou can still use the API over HTTP, you just need to add the following line right after
|
731
|
-
|
757
|
+
raise Error.new("400.356 - There was a problem connecting to PDFCrowd servers over HTTPS:\n#{why}" +
|
758
|
+
"\nYou can still use the API over HTTP, you just need to add the following line right after PDFCrowd client initialization:\nself.setUseHttp(true)",
|
759
|
+
0)
|
732
760
|
end
|
733
761
|
end
|
734
762
|
end
|
735
763
|
end
|
736
764
|
|
737
765
|
def self.create_invalid_value_message(value, field, converter, hint, id)
|
738
|
-
message = "Invalid value '%s' for %s." % [value, field]
|
766
|
+
message = "400.311 - Invalid value '%s' for the '%s' option." % [value, field]
|
739
767
|
message += " " + hint if hint
|
740
|
-
return message + " " + "
|
768
|
+
return message + " " + "Documentation link: https://www.pdfcrowd.com/api/%s-ruby/ref/#%s" % [converter, id]
|
741
769
|
end
|
742
770
|
|
743
771
|
# generated code
|
@@ -761,11 +789,11 @@ module Pdfcrowd
|
|
761
789
|
|
762
790
|
# Convert a web page.
|
763
791
|
#
|
764
|
-
# * +url+ - The address of the web page to convert.
|
792
|
+
# * +url+ - The address of the web page to convert. Supported protocols are http:// and https://.
|
765
793
|
# * *Returns* - Byte array containing the conversion output.
|
766
794
|
def convertUrl(url)
|
767
795
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
768
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "html-to-pdf", "
|
796
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "html-to-pdf", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
769
797
|
end
|
770
798
|
|
771
799
|
@fields['url'] = url
|
@@ -774,11 +802,11 @@ module Pdfcrowd
|
|
774
802
|
|
775
803
|
# Convert a web page and write the result to an output stream.
|
776
804
|
#
|
777
|
-
# * +url+ - The address of the web page to convert.
|
805
|
+
# * +url+ - The address of the web page to convert. Supported protocols are http:// and https://.
|
778
806
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
779
807
|
def convertUrlToStream(url, out_stream)
|
780
808
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
781
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "html-to-pdf", "
|
809
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "html-to-pdf", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
782
810
|
end
|
783
811
|
|
784
812
|
@fields['url'] = url
|
@@ -787,7 +815,7 @@ module Pdfcrowd
|
|
787
815
|
|
788
816
|
# Convert a web page and write the result to a local file.
|
789
817
|
#
|
790
|
-
# * +url+ - The address of the web page to convert.
|
818
|
+
# * +url+ - The address of the web page to convert. Supported protocols are http:// and https://.
|
791
819
|
# * +file_path+ - The output file path. The string must not be empty.
|
792
820
|
def convertUrlToFile(url, file_path)
|
793
821
|
if (!(!file_path.nil? && !file_path.empty?))
|
@@ -959,11 +987,11 @@ module Pdfcrowd
|
|
959
987
|
|
960
988
|
# Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
|
961
989
|
#
|
962
|
-
# * +width+ - The value must be specified in inches
|
990
|
+
# * +width+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
963
991
|
# * *Returns* - The converter object.
|
964
992
|
def setPageWidth(width)
|
965
993
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
|
966
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setPageWidth", "html-to-pdf", "The value must be specified in inches
|
994
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setPageWidth", "html-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_page_width"), 470);
|
967
995
|
end
|
968
996
|
|
969
997
|
@fields['page_width'] = width
|
@@ -972,11 +1000,11 @@ module Pdfcrowd
|
|
972
1000
|
|
973
1001
|
# 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.
|
974
1002
|
#
|
975
|
-
# * +height+ - The value must be -1 or specified in inches
|
1003
|
+
# * +height+ - The value must be -1 or specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
976
1004
|
# * *Returns* - The converter object.
|
977
1005
|
def setPageHeight(height)
|
978
1006
|
unless /(?i)^0$|^\-1$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
979
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setPageHeight", "html-to-pdf", "The value must be -1 or specified in inches
|
1007
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setPageHeight", "html-to-pdf", "The value must be -1 or specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_page_height"), 470);
|
980
1008
|
end
|
981
1009
|
|
982
1010
|
@fields['page_height'] = height
|
@@ -985,8 +1013,8 @@ module Pdfcrowd
|
|
985
1013
|
|
986
1014
|
# Set the output page dimensions.
|
987
1015
|
#
|
988
|
-
# * +width+ - Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF. The value must be specified in inches
|
989
|
-
# * +height+ - 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. The value must be -1 or specified in inches
|
1016
|
+
# * +width+ - Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
1017
|
+
# * +height+ - 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. The value must be -1 or specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
990
1018
|
# * *Returns* - The converter object.
|
991
1019
|
def setPageDimensions(width, height)
|
992
1020
|
setPageWidth(width)
|
@@ -1009,11 +1037,11 @@ module Pdfcrowd
|
|
1009
1037
|
|
1010
1038
|
# Set the output page top margin.
|
1011
1039
|
#
|
1012
|
-
# * +top+ - The value must be specified in inches
|
1040
|
+
# * +top+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
1013
1041
|
# * *Returns* - The converter object.
|
1014
1042
|
def setMarginTop(top)
|
1015
1043
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(top)
|
1016
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(top, "setMarginTop", "html-to-pdf", "The value must be specified in inches
|
1044
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(top, "setMarginTop", "html-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_margin_top"), 470);
|
1017
1045
|
end
|
1018
1046
|
|
1019
1047
|
@fields['margin_top'] = top
|
@@ -1022,11 +1050,11 @@ module Pdfcrowd
|
|
1022
1050
|
|
1023
1051
|
# Set the output page right margin.
|
1024
1052
|
#
|
1025
|
-
# * +right+ - The value must be specified in inches
|
1053
|
+
# * +right+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
1026
1054
|
# * *Returns* - The converter object.
|
1027
1055
|
def setMarginRight(right)
|
1028
1056
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(right)
|
1029
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(right, "setMarginRight", "html-to-pdf", "The value must be specified in inches
|
1057
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(right, "setMarginRight", "html-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_margin_right"), 470);
|
1030
1058
|
end
|
1031
1059
|
|
1032
1060
|
@fields['margin_right'] = right
|
@@ -1035,11 +1063,11 @@ module Pdfcrowd
|
|
1035
1063
|
|
1036
1064
|
# Set the output page bottom margin.
|
1037
1065
|
#
|
1038
|
-
# * +bottom+ - The value must be specified in inches
|
1066
|
+
# * +bottom+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
1039
1067
|
# * *Returns* - The converter object.
|
1040
1068
|
def setMarginBottom(bottom)
|
1041
1069
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(bottom)
|
1042
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(bottom, "setMarginBottom", "html-to-pdf", "The value must be specified in inches
|
1070
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(bottom, "setMarginBottom", "html-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_margin_bottom"), 470);
|
1043
1071
|
end
|
1044
1072
|
|
1045
1073
|
@fields['margin_bottom'] = bottom
|
@@ -1048,11 +1076,11 @@ module Pdfcrowd
|
|
1048
1076
|
|
1049
1077
|
# Set the output page left margin.
|
1050
1078
|
#
|
1051
|
-
# * +left+ - The value must be specified in inches
|
1079
|
+
# * +left+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
1052
1080
|
# * *Returns* - The converter object.
|
1053
1081
|
def setMarginLeft(left)
|
1054
1082
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(left)
|
1055
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(left, "setMarginLeft", "html-to-pdf", "The value must be specified in inches
|
1083
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(left, "setMarginLeft", "html-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_margin_left"), 470);
|
1056
1084
|
end
|
1057
1085
|
|
1058
1086
|
@fields['margin_left'] = left
|
@@ -1070,10 +1098,10 @@ module Pdfcrowd
|
|
1070
1098
|
|
1071
1099
|
# Set the output page margins.
|
1072
1100
|
#
|
1073
|
-
# * +top+ - Set the output page top margin. The value must be specified in inches
|
1074
|
-
# * +right+ - Set the output page right margin. The value must be specified in inches
|
1075
|
-
# * +bottom+ - Set the output page bottom margin. The value must be specified in inches
|
1076
|
-
# * +left+ - Set the output page left margin. The value must be specified in inches
|
1101
|
+
# * +top+ - Set the output page top margin. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
1102
|
+
# * +right+ - Set the output page right margin. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
1103
|
+
# * +bottom+ - Set the output page bottom margin. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
1104
|
+
# * +left+ - Set the output page left margin. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
1077
1105
|
# * *Returns* - The converter object.
|
1078
1106
|
def setPageMargins(top, right, bottom, left)
|
1079
1107
|
setMarginTop(top)
|
@@ -1085,11 +1113,11 @@ module Pdfcrowd
|
|
1085
1113
|
|
1086
1114
|
# Set the page range to print.
|
1087
1115
|
#
|
1088
|
-
# * +pages+ - A comma separated list of page numbers or ranges. Special strings may be used, such as
|
1116
|
+
# * +pages+ - A comma separated list of page numbers or ranges. Special strings may be used, such as 'odd', 'even' and 'last'.
|
1089
1117
|
# * *Returns* - The converter object.
|
1090
1118
|
def setPrintPageRange(pages)
|
1091
1119
|
unless /^(?:\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*)|odd|even|last)\s*,\s*)*\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*)|odd|even|last)\s*$/.match(pages)
|
1092
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setPrintPageRange", "html-to-pdf", "A comma separated list of page numbers or ranges. Special strings may be used, such as
|
1120
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setPrintPageRange", "html-to-pdf", "A comma separated list of page numbers or ranges. Special strings may be used, such as 'odd', 'even' and 'last'.", "set_print_page_range"), 470);
|
1093
1121
|
end
|
1094
1122
|
|
1095
1123
|
@fields['print_page_range'] = pages
|
@@ -1098,11 +1126,11 @@ module Pdfcrowd
|
|
1098
1126
|
|
1099
1127
|
# Set the viewport width for formatting the HTML content when generating a PDF. By specifying a viewport width, you can control how the content is rendered, ensuring it mimics the appearance on various devices or matches specific design requirements.
|
1100
1128
|
#
|
1101
|
-
# * +width+ - The width of the viewport. The value must be
|
1129
|
+
# * +width+ - The width of the viewport. The value must be 'balanced', 'small', 'medium', 'large', 'extra-large', or a number in the range 96-65000px.
|
1102
1130
|
# * *Returns* - The converter object.
|
1103
1131
|
def setContentViewportWidth(width)
|
1104
1132
|
unless /(?i)^(balanced|small|medium|large|extra-large|[0-9]+(px)?)$/.match(width)
|
1105
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setContentViewportWidth", "html-to-pdf", "The value must be
|
1133
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setContentViewportWidth", "html-to-pdf", "The value must be 'balanced', 'small', 'medium', 'large', 'extra-large', or a number in the range 96-65000px.", "set_content_viewport_width"), 470);
|
1106
1134
|
end
|
1107
1135
|
|
1108
1136
|
@fields['content_viewport_width'] = width
|
@@ -1111,11 +1139,11 @@ module Pdfcrowd
|
|
1111
1139
|
|
1112
1140
|
# Set the viewport height for formatting the HTML content when generating a PDF. By specifying a viewport height, you can enforce loading of lazy-loaded images and also affect vertical positioning of absolutely positioned elements within the content.
|
1113
1141
|
#
|
1114
|
-
# * +height+ - The viewport height. The value must be
|
1142
|
+
# * +height+ - The viewport height. The value must be 'auto', 'large', or a number.
|
1115
1143
|
# * *Returns* - The converter object.
|
1116
1144
|
def setContentViewportHeight(height)
|
1117
1145
|
unless /(?i)^(auto|large|[0-9]+(px)?)$/.match(height)
|
1118
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setContentViewportHeight", "html-to-pdf", "The value must be
|
1146
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setContentViewportHeight", "html-to-pdf", "The value must be 'auto', 'large', or a number.", "set_content_viewport_height"), 470);
|
1119
1147
|
end
|
1120
1148
|
|
1121
1149
|
@fields['content_viewport_height'] = height
|
@@ -1150,11 +1178,11 @@ module Pdfcrowd
|
|
1150
1178
|
|
1151
1179
|
# 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 the converted document pdfcrowd-source-title - the title of the converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1152
1180
|
#
|
1153
|
-
# * +url+ -
|
1181
|
+
# * +url+ - Supported protocols are http:// and https://.
|
1154
1182
|
# * *Returns* - The converter object.
|
1155
1183
|
def setHeaderUrl(url)
|
1156
1184
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
1157
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setHeaderUrl", "html-to-pdf", "
|
1185
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setHeaderUrl", "html-to-pdf", "Supported protocols are http:// and https://.", "set_header_url"), 470);
|
1158
1186
|
end
|
1159
1187
|
|
1160
1188
|
@fields['header_url'] = url
|
@@ -1176,11 +1204,11 @@ module Pdfcrowd
|
|
1176
1204
|
|
1177
1205
|
# Set the header height.
|
1178
1206
|
#
|
1179
|
-
# * +height+ - The value must be specified in inches
|
1207
|
+
# * +height+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
1180
1208
|
# * *Returns* - The converter object.
|
1181
1209
|
def setHeaderHeight(height)
|
1182
1210
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1183
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setHeaderHeight", "html-to-pdf", "The value must be specified in inches
|
1211
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setHeaderHeight", "html-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_header_height"), 470);
|
1184
1212
|
end
|
1185
1213
|
|
1186
1214
|
@fields['header_height'] = height
|
@@ -1198,11 +1226,11 @@ module Pdfcrowd
|
|
1198
1226
|
|
1199
1227
|
# 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 the converted document pdfcrowd-source-title - the title of the converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1200
1228
|
#
|
1201
|
-
# * +url+ -
|
1229
|
+
# * +url+ - Supported protocols are http:// and https://.
|
1202
1230
|
# * *Returns* - The converter object.
|
1203
1231
|
def setFooterUrl(url)
|
1204
1232
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
1205
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setFooterUrl", "html-to-pdf", "
|
1233
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setFooterUrl", "html-to-pdf", "Supported protocols are http:// and https://.", "set_footer_url"), 470);
|
1206
1234
|
end
|
1207
1235
|
|
1208
1236
|
@fields['footer_url'] = url
|
@@ -1224,11 +1252,11 @@ module Pdfcrowd
|
|
1224
1252
|
|
1225
1253
|
# Set the footer height.
|
1226
1254
|
#
|
1227
|
-
# * +height+ - The value must be specified in inches
|
1255
|
+
# * +height+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
1228
1256
|
# * *Returns* - The converter object.
|
1229
1257
|
def setFooterHeight(height)
|
1230
1258
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1231
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setFooterHeight", "html-to-pdf", "The value must be specified in inches
|
1259
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setFooterHeight", "html-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_footer_height"), 470);
|
1232
1260
|
end
|
1233
1261
|
|
1234
1262
|
@fields['footer_height'] = height
|
@@ -1281,11 +1309,11 @@ module Pdfcrowd
|
|
1281
1309
|
|
1282
1310
|
# Set the scaling factor (zoom) for the header and footer.
|
1283
1311
|
#
|
1284
|
-
# * +factor+ - The percentage value. The
|
1312
|
+
# * +factor+ - The percentage value. The accepted range is 10-500.
|
1285
1313
|
# * *Returns* - The converter object.
|
1286
1314
|
def setHeaderFooterScaleFactor(factor)
|
1287
1315
|
if (!(Integer(factor) >= 10 && Integer(factor) <= 500))
|
1288
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setHeaderFooterScaleFactor", "html-to-pdf", "The
|
1316
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setHeaderFooterScaleFactor", "html-to-pdf", "The accepted range is 10-500.", "set_header_footer_scale_factor"), 470);
|
1289
1317
|
end
|
1290
1318
|
|
1291
1319
|
@fields['header_footer_scale_factor'] = factor
|
@@ -1316,11 +1344,11 @@ module Pdfcrowd
|
|
1316
1344
|
|
1317
1345
|
# Load a file from the specified URL and apply the file as a watermark to each page of the output PDF. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.
|
1318
1346
|
#
|
1319
|
-
# * +url+ -
|
1347
|
+
# * +url+ - Supported protocols are http:// and https://.
|
1320
1348
|
# * *Returns* - The converter object.
|
1321
1349
|
def setPageWatermarkUrl(url)
|
1322
1350
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
1323
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageWatermarkUrl", "html-to-pdf", "
|
1351
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageWatermarkUrl", "html-to-pdf", "Supported protocols are http:// and https://.", "set_page_watermark_url"), 470);
|
1324
1352
|
end
|
1325
1353
|
|
1326
1354
|
@fields['page_watermark_url'] = url
|
@@ -1342,11 +1370,11 @@ module Pdfcrowd
|
|
1342
1370
|
|
1343
1371
|
# Load a file from the specified URL and apply each page of the file as a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.
|
1344
1372
|
#
|
1345
|
-
# * +url+ -
|
1373
|
+
# * +url+ - Supported protocols are http:// and https://.
|
1346
1374
|
# * *Returns* - The converter object.
|
1347
1375
|
def setMultipageWatermarkUrl(url)
|
1348
1376
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
1349
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageWatermarkUrl", "html-to-pdf", "
|
1377
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageWatermarkUrl", "html-to-pdf", "Supported protocols are http:// and https://.", "set_multipage_watermark_url"), 470);
|
1350
1378
|
end
|
1351
1379
|
|
1352
1380
|
@fields['multipage_watermark_url'] = url
|
@@ -1368,11 +1396,11 @@ module Pdfcrowd
|
|
1368
1396
|
|
1369
1397
|
# Load a file from the specified URL and apply the file as a background to each page of the output PDF. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.
|
1370
1398
|
#
|
1371
|
-
# * +url+ -
|
1399
|
+
# * +url+ - Supported protocols are http:// and https://.
|
1372
1400
|
# * *Returns* - The converter object.
|
1373
1401
|
def setPageBackgroundUrl(url)
|
1374
1402
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
1375
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageBackgroundUrl", "html-to-pdf", "
|
1403
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageBackgroundUrl", "html-to-pdf", "Supported protocols are http:// and https://.", "set_page_background_url"), 470);
|
1376
1404
|
end
|
1377
1405
|
|
1378
1406
|
@fields['page_background_url'] = url
|
@@ -1394,11 +1422,11 @@ module Pdfcrowd
|
|
1394
1422
|
|
1395
1423
|
# Load a file from the specified URL and apply each page of the file as a background to the corresponding page of the output PDF. A background can be either a PDF or an image.
|
1396
1424
|
#
|
1397
|
-
# * +url+ -
|
1425
|
+
# * +url+ - Supported protocols are http:// and https://.
|
1398
1426
|
# * *Returns* - The converter object.
|
1399
1427
|
def setMultipageBackgroundUrl(url)
|
1400
1428
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
1401
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageBackgroundUrl", "html-to-pdf", "
|
1429
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageBackgroundUrl", "html-to-pdf", "Supported protocols are http:// and https://.", "set_multipage_background_url"), 470);
|
1402
1430
|
end
|
1403
1431
|
|
1404
1432
|
@fields['multipage_background_url'] = url
|
@@ -1512,19 +1540,13 @@ module Pdfcrowd
|
|
1512
1540
|
self
|
1513
1541
|
end
|
1514
1542
|
|
1515
|
-
|
1516
|
-
#
|
1517
|
-
# * +user_name+ - The user name.
|
1518
|
-
# * *Returns* - The converter object.
|
1543
|
+
|
1519
1544
|
def setHttpAuthUserName(user_name)
|
1520
1545
|
@fields['http_auth_user_name'] = user_name
|
1521
1546
|
self
|
1522
1547
|
end
|
1523
1548
|
|
1524
|
-
|
1525
|
-
#
|
1526
|
-
# * +password+ - The password.
|
1527
|
-
# * *Returns* - The converter object.
|
1549
|
+
|
1528
1550
|
def setHttpAuthPassword(password)
|
1529
1551
|
@fields['http_auth_password'] = password
|
1530
1552
|
self
|
@@ -1653,11 +1675,11 @@ module Pdfcrowd
|
|
1653
1675
|
|
1654
1676
|
# 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.
|
1655
1677
|
#
|
1656
|
-
# * +delay+ - The number of milliseconds to wait. Must be a positive integer
|
1678
|
+
# * +delay+ - The number of milliseconds to wait. Must be a positive integer or 0.
|
1657
1679
|
# * *Returns* - The converter object.
|
1658
1680
|
def setJavascriptDelay(delay)
|
1659
1681
|
if (!(Integer(delay) >= 0))
|
1660
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(delay, "setJavascriptDelay", "html-to-pdf", "Must be a positive integer
|
1682
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(delay, "setJavascriptDelay", "html-to-pdf", "Must be a positive integer or 0.", "set_javascript_delay"), 470);
|
1661
1683
|
end
|
1662
1684
|
|
1663
1685
|
@fields['javascript_delay'] = delay
|
@@ -1727,11 +1749,11 @@ module Pdfcrowd
|
|
1727
1749
|
|
1728
1750
|
# Set the viewport width in pixels. The viewport is the user's visible area of the page.
|
1729
1751
|
#
|
1730
|
-
# * +width+ - The
|
1752
|
+
# * +width+ - The accepted range is 96-65000.
|
1731
1753
|
# * *Returns* - The converter object.
|
1732
1754
|
def setViewportWidth(width)
|
1733
1755
|
if (!(Integer(width) >= 96 && Integer(width) <= 65000))
|
1734
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setViewportWidth", "html-to-pdf", "The
|
1756
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setViewportWidth", "html-to-pdf", "The accepted range is 96-65000.", "set_viewport_width"), 470);
|
1735
1757
|
end
|
1736
1758
|
|
1737
1759
|
@fields['viewport_width'] = width
|
@@ -1740,11 +1762,11 @@ module Pdfcrowd
|
|
1740
1762
|
|
1741
1763
|
# Set the viewport height in pixels. The viewport is the user's visible area of the page. If the input HTML uses lazily loaded images, try using a large value that covers the entire height of the HTML, e.g. 100000.
|
1742
1764
|
#
|
1743
|
-
# * +height+ - Must be a positive integer
|
1765
|
+
# * +height+ - Must be a positive integer.
|
1744
1766
|
# * *Returns* - The converter object.
|
1745
1767
|
def setViewportHeight(height)
|
1746
1768
|
if (!(Integer(height) > 0))
|
1747
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setViewportHeight", "html-to-pdf", "Must be a positive integer
|
1769
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setViewportHeight", "html-to-pdf", "Must be a positive integer.", "set_viewport_height"), 470);
|
1748
1770
|
end
|
1749
1771
|
|
1750
1772
|
@fields['viewport_height'] = height
|
@@ -1753,8 +1775,8 @@ module Pdfcrowd
|
|
1753
1775
|
|
1754
1776
|
# Set the viewport size. The viewport is the user's visible area of the page.
|
1755
1777
|
#
|
1756
|
-
# * +width+ - Set the viewport width in pixels. The viewport is the user's visible area of the page. The
|
1757
|
-
# * +height+ - Set the viewport height in pixels. The viewport is the user's visible area of the page. If the input HTML uses lazily loaded images, try using a large value that covers the entire height of the HTML, e.g. 100000. Must be a positive integer
|
1778
|
+
# * +width+ - Set the viewport width in pixels. The viewport is the user's visible area of the page. The accepted range is 96-65000.
|
1779
|
+
# * +height+ - Set the viewport height in pixels. The viewport is the user's visible area of the page. If the input HTML uses lazily loaded images, try using a large value that covers the entire height of the HTML, e.g. 100000. Must be a positive integer.
|
1758
1780
|
# * *Returns* - The converter object.
|
1759
1781
|
def setViewport(width, height)
|
1760
1782
|
setViewportWidth(width)
|
@@ -1790,11 +1812,11 @@ module Pdfcrowd
|
|
1790
1812
|
|
1791
1813
|
# Set the scaling factor (zoom) for the main page area.
|
1792
1814
|
#
|
1793
|
-
# * +factor+ - The percentage value. The
|
1815
|
+
# * +factor+ - The percentage value. The accepted range is 10-500.
|
1794
1816
|
# * *Returns* - The converter object.
|
1795
1817
|
def setScaleFactor(factor)
|
1796
1818
|
if (!(Integer(factor) >= 10 && Integer(factor) <= 500))
|
1797
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "html-to-pdf", "The
|
1819
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "html-to-pdf", "The accepted range is 10-500.", "set_scale_factor"), 470);
|
1798
1820
|
end
|
1799
1821
|
|
1800
1822
|
@fields['scale_factor'] = factor
|
@@ -1803,11 +1825,11 @@ module Pdfcrowd
|
|
1803
1825
|
|
1804
1826
|
# Set the quality of embedded JPEG images. A lower quality results in a smaller PDF file but can lead to compression artifacts.
|
1805
1827
|
#
|
1806
|
-
# * +quality+ - The percentage value. The
|
1828
|
+
# * +quality+ - The percentage value. The accepted range is 1-100.
|
1807
1829
|
# * *Returns* - The converter object.
|
1808
1830
|
def setJpegQuality(quality)
|
1809
1831
|
if (!(Integer(quality) >= 1 && Integer(quality) <= 100))
|
1810
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(quality, "setJpegQuality", "html-to-pdf", "The
|
1832
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(quality, "setJpegQuality", "html-to-pdf", "The accepted range is 1-100.", "set_jpeg_quality"), 470);
|
1811
1833
|
end
|
1812
1834
|
|
1813
1835
|
@fields['jpeg_quality'] = quality
|
@@ -1829,11 +1851,11 @@ module Pdfcrowd
|
|
1829
1851
|
|
1830
1852
|
# 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.
|
1831
1853
|
#
|
1832
|
-
# * +dpi+ - The DPI value. Must be a positive integer
|
1854
|
+
# * +dpi+ - The DPI value. Must be a positive integer or 0.
|
1833
1855
|
# * *Returns* - The converter object.
|
1834
1856
|
def setImageDpi(dpi)
|
1835
1857
|
if (!(Integer(dpi) >= 0))
|
1836
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(dpi, "setImageDpi", "html-to-pdf", "Must be a positive integer
|
1858
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(dpi, "setImageDpi", "html-to-pdf", "Must be a positive integer or 0.", "set_image_dpi"), 470);
|
1837
1859
|
end
|
1838
1860
|
|
1839
1861
|
@fields['image_dpi'] = dpi
|
@@ -1998,11 +2020,11 @@ module Pdfcrowd
|
|
1998
2020
|
|
1999
2021
|
# Display the specified page when the document is opened.
|
2000
2022
|
#
|
2001
|
-
# * +page+ - Must be a positive integer
|
2023
|
+
# * +page+ - Must be a positive integer.
|
2002
2024
|
# * *Returns* - The converter object.
|
2003
2025
|
def setInitialPage(page)
|
2004
2026
|
if (!(Integer(page) > 0))
|
2005
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "html-to-pdf", "Must be a positive integer
|
2027
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "html-to-pdf", "Must be a positive integer.", "set_initial_page"), 470);
|
2006
2028
|
end
|
2007
2029
|
|
2008
2030
|
@fields['initial_page'] = page
|
@@ -2011,11 +2033,11 @@ module Pdfcrowd
|
|
2011
2033
|
|
2012
2034
|
# Specify the initial page zoom in percents when the document is opened.
|
2013
2035
|
#
|
2014
|
-
# * +zoom+ - Must be a positive integer
|
2036
|
+
# * +zoom+ - Must be a positive integer.
|
2015
2037
|
# * *Returns* - The converter object.
|
2016
2038
|
def setInitialZoom(zoom)
|
2017
2039
|
if (!(Integer(zoom) > 0))
|
2018
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "html-to-pdf", "Must be a positive integer
|
2040
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "html-to-pdf", "Must be a positive integer.", "set_initial_zoom"), 470);
|
2019
2041
|
end
|
2020
2042
|
|
2021
2043
|
@fields['initial_zoom'] = zoom
|
@@ -2280,11 +2302,11 @@ module Pdfcrowd
|
|
2280
2302
|
|
2281
2303
|
# 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.
|
2282
2304
|
#
|
2283
|
-
# * +dpi+ - The DPI value. The
|
2305
|
+
# * +dpi+ - The DPI value. The accepted range is 72-600.
|
2284
2306
|
# * *Returns* - The converter object.
|
2285
2307
|
def setLayoutDpi(dpi)
|
2286
2308
|
if (!(Integer(dpi) >= 72 && Integer(dpi) <= 600))
|
2287
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(dpi, "setLayoutDpi", "html-to-pdf", "The
|
2309
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(dpi, "setLayoutDpi", "html-to-pdf", "The accepted range is 72-600.", "set_layout_dpi"), 470);
|
2288
2310
|
end
|
2289
2311
|
|
2290
2312
|
@fields['layout_dpi'] = dpi
|
@@ -2293,11 +2315,11 @@ module Pdfcrowd
|
|
2293
2315
|
|
2294
2316
|
# Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
|
2295
2317
|
#
|
2296
|
-
# * +x+ - The value must be specified in inches
|
2318
|
+
# * +x+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'. It may contain a negative value.
|
2297
2319
|
# * *Returns* - The converter object.
|
2298
2320
|
def setContentAreaX(x)
|
2299
2321
|
unless /(?i)^0$|^\-?[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(x)
|
2300
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setContentAreaX", "html-to-pdf", "The value must be specified in inches
|
2322
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setContentAreaX", "html-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'. It may contain a negative value.", "set_content_area_x"), 470);
|
2301
2323
|
end
|
2302
2324
|
|
2303
2325
|
@fields['content_area_x'] = x
|
@@ -2306,11 +2328,11 @@ module Pdfcrowd
|
|
2306
2328
|
|
2307
2329
|
# Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
|
2308
2330
|
#
|
2309
|
-
# * +y+ - The value must be specified in inches
|
2331
|
+
# * +y+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'. It may contain a negative value.
|
2310
2332
|
# * *Returns* - The converter object.
|
2311
2333
|
def setContentAreaY(y)
|
2312
2334
|
unless /(?i)^0$|^\-?[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(y)
|
2313
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setContentAreaY", "html-to-pdf", "The value must be specified in inches
|
2335
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setContentAreaY", "html-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'. It may contain a negative value.", "set_content_area_y"), 470);
|
2314
2336
|
end
|
2315
2337
|
|
2316
2338
|
@fields['content_area_y'] = y
|
@@ -2319,11 +2341,11 @@ module Pdfcrowd
|
|
2319
2341
|
|
2320
2342
|
# Set the width of the content area. It should be at least 1 inch.
|
2321
2343
|
#
|
2322
|
-
# * +width+ - The value must be specified in inches
|
2344
|
+
# * +width+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
2323
2345
|
# * *Returns* - The converter object.
|
2324
2346
|
def setContentAreaWidth(width)
|
2325
2347
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
|
2326
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setContentAreaWidth", "html-to-pdf", "The value must be specified in inches
|
2348
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setContentAreaWidth", "html-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_content_area_width"), 470);
|
2327
2349
|
end
|
2328
2350
|
|
2329
2351
|
@fields['content_area_width'] = width
|
@@ -2332,11 +2354,11 @@ module Pdfcrowd
|
|
2332
2354
|
|
2333
2355
|
# Set the height of the content area. It should be at least 1 inch.
|
2334
2356
|
#
|
2335
|
-
# * +height+ - The value must be specified in inches
|
2357
|
+
# * +height+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
2336
2358
|
# * *Returns* - The converter object.
|
2337
2359
|
def setContentAreaHeight(height)
|
2338
2360
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
2339
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setContentAreaHeight", "html-to-pdf", "The value must be specified in inches
|
2361
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setContentAreaHeight", "html-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_content_area_height"), 470);
|
2340
2362
|
end
|
2341
2363
|
|
2342
2364
|
@fields['content_area_height'] = height
|
@@ -2345,10 +2367,10 @@ module Pdfcrowd
|
|
2345
2367
|
|
2346
2368
|
# Set the content area position and size. The content area enables to specify a web page area to be converted.
|
2347
2369
|
#
|
2348
|
-
# * +x+ - Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area. The value must be specified in inches
|
2349
|
-
# * +y+ - Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. The value must be specified in inches
|
2350
|
-
# * +width+ - Set the width of the content area. It should be at least 1 inch. The value must be specified in inches
|
2351
|
-
# * +height+ - Set the height of the content area. It should be at least 1 inch. The value must be specified in inches
|
2370
|
+
# * +x+ - Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'. It may contain a negative value.
|
2371
|
+
# * +y+ - Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'. It may contain a negative value.
|
2372
|
+
# * +width+ - Set the width of the content area. It should be at least 1 inch. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
2373
|
+
# * +height+ - Set the height of the content area. It should be at least 1 inch. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
2352
2374
|
# * *Returns* - The converter object.
|
2353
2375
|
def setContentArea(x, y, width, height)
|
2354
2376
|
setContentAreaX(x)
|
@@ -2415,18 +2437,18 @@ module Pdfcrowd
|
|
2415
2437
|
|
2416
2438
|
# Set the maximum time to load the page and its resources. After this time, all requests will be considered successful. This can be useful to ensure that the conversion does not timeout. Use this method if there is no other way to fix page loading.
|
2417
2439
|
#
|
2418
|
-
# * +max_time+ - The number of seconds to wait. The
|
2440
|
+
# * +max_time+ - The number of seconds to wait. The accepted range is 10-30.
|
2419
2441
|
# * *Returns* - The converter object.
|
2420
2442
|
def setMaxLoadingTime(max_time)
|
2421
2443
|
if (!(Integer(max_time) >= 10 && Integer(max_time) <= 30))
|
2422
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(max_time, "setMaxLoadingTime", "html-to-pdf", "The
|
2444
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(max_time, "setMaxLoadingTime", "html-to-pdf", "The accepted range is 10-30.", "set_max_loading_time"), 470);
|
2423
2445
|
end
|
2424
2446
|
|
2425
2447
|
@fields['max_loading_time'] = max_time
|
2426
2448
|
self
|
2427
2449
|
end
|
2428
2450
|
|
2429
|
-
# Allows to configure conversion via JSON. The configuration defines various page settings for individual PDF pages or ranges of pages. It provides flexibility in designing each page of the PDF, giving control over each page's size, header, footer etc. If a page or parameter is not explicitly specified, the system will use the default settings for that page or attribute. If a JSON configuration is provided, the settings in the JSON will take precedence over the global options. The structure of the JSON must be: pageSetup: An array of objects where each object defines the configuration for a specific page or range of pages. The following properties can be set for each page object: pages: A comma-separated list of page numbers or ranges. Special strings may be used, such as `odd`, `even` and `last`. For example: 1-: from page 1 to the end of the document 2: only the 2nd page 2,4,6: pages 2, 4, and 6 2-5: pages 2 through 5 odd,2: the 2nd page and all odd pages pageSize: The page size (optional). Possible values: A0, A1, A2, A3, A4, A5, A6, Letter. pageWidth: The width of the page (optional). pageHeight: The height of the page (optional). marginLeft: Left margin (optional). marginRight: Right margin (optional). marginTop: Top margin (optional). marginBottom: Bottom margin (optional). displayHeader: Header appearance (optional). Possible values: none: completely excluded space: only the content is excluded, the space is used content: the content is printed (default) displayFooter: Footer appearance (optional). Possible values: none: completely excluded space: only the content is excluded, the space is used content: the content is printed (default) headerHeight: Height of the header (optional). footerHeight: Height of the footer (optional). orientation: Page orientation, such as "portrait" or "landscape" (optional). Dimensions may be empty, 0 or specified in inches
|
2451
|
+
# Allows to configure conversion via JSON. The configuration defines various page settings for individual PDF pages or ranges of pages. It provides flexibility in designing each page of the PDF, giving control over each page's size, header, footer etc. If a page or parameter is not explicitly specified, the system will use the default settings for that page or attribute. If a JSON configuration is provided, the settings in the JSON will take precedence over the global options. The structure of the JSON must be: pageSetup: An array of objects where each object defines the configuration for a specific page or range of pages. The following properties can be set for each page object: pages: A comma-separated list of page numbers or ranges. Special strings may be used, such as `odd`, `even` and `last`. For example: 1-: from page 1 to the end of the document 2: only the 2nd page 2,4,6: pages 2, 4, and 6 2-5: pages 2 through 5 odd,2: the 2nd page and all odd pages pageSize: The page size (optional). Possible values: A0, A1, A2, A3, A4, A5, A6, Letter. pageWidth: The width of the page (optional). pageHeight: The height of the page (optional). marginLeft: Left margin (optional). marginRight: Right margin (optional). marginTop: Top margin (optional). marginBottom: Bottom margin (optional). displayHeader: Header appearance (optional). Possible values: none: completely excluded space: only the content is excluded, the space is used content: the content is printed (default) displayFooter: Footer appearance (optional). Possible values: none: completely excluded space: only the content is excluded, the space is used content: the content is printed (default) headerHeight: Height of the header (optional). footerHeight: Height of the footer (optional). orientation: Page orientation, such as "portrait" or "landscape" (optional). backgroundColor: Page background color in RRGGBB or RRGGBBAA hexadecimal format (optional). Dimensions may be empty, 0 or specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
2430
2452
|
#
|
2431
2453
|
# * +json_string+ - The JSON string.
|
2432
2454
|
# * *Returns* - The converter object.
|
@@ -2448,6 +2470,21 @@ module Pdfcrowd
|
|
2448
2470
|
self
|
2449
2471
|
end
|
2450
2472
|
|
2473
|
+
|
2474
|
+
def setSubprocessReferrer(referrer)
|
2475
|
+
@fields['subprocess_referrer'] = referrer
|
2476
|
+
self
|
2477
|
+
end
|
2478
|
+
|
2479
|
+
# Specifies the User-Agent HTTP header that will be used by the converter when a request is made to the converted web page.
|
2480
|
+
#
|
2481
|
+
# * +agent+ - The user agent.
|
2482
|
+
# * *Returns* - The converter object.
|
2483
|
+
def setConverterUserAgent(agent)
|
2484
|
+
@fields['converter_user_agent'] = agent
|
2485
|
+
self
|
2486
|
+
end
|
2487
|
+
|
2451
2488
|
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
2452
2489
|
#
|
2453
2490
|
# * +version+ - The version identifier. Allowed values are 24.04, 20.10, 18.10, latest.
|
@@ -2471,6 +2508,15 @@ module Pdfcrowd
|
|
2471
2508
|
self
|
2472
2509
|
end
|
2473
2510
|
|
2511
|
+
# Specifies the User-Agent HTTP header that the client library will use when interacting with the API.
|
2512
|
+
#
|
2513
|
+
# * +agent+ - The user agent string.
|
2514
|
+
# * *Returns* - The converter object.
|
2515
|
+
def setClientUserAgent(agent)
|
2516
|
+
@helper.setUserAgent(agent)
|
2517
|
+
self
|
2518
|
+
end
|
2519
|
+
|
2474
2520
|
# Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
|
2475
2521
|
#
|
2476
2522
|
# * +agent+ - The user agent string.
|
@@ -2535,11 +2581,11 @@ module Pdfcrowd
|
|
2535
2581
|
|
2536
2582
|
# Convert a web page.
|
2537
2583
|
#
|
2538
|
-
# * +url+ - The address of the web page to convert.
|
2584
|
+
# * +url+ - The address of the web page to convert. Supported protocols are http:// and https://.
|
2539
2585
|
# * *Returns* - Byte array containing the conversion output.
|
2540
2586
|
def convertUrl(url)
|
2541
2587
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
2542
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "html-to-image", "
|
2588
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "html-to-image", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
2543
2589
|
end
|
2544
2590
|
|
2545
2591
|
@fields['url'] = url
|
@@ -2548,11 +2594,11 @@ module Pdfcrowd
|
|
2548
2594
|
|
2549
2595
|
# Convert a web page and write the result to an output stream.
|
2550
2596
|
#
|
2551
|
-
# * +url+ - The address of the web page to convert.
|
2597
|
+
# * +url+ - The address of the web page to convert. Supported protocols are http:// and https://.
|
2552
2598
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2553
2599
|
def convertUrlToStream(url, out_stream)
|
2554
2600
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
2555
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "html-to-image", "
|
2601
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "html-to-image", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
2556
2602
|
end
|
2557
2603
|
|
2558
2604
|
@fields['url'] = url
|
@@ -2561,7 +2607,7 @@ module Pdfcrowd
|
|
2561
2607
|
|
2562
2608
|
# Convert a web page and write the result to a local file.
|
2563
2609
|
#
|
2564
|
-
# * +url+ - The address of the web page to convert.
|
2610
|
+
# * +url+ - The address of the web page to convert. Supported protocols are http:// and https://.
|
2565
2611
|
# * +file_path+ - The output file path. The string must not be empty.
|
2566
2612
|
def convertUrlToFile(url, file_path)
|
2567
2613
|
if (!(!file_path.nil? && !file_path.empty?))
|
@@ -2720,11 +2766,11 @@ module Pdfcrowd
|
|
2720
2766
|
|
2721
2767
|
# Set the output image width in pixels.
|
2722
2768
|
#
|
2723
|
-
# * +width+ - The
|
2769
|
+
# * +width+ - The accepted range is 96-65000.
|
2724
2770
|
# * *Returns* - The converter object.
|
2725
2771
|
def setScreenshotWidth(width)
|
2726
2772
|
if (!(Integer(width) >= 96 && Integer(width) <= 65000))
|
2727
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setScreenshotWidth", "html-to-image", "The
|
2773
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setScreenshotWidth", "html-to-image", "The accepted range is 96-65000.", "set_screenshot_width"), 470);
|
2728
2774
|
end
|
2729
2775
|
|
2730
2776
|
@fields['screenshot_width'] = width
|
@@ -2733,11 +2779,11 @@ module Pdfcrowd
|
|
2733
2779
|
|
2734
2780
|
# Set the output image height in pixels. If it is not specified, actual document height is used.
|
2735
2781
|
#
|
2736
|
-
# * +height+ - Must be a positive integer
|
2782
|
+
# * +height+ - Must be a positive integer.
|
2737
2783
|
# * *Returns* - The converter object.
|
2738
2784
|
def setScreenshotHeight(height)
|
2739
2785
|
if (!(Integer(height) > 0))
|
2740
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setScreenshotHeight", "html-to-image", "Must be a positive integer
|
2786
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setScreenshotHeight", "html-to-image", "Must be a positive integer.", "set_screenshot_height"), 470);
|
2741
2787
|
end
|
2742
2788
|
|
2743
2789
|
@fields['screenshot_height'] = height
|
@@ -2746,11 +2792,11 @@ module Pdfcrowd
|
|
2746
2792
|
|
2747
2793
|
# Set the scaling factor (zoom) for the output image.
|
2748
2794
|
#
|
2749
|
-
# * +factor+ - The percentage value. Must be a positive integer
|
2795
|
+
# * +factor+ - The percentage value. Must be a positive integer.
|
2750
2796
|
# * *Returns* - The converter object.
|
2751
2797
|
def setScaleFactor(factor)
|
2752
2798
|
if (!(Integer(factor) > 0))
|
2753
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "html-to-image", "Must be a positive integer
|
2799
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "html-to-image", "Must be a positive integer.", "set_scale_factor"), 470);
|
2754
2800
|
end
|
2755
2801
|
|
2756
2802
|
@fields['scale_factor'] = factor
|
@@ -2864,19 +2910,13 @@ module Pdfcrowd
|
|
2864
2910
|
self
|
2865
2911
|
end
|
2866
2912
|
|
2867
|
-
|
2868
|
-
#
|
2869
|
-
# * +user_name+ - The user name.
|
2870
|
-
# * *Returns* - The converter object.
|
2913
|
+
|
2871
2914
|
def setHttpAuthUserName(user_name)
|
2872
2915
|
@fields['http_auth_user_name'] = user_name
|
2873
2916
|
self
|
2874
2917
|
end
|
2875
2918
|
|
2876
|
-
|
2877
|
-
#
|
2878
|
-
# * +password+ - The password.
|
2879
|
-
# * *Returns* - The converter object.
|
2919
|
+
|
2880
2920
|
def setHttpAuthPassword(password)
|
2881
2921
|
@fields['http_auth_password'] = password
|
2882
2922
|
self
|
@@ -2992,11 +3032,11 @@ module Pdfcrowd
|
|
2992
3032
|
|
2993
3033
|
# 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.
|
2994
3034
|
#
|
2995
|
-
# * +delay+ - The number of milliseconds to wait. Must be a positive integer
|
3035
|
+
# * +delay+ - The number of milliseconds to wait. Must be a positive integer or 0.
|
2996
3036
|
# * *Returns* - The converter object.
|
2997
3037
|
def setJavascriptDelay(delay)
|
2998
3038
|
if (!(Integer(delay) >= 0))
|
2999
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(delay, "setJavascriptDelay", "html-to-image", "Must be a positive integer
|
3039
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(delay, "setJavascriptDelay", "html-to-image", "Must be a positive integer or 0.", "set_javascript_delay"), 470);
|
3000
3040
|
end
|
3001
3041
|
|
3002
3042
|
@fields['javascript_delay'] = delay
|
@@ -3247,17 +3287,32 @@ module Pdfcrowd
|
|
3247
3287
|
|
3248
3288
|
# Set the maximum time to load the page and its resources. After this time, all requests will be considered successful. This can be useful to ensure that the conversion does not timeout. Use this method if there is no other way to fix page loading.
|
3249
3289
|
#
|
3250
|
-
# * +max_time+ - The number of seconds to wait. The
|
3290
|
+
# * +max_time+ - The number of seconds to wait. The accepted range is 10-30.
|
3251
3291
|
# * *Returns* - The converter object.
|
3252
3292
|
def setMaxLoadingTime(max_time)
|
3253
3293
|
if (!(Integer(max_time) >= 10 && Integer(max_time) <= 30))
|
3254
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(max_time, "setMaxLoadingTime", "html-to-image", "The
|
3294
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(max_time, "setMaxLoadingTime", "html-to-image", "The accepted range is 10-30.", "set_max_loading_time"), 470);
|
3255
3295
|
end
|
3256
3296
|
|
3257
3297
|
@fields['max_loading_time'] = max_time
|
3258
3298
|
self
|
3259
3299
|
end
|
3260
3300
|
|
3301
|
+
|
3302
|
+
def setSubprocessReferrer(referrer)
|
3303
|
+
@fields['subprocess_referrer'] = referrer
|
3304
|
+
self
|
3305
|
+
end
|
3306
|
+
|
3307
|
+
# Specifies the User-Agent HTTP header that will be used by the converter when a request is made to the converted web page.
|
3308
|
+
#
|
3309
|
+
# * +agent+ - The user agent.
|
3310
|
+
# * *Returns* - The converter object.
|
3311
|
+
def setConverterUserAgent(agent)
|
3312
|
+
@fields['converter_user_agent'] = agent
|
3313
|
+
self
|
3314
|
+
end
|
3315
|
+
|
3261
3316
|
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
3262
3317
|
#
|
3263
3318
|
# * +version+ - The version identifier. Allowed values are 24.04, 20.10, 18.10, latest.
|
@@ -3281,6 +3336,15 @@ module Pdfcrowd
|
|
3281
3336
|
self
|
3282
3337
|
end
|
3283
3338
|
|
3339
|
+
# Specifies the User-Agent HTTP header that the client library will use when interacting with the API.
|
3340
|
+
#
|
3341
|
+
# * +agent+ - The user agent string.
|
3342
|
+
# * *Returns* - The converter object.
|
3343
|
+
def setClientUserAgent(agent)
|
3344
|
+
@helper.setUserAgent(agent)
|
3345
|
+
self
|
3346
|
+
end
|
3347
|
+
|
3284
3348
|
# Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
|
3285
3349
|
#
|
3286
3350
|
# * +agent+ - The user agent string.
|
@@ -3332,11 +3396,11 @@ module Pdfcrowd
|
|
3332
3396
|
|
3333
3397
|
# Convert an image.
|
3334
3398
|
#
|
3335
|
-
# * +url+ - The address of the image to convert.
|
3399
|
+
# * +url+ - The address of the image to convert. Supported protocols are http:// and https://.
|
3336
3400
|
# * *Returns* - Byte array containing the conversion output.
|
3337
3401
|
def convertUrl(url)
|
3338
3402
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
3339
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-image", "
|
3403
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-image", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
3340
3404
|
end
|
3341
3405
|
|
3342
3406
|
@fields['url'] = url
|
@@ -3345,11 +3409,11 @@ module Pdfcrowd
|
|
3345
3409
|
|
3346
3410
|
# Convert an image and write the result to an output stream.
|
3347
3411
|
#
|
3348
|
-
# * +url+ - The address of the image to convert.
|
3412
|
+
# * +url+ - The address of the image to convert. Supported protocols are http:// and https://.
|
3349
3413
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
3350
3414
|
def convertUrlToStream(url, out_stream)
|
3351
3415
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
3352
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "image-to-image", "
|
3416
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "image-to-image", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
3353
3417
|
end
|
3354
3418
|
|
3355
3419
|
@fields['url'] = url
|
@@ -3358,7 +3422,7 @@ module Pdfcrowd
|
|
3358
3422
|
|
3359
3423
|
# Convert an image and write the result to a local file.
|
3360
3424
|
#
|
3361
|
-
# * +url+ - The address of the image to convert.
|
3425
|
+
# * +url+ - The address of the image to convert. Supported protocols are http:// and https://.
|
3362
3426
|
# * +file_path+ - The output file path. The string must not be empty.
|
3363
3427
|
def convertUrlToFile(url, file_path)
|
3364
3428
|
if (!(!file_path.nil? && !file_path.empty?))
|
@@ -3531,11 +3595,11 @@ module Pdfcrowd
|
|
3531
3595
|
|
3532
3596
|
# Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
|
3533
3597
|
#
|
3534
|
-
# * +x+ - The value must be specified in inches
|
3598
|
+
# * +x+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3535
3599
|
# * *Returns* - The converter object.
|
3536
3600
|
def setCropAreaX(x)
|
3537
3601
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(x)
|
3538
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setCropAreaX", "image-to-image", "The value must be specified in inches
|
3602
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setCropAreaX", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_crop_area_x"), 470);
|
3539
3603
|
end
|
3540
3604
|
|
3541
3605
|
@fields['crop_area_x'] = x
|
@@ -3544,11 +3608,11 @@ module Pdfcrowd
|
|
3544
3608
|
|
3545
3609
|
# Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
|
3546
3610
|
#
|
3547
|
-
# * +y+ - The value must be specified in inches
|
3611
|
+
# * +y+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3548
3612
|
# * *Returns* - The converter object.
|
3549
3613
|
def setCropAreaY(y)
|
3550
3614
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(y)
|
3551
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setCropAreaY", "image-to-image", "The value must be specified in inches
|
3615
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setCropAreaY", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_crop_area_y"), 470);
|
3552
3616
|
end
|
3553
3617
|
|
3554
3618
|
@fields['crop_area_y'] = y
|
@@ -3557,11 +3621,11 @@ module Pdfcrowd
|
|
3557
3621
|
|
3558
3622
|
# Set the width of the content area. It should be at least 1 inch.
|
3559
3623
|
#
|
3560
|
-
# * +width+ - The value must be specified in inches
|
3624
|
+
# * +width+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3561
3625
|
# * *Returns* - The converter object.
|
3562
3626
|
def setCropAreaWidth(width)
|
3563
3627
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
|
3564
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCropAreaWidth", "image-to-image", "The value must be specified in inches
|
3628
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCropAreaWidth", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_crop_area_width"), 470);
|
3565
3629
|
end
|
3566
3630
|
|
3567
3631
|
@fields['crop_area_width'] = width
|
@@ -3570,11 +3634,11 @@ module Pdfcrowd
|
|
3570
3634
|
|
3571
3635
|
# Set the height of the content area. It should be at least 1 inch.
|
3572
3636
|
#
|
3573
|
-
# * +height+ - The value must be specified in inches
|
3637
|
+
# * +height+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3574
3638
|
# * *Returns* - The converter object.
|
3575
3639
|
def setCropAreaHeight(height)
|
3576
3640
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
3577
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCropAreaHeight", "image-to-image", "The value must be specified in inches
|
3641
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCropAreaHeight", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_crop_area_height"), 470);
|
3578
3642
|
end
|
3579
3643
|
|
3580
3644
|
@fields['crop_area_height'] = height
|
@@ -3583,10 +3647,10 @@ module Pdfcrowd
|
|
3583
3647
|
|
3584
3648
|
# Set the content area position and size. The content area enables to specify the part to be converted.
|
3585
3649
|
#
|
3586
|
-
# * +x+ - Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area. The value must be specified in inches
|
3587
|
-
# * +y+ - Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. The value must be specified in inches
|
3588
|
-
# * +width+ - Set the width of the content area. It should be at least 1 inch. The value must be specified in inches
|
3589
|
-
# * +height+ - Set the height of the content area. It should be at least 1 inch. The value must be specified in inches
|
3650
|
+
# * +x+ - Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3651
|
+
# * +y+ - Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3652
|
+
# * +width+ - Set the width of the content area. It should be at least 1 inch. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3653
|
+
# * +height+ - Set the height of the content area. It should be at least 1 inch. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3590
3654
|
# * *Returns* - The converter object.
|
3591
3655
|
def setCropArea(x, y, width, height)
|
3592
3656
|
setCropAreaX(x)
|
@@ -3620,11 +3684,11 @@ module Pdfcrowd
|
|
3620
3684
|
|
3621
3685
|
# Set the output canvas width.
|
3622
3686
|
#
|
3623
|
-
# * +width+ - The value must be specified in inches
|
3687
|
+
# * +width+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3624
3688
|
# * *Returns* - The converter object.
|
3625
3689
|
def setCanvasWidth(width)
|
3626
3690
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
|
3627
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCanvasWidth", "image-to-image", "The value must be specified in inches
|
3691
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCanvasWidth", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_canvas_width"), 470);
|
3628
3692
|
end
|
3629
3693
|
|
3630
3694
|
@fields['canvas_width'] = width
|
@@ -3633,11 +3697,11 @@ module Pdfcrowd
|
|
3633
3697
|
|
3634
3698
|
# Set the output canvas height.
|
3635
3699
|
#
|
3636
|
-
# * +height+ - The value must be specified in inches
|
3700
|
+
# * +height+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3637
3701
|
# * *Returns* - The converter object.
|
3638
3702
|
def setCanvasHeight(height)
|
3639
3703
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
3640
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCanvasHeight", "image-to-image", "The value must be specified in inches
|
3704
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCanvasHeight", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_canvas_height"), 470);
|
3641
3705
|
end
|
3642
3706
|
|
3643
3707
|
@fields['canvas_height'] = height
|
@@ -3646,8 +3710,8 @@ module Pdfcrowd
|
|
3646
3710
|
|
3647
3711
|
# Set the output canvas dimensions. If no canvas size is specified, margins are applied as a border around the image.
|
3648
3712
|
#
|
3649
|
-
# * +width+ - Set the output canvas width. The value must be specified in inches
|
3650
|
-
# * +height+ - Set the output canvas height. The value must be specified in inches
|
3713
|
+
# * +width+ - Set the output canvas width. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3714
|
+
# * +height+ - Set the output canvas height. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3651
3715
|
# * *Returns* - The converter object.
|
3652
3716
|
def setCanvasDimensions(width, height)
|
3653
3717
|
setCanvasWidth(width)
|
@@ -3696,11 +3760,11 @@ module Pdfcrowd
|
|
3696
3760
|
|
3697
3761
|
# Set the output canvas top margin.
|
3698
3762
|
#
|
3699
|
-
# * +top+ - The value must be specified in inches
|
3763
|
+
# * +top+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3700
3764
|
# * *Returns* - The converter object.
|
3701
3765
|
def setMarginTop(top)
|
3702
3766
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(top)
|
3703
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(top, "setMarginTop", "image-to-image", "The value must be specified in inches
|
3767
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(top, "setMarginTop", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_margin_top"), 470);
|
3704
3768
|
end
|
3705
3769
|
|
3706
3770
|
@fields['margin_top'] = top
|
@@ -3709,11 +3773,11 @@ module Pdfcrowd
|
|
3709
3773
|
|
3710
3774
|
# Set the output canvas right margin.
|
3711
3775
|
#
|
3712
|
-
# * +right+ - The value must be specified in inches
|
3776
|
+
# * +right+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3713
3777
|
# * *Returns* - The converter object.
|
3714
3778
|
def setMarginRight(right)
|
3715
3779
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(right)
|
3716
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(right, "setMarginRight", "image-to-image", "The value must be specified in inches
|
3780
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(right, "setMarginRight", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_margin_right"), 470);
|
3717
3781
|
end
|
3718
3782
|
|
3719
3783
|
@fields['margin_right'] = right
|
@@ -3722,11 +3786,11 @@ module Pdfcrowd
|
|
3722
3786
|
|
3723
3787
|
# Set the output canvas bottom margin.
|
3724
3788
|
#
|
3725
|
-
# * +bottom+ - The value must be specified in inches
|
3789
|
+
# * +bottom+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3726
3790
|
# * *Returns* - The converter object.
|
3727
3791
|
def setMarginBottom(bottom)
|
3728
3792
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(bottom)
|
3729
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(bottom, "setMarginBottom", "image-to-image", "The value must be specified in inches
|
3793
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(bottom, "setMarginBottom", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_margin_bottom"), 470);
|
3730
3794
|
end
|
3731
3795
|
|
3732
3796
|
@fields['margin_bottom'] = bottom
|
@@ -3735,11 +3799,11 @@ module Pdfcrowd
|
|
3735
3799
|
|
3736
3800
|
# Set the output canvas left margin.
|
3737
3801
|
#
|
3738
|
-
# * +left+ - The value must be specified in inches
|
3802
|
+
# * +left+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3739
3803
|
# * *Returns* - The converter object.
|
3740
3804
|
def setMarginLeft(left)
|
3741
3805
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(left)
|
3742
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(left, "setMarginLeft", "image-to-image", "The value must be specified in inches
|
3806
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(left, "setMarginLeft", "image-to-image", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_margin_left"), 470);
|
3743
3807
|
end
|
3744
3808
|
|
3745
3809
|
@fields['margin_left'] = left
|
@@ -3748,10 +3812,10 @@ module Pdfcrowd
|
|
3748
3812
|
|
3749
3813
|
# Set the output canvas margins.
|
3750
3814
|
#
|
3751
|
-
# * +top+ - Set the output canvas top margin. The value must be specified in inches
|
3752
|
-
# * +right+ - Set the output canvas right margin. The value must be specified in inches
|
3753
|
-
# * +bottom+ - Set the output canvas bottom margin. The value must be specified in inches
|
3754
|
-
# * +left+ - Set the output canvas left margin. The value must be specified in inches
|
3815
|
+
# * +top+ - Set the output canvas top margin. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3816
|
+
# * +right+ - Set the output canvas right margin. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3817
|
+
# * +bottom+ - Set the output canvas bottom margin. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3818
|
+
# * +left+ - Set the output canvas left margin. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
3755
3819
|
# * *Returns* - The converter object.
|
3756
3820
|
def setMargins(top, right, bottom, left)
|
3757
3821
|
setMarginTop(top)
|
@@ -3889,6 +3953,15 @@ module Pdfcrowd
|
|
3889
3953
|
self
|
3890
3954
|
end
|
3891
3955
|
|
3956
|
+
# Specifies the User-Agent HTTP header that the client library will use when interacting with the API.
|
3957
|
+
#
|
3958
|
+
# * +agent+ - The user agent string.
|
3959
|
+
# * *Returns* - The converter object.
|
3960
|
+
def setClientUserAgent(agent)
|
3961
|
+
@helper.setUserAgent(agent)
|
3962
|
+
self
|
3963
|
+
end
|
3964
|
+
|
3892
3965
|
# Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
|
3893
3966
|
#
|
3894
3967
|
# * +agent+ - The user agent string.
|
@@ -4042,11 +4115,11 @@ module Pdfcrowd
|
|
4042
4115
|
|
4043
4116
|
# Load a file from the specified URL and apply the file as a watermark to each page of the output PDF. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.
|
4044
4117
|
#
|
4045
|
-
# * +url+ -
|
4118
|
+
# * +url+ - Supported protocols are http:// and https://.
|
4046
4119
|
# * *Returns* - The converter object.
|
4047
4120
|
def setPageWatermarkUrl(url)
|
4048
4121
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
4049
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageWatermarkUrl", "pdf-to-pdf", "
|
4122
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageWatermarkUrl", "pdf-to-pdf", "Supported protocols are http:// and https://.", "set_page_watermark_url"), 470);
|
4050
4123
|
end
|
4051
4124
|
|
4052
4125
|
@fields['page_watermark_url'] = url
|
@@ -4068,11 +4141,11 @@ module Pdfcrowd
|
|
4068
4141
|
|
4069
4142
|
# Load a file from the specified URL and apply each page of the file as a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.
|
4070
4143
|
#
|
4071
|
-
# * +url+ -
|
4144
|
+
# * +url+ - Supported protocols are http:// and https://.
|
4072
4145
|
# * *Returns* - The converter object.
|
4073
4146
|
def setMultipageWatermarkUrl(url)
|
4074
4147
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
4075
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageWatermarkUrl", "pdf-to-pdf", "
|
4148
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageWatermarkUrl", "pdf-to-pdf", "Supported protocols are http:// and https://.", "set_multipage_watermark_url"), 470);
|
4076
4149
|
end
|
4077
4150
|
|
4078
4151
|
@fields['multipage_watermark_url'] = url
|
@@ -4094,11 +4167,11 @@ module Pdfcrowd
|
|
4094
4167
|
|
4095
4168
|
# Load a file from the specified URL and apply the file as a background to each page of the output PDF. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.
|
4096
4169
|
#
|
4097
|
-
# * +url+ -
|
4170
|
+
# * +url+ - Supported protocols are http:// and https://.
|
4098
4171
|
# * *Returns* - The converter object.
|
4099
4172
|
def setPageBackgroundUrl(url)
|
4100
4173
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
4101
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageBackgroundUrl", "pdf-to-pdf", "
|
4174
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageBackgroundUrl", "pdf-to-pdf", "Supported protocols are http:// and https://.", "set_page_background_url"), 470);
|
4102
4175
|
end
|
4103
4176
|
|
4104
4177
|
@fields['page_background_url'] = url
|
@@ -4120,11 +4193,11 @@ module Pdfcrowd
|
|
4120
4193
|
|
4121
4194
|
# Load a file from the specified URL and apply each page of the file as a background to the corresponding page of the output PDF. A background can be either a PDF or an image.
|
4122
4195
|
#
|
4123
|
-
# * +url+ -
|
4196
|
+
# * +url+ - Supported protocols are http:// and https://.
|
4124
4197
|
# * *Returns* - The converter object.
|
4125
4198
|
def setMultipageBackgroundUrl(url)
|
4126
4199
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
4127
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageBackgroundUrl", "pdf-to-pdf", "
|
4200
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageBackgroundUrl", "pdf-to-pdf", "Supported protocols are http:// and https://.", "set_multipage_background_url"), 470);
|
4128
4201
|
end
|
4129
4202
|
|
4130
4203
|
@fields['multipage_background_url'] = url
|
@@ -4232,11 +4305,11 @@ module Pdfcrowd
|
|
4232
4305
|
|
4233
4306
|
# Use metadata (title, subject, author and keywords) from the n-th input PDF.
|
4234
4307
|
#
|
4235
|
-
# * +index+ - Set the index of the input PDF file from which to use the metadata. 0 means no metadata. Must be a positive integer
|
4308
|
+
# * +index+ - Set the index of the input PDF file from which to use the metadata. 0 means no metadata. Must be a positive integer or 0.
|
4236
4309
|
# * *Returns* - The converter object.
|
4237
4310
|
def setUseMetadataFrom(index)
|
4238
4311
|
if (!(Integer(index) >= 0))
|
4239
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(index, "setUseMetadataFrom", "pdf-to-pdf", "Must be a positive integer
|
4312
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(index, "setUseMetadataFrom", "pdf-to-pdf", "Must be a positive integer or 0.", "set_use_metadata_from"), 470);
|
4240
4313
|
end
|
4241
4314
|
|
4242
4315
|
@fields['use_metadata_from'] = index
|
@@ -4284,11 +4357,11 @@ module Pdfcrowd
|
|
4284
4357
|
|
4285
4358
|
# Display the specified page when the document is opened.
|
4286
4359
|
#
|
4287
|
-
# * +page+ - Must be a positive integer
|
4360
|
+
# * +page+ - Must be a positive integer.
|
4288
4361
|
# * *Returns* - The converter object.
|
4289
4362
|
def setInitialPage(page)
|
4290
4363
|
if (!(Integer(page) > 0))
|
4291
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "pdf-to-pdf", "Must be a positive integer
|
4364
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "pdf-to-pdf", "Must be a positive integer.", "set_initial_page"), 470);
|
4292
4365
|
end
|
4293
4366
|
|
4294
4367
|
@fields['initial_page'] = page
|
@@ -4297,11 +4370,11 @@ module Pdfcrowd
|
|
4297
4370
|
|
4298
4371
|
# Specify the initial page zoom in percents when the document is opened.
|
4299
4372
|
#
|
4300
|
-
# * +zoom+ - Must be a positive integer
|
4373
|
+
# * +zoom+ - Must be a positive integer.
|
4301
4374
|
# * *Returns* - The converter object.
|
4302
4375
|
def setInitialZoom(zoom)
|
4303
4376
|
if (!(Integer(zoom) > 0))
|
4304
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "pdf-to-pdf", "Must be a positive integer
|
4377
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "pdf-to-pdf", "Must be a positive integer.", "set_initial_zoom"), 470);
|
4305
4378
|
end
|
4306
4379
|
|
4307
4380
|
@fields['initial_zoom'] = zoom
|
@@ -4457,6 +4530,15 @@ module Pdfcrowd
|
|
4457
4530
|
self
|
4458
4531
|
end
|
4459
4532
|
|
4533
|
+
# Specifies the User-Agent HTTP header that the client library will use when interacting with the API.
|
4534
|
+
#
|
4535
|
+
# * +agent+ - The user agent string.
|
4536
|
+
# * *Returns* - The converter object.
|
4537
|
+
def setClientUserAgent(agent)
|
4538
|
+
@helper.setUserAgent(agent)
|
4539
|
+
self
|
4540
|
+
end
|
4541
|
+
|
4460
4542
|
# Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
|
4461
4543
|
#
|
4462
4544
|
# * +agent+ - The user agent string.
|
@@ -4508,11 +4590,11 @@ module Pdfcrowd
|
|
4508
4590
|
|
4509
4591
|
# Convert an image.
|
4510
4592
|
#
|
4511
|
-
# * +url+ - The address of the image to convert.
|
4593
|
+
# * +url+ - The address of the image to convert. Supported protocols are http:// and https://.
|
4512
4594
|
# * *Returns* - Byte array containing the conversion output.
|
4513
4595
|
def convertUrl(url)
|
4514
4596
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
4515
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-pdf", "
|
4597
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-pdf", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
4516
4598
|
end
|
4517
4599
|
|
4518
4600
|
@fields['url'] = url
|
@@ -4521,11 +4603,11 @@ module Pdfcrowd
|
|
4521
4603
|
|
4522
4604
|
# Convert an image and write the result to an output stream.
|
4523
4605
|
#
|
4524
|
-
# * +url+ - The address of the image to convert.
|
4606
|
+
# * +url+ - The address of the image to convert. Supported protocols are http:// and https://.
|
4525
4607
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
4526
4608
|
def convertUrlToStream(url, out_stream)
|
4527
4609
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
4528
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "image-to-pdf", "
|
4610
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "image-to-pdf", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
4529
4611
|
end
|
4530
4612
|
|
4531
4613
|
@fields['url'] = url
|
@@ -4534,7 +4616,7 @@ module Pdfcrowd
|
|
4534
4616
|
|
4535
4617
|
# Convert an image and write the result to a local file.
|
4536
4618
|
#
|
4537
|
-
# * +url+ - The address of the image to convert.
|
4619
|
+
# * +url+ - The address of the image to convert. Supported protocols are http:// and https://.
|
4538
4620
|
# * +file_path+ - The output file path. The string must not be empty.
|
4539
4621
|
def convertUrlToFile(url, file_path)
|
4540
4622
|
if (!(!file_path.nil? && !file_path.empty?))
|
@@ -4694,11 +4776,11 @@ module Pdfcrowd
|
|
4694
4776
|
|
4695
4777
|
# Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
|
4696
4778
|
#
|
4697
|
-
# * +x+ - The value must be specified in inches
|
4779
|
+
# * +x+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4698
4780
|
# * *Returns* - The converter object.
|
4699
4781
|
def setCropAreaX(x)
|
4700
4782
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(x)
|
4701
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setCropAreaX", "image-to-pdf", "The value must be specified in inches
|
4783
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setCropAreaX", "image-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_crop_area_x"), 470);
|
4702
4784
|
end
|
4703
4785
|
|
4704
4786
|
@fields['crop_area_x'] = x
|
@@ -4707,11 +4789,11 @@ module Pdfcrowd
|
|
4707
4789
|
|
4708
4790
|
# Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
|
4709
4791
|
#
|
4710
|
-
# * +y+ - The value must be specified in inches
|
4792
|
+
# * +y+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4711
4793
|
# * *Returns* - The converter object.
|
4712
4794
|
def setCropAreaY(y)
|
4713
4795
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(y)
|
4714
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setCropAreaY", "image-to-pdf", "The value must be specified in inches
|
4796
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setCropAreaY", "image-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_crop_area_y"), 470);
|
4715
4797
|
end
|
4716
4798
|
|
4717
4799
|
@fields['crop_area_y'] = y
|
@@ -4720,11 +4802,11 @@ module Pdfcrowd
|
|
4720
4802
|
|
4721
4803
|
# Set the width of the content area. It should be at least 1 inch.
|
4722
4804
|
#
|
4723
|
-
# * +width+ - The value must be specified in inches
|
4805
|
+
# * +width+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4724
4806
|
# * *Returns* - The converter object.
|
4725
4807
|
def setCropAreaWidth(width)
|
4726
4808
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
|
4727
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCropAreaWidth", "image-to-pdf", "The value must be specified in inches
|
4809
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCropAreaWidth", "image-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_crop_area_width"), 470);
|
4728
4810
|
end
|
4729
4811
|
|
4730
4812
|
@fields['crop_area_width'] = width
|
@@ -4733,11 +4815,11 @@ module Pdfcrowd
|
|
4733
4815
|
|
4734
4816
|
# Set the height of the content area. It should be at least 1 inch.
|
4735
4817
|
#
|
4736
|
-
# * +height+ - The value must be specified in inches
|
4818
|
+
# * +height+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4737
4819
|
# * *Returns* - The converter object.
|
4738
4820
|
def setCropAreaHeight(height)
|
4739
4821
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
4740
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCropAreaHeight", "image-to-pdf", "The value must be specified in inches
|
4822
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCropAreaHeight", "image-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_crop_area_height"), 470);
|
4741
4823
|
end
|
4742
4824
|
|
4743
4825
|
@fields['crop_area_height'] = height
|
@@ -4746,10 +4828,10 @@ module Pdfcrowd
|
|
4746
4828
|
|
4747
4829
|
# Set the content area position and size. The content area enables to specify the part to be converted.
|
4748
4830
|
#
|
4749
|
-
# * +x+ - Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area. The value must be specified in inches
|
4750
|
-
# * +y+ - Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. The value must be specified in inches
|
4751
|
-
# * +width+ - Set the width of the content area. It should be at least 1 inch. The value must be specified in inches
|
4752
|
-
# * +height+ - Set the height of the content area. It should be at least 1 inch. The value must be specified in inches
|
4831
|
+
# * +x+ - Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4832
|
+
# * +y+ - Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4833
|
+
# * +width+ - Set the width of the content area. It should be at least 1 inch. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4834
|
+
# * +height+ - Set the height of the content area. It should be at least 1 inch. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4753
4835
|
# * *Returns* - The converter object.
|
4754
4836
|
def setCropArea(x, y, width, height)
|
4755
4837
|
setCropAreaX(x)
|
@@ -4783,11 +4865,11 @@ module Pdfcrowd
|
|
4783
4865
|
|
4784
4866
|
# Set the output page width.
|
4785
4867
|
#
|
4786
|
-
# * +width+ - The value must be specified in inches
|
4868
|
+
# * +width+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4787
4869
|
# * *Returns* - The converter object.
|
4788
4870
|
def setPageWidth(width)
|
4789
4871
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
|
4790
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setPageWidth", "image-to-pdf", "The value must be specified in inches
|
4872
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setPageWidth", "image-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_page_width"), 470);
|
4791
4873
|
end
|
4792
4874
|
|
4793
4875
|
@fields['page_width'] = width
|
@@ -4796,11 +4878,11 @@ module Pdfcrowd
|
|
4796
4878
|
|
4797
4879
|
# Set the output page height.
|
4798
4880
|
#
|
4799
|
-
# * +height+ - The value must be specified in inches
|
4881
|
+
# * +height+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4800
4882
|
# * *Returns* - The converter object.
|
4801
4883
|
def setPageHeight(height)
|
4802
4884
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
4803
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setPageHeight", "image-to-pdf", "The value must be specified in inches
|
4885
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setPageHeight", "image-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_page_height"), 470);
|
4804
4886
|
end
|
4805
4887
|
|
4806
4888
|
@fields['page_height'] = height
|
@@ -4809,8 +4891,8 @@ module Pdfcrowd
|
|
4809
4891
|
|
4810
4892
|
# Set the output page dimensions. If no page size is specified, margins are applied as a border around the image.
|
4811
4893
|
#
|
4812
|
-
# * +width+ - Set the output page width. The value must be specified in inches
|
4813
|
-
# * +height+ - Set the output page height. The value must be specified in inches
|
4894
|
+
# * +width+ - Set the output page width. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4895
|
+
# * +height+ - Set the output page height. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4814
4896
|
# * *Returns* - The converter object.
|
4815
4897
|
def setPageDimensions(width, height)
|
4816
4898
|
setPageWidth(width)
|
@@ -4859,11 +4941,11 @@ module Pdfcrowd
|
|
4859
4941
|
|
4860
4942
|
# Set the output page top margin.
|
4861
4943
|
#
|
4862
|
-
# * +top+ - The value must be specified in inches
|
4944
|
+
# * +top+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4863
4945
|
# * *Returns* - The converter object.
|
4864
4946
|
def setMarginTop(top)
|
4865
4947
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(top)
|
4866
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(top, "setMarginTop", "image-to-pdf", "The value must be specified in inches
|
4948
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(top, "setMarginTop", "image-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_margin_top"), 470);
|
4867
4949
|
end
|
4868
4950
|
|
4869
4951
|
@fields['margin_top'] = top
|
@@ -4872,11 +4954,11 @@ module Pdfcrowd
|
|
4872
4954
|
|
4873
4955
|
# Set the output page right margin.
|
4874
4956
|
#
|
4875
|
-
# * +right+ - The value must be specified in inches
|
4957
|
+
# * +right+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4876
4958
|
# * *Returns* - The converter object.
|
4877
4959
|
def setMarginRight(right)
|
4878
4960
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(right)
|
4879
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(right, "setMarginRight", "image-to-pdf", "The value must be specified in inches
|
4961
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(right, "setMarginRight", "image-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_margin_right"), 470);
|
4880
4962
|
end
|
4881
4963
|
|
4882
4964
|
@fields['margin_right'] = right
|
@@ -4885,11 +4967,11 @@ module Pdfcrowd
|
|
4885
4967
|
|
4886
4968
|
# Set the output page bottom margin.
|
4887
4969
|
#
|
4888
|
-
# * +bottom+ - The value must be specified in inches
|
4970
|
+
# * +bottom+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4889
4971
|
# * *Returns* - The converter object.
|
4890
4972
|
def setMarginBottom(bottom)
|
4891
4973
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(bottom)
|
4892
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(bottom, "setMarginBottom", "image-to-pdf", "The value must be specified in inches
|
4974
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(bottom, "setMarginBottom", "image-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_margin_bottom"), 470);
|
4893
4975
|
end
|
4894
4976
|
|
4895
4977
|
@fields['margin_bottom'] = bottom
|
@@ -4898,11 +4980,11 @@ module Pdfcrowd
|
|
4898
4980
|
|
4899
4981
|
# Set the output page left margin.
|
4900
4982
|
#
|
4901
|
-
# * +left+ - The value must be specified in inches
|
4983
|
+
# * +left+ - The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4902
4984
|
# * *Returns* - The converter object.
|
4903
4985
|
def setMarginLeft(left)
|
4904
4986
|
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(left)
|
4905
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(left, "setMarginLeft", "image-to-pdf", "The value must be specified in inches
|
4987
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(left, "setMarginLeft", "image-to-pdf", "The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.", "set_margin_left"), 470);
|
4906
4988
|
end
|
4907
4989
|
|
4908
4990
|
@fields['margin_left'] = left
|
@@ -4911,10 +4993,10 @@ module Pdfcrowd
|
|
4911
4993
|
|
4912
4994
|
# Set the output page margins.
|
4913
4995
|
#
|
4914
|
-
# * +top+ - Set the output page top margin. The value must be specified in inches
|
4915
|
-
# * +right+ - Set the output page right margin. The value must be specified in inches
|
4916
|
-
# * +bottom+ - Set the output page bottom margin. The value must be specified in inches
|
4917
|
-
# * +left+ - Set the output page left margin. The value must be specified in inches
|
4996
|
+
# * +top+ - Set the output page top margin. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4997
|
+
# * +right+ - Set the output page right margin. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4998
|
+
# * +bottom+ - Set the output page bottom margin. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4999
|
+
# * +left+ - Set the output page left margin. The value must be specified in inches 'in', millimeters 'mm', centimeters 'cm', pixels 'px', or points 'pt'.
|
4918
5000
|
# * *Returns* - The converter object.
|
4919
5001
|
def setPageMargins(top, right, bottom, left)
|
4920
5002
|
setMarginTop(top)
|
@@ -4961,11 +5043,11 @@ module Pdfcrowd
|
|
4961
5043
|
|
4962
5044
|
# Load a file from the specified URL and apply the file as a watermark to each page of the output PDF. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.
|
4963
5045
|
#
|
4964
|
-
# * +url+ -
|
5046
|
+
# * +url+ - Supported protocols are http:// and https://.
|
4965
5047
|
# * *Returns* - The converter object.
|
4966
5048
|
def setPageWatermarkUrl(url)
|
4967
5049
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
4968
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageWatermarkUrl", "image-to-pdf", "
|
5050
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageWatermarkUrl", "image-to-pdf", "Supported protocols are http:// and https://.", "set_page_watermark_url"), 470);
|
4969
5051
|
end
|
4970
5052
|
|
4971
5053
|
@fields['page_watermark_url'] = url
|
@@ -4987,11 +5069,11 @@ module Pdfcrowd
|
|
4987
5069
|
|
4988
5070
|
# Load a file from the specified URL and apply each page of the file as a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.
|
4989
5071
|
#
|
4990
|
-
# * +url+ -
|
5072
|
+
# * +url+ - Supported protocols are http:// and https://.
|
4991
5073
|
# * *Returns* - The converter object.
|
4992
5074
|
def setMultipageWatermarkUrl(url)
|
4993
5075
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
4994
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageWatermarkUrl", "image-to-pdf", "
|
5076
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageWatermarkUrl", "image-to-pdf", "Supported protocols are http:// and https://.", "set_multipage_watermark_url"), 470);
|
4995
5077
|
end
|
4996
5078
|
|
4997
5079
|
@fields['multipage_watermark_url'] = url
|
@@ -5013,11 +5095,11 @@ module Pdfcrowd
|
|
5013
5095
|
|
5014
5096
|
# Load a file from the specified URL and apply the file as a background to each page of the output PDF. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.
|
5015
5097
|
#
|
5016
|
-
# * +url+ -
|
5098
|
+
# * +url+ - Supported protocols are http:// and https://.
|
5017
5099
|
# * *Returns* - The converter object.
|
5018
5100
|
def setPageBackgroundUrl(url)
|
5019
5101
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
5020
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageBackgroundUrl", "image-to-pdf", "
|
5102
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageBackgroundUrl", "image-to-pdf", "Supported protocols are http:// and https://.", "set_page_background_url"), 470);
|
5021
5103
|
end
|
5022
5104
|
|
5023
5105
|
@fields['page_background_url'] = url
|
@@ -5039,11 +5121,11 @@ module Pdfcrowd
|
|
5039
5121
|
|
5040
5122
|
# Load a file from the specified URL and apply each page of the file as a background to the corresponding page of the output PDF. A background can be either a PDF or an image.
|
5041
5123
|
#
|
5042
|
-
# * +url+ -
|
5124
|
+
# * +url+ - Supported protocols are http:// and https://.
|
5043
5125
|
# * *Returns* - The converter object.
|
5044
5126
|
def setMultipageBackgroundUrl(url)
|
5045
5127
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
5046
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageBackgroundUrl", "image-to-pdf", "
|
5128
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageBackgroundUrl", "image-to-pdf", "Supported protocols are http:// and https://.", "set_multipage_background_url"), 470);
|
5047
5129
|
end
|
5048
5130
|
|
5049
5131
|
@fields['multipage_background_url'] = url
|
@@ -5190,11 +5272,11 @@ module Pdfcrowd
|
|
5190
5272
|
|
5191
5273
|
# Display the specified page when the document is opened.
|
5192
5274
|
#
|
5193
|
-
# * +page+ - Must be a positive integer
|
5275
|
+
# * +page+ - Must be a positive integer.
|
5194
5276
|
# * *Returns* - The converter object.
|
5195
5277
|
def setInitialPage(page)
|
5196
5278
|
if (!(Integer(page) > 0))
|
5197
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "image-to-pdf", "Must be a positive integer
|
5279
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "image-to-pdf", "Must be a positive integer.", "set_initial_page"), 470);
|
5198
5280
|
end
|
5199
5281
|
|
5200
5282
|
@fields['initial_page'] = page
|
@@ -5203,11 +5285,11 @@ module Pdfcrowd
|
|
5203
5285
|
|
5204
5286
|
# Specify the initial page zoom in percents when the document is opened.
|
5205
5287
|
#
|
5206
|
-
# * +zoom+ - Must be a positive integer
|
5288
|
+
# * +zoom+ - Must be a positive integer.
|
5207
5289
|
# * *Returns* - The converter object.
|
5208
5290
|
def setInitialZoom(zoom)
|
5209
5291
|
if (!(Integer(zoom) > 0))
|
5210
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "image-to-pdf", "Must be a positive integer
|
5292
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "image-to-pdf", "Must be a positive integer.", "set_initial_zoom"), 470);
|
5211
5293
|
end
|
5212
5294
|
|
5213
5295
|
@fields['initial_zoom'] = zoom
|
@@ -5374,6 +5456,15 @@ module Pdfcrowd
|
|
5374
5456
|
self
|
5375
5457
|
end
|
5376
5458
|
|
5459
|
+
# Specifies the User-Agent HTTP header that the client library will use when interacting with the API.
|
5460
|
+
#
|
5461
|
+
# * +agent+ - The user agent string.
|
5462
|
+
# * *Returns* - The converter object.
|
5463
|
+
def setClientUserAgent(agent)
|
5464
|
+
@helper.setUserAgent(agent)
|
5465
|
+
self
|
5466
|
+
end
|
5467
|
+
|
5377
5468
|
# Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
|
5378
5469
|
#
|
5379
5470
|
# * +agent+ - The user agent string.
|
@@ -5425,11 +5516,11 @@ module Pdfcrowd
|
|
5425
5516
|
|
5426
5517
|
# Convert a PDF.
|
5427
5518
|
#
|
5428
|
-
# * +url+ - The address of the PDF to convert.
|
5519
|
+
# * +url+ - The address of the PDF to convert. Supported protocols are http:// and https://.
|
5429
5520
|
# * *Returns* - Byte array containing the conversion output.
|
5430
5521
|
def convertUrl(url)
|
5431
5522
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
5432
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-html", "
|
5523
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-html", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
5433
5524
|
end
|
5434
5525
|
|
5435
5526
|
@fields['url'] = url
|
@@ -5438,11 +5529,11 @@ module Pdfcrowd
|
|
5438
5529
|
|
5439
5530
|
# Convert a PDF and write the result to an output stream.
|
5440
5531
|
#
|
5441
|
-
# * +url+ - The address of the PDF to convert.
|
5532
|
+
# * +url+ - The address of the PDF to convert. Supported protocols are http:// and https://.
|
5442
5533
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
5443
5534
|
def convertUrlToStream(url, out_stream)
|
5444
5535
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
5445
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "pdf-to-html", "
|
5536
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "pdf-to-html", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
5446
5537
|
end
|
5447
5538
|
|
5448
5539
|
@fields['url'] = url
|
@@ -5451,7 +5542,7 @@ module Pdfcrowd
|
|
5451
5542
|
|
5452
5543
|
# Convert a PDF and write the result to a local file.
|
5453
5544
|
#
|
5454
|
-
# * +url+ - The address of the PDF to convert.
|
5545
|
+
# * +url+ - The address of the PDF to convert. Supported protocols are http:// and https://.
|
5455
5546
|
# * +file_path+ - The output file path. The string must not be empty. The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.
|
5456
5547
|
def convertUrlToFile(url, file_path)
|
5457
5548
|
if (!(!file_path.nil? && !file_path.empty?))
|
@@ -5618,11 +5709,11 @@ module Pdfcrowd
|
|
5618
5709
|
|
5619
5710
|
# Set the scaling factor (zoom) for the main page area.
|
5620
5711
|
#
|
5621
|
-
# * +factor+ - The percentage value. Must be a positive integer
|
5712
|
+
# * +factor+ - The percentage value. Must be a positive integer.
|
5622
5713
|
# * *Returns* - The converter object.
|
5623
5714
|
def setScaleFactor(factor)
|
5624
5715
|
if (!(Integer(factor) > 0))
|
5625
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "pdf-to-html", "Must be a positive integer
|
5716
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "pdf-to-html", "Must be a positive integer.", "set_scale_factor"), 470);
|
5626
5717
|
end
|
5627
5718
|
|
5628
5719
|
@fields['scale_factor'] = factor
|
@@ -5738,7 +5829,7 @@ module Pdfcrowd
|
|
5738
5829
|
self
|
5739
5830
|
end
|
5740
5831
|
|
5741
|
-
# Add
|
5832
|
+
# Add the specified prefix to all id and class attributes in the HTML content, creating a namespace for safe integration into another HTML document. This ensures unique identifiers, preventing conflicts when merging with other HTML.
|
5742
5833
|
#
|
5743
5834
|
# * +prefix+ - The prefix to add before each id and class attribute name. Start with a letter or underscore, and use only letters, numbers, hyphens, underscores, or colons.
|
5744
5835
|
# * *Returns* - The converter object.
|
@@ -5914,6 +6005,15 @@ module Pdfcrowd
|
|
5914
6005
|
self
|
5915
6006
|
end
|
5916
6007
|
|
6008
|
+
# Specifies the User-Agent HTTP header that the client library will use when interacting with the API.
|
6009
|
+
#
|
6010
|
+
# * +agent+ - The user agent string.
|
6011
|
+
# * *Returns* - The converter object.
|
6012
|
+
def setClientUserAgent(agent)
|
6013
|
+
@helper.setUserAgent(agent)
|
6014
|
+
self
|
6015
|
+
end
|
6016
|
+
|
5917
6017
|
# Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
|
5918
6018
|
#
|
5919
6019
|
# * +agent+ - The user agent string.
|
@@ -5971,11 +6071,11 @@ module Pdfcrowd
|
|
5971
6071
|
|
5972
6072
|
# Convert a PDF.
|
5973
6073
|
#
|
5974
|
-
# * +url+ - The address of the PDF to convert.
|
6074
|
+
# * +url+ - The address of the PDF to convert. Supported protocols are http:// and https://.
|
5975
6075
|
# * *Returns* - Byte array containing the conversion output.
|
5976
6076
|
def convertUrl(url)
|
5977
6077
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
5978
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-text", "
|
6078
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-text", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
5979
6079
|
end
|
5980
6080
|
|
5981
6081
|
@fields['url'] = url
|
@@ -5984,11 +6084,11 @@ module Pdfcrowd
|
|
5984
6084
|
|
5985
6085
|
# Convert a PDF and write the result to an output stream.
|
5986
6086
|
#
|
5987
|
-
# * +url+ - The address of the PDF to convert.
|
6087
|
+
# * +url+ - The address of the PDF to convert. Supported protocols are http:// and https://.
|
5988
6088
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
5989
6089
|
def convertUrlToStream(url, out_stream)
|
5990
6090
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
5991
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "pdf-to-text", "
|
6091
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "pdf-to-text", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
5992
6092
|
end
|
5993
6093
|
|
5994
6094
|
@fields['url'] = url
|
@@ -5997,7 +6097,7 @@ module Pdfcrowd
|
|
5997
6097
|
|
5998
6098
|
# Convert a PDF and write the result to a local file.
|
5999
6099
|
#
|
6000
|
-
# * +url+ - The address of the PDF to convert.
|
6100
|
+
# * +url+ - The address of the PDF to convert. Supported protocols are http:// and https://.
|
6001
6101
|
# * +file_path+ - The output file path. The string must not be empty.
|
6002
6102
|
def convertUrlToFile(url, file_path)
|
6003
6103
|
if (!(!file_path.nil? && !file_path.empty?))
|
@@ -6249,11 +6349,11 @@ module Pdfcrowd
|
|
6249
6349
|
|
6250
6350
|
# Set the top left X coordinate of the crop area in points.
|
6251
6351
|
#
|
6252
|
-
# * +x+ - Must be a positive integer
|
6352
|
+
# * +x+ - Must be a positive integer or 0.
|
6253
6353
|
# * *Returns* - The converter object.
|
6254
6354
|
def setCropAreaX(x)
|
6255
6355
|
if (!(Integer(x) >= 0))
|
6256
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setCropAreaX", "pdf-to-text", "Must be a positive integer
|
6356
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setCropAreaX", "pdf-to-text", "Must be a positive integer or 0.", "set_crop_area_x"), 470);
|
6257
6357
|
end
|
6258
6358
|
|
6259
6359
|
@fields['crop_area_x'] = x
|
@@ -6262,11 +6362,11 @@ module Pdfcrowd
|
|
6262
6362
|
|
6263
6363
|
# Set the top left Y coordinate of the crop area in points.
|
6264
6364
|
#
|
6265
|
-
# * +y+ - Must be a positive integer
|
6365
|
+
# * +y+ - Must be a positive integer or 0.
|
6266
6366
|
# * *Returns* - The converter object.
|
6267
6367
|
def setCropAreaY(y)
|
6268
6368
|
if (!(Integer(y) >= 0))
|
6269
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setCropAreaY", "pdf-to-text", "Must be a positive integer
|
6369
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setCropAreaY", "pdf-to-text", "Must be a positive integer or 0.", "set_crop_area_y"), 470);
|
6270
6370
|
end
|
6271
6371
|
|
6272
6372
|
@fields['crop_area_y'] = y
|
@@ -6275,11 +6375,11 @@ module Pdfcrowd
|
|
6275
6375
|
|
6276
6376
|
# Set the width of the crop area in points.
|
6277
6377
|
#
|
6278
|
-
# * +width+ - Must be a positive integer
|
6378
|
+
# * +width+ - Must be a positive integer or 0.
|
6279
6379
|
# * *Returns* - The converter object.
|
6280
6380
|
def setCropAreaWidth(width)
|
6281
6381
|
if (!(Integer(width) >= 0))
|
6282
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCropAreaWidth", "pdf-to-text", "Must be a positive integer
|
6382
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCropAreaWidth", "pdf-to-text", "Must be a positive integer or 0.", "set_crop_area_width"), 470);
|
6283
6383
|
end
|
6284
6384
|
|
6285
6385
|
@fields['crop_area_width'] = width
|
@@ -6288,11 +6388,11 @@ module Pdfcrowd
|
|
6288
6388
|
|
6289
6389
|
# Set the height of the crop area in points.
|
6290
6390
|
#
|
6291
|
-
# * +height+ - Must be a positive integer
|
6391
|
+
# * +height+ - Must be a positive integer or 0.
|
6292
6392
|
# * *Returns* - The converter object.
|
6293
6393
|
def setCropAreaHeight(height)
|
6294
6394
|
if (!(Integer(height) >= 0))
|
6295
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCropAreaHeight", "pdf-to-text", "Must be a positive integer
|
6395
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCropAreaHeight", "pdf-to-text", "Must be a positive integer or 0.", "set_crop_area_height"), 470);
|
6296
6396
|
end
|
6297
6397
|
|
6298
6398
|
@fields['crop_area_height'] = height
|
@@ -6301,10 +6401,10 @@ module Pdfcrowd
|
|
6301
6401
|
|
6302
6402
|
# Set the crop area. It allows to extract just a part of a PDF page.
|
6303
6403
|
#
|
6304
|
-
# * +x+ - Set the top left X coordinate of the crop area in points. Must be a positive integer
|
6305
|
-
# * +y+ - Set the top left Y coordinate of the crop area in points. Must be a positive integer
|
6306
|
-
# * +width+ - Set the width of the crop area in points. Must be a positive integer
|
6307
|
-
# * +height+ - Set the height of the crop area in points. Must be a positive integer
|
6404
|
+
# * +x+ - Set the top left X coordinate of the crop area in points. Must be a positive integer or 0.
|
6405
|
+
# * +y+ - Set the top left Y coordinate of the crop area in points. Must be a positive integer or 0.
|
6406
|
+
# * +width+ - Set the width of the crop area in points. Must be a positive integer or 0.
|
6407
|
+
# * +height+ - Set the height of the crop area in points. Must be a positive integer or 0.
|
6308
6408
|
# * *Returns* - The converter object.
|
6309
6409
|
def setCropArea(x, y, width, height)
|
6310
6410
|
setCropAreaX(x)
|
@@ -6413,6 +6513,15 @@ module Pdfcrowd
|
|
6413
6513
|
self
|
6414
6514
|
end
|
6415
6515
|
|
6516
|
+
# Specifies the User-Agent HTTP header that the client library will use when interacting with the API.
|
6517
|
+
#
|
6518
|
+
# * +agent+ - The user agent string.
|
6519
|
+
# * *Returns* - The converter object.
|
6520
|
+
def setClientUserAgent(agent)
|
6521
|
+
@helper.setUserAgent(agent)
|
6522
|
+
self
|
6523
|
+
end
|
6524
|
+
|
6416
6525
|
# Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
|
6417
6526
|
#
|
6418
6527
|
# * +agent+ - The user agent string.
|
@@ -6464,11 +6573,11 @@ module Pdfcrowd
|
|
6464
6573
|
|
6465
6574
|
# Convert an image.
|
6466
6575
|
#
|
6467
|
-
# * +url+ - The address of the image to convert.
|
6576
|
+
# * +url+ - The address of the image to convert. Supported protocols are http:// and https://.
|
6468
6577
|
# * *Returns* - Byte array containing the conversion output.
|
6469
6578
|
def convertUrl(url)
|
6470
6579
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
6471
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-image", "
|
6580
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-image", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
6472
6581
|
end
|
6473
6582
|
|
6474
6583
|
@fields['url'] = url
|
@@ -6477,11 +6586,11 @@ module Pdfcrowd
|
|
6477
6586
|
|
6478
6587
|
# Convert an image and write the result to an output stream.
|
6479
6588
|
#
|
6480
|
-
# * +url+ - The address of the image to convert.
|
6589
|
+
# * +url+ - The address of the image to convert. Supported protocols are http:// and https://.
|
6481
6590
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
6482
6591
|
def convertUrlToStream(url, out_stream)
|
6483
6592
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
6484
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "pdf-to-image", "
|
6593
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "pdf-to-image", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
6485
6594
|
end
|
6486
6595
|
|
6487
6596
|
@fields['url'] = url
|
@@ -6490,7 +6599,7 @@ module Pdfcrowd
|
|
6490
6599
|
|
6491
6600
|
# Convert an image and write the result to a local file.
|
6492
6601
|
#
|
6493
|
-
# * +url+ - The address of the image to convert.
|
6602
|
+
# * +url+ - The address of the image to convert. Supported protocols are http:// and https://.
|
6494
6603
|
# * +file_path+ - The output file path. The string must not be empty.
|
6495
6604
|
def convertUrlToFile(url, file_path)
|
6496
6605
|
if (!(!file_path.nil? && !file_path.empty?))
|
@@ -6700,11 +6809,11 @@ module Pdfcrowd
|
|
6700
6809
|
|
6701
6810
|
# Set the top left X coordinate of the crop area in points.
|
6702
6811
|
#
|
6703
|
-
# * +x+ - Must be a positive integer
|
6812
|
+
# * +x+ - Must be a positive integer or 0.
|
6704
6813
|
# * *Returns* - The converter object.
|
6705
6814
|
def setCropAreaX(x)
|
6706
6815
|
if (!(Integer(x) >= 0))
|
6707
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setCropAreaX", "pdf-to-image", "Must be a positive integer
|
6816
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setCropAreaX", "pdf-to-image", "Must be a positive integer or 0.", "set_crop_area_x"), 470);
|
6708
6817
|
end
|
6709
6818
|
|
6710
6819
|
@fields['crop_area_x'] = x
|
@@ -6713,11 +6822,11 @@ module Pdfcrowd
|
|
6713
6822
|
|
6714
6823
|
# Set the top left Y coordinate of the crop area in points.
|
6715
6824
|
#
|
6716
|
-
# * +y+ - Must be a positive integer
|
6825
|
+
# * +y+ - Must be a positive integer or 0.
|
6717
6826
|
# * *Returns* - The converter object.
|
6718
6827
|
def setCropAreaY(y)
|
6719
6828
|
if (!(Integer(y) >= 0))
|
6720
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setCropAreaY", "pdf-to-image", "Must be a positive integer
|
6829
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setCropAreaY", "pdf-to-image", "Must be a positive integer or 0.", "set_crop_area_y"), 470);
|
6721
6830
|
end
|
6722
6831
|
|
6723
6832
|
@fields['crop_area_y'] = y
|
@@ -6726,11 +6835,11 @@ module Pdfcrowd
|
|
6726
6835
|
|
6727
6836
|
# Set the width of the crop area in points.
|
6728
6837
|
#
|
6729
|
-
# * +width+ - Must be a positive integer
|
6838
|
+
# * +width+ - Must be a positive integer or 0.
|
6730
6839
|
# * *Returns* - The converter object.
|
6731
6840
|
def setCropAreaWidth(width)
|
6732
6841
|
if (!(Integer(width) >= 0))
|
6733
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCropAreaWidth", "pdf-to-image", "Must be a positive integer
|
6842
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCropAreaWidth", "pdf-to-image", "Must be a positive integer or 0.", "set_crop_area_width"), 470);
|
6734
6843
|
end
|
6735
6844
|
|
6736
6845
|
@fields['crop_area_width'] = width
|
@@ -6739,11 +6848,11 @@ module Pdfcrowd
|
|
6739
6848
|
|
6740
6849
|
# Set the height of the crop area in points.
|
6741
6850
|
#
|
6742
|
-
# * +height+ - Must be a positive integer
|
6851
|
+
# * +height+ - Must be a positive integer or 0.
|
6743
6852
|
# * *Returns* - The converter object.
|
6744
6853
|
def setCropAreaHeight(height)
|
6745
6854
|
if (!(Integer(height) >= 0))
|
6746
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCropAreaHeight", "pdf-to-image", "Must be a positive integer
|
6855
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCropAreaHeight", "pdf-to-image", "Must be a positive integer or 0.", "set_crop_area_height"), 470);
|
6747
6856
|
end
|
6748
6857
|
|
6749
6858
|
@fields['crop_area_height'] = height
|
@@ -6752,10 +6861,10 @@ module Pdfcrowd
|
|
6752
6861
|
|
6753
6862
|
# Set the crop area. It allows to extract just a part of a PDF page.
|
6754
6863
|
#
|
6755
|
-
# * +x+ - Set the top left X coordinate of the crop area in points. Must be a positive integer
|
6756
|
-
# * +y+ - Set the top left Y coordinate of the crop area in points. Must be a positive integer
|
6757
|
-
# * +width+ - Set the width of the crop area in points. Must be a positive integer
|
6758
|
-
# * +height+ - Set the height of the crop area in points. Must be a positive integer
|
6864
|
+
# * +x+ - Set the top left X coordinate of the crop area in points. Must be a positive integer or 0.
|
6865
|
+
# * +y+ - Set the top left Y coordinate of the crop area in points. Must be a positive integer or 0.
|
6866
|
+
# * +width+ - Set the width of the crop area in points. Must be a positive integer or 0.
|
6867
|
+
# * +height+ - Set the height of the crop area in points. Must be a positive integer or 0.
|
6759
6868
|
# * *Returns* - The converter object.
|
6760
6869
|
def setCropArea(x, y, width, height)
|
6761
6870
|
setCropAreaX(x)
|
@@ -6873,6 +6982,15 @@ module Pdfcrowd
|
|
6873
6982
|
self
|
6874
6983
|
end
|
6875
6984
|
|
6985
|
+
# Specifies the User-Agent HTTP header that the client library will use when interacting with the API.
|
6986
|
+
#
|
6987
|
+
# * +agent+ - The user agent string.
|
6988
|
+
# * *Returns* - The converter object.
|
6989
|
+
def setClientUserAgent(agent)
|
6990
|
+
@helper.setUserAgent(agent)
|
6991
|
+
self
|
6992
|
+
end
|
6993
|
+
|
6876
6994
|
# Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
|
6877
6995
|
#
|
6878
6996
|
# * +agent+ - The user agent string.
|