pdfcrowd 5.0.0 → 5.2.2
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 +478 -232
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e22bed7779bf0e1ef8c80b87beb45fa1f282de154265bd58c6d4caacfa709d6b
|
4
|
+
data.tar.gz: 2e1d7202fface710faeed72d73bbe0cd7698595e175223c52b005f86c3739854
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1223499de57fd5db8ff4a3ff0bd4dbf32017c1b9bc1b63733d4f4b40bfccb6934f8ac8a4dd9cc95d91913d577b9671182cc33acadac5857b1349d1995583a8bf
|
7
|
+
data.tar.gz: 8555f3aa2b3d0b617bef88bad26430cc0cf772655beec1c1915ebd7602594c6656fc1941a27d4a4dc71add24d81eabf40f44fb2f262d324306fef2b2b914f5ca
|
data/lib/pdfcrowd.rb
CHANGED
@@ -530,7 +530,7 @@ end
|
|
530
530
|
module Pdfcrowd
|
531
531
|
HOST = ENV["PDFCROWD_HOST"] || 'api.pdfcrowd.com'
|
532
532
|
MULTIPART_BOUNDARY = '----------ThIs_Is_tHe_bOUnDary_$'
|
533
|
-
CLIENT_VERSION = '5.
|
533
|
+
CLIENT_VERSION = '5.2.2'
|
534
534
|
|
535
535
|
class ConnectionHelper
|
536
536
|
def initialize(user_name, api_key)
|
@@ -541,7 +541,7 @@ module Pdfcrowd
|
|
541
541
|
|
542
542
|
setProxy(nil, nil, nil, nil)
|
543
543
|
setUseHttp(false)
|
544
|
-
setUserAgent('pdfcrowd_ruby_client/5.
|
544
|
+
setUserAgent('pdfcrowd_ruby_client/5.2.2 (https://pdfcrowd.com)')
|
545
545
|
|
546
546
|
@retry_count = 1
|
547
547
|
@converter_version = '20.10'
|
@@ -626,7 +626,7 @@ module Pdfcrowd
|
|
626
626
|
body << 'Content-Disposition: form-data; name="%s"; filename="%s"' % [name, file_name]
|
627
627
|
body << 'Content-Type: application/octet-stream'
|
628
628
|
body << ''
|
629
|
-
body << data
|
629
|
+
body << data.force_encoding('UTF-8')
|
630
630
|
end
|
631
631
|
|
632
632
|
def self.encode_multipart_post_data(fields, files, raw_data)
|
@@ -735,7 +735,7 @@ module Pdfcrowd
|
|
735
735
|
def self.create_invalid_value_message(value, field, converter, hint, id)
|
736
736
|
message = "Invalid value '%s' for %s." % [value, field]
|
737
737
|
message += " " + hint if hint
|
738
|
-
return message + " " + "Details: https://www.pdfcrowd.com/doc/api/%s/ruby/#%s" % [converter, id]
|
738
|
+
return message + " " + "Details: https://www.pdfcrowd.com/doc/api/%s/ruby/ref/#%s" % [converter, id]
|
739
739
|
end
|
740
740
|
|
741
741
|
# generated code
|
@@ -895,6 +895,53 @@ module Pdfcrowd
|
|
895
895
|
end
|
896
896
|
end
|
897
897
|
|
898
|
+
# Convert the contents of an input stream.
|
899
|
+
#
|
900
|
+
# * +in_stream+ - The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript).
|
901
|
+
# * *Returns* - Byte array containing the conversion output.
|
902
|
+
def convertStream(in_stream)
|
903
|
+
@raw_data['stream'] = in_stream.read
|
904
|
+
@helper.post(@fields, @files, @raw_data)
|
905
|
+
end
|
906
|
+
|
907
|
+
# Convert the contents of an input stream and write the result to an output stream.
|
908
|
+
#
|
909
|
+
# * +in_stream+ - The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript).
|
910
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
911
|
+
def convertStreamToStream(in_stream, out_stream)
|
912
|
+
@raw_data['stream'] = in_stream.read
|
913
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
914
|
+
end
|
915
|
+
|
916
|
+
# Convert the contents of an input stream and write the result to a local file.
|
917
|
+
#
|
918
|
+
# * +in_stream+ - The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript).
|
919
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
920
|
+
def convertStreamToFile(in_stream, file_path)
|
921
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
922
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "html-to-pdf", "The string must not be empty.", "convert_stream_to_file"), 470);
|
923
|
+
end
|
924
|
+
|
925
|
+
output_file = open(file_path, "wb")
|
926
|
+
begin
|
927
|
+
convertStreamToStream(in_stream, output_file)
|
928
|
+
output_file.close()
|
929
|
+
rescue Error => why
|
930
|
+
output_file.close()
|
931
|
+
FileUtils.rm(file_path)
|
932
|
+
raise
|
933
|
+
end
|
934
|
+
end
|
935
|
+
|
936
|
+
# Set the file name of the main HTML document stored in the input archive. If not specified, the first HTML file in the archive is used for conversion. Use this method if the input archive contains multiple HTML documents.
|
937
|
+
#
|
938
|
+
# * +filename+ - The file name.
|
939
|
+
# * *Returns* - The converter object.
|
940
|
+
def setZipMainFilename(filename)
|
941
|
+
@fields['zip_main_filename'] = filename
|
942
|
+
self
|
943
|
+
end
|
944
|
+
|
898
945
|
# Set the output page size.
|
899
946
|
#
|
900
947
|
# * +size+ - Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.
|
@@ -1034,93 +1081,6 @@ module Pdfcrowd
|
|
1034
1081
|
self
|
1035
1082
|
end
|
1036
1083
|
|
1037
|
-
# Load an HTML code from the specified URL and use it as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1038
|
-
#
|
1039
|
-
# * +url+ - The supported protocols are http:// and https://.
|
1040
|
-
# * *Returns* - The converter object.
|
1041
|
-
def setHeaderUrl(url)
|
1042
|
-
unless /(?i)^https?:\/\/.*$/.match(url)
|
1043
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setHeaderUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_header_url"), 470);
|
1044
|
-
end
|
1045
|
-
|
1046
|
-
@fields['header_url'] = url
|
1047
|
-
self
|
1048
|
-
end
|
1049
|
-
|
1050
|
-
# Use the specified HTML code as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1051
|
-
#
|
1052
|
-
# * +html+ - The string must not be empty.
|
1053
|
-
# * *Returns* - The converter object.
|
1054
|
-
def setHeaderHtml(html)
|
1055
|
-
if (!(!html.nil? && !html.empty?))
|
1056
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setHeaderHtml", "html-to-pdf", "The string must not be empty.", "set_header_html"), 470);
|
1057
|
-
end
|
1058
|
-
|
1059
|
-
@fields['header_html'] = html
|
1060
|
-
self
|
1061
|
-
end
|
1062
|
-
|
1063
|
-
# Set the header height.
|
1064
|
-
#
|
1065
|
-
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1066
|
-
# * *Returns* - The converter object.
|
1067
|
-
def setHeaderHeight(height)
|
1068
|
-
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1069
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setHeaderHeight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_header_height"), 470);
|
1070
|
-
end
|
1071
|
-
|
1072
|
-
@fields['header_height'] = height
|
1073
|
-
self
|
1074
|
-
end
|
1075
|
-
|
1076
|
-
# Load an HTML code from the specified URL and use it as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1077
|
-
#
|
1078
|
-
# * +url+ - The supported protocols are http:// and https://.
|
1079
|
-
# * *Returns* - The converter object.
|
1080
|
-
def setFooterUrl(url)
|
1081
|
-
unless /(?i)^https?:\/\/.*$/.match(url)
|
1082
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setFooterUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_footer_url"), 470);
|
1083
|
-
end
|
1084
|
-
|
1085
|
-
@fields['footer_url'] = url
|
1086
|
-
self
|
1087
|
-
end
|
1088
|
-
|
1089
|
-
# Use the specified HTML as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1090
|
-
#
|
1091
|
-
# * +html+ - The string must not be empty.
|
1092
|
-
# * *Returns* - The converter object.
|
1093
|
-
def setFooterHtml(html)
|
1094
|
-
if (!(!html.nil? && !html.empty?))
|
1095
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setFooterHtml", "html-to-pdf", "The string must not be empty.", "set_footer_html"), 470);
|
1096
|
-
end
|
1097
|
-
|
1098
|
-
@fields['footer_html'] = html
|
1099
|
-
self
|
1100
|
-
end
|
1101
|
-
|
1102
|
-
# Set the footer height.
|
1103
|
-
#
|
1104
|
-
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1105
|
-
# * *Returns* - The converter object.
|
1106
|
-
def setFooterHeight(height)
|
1107
|
-
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1108
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setFooterHeight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_footer_height"), 470);
|
1109
|
-
end
|
1110
|
-
|
1111
|
-
@fields['footer_height'] = height
|
1112
|
-
self
|
1113
|
-
end
|
1114
|
-
|
1115
|
-
# Disable horizontal page margins for header and footer. The header/footer contents width will be equal to the physical page width.
|
1116
|
-
#
|
1117
|
-
# * +value+ - Set to true to disable horizontal margins for header and footer.
|
1118
|
-
# * *Returns* - The converter object.
|
1119
|
-
def setNoHeaderFooterHorizontalMargins(value)
|
1120
|
-
@fields['no_header_footer_horizontal_margins'] = value
|
1121
|
-
self
|
1122
|
-
end
|
1123
|
-
|
1124
1084
|
# Set the page range to print.
|
1125
1085
|
#
|
1126
1086
|
# * +pages+ - A comma separated list of page numbers or ranges.
|
@@ -1134,32 +1094,6 @@ module Pdfcrowd
|
|
1134
1094
|
self
|
1135
1095
|
end
|
1136
1096
|
|
1137
|
-
# The page header is not printed on the specified pages.
|
1138
|
-
#
|
1139
|
-
# * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma separated list of page numbers.
|
1140
|
-
# * *Returns* - The converter object.
|
1141
|
-
def setExcludeHeaderOnPages(pages)
|
1142
|
-
unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
|
1143
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setExcludeHeaderOnPages", "html-to-pdf", "A comma separated list of page numbers.", "set_exclude_header_on_pages"), 470);
|
1144
|
-
end
|
1145
|
-
|
1146
|
-
@fields['exclude_header_on_pages'] = pages
|
1147
|
-
self
|
1148
|
-
end
|
1149
|
-
|
1150
|
-
# The page footer is not printed on the specified pages.
|
1151
|
-
#
|
1152
|
-
# * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma separated list of page numbers.
|
1153
|
-
# * *Returns* - The converter object.
|
1154
|
-
def setExcludeFooterOnPages(pages)
|
1155
|
-
unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
|
1156
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setExcludeFooterOnPages", "html-to-pdf", "A comma separated list of page numbers.", "set_exclude_footer_on_pages"), 470);
|
1157
|
-
end
|
1158
|
-
|
1159
|
-
@fields['exclude_footer_on_pages'] = pages
|
1160
|
-
self
|
1161
|
-
end
|
1162
|
-
|
1163
1097
|
# Set an offset between physical and logical page numbers.
|
1164
1098
|
#
|
1165
1099
|
# * +offset+ - Integer specifying page offset.
|
@@ -1249,79 +1183,147 @@ module Pdfcrowd
|
|
1249
1183
|
self
|
1250
1184
|
end
|
1251
1185
|
|
1252
|
-
#
|
1186
|
+
# Load an HTML code from the specified URL and use it as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1253
1187
|
#
|
1254
|
-
# * +
|
1188
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1255
1189
|
# * *Returns* - The converter object.
|
1256
|
-
def
|
1257
|
-
|
1190
|
+
def setHeaderUrl(url)
|
1191
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1192
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setHeaderUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_header_url"), 470);
|
1193
|
+
end
|
1194
|
+
|
1195
|
+
@fields['header_url'] = url
|
1258
1196
|
self
|
1259
1197
|
end
|
1260
1198
|
|
1261
|
-
#
|
1199
|
+
# Use the specified HTML code as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1262
1200
|
#
|
1263
|
-
# * +
|
1201
|
+
# * +html+ - The string must not be empty.
|
1264
1202
|
# * *Returns* - The converter object.
|
1265
|
-
def
|
1266
|
-
|
1203
|
+
def setHeaderHtml(html)
|
1204
|
+
if (!(!html.nil? && !html.empty?))
|
1205
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setHeaderHtml", "html-to-pdf", "The string must not be empty.", "set_header_html"), 470);
|
1206
|
+
end
|
1207
|
+
|
1208
|
+
@fields['header_html'] = html
|
1267
1209
|
self
|
1268
1210
|
end
|
1269
1211
|
|
1270
|
-
#
|
1212
|
+
# Set the header height.
|
1271
1213
|
#
|
1272
|
-
# * +
|
1214
|
+
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1273
1215
|
# * *Returns* - The converter object.
|
1274
|
-
def
|
1275
|
-
unless /(?i)^(
|
1276
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1216
|
+
def setHeaderHeight(height)
|
1217
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1218
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setHeaderHeight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_header_height"), 470);
|
1277
1219
|
end
|
1278
1220
|
|
1279
|
-
@fields['
|
1221
|
+
@fields['header_height'] = height
|
1280
1222
|
self
|
1281
1223
|
end
|
1282
1224
|
|
1283
|
-
# Set the
|
1225
|
+
# Set the file name of the header HTML document stored in the input archive. Use this method if the input archive contains multiple HTML documents.
|
1284
1226
|
#
|
1285
|
-
# * +
|
1227
|
+
# * +filename+ - The file name.
|
1286
1228
|
# * *Returns* - The converter object.
|
1287
|
-
def
|
1288
|
-
@fields['
|
1229
|
+
def setZipHeaderFilename(filename)
|
1230
|
+
@fields['zip_header_filename'] = filename
|
1289
1231
|
self
|
1290
1232
|
end
|
1291
1233
|
|
1292
|
-
#
|
1234
|
+
# Load an HTML code from the specified URL and use it as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1293
1235
|
#
|
1294
|
-
# * +
|
1236
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1295
1237
|
# * *Returns* - The converter object.
|
1296
|
-
def
|
1297
|
-
|
1238
|
+
def setFooterUrl(url)
|
1239
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1240
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setFooterUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_footer_url"), 470);
|
1241
|
+
end
|
1242
|
+
|
1243
|
+
@fields['footer_url'] = url
|
1298
1244
|
self
|
1299
1245
|
end
|
1300
1246
|
|
1301
|
-
#
|
1247
|
+
# Use the specified HTML as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1302
1248
|
#
|
1303
|
-
# * +
|
1249
|
+
# * +html+ - The string must not be empty.
|
1304
1250
|
# * *Returns* - The converter object.
|
1305
|
-
def
|
1306
|
-
|
1251
|
+
def setFooterHtml(html)
|
1252
|
+
if (!(!html.nil? && !html.empty?))
|
1253
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setFooterHtml", "html-to-pdf", "The string must not be empty.", "set_footer_html"), 470);
|
1254
|
+
end
|
1255
|
+
|
1256
|
+
@fields['footer_html'] = html
|
1307
1257
|
self
|
1308
1258
|
end
|
1309
1259
|
|
1310
|
-
#
|
1260
|
+
# Set the footer height.
|
1311
1261
|
#
|
1312
|
-
# * +
|
1262
|
+
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1313
1263
|
# * *Returns* - The converter object.
|
1314
|
-
def
|
1315
|
-
|
1264
|
+
def setFooterHeight(height)
|
1265
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1266
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setFooterHeight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_footer_height"), 470);
|
1267
|
+
end
|
1268
|
+
|
1269
|
+
@fields['footer_height'] = height
|
1316
1270
|
self
|
1317
1271
|
end
|
1318
1272
|
|
1319
|
-
# Set the
|
1273
|
+
# Set the file name of the footer HTML document stored in the input archive. Use this method if the input archive contains multiple HTML documents.
|
1320
1274
|
#
|
1321
|
-
# * +
|
1275
|
+
# * +filename+ - The file name.
|
1322
1276
|
# * *Returns* - The converter object.
|
1323
|
-
def
|
1324
|
-
@fields['
|
1277
|
+
def setZipFooterFilename(filename)
|
1278
|
+
@fields['zip_footer_filename'] = filename
|
1279
|
+
self
|
1280
|
+
end
|
1281
|
+
|
1282
|
+
# Disable horizontal page margins for header and footer. The header/footer contents width will be equal to the physical page width.
|
1283
|
+
#
|
1284
|
+
# * +value+ - Set to true to disable horizontal margins for header and footer.
|
1285
|
+
# * *Returns* - The converter object.
|
1286
|
+
def setNoHeaderFooterHorizontalMargins(value)
|
1287
|
+
@fields['no_header_footer_horizontal_margins'] = value
|
1288
|
+
self
|
1289
|
+
end
|
1290
|
+
|
1291
|
+
# The page header is not printed on the specified pages.
|
1292
|
+
#
|
1293
|
+
# * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma separated list of page numbers.
|
1294
|
+
# * *Returns* - The converter object.
|
1295
|
+
def setExcludeHeaderOnPages(pages)
|
1296
|
+
unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
|
1297
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setExcludeHeaderOnPages", "html-to-pdf", "A comma separated list of page numbers.", "set_exclude_header_on_pages"), 470);
|
1298
|
+
end
|
1299
|
+
|
1300
|
+
@fields['exclude_header_on_pages'] = pages
|
1301
|
+
self
|
1302
|
+
end
|
1303
|
+
|
1304
|
+
# The page footer is not printed on the specified pages.
|
1305
|
+
#
|
1306
|
+
# * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma separated list of page numbers.
|
1307
|
+
# * *Returns* - The converter object.
|
1308
|
+
def setExcludeFooterOnPages(pages)
|
1309
|
+
unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
|
1310
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setExcludeFooterOnPages", "html-to-pdf", "A comma separated list of page numbers.", "set_exclude_footer_on_pages"), 470);
|
1311
|
+
end
|
1312
|
+
|
1313
|
+
@fields['exclude_footer_on_pages'] = pages
|
1314
|
+
self
|
1315
|
+
end
|
1316
|
+
|
1317
|
+
# Set the scaling factor (zoom) for the header and footer.
|
1318
|
+
#
|
1319
|
+
# * +factor+ - The percentage value. The value must be in the range 10-500.
|
1320
|
+
# * *Returns* - The converter object.
|
1321
|
+
def setHeaderFooterScaleFactor(factor)
|
1322
|
+
if (!(Integer(factor) >= 10 && Integer(factor) <= 500))
|
1323
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setHeaderFooterScaleFactor", "html-to-pdf", "The value must be in the range 10-500.", "set_header_footer_scale_factor"), 470);
|
1324
|
+
end
|
1325
|
+
|
1326
|
+
@fields['header_footer_scale_factor'] = factor
|
1325
1327
|
self
|
1326
1328
|
end
|
1327
1329
|
|
@@ -1666,7 +1668,7 @@ module Pdfcrowd
|
|
1666
1668
|
self
|
1667
1669
|
end
|
1668
1670
|
|
1669
|
-
# Specify the DOM handling when only a part of the document is converted.
|
1671
|
+
# Specify the DOM handling when only a part of the document is converted. This can affect the CSS rules used.
|
1670
1672
|
#
|
1671
1673
|
# * +mode+ - Allowed values are cut-out, remove-siblings, hide-siblings.
|
1672
1674
|
# * *Returns* - The converter object.
|
@@ -1768,19 +1770,6 @@ module Pdfcrowd
|
|
1768
1770
|
self
|
1769
1771
|
end
|
1770
1772
|
|
1771
|
-
# Set the scaling factor (zoom) for the header and footer.
|
1772
|
-
#
|
1773
|
-
# * +factor+ - The percentage value. The value must be in the range 10-500.
|
1774
|
-
# * *Returns* - The converter object.
|
1775
|
-
def setHeaderFooterScaleFactor(factor)
|
1776
|
-
if (!(Integer(factor) >= 10 && Integer(factor) <= 500))
|
1777
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setHeaderFooterScaleFactor", "html-to-pdf", "The value must be in the range 10-500.", "set_header_footer_scale_factor"), 470);
|
1778
|
-
end
|
1779
|
-
|
1780
|
-
@fields['header_footer_scale_factor'] = factor
|
1781
|
-
self
|
1782
|
-
end
|
1783
|
-
|
1784
1773
|
# Set the quality of embedded JPEG images. A lower quality results in a smaller PDF file but can lead to compression artifacts.
|
1785
1774
|
#
|
1786
1775
|
# * +quality+ - The percentage value. The value must be in the range 1-100.
|
@@ -1919,6 +1908,15 @@ module Pdfcrowd
|
|
1919
1908
|
self
|
1920
1909
|
end
|
1921
1910
|
|
1911
|
+
# Extract meta tags (author, keywords and description) from the input HTML and use them in the output PDF.
|
1912
|
+
#
|
1913
|
+
# * +value+ - Set to true to extract meta tags.
|
1914
|
+
# * *Returns* - The converter object.
|
1915
|
+
def setExtractMetaTags(value)
|
1916
|
+
@fields['extract_meta_tags'] = value
|
1917
|
+
self
|
1918
|
+
end
|
1919
|
+
|
1922
1920
|
# Specify the page layout to be used when the document is opened.
|
1923
1921
|
#
|
1924
1922
|
# * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
|
@@ -2033,17 +2031,93 @@ module Pdfcrowd
|
|
2033
2031
|
#
|
2034
2032
|
# * +value+ - Set to true to display the title.
|
2035
2033
|
# * *Returns* - The converter object.
|
2036
|
-
def setDisplayTitle(value)
|
2037
|
-
@fields['display_title'] = value
|
2034
|
+
def setDisplayTitle(value)
|
2035
|
+
@fields['display_title'] = value
|
2036
|
+
self
|
2037
|
+
end
|
2038
|
+
|
2039
|
+
# Set the predominant reading order for text to right-to-left. This option has no direct effect on the document's contents or page numbering but can be used to determine the relative positioning of pages when displayed side by side or printed n-up
|
2040
|
+
#
|
2041
|
+
# * +value+ - Set to true to set right-to-left reading order.
|
2042
|
+
# * *Returns* - The converter object.
|
2043
|
+
def setRightToLeft(value)
|
2044
|
+
@fields['right_to_left'] = value
|
2045
|
+
self
|
2046
|
+
end
|
2047
|
+
|
2048
|
+
# Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
|
2049
|
+
#
|
2050
|
+
# * +data_string+ - The input data string.
|
2051
|
+
# * *Returns* - The converter object.
|
2052
|
+
def setDataString(data_string)
|
2053
|
+
@fields['data_string'] = data_string
|
2054
|
+
self
|
2055
|
+
end
|
2056
|
+
|
2057
|
+
# Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
|
2058
|
+
#
|
2059
|
+
# * +data_file+ - The file path to a local file containing the input data.
|
2060
|
+
# * *Returns* - The converter object.
|
2061
|
+
def setDataFile(data_file)
|
2062
|
+
@files['data_file'] = data_file
|
2063
|
+
self
|
2064
|
+
end
|
2065
|
+
|
2066
|
+
# Specify the input data format.
|
2067
|
+
#
|
2068
|
+
# * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
|
2069
|
+
# * *Returns* - The converter object.
|
2070
|
+
def setDataFormat(data_format)
|
2071
|
+
unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
|
2072
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(data_format, "setDataFormat", "html-to-pdf", "Allowed values are auto, json, xml, yaml, csv.", "set_data_format"), 470);
|
2073
|
+
end
|
2074
|
+
|
2075
|
+
@fields['data_format'] = data_format
|
2076
|
+
self
|
2077
|
+
end
|
2078
|
+
|
2079
|
+
# Set the encoding of the data file set by setDataFile.
|
2080
|
+
#
|
2081
|
+
# * +encoding+ - The data file encoding.
|
2082
|
+
# * *Returns* - The converter object.
|
2083
|
+
def setDataEncoding(encoding)
|
2084
|
+
@fields['data_encoding'] = encoding
|
2085
|
+
self
|
2086
|
+
end
|
2087
|
+
|
2088
|
+
# Ignore undefined variables in the HTML template. The default mode is strict so any undefined variable causes the conversion to fail. You can use {% if variable is defined %} to check if the variable is defined.
|
2089
|
+
#
|
2090
|
+
# * +value+ - Set to true to ignore undefined variables.
|
2091
|
+
# * *Returns* - The converter object.
|
2092
|
+
def setDataIgnoreUndefined(value)
|
2093
|
+
@fields['data_ignore_undefined'] = value
|
2094
|
+
self
|
2095
|
+
end
|
2096
|
+
|
2097
|
+
# Auto escape HTML symbols in the input data before placing them into the output.
|
2098
|
+
#
|
2099
|
+
# * +value+ - Set to true to turn auto escaping on.
|
2100
|
+
# * *Returns* - The converter object.
|
2101
|
+
def setDataAutoEscape(value)
|
2102
|
+
@fields['data_auto_escape'] = value
|
2103
|
+
self
|
2104
|
+
end
|
2105
|
+
|
2106
|
+
# Auto trim whitespace around each template command block.
|
2107
|
+
#
|
2108
|
+
# * +value+ - Set to true to turn auto trimming on.
|
2109
|
+
# * *Returns* - The converter object.
|
2110
|
+
def setDataTrimBlocks(value)
|
2111
|
+
@fields['data_trim_blocks'] = value
|
2038
2112
|
self
|
2039
2113
|
end
|
2040
2114
|
|
2041
|
-
# Set the
|
2115
|
+
# Set the advanced data options:csv_delimiter - The CSV data delimiter, the default is ,.xml_remove_root - Remove the root XML element from the input data.data_root - The name of the root element inserted into the input data without a root node (e.g. CSV), the default is data.
|
2042
2116
|
#
|
2043
|
-
# * +
|
2117
|
+
# * +options+ - Comma separated list of options.
|
2044
2118
|
# * *Returns* - The converter object.
|
2045
|
-
def
|
2046
|
-
@fields['
|
2119
|
+
def setDataOptions(options)
|
2120
|
+
@fields['data_options'] = options
|
2047
2121
|
self
|
2048
2122
|
end
|
2049
2123
|
|
@@ -2449,79 +2523,50 @@ module Pdfcrowd
|
|
2449
2523
|
end
|
2450
2524
|
end
|
2451
2525
|
|
2452
|
-
#
|
2526
|
+
# Convert the contents of an input stream.
|
2453
2527
|
#
|
2454
|
-
# * +
|
2455
|
-
# * *Returns* -
|
2456
|
-
def
|
2457
|
-
@
|
2458
|
-
|
2528
|
+
# * +in_stream+ - The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript).
|
2529
|
+
# * *Returns* - Byte array containing the conversion output.
|
2530
|
+
def convertStream(in_stream)
|
2531
|
+
@raw_data['stream'] = in_stream.read
|
2532
|
+
@helper.post(@fields, @files, @raw_data)
|
2459
2533
|
end
|
2460
2534
|
|
2461
|
-
#
|
2535
|
+
# Convert the contents of an input stream and write the result to an output stream.
|
2462
2536
|
#
|
2463
|
-
# * +
|
2464
|
-
# *
|
2465
|
-
def
|
2466
|
-
@
|
2467
|
-
|
2537
|
+
# * +in_stream+ - The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript).
|
2538
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
2539
|
+
def convertStreamToStream(in_stream, out_stream)
|
2540
|
+
@raw_data['stream'] = in_stream.read
|
2541
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
2468
2542
|
end
|
2469
2543
|
|
2470
|
-
#
|
2544
|
+
# Convert the contents of an input stream and write the result to a local file.
|
2471
2545
|
#
|
2472
|
-
# * +
|
2473
|
-
# *
|
2474
|
-
def
|
2475
|
-
|
2476
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2546
|
+
# * +in_stream+ - The input stream with source data. The stream can contain either HTML code or an archive (.zip, .tar.gz, .tar.bz2).The archive can contain HTML code and its external assets (images, style sheets, javascript).
|
2547
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
2548
|
+
def convertStreamToFile(in_stream, file_path)
|
2549
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
2550
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "html-to-image", "The string must not be empty.", "convert_stream_to_file"), 470);
|
2477
2551
|
end
|
2478
2552
|
|
2479
|
-
|
2480
|
-
|
2481
|
-
|
2482
|
-
|
2483
|
-
|
2484
|
-
|
2485
|
-
|
2486
|
-
|
2487
|
-
|
2488
|
-
@fields['data_encoding'] = encoding
|
2489
|
-
self
|
2490
|
-
end
|
2491
|
-
|
2492
|
-
# Ignore undefined variables in the HTML template. The default mode is strict so any undefined variable causes the conversion to fail. You can use {% if variable is defined %} to check if the variable is defined.
|
2493
|
-
#
|
2494
|
-
# * +value+ - Set to true to ignore undefined variables.
|
2495
|
-
# * *Returns* - The converter object.
|
2496
|
-
def setDataIgnoreUndefined(value)
|
2497
|
-
@fields['data_ignore_undefined'] = value
|
2498
|
-
self
|
2499
|
-
end
|
2500
|
-
|
2501
|
-
# Auto escape HTML symbols in the input data before placing them into the output.
|
2502
|
-
#
|
2503
|
-
# * +value+ - Set to true to turn auto escaping on.
|
2504
|
-
# * *Returns* - The converter object.
|
2505
|
-
def setDataAutoEscape(value)
|
2506
|
-
@fields['data_auto_escape'] = value
|
2507
|
-
self
|
2508
|
-
end
|
2509
|
-
|
2510
|
-
# Auto trim whitespace around each template command block.
|
2511
|
-
#
|
2512
|
-
# * +value+ - Set to true to turn auto trimming on.
|
2513
|
-
# * *Returns* - The converter object.
|
2514
|
-
def setDataTrimBlocks(value)
|
2515
|
-
@fields['data_trim_blocks'] = value
|
2516
|
-
self
|
2553
|
+
output_file = open(file_path, "wb")
|
2554
|
+
begin
|
2555
|
+
convertStreamToStream(in_stream, output_file)
|
2556
|
+
output_file.close()
|
2557
|
+
rescue Error => why
|
2558
|
+
output_file.close()
|
2559
|
+
FileUtils.rm(file_path)
|
2560
|
+
raise
|
2561
|
+
end
|
2517
2562
|
end
|
2518
2563
|
|
2519
|
-
# Set the
|
2564
|
+
# Set the file name of the main HTML document stored in the input archive. If not specified, the first HTML file in the archive is used for conversion. Use this method if the input archive contains multiple HTML documents.
|
2520
2565
|
#
|
2521
|
-
# * +
|
2566
|
+
# * +filename+ - The file name.
|
2522
2567
|
# * *Returns* - The converter object.
|
2523
|
-
def
|
2524
|
-
@fields['
|
2568
|
+
def setZipMainFilename(filename)
|
2569
|
+
@fields['zip_main_filename'] = filename
|
2525
2570
|
self
|
2526
2571
|
end
|
2527
2572
|
|
@@ -2749,7 +2794,7 @@ module Pdfcrowd
|
|
2749
2794
|
self
|
2750
2795
|
end
|
2751
2796
|
|
2752
|
-
# Specify the DOM handling when only a part of the document is converted.
|
2797
|
+
# Specify the DOM handling when only a part of the document is converted. This can affect the CSS rules used.
|
2753
2798
|
#
|
2754
2799
|
# * +mode+ - Allowed values are cut-out, remove-siblings, hide-siblings.
|
2755
2800
|
# * *Returns* - The converter object.
|
@@ -2827,6 +2872,82 @@ module Pdfcrowd
|
|
2827
2872
|
self
|
2828
2873
|
end
|
2829
2874
|
|
2875
|
+
# Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
|
2876
|
+
#
|
2877
|
+
# * +data_string+ - The input data string.
|
2878
|
+
# * *Returns* - The converter object.
|
2879
|
+
def setDataString(data_string)
|
2880
|
+
@fields['data_string'] = data_string
|
2881
|
+
self
|
2882
|
+
end
|
2883
|
+
|
2884
|
+
# Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
|
2885
|
+
#
|
2886
|
+
# * +data_file+ - The file path to a local file containing the input data.
|
2887
|
+
# * *Returns* - The converter object.
|
2888
|
+
def setDataFile(data_file)
|
2889
|
+
@files['data_file'] = data_file
|
2890
|
+
self
|
2891
|
+
end
|
2892
|
+
|
2893
|
+
# Specify the input data format.
|
2894
|
+
#
|
2895
|
+
# * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
|
2896
|
+
# * *Returns* - The converter object.
|
2897
|
+
def setDataFormat(data_format)
|
2898
|
+
unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
|
2899
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(data_format, "setDataFormat", "html-to-image", "Allowed values are auto, json, xml, yaml, csv.", "set_data_format"), 470);
|
2900
|
+
end
|
2901
|
+
|
2902
|
+
@fields['data_format'] = data_format
|
2903
|
+
self
|
2904
|
+
end
|
2905
|
+
|
2906
|
+
# Set the encoding of the data file set by setDataFile.
|
2907
|
+
#
|
2908
|
+
# * +encoding+ - The data file encoding.
|
2909
|
+
# * *Returns* - The converter object.
|
2910
|
+
def setDataEncoding(encoding)
|
2911
|
+
@fields['data_encoding'] = encoding
|
2912
|
+
self
|
2913
|
+
end
|
2914
|
+
|
2915
|
+
# Ignore undefined variables in the HTML template. The default mode is strict so any undefined variable causes the conversion to fail. You can use {% if variable is defined %} to check if the variable is defined.
|
2916
|
+
#
|
2917
|
+
# * +value+ - Set to true to ignore undefined variables.
|
2918
|
+
# * *Returns* - The converter object.
|
2919
|
+
def setDataIgnoreUndefined(value)
|
2920
|
+
@fields['data_ignore_undefined'] = value
|
2921
|
+
self
|
2922
|
+
end
|
2923
|
+
|
2924
|
+
# Auto escape HTML symbols in the input data before placing them into the output.
|
2925
|
+
#
|
2926
|
+
# * +value+ - Set to true to turn auto escaping on.
|
2927
|
+
# * *Returns* - The converter object.
|
2928
|
+
def setDataAutoEscape(value)
|
2929
|
+
@fields['data_auto_escape'] = value
|
2930
|
+
self
|
2931
|
+
end
|
2932
|
+
|
2933
|
+
# Auto trim whitespace around each template command block.
|
2934
|
+
#
|
2935
|
+
# * +value+ - Set to true to turn auto trimming on.
|
2936
|
+
# * *Returns* - The converter object.
|
2937
|
+
def setDataTrimBlocks(value)
|
2938
|
+
@fields['data_trim_blocks'] = value
|
2939
|
+
self
|
2940
|
+
end
|
2941
|
+
|
2942
|
+
# Set the advanced data options:csv_delimiter - The CSV data delimiter, the default is ,.xml_remove_root - Remove the root XML element from the input data.data_root - The name of the root element inserted into the input data without a root node (e.g. CSV), the default is data.
|
2943
|
+
#
|
2944
|
+
# * +options+ - Comma separated list of options.
|
2945
|
+
# * *Returns* - The converter object.
|
2946
|
+
def setDataOptions(options)
|
2947
|
+
@fields['data_options'] = options
|
2948
|
+
self
|
2949
|
+
end
|
2950
|
+
|
2830
2951
|
# Turn on the debug logging. Details about the conversion are stored in the debug log. The URL of the log can be obtained from the getDebugLogUrl method or available in conversion statistics.
|
2831
2952
|
#
|
2832
2953
|
# * +value+ - Set to true to enable the debug logging.
|
@@ -3134,6 +3255,44 @@ module Pdfcrowd
|
|
3134
3255
|
end
|
3135
3256
|
end
|
3136
3257
|
|
3258
|
+
# Convert the contents of an input stream.
|
3259
|
+
#
|
3260
|
+
# * +in_stream+ - The input stream with source data.
|
3261
|
+
# * *Returns* - Byte array containing the conversion output.
|
3262
|
+
def convertStream(in_stream)
|
3263
|
+
@raw_data['stream'] = in_stream.read
|
3264
|
+
@helper.post(@fields, @files, @raw_data)
|
3265
|
+
end
|
3266
|
+
|
3267
|
+
# Convert the contents of an input stream and write the result to an output stream.
|
3268
|
+
#
|
3269
|
+
# * +in_stream+ - The input stream with source data.
|
3270
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
3271
|
+
def convertStreamToStream(in_stream, out_stream)
|
3272
|
+
@raw_data['stream'] = in_stream.read
|
3273
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
3274
|
+
end
|
3275
|
+
|
3276
|
+
# Convert the contents of an input stream and write the result to a local file.
|
3277
|
+
#
|
3278
|
+
# * +in_stream+ - The input stream with source data.
|
3279
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
3280
|
+
def convertStreamToFile(in_stream, file_path)
|
3281
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
3282
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "image-to-image", "The string must not be empty.", "convert_stream_to_file"), 470);
|
3283
|
+
end
|
3284
|
+
|
3285
|
+
output_file = open(file_path, "wb")
|
3286
|
+
begin
|
3287
|
+
convertStreamToStream(in_stream, output_file)
|
3288
|
+
output_file.close()
|
3289
|
+
rescue Error => why
|
3290
|
+
output_file.close()
|
3291
|
+
FileUtils.rm(file_path)
|
3292
|
+
raise
|
3293
|
+
end
|
3294
|
+
end
|
3295
|
+
|
3137
3296
|
# The format of the output file.
|
3138
3297
|
#
|
3139
3298
|
# * +output_format+ - Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.
|
@@ -3554,6 +3713,55 @@ module Pdfcrowd
|
|
3554
3713
|
self
|
3555
3714
|
end
|
3556
3715
|
|
3716
|
+
# Set the title of the PDF.
|
3717
|
+
#
|
3718
|
+
# * +title+ - The title.
|
3719
|
+
# * *Returns* - The converter object.
|
3720
|
+
def setTitle(title)
|
3721
|
+
@fields['title'] = title
|
3722
|
+
self
|
3723
|
+
end
|
3724
|
+
|
3725
|
+
# Set the subject of the PDF.
|
3726
|
+
#
|
3727
|
+
# * +subject+ - The subject.
|
3728
|
+
# * *Returns* - The converter object.
|
3729
|
+
def setSubject(subject)
|
3730
|
+
@fields['subject'] = subject
|
3731
|
+
self
|
3732
|
+
end
|
3733
|
+
|
3734
|
+
# Set the author of the PDF.
|
3735
|
+
#
|
3736
|
+
# * +author+ - The author.
|
3737
|
+
# * *Returns* - The converter object.
|
3738
|
+
def setAuthor(author)
|
3739
|
+
@fields['author'] = author
|
3740
|
+
self
|
3741
|
+
end
|
3742
|
+
|
3743
|
+
# Associate keywords with the document.
|
3744
|
+
#
|
3745
|
+
# * +keywords+ - The string with the keywords.
|
3746
|
+
# * *Returns* - The converter object.
|
3747
|
+
def setKeywords(keywords)
|
3748
|
+
@fields['keywords'] = keywords
|
3749
|
+
self
|
3750
|
+
end
|
3751
|
+
|
3752
|
+
# Use metadata (title, subject, author and keywords) from the n-th input PDF.
|
3753
|
+
#
|
3754
|
+
# * +index+ - Set the index of the input PDF file from which to use the metadata. 0 means no metadata. Must be a positive integer number or 0.
|
3755
|
+
# * *Returns* - The converter object.
|
3756
|
+
def setUseMetadataFrom(index)
|
3757
|
+
if (!(Integer(index) >= 0))
|
3758
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(index, "setUseMetadataFrom", "pdf-to-pdf", "Must be a positive integer number or 0.", "set_use_metadata_from"), 470);
|
3759
|
+
end
|
3760
|
+
|
3761
|
+
@fields['use_metadata_from'] = index
|
3762
|
+
self
|
3763
|
+
end
|
3764
|
+
|
3557
3765
|
# Specify the page layout to be used when the document is opened.
|
3558
3766
|
#
|
3559
3767
|
# * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
|
@@ -3947,6 +4155,44 @@ module Pdfcrowd
|
|
3947
4155
|
end
|
3948
4156
|
end
|
3949
4157
|
|
4158
|
+
# Convert the contents of an input stream.
|
4159
|
+
#
|
4160
|
+
# * +in_stream+ - The input stream with source data.
|
4161
|
+
# * *Returns* - Byte array containing the conversion output.
|
4162
|
+
def convertStream(in_stream)
|
4163
|
+
@raw_data['stream'] = in_stream.read
|
4164
|
+
@helper.post(@fields, @files, @raw_data)
|
4165
|
+
end
|
4166
|
+
|
4167
|
+
# Convert the contents of an input stream and write the result to an output stream.
|
4168
|
+
#
|
4169
|
+
# * +in_stream+ - The input stream with source data.
|
4170
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
4171
|
+
def convertStreamToStream(in_stream, out_stream)
|
4172
|
+
@raw_data['stream'] = in_stream.read
|
4173
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
4174
|
+
end
|
4175
|
+
|
4176
|
+
# Convert the contents of an input stream and write the result to a local file.
|
4177
|
+
#
|
4178
|
+
# * +in_stream+ - The input stream with source data.
|
4179
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
4180
|
+
def convertStreamToFile(in_stream, file_path)
|
4181
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
4182
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "image-to-pdf", "The string must not be empty.", "convert_stream_to_file"), 470);
|
4183
|
+
end
|
4184
|
+
|
4185
|
+
output_file = open(file_path, "wb")
|
4186
|
+
begin
|
4187
|
+
convertStreamToStream(in_stream, output_file)
|
4188
|
+
output_file.close()
|
4189
|
+
rescue Error => why
|
4190
|
+
output_file.close()
|
4191
|
+
FileUtils.rm(file_path)
|
4192
|
+
raise
|
4193
|
+
end
|
4194
|
+
end
|
4195
|
+
|
3950
4196
|
# Resize the image.
|
3951
4197
|
#
|
3952
4198
|
# * +resize+ - The resize percentage or new image dimensions.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pdfcrowd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.
|
4
|
+
version: 5.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pdfcrowd Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The Pdfcrowd API lets you easily convert between HTML, PDF and various
|
14
14
|
image formats.
|
@@ -37,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '0'
|
39
39
|
requirements: []
|
40
|
-
rubygems_version: 3.1.
|
40
|
+
rubygems_version: 3.1.2
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: A client for the Pdfcrowd API.
|