pdfcrowd 5.1.0 → 5.3.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 +401 -289
- 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: ed729dfe75e90562328dd5177f9c60fcf157e3166bc536c5d401915bea22dc80
|
4
|
+
data.tar.gz: 6c8ac01b9a57fc133dfb36d2fb29b6f40e73d401258de35c18415095d3cdf069
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce55f67a0b100d59ecc270053f943dcad2c047713f0a5d6e78fdff4702985c0c18d433aee8c476458d50a5aa28f85e74bbfd707690b73bbdddb23465666b7ef2
|
7
|
+
data.tar.gz: 2533a247f44824b1124cc388ac92f0c16d9b10503c20f4f71d602668ba7b7ac7601df51f366f7ac5c64cd345ed786fea55c2590d49da5a89aa5269f4e295f2fa
|
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.3.0'
|
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.3.0 (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,27 +895,27 @@ module Pdfcrowd
|
|
895
895
|
end
|
896
896
|
end
|
897
897
|
|
898
|
-
# Convert an input stream.
|
898
|
+
# Convert the contents of an input stream.
|
899
899
|
#
|
900
|
-
# * +in_stream+ - The input stream with
|
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
901
|
# * *Returns* - Byte array containing the conversion output.
|
902
902
|
def convertStream(in_stream)
|
903
903
|
@raw_data['stream'] = in_stream.read
|
904
904
|
@helper.post(@fields, @files, @raw_data)
|
905
905
|
end
|
906
906
|
|
907
|
-
# Convert an input stream and write the result to an output stream.
|
907
|
+
# Convert the contents of an input stream and write the result to an output stream.
|
908
908
|
#
|
909
|
-
# * +in_stream+ - The input stream with
|
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
910
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
911
911
|
def convertStreamToStream(in_stream, out_stream)
|
912
912
|
@raw_data['stream'] = in_stream.read
|
913
913
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
914
914
|
end
|
915
915
|
|
916
|
-
# Convert an input stream and write the result to a local file.
|
916
|
+
# Convert the contents of an input stream and write the result to a local file.
|
917
917
|
#
|
918
|
-
# * +in_stream+ - The input stream with
|
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
919
|
# * +file_path+ - The output file path. The string must not be empty.
|
920
920
|
def convertStreamToFile(in_stream, file_path)
|
921
921
|
if (!(!file_path.nil? && !file_path.empty?))
|
@@ -933,6 +933,15 @@ module Pdfcrowd
|
|
933
933
|
end
|
934
934
|
end
|
935
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
|
+
|
936
945
|
# Set the output page size.
|
937
946
|
#
|
938
947
|
# * +size+ - Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.
|
@@ -1072,93 +1081,6 @@ module Pdfcrowd
|
|
1072
1081
|
self
|
1073
1082
|
end
|
1074
1083
|
|
1075
|
-
# 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>
|
1076
|
-
#
|
1077
|
-
# * +url+ - The supported protocols are http:// and https://.
|
1078
|
-
# * *Returns* - The converter object.
|
1079
|
-
def setHeaderUrl(url)
|
1080
|
-
unless /(?i)^https?:\/\/.*$/.match(url)
|
1081
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setHeaderUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_header_url"), 470);
|
1082
|
-
end
|
1083
|
-
|
1084
|
-
@fields['header_url'] = url
|
1085
|
-
self
|
1086
|
-
end
|
1087
|
-
|
1088
|
-
# 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>
|
1089
|
-
#
|
1090
|
-
# * +html+ - The string must not be empty.
|
1091
|
-
# * *Returns* - The converter object.
|
1092
|
-
def setHeaderHtml(html)
|
1093
|
-
if (!(!html.nil? && !html.empty?))
|
1094
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setHeaderHtml", "html-to-pdf", "The string must not be empty.", "set_header_html"), 470);
|
1095
|
-
end
|
1096
|
-
|
1097
|
-
@fields['header_html'] = html
|
1098
|
-
self
|
1099
|
-
end
|
1100
|
-
|
1101
|
-
# Set the header height.
|
1102
|
-
#
|
1103
|
-
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1104
|
-
# * *Returns* - The converter object.
|
1105
|
-
def setHeaderHeight(height)
|
1106
|
-
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1107
|
-
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);
|
1108
|
-
end
|
1109
|
-
|
1110
|
-
@fields['header_height'] = height
|
1111
|
-
self
|
1112
|
-
end
|
1113
|
-
|
1114
|
-
# 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>
|
1115
|
-
#
|
1116
|
-
# * +url+ - The supported protocols are http:// and https://.
|
1117
|
-
# * *Returns* - The converter object.
|
1118
|
-
def setFooterUrl(url)
|
1119
|
-
unless /(?i)^https?:\/\/.*$/.match(url)
|
1120
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setFooterUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_footer_url"), 470);
|
1121
|
-
end
|
1122
|
-
|
1123
|
-
@fields['footer_url'] = url
|
1124
|
-
self
|
1125
|
-
end
|
1126
|
-
|
1127
|
-
# 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>
|
1128
|
-
#
|
1129
|
-
# * +html+ - The string must not be empty.
|
1130
|
-
# * *Returns* - The converter object.
|
1131
|
-
def setFooterHtml(html)
|
1132
|
-
if (!(!html.nil? && !html.empty?))
|
1133
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setFooterHtml", "html-to-pdf", "The string must not be empty.", "set_footer_html"), 470);
|
1134
|
-
end
|
1135
|
-
|
1136
|
-
@fields['footer_html'] = html
|
1137
|
-
self
|
1138
|
-
end
|
1139
|
-
|
1140
|
-
# Set the footer height.
|
1141
|
-
#
|
1142
|
-
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1143
|
-
# * *Returns* - The converter object.
|
1144
|
-
def setFooterHeight(height)
|
1145
|
-
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1146
|
-
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);
|
1147
|
-
end
|
1148
|
-
|
1149
|
-
@fields['footer_height'] = height
|
1150
|
-
self
|
1151
|
-
end
|
1152
|
-
|
1153
|
-
# Disable horizontal page margins for header and footer. The header/footer contents width will be equal to the physical page width.
|
1154
|
-
#
|
1155
|
-
# * +value+ - Set to true to disable horizontal margins for header and footer.
|
1156
|
-
# * *Returns* - The converter object.
|
1157
|
-
def setNoHeaderFooterHorizontalMargins(value)
|
1158
|
-
@fields['no_header_footer_horizontal_margins'] = value
|
1159
|
-
self
|
1160
|
-
end
|
1161
|
-
|
1162
1084
|
# Set the page range to print.
|
1163
1085
|
#
|
1164
1086
|
# * +pages+ - A comma separated list of page numbers or ranges.
|
@@ -1172,32 +1094,6 @@ module Pdfcrowd
|
|
1172
1094
|
self
|
1173
1095
|
end
|
1174
1096
|
|
1175
|
-
# The page header is not printed on the specified pages.
|
1176
|
-
#
|
1177
|
-
# * +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.
|
1178
|
-
# * *Returns* - The converter object.
|
1179
|
-
def setExcludeHeaderOnPages(pages)
|
1180
|
-
unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
|
1181
|
-
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);
|
1182
|
-
end
|
1183
|
-
|
1184
|
-
@fields['exclude_header_on_pages'] = pages
|
1185
|
-
self
|
1186
|
-
end
|
1187
|
-
|
1188
|
-
# The page footer is not printed on the specified pages.
|
1189
|
-
#
|
1190
|
-
# * +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.
|
1191
|
-
# * *Returns* - The converter object.
|
1192
|
-
def setExcludeFooterOnPages(pages)
|
1193
|
-
unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
|
1194
|
-
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);
|
1195
|
-
end
|
1196
|
-
|
1197
|
-
@fields['exclude_footer_on_pages'] = pages
|
1198
|
-
self
|
1199
|
-
end
|
1200
|
-
|
1201
1097
|
# Set an offset between physical and logical page numbers.
|
1202
1098
|
#
|
1203
1099
|
# * +offset+ - Integer specifying page offset.
|
@@ -1287,79 +1183,147 @@ module Pdfcrowd
|
|
1287
1183
|
self
|
1288
1184
|
end
|
1289
1185
|
|
1290
|
-
#
|
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>
|
1291
1187
|
#
|
1292
|
-
# * +
|
1188
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1293
1189
|
# * *Returns* - The converter object.
|
1294
|
-
def
|
1295
|
-
|
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
|
1296
1196
|
self
|
1297
1197
|
end
|
1298
1198
|
|
1299
|
-
#
|
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>
|
1300
1200
|
#
|
1301
|
-
# * +
|
1201
|
+
# * +html+ - The string must not be empty.
|
1302
1202
|
# * *Returns* - The converter object.
|
1303
|
-
def
|
1304
|
-
|
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
|
1305
1209
|
self
|
1306
1210
|
end
|
1307
1211
|
|
1308
|
-
#
|
1212
|
+
# Set the header height.
|
1309
1213
|
#
|
1310
|
-
# * +
|
1214
|
+
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1311
1215
|
# * *Returns* - The converter object.
|
1312
|
-
def
|
1313
|
-
unless /(?i)^(
|
1314
|
-
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);
|
1315
1219
|
end
|
1316
1220
|
|
1317
|
-
@fields['
|
1221
|
+
@fields['header_height'] = height
|
1318
1222
|
self
|
1319
1223
|
end
|
1320
1224
|
|
1321
|
-
# 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.
|
1322
1226
|
#
|
1323
|
-
# * +
|
1227
|
+
# * +filename+ - The file name.
|
1324
1228
|
# * *Returns* - The converter object.
|
1325
|
-
def
|
1326
|
-
@fields['
|
1229
|
+
def setZipHeaderFilename(filename)
|
1230
|
+
@fields['zip_header_filename'] = filename
|
1327
1231
|
self
|
1328
1232
|
end
|
1329
1233
|
|
1330
|
-
#
|
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>
|
1331
1235
|
#
|
1332
|
-
# * +
|
1236
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1333
1237
|
# * *Returns* - The converter object.
|
1334
|
-
def
|
1335
|
-
|
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
|
1336
1244
|
self
|
1337
1245
|
end
|
1338
1246
|
|
1339
|
-
#
|
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>
|
1340
1248
|
#
|
1341
|
-
# * +
|
1249
|
+
# * +html+ - The string must not be empty.
|
1342
1250
|
# * *Returns* - The converter object.
|
1343
|
-
def
|
1344
|
-
|
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
|
1345
1257
|
self
|
1346
1258
|
end
|
1347
1259
|
|
1348
|
-
#
|
1260
|
+
# Set the footer height.
|
1349
1261
|
#
|
1350
|
-
# * +
|
1262
|
+
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1351
1263
|
# * *Returns* - The converter object.
|
1352
|
-
def
|
1353
|
-
|
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
|
1354
1270
|
self
|
1355
1271
|
end
|
1356
1272
|
|
1357
|
-
# 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.
|
1358
1274
|
#
|
1359
|
-
# * +
|
1275
|
+
# * +filename+ - The file name.
|
1360
1276
|
# * *Returns* - The converter object.
|
1361
|
-
def
|
1362
|
-
@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
|
1363
1327
|
self
|
1364
1328
|
end
|
1365
1329
|
|
@@ -1525,6 +1489,15 @@ module Pdfcrowd
|
|
1525
1489
|
self
|
1526
1490
|
end
|
1527
1491
|
|
1492
|
+
# Use a mobile user agent.
|
1493
|
+
#
|
1494
|
+
# * +value+ - Set to true to use a mobile user agent.
|
1495
|
+
# * *Returns* - The converter object.
|
1496
|
+
def setUseMobileUserAgent(value)
|
1497
|
+
@fields['use_mobile_user_agent'] = value
|
1498
|
+
self
|
1499
|
+
end
|
1500
|
+
|
1528
1501
|
# Specifies how iframes are handled.
|
1529
1502
|
#
|
1530
1503
|
# * +iframes+ - Allowed values are all, same-origin, none.
|
@@ -1704,7 +1677,7 @@ module Pdfcrowd
|
|
1704
1677
|
self
|
1705
1678
|
end
|
1706
1679
|
|
1707
|
-
# Specify the DOM handling when only a part of the document is converted.
|
1680
|
+
# Specify the DOM handling when only a part of the document is converted. This can affect the CSS rules used.
|
1708
1681
|
#
|
1709
1682
|
# * +mode+ - Allowed values are cut-out, remove-siblings, hide-siblings.
|
1710
1683
|
# * *Returns* - The converter object.
|
@@ -1806,19 +1779,6 @@ module Pdfcrowd
|
|
1806
1779
|
self
|
1807
1780
|
end
|
1808
1781
|
|
1809
|
-
# Set the scaling factor (zoom) for the header and footer.
|
1810
|
-
#
|
1811
|
-
# * +factor+ - The percentage value. The value must be in the range 10-500.
|
1812
|
-
# * *Returns* - The converter object.
|
1813
|
-
def setHeaderFooterScaleFactor(factor)
|
1814
|
-
if (!(Integer(factor) >= 10 && Integer(factor) <= 500))
|
1815
|
-
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);
|
1816
|
-
end
|
1817
|
-
|
1818
|
-
@fields['header_footer_scale_factor'] = factor
|
1819
|
-
self
|
1820
|
-
end
|
1821
|
-
|
1822
1782
|
# Set the quality of embedded JPEG images. A lower quality results in a smaller PDF file but can lead to compression artifacts.
|
1823
1783
|
#
|
1824
1784
|
# * +quality+ - The percentage value. The value must be in the range 1-100.
|
@@ -1957,6 +1917,15 @@ module Pdfcrowd
|
|
1957
1917
|
self
|
1958
1918
|
end
|
1959
1919
|
|
1920
|
+
# Extract meta tags (author, keywords and description) from the input HTML and use them in the output PDF.
|
1921
|
+
#
|
1922
|
+
# * +value+ - Set to true to extract meta tags.
|
1923
|
+
# * *Returns* - The converter object.
|
1924
|
+
def setExtractMetaTags(value)
|
1925
|
+
@fields['extract_meta_tags'] = value
|
1926
|
+
self
|
1927
|
+
end
|
1928
|
+
|
1960
1929
|
# Specify the page layout to be used when the document is opened.
|
1961
1930
|
#
|
1962
1931
|
# * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
|
@@ -2022,66 +1991,142 @@ module Pdfcrowd
|
|
2022
1991
|
self
|
2023
1992
|
end
|
2024
1993
|
|
2025
|
-
# Specify whether to hide the viewer application's tool bars when the document is active.
|
1994
|
+
# Specify whether to hide the viewer application's tool bars when the document is active.
|
1995
|
+
#
|
1996
|
+
# * +value+ - Set to true to hide tool bars.
|
1997
|
+
# * *Returns* - The converter object.
|
1998
|
+
def setHideToolbar(value)
|
1999
|
+
@fields['hide_toolbar'] = value
|
2000
|
+
self
|
2001
|
+
end
|
2002
|
+
|
2003
|
+
# Specify whether to hide the viewer application's menu bar when the document is active.
|
2004
|
+
#
|
2005
|
+
# * +value+ - Set to true to hide the menu bar.
|
2006
|
+
# * *Returns* - The converter object.
|
2007
|
+
def setHideMenubar(value)
|
2008
|
+
@fields['hide_menubar'] = value
|
2009
|
+
self
|
2010
|
+
end
|
2011
|
+
|
2012
|
+
# Specify whether to hide user interface elements in the document's window (such as scroll bars and navigation controls), leaving only the document's contents displayed.
|
2013
|
+
#
|
2014
|
+
# * +value+ - Set to true to hide ui elements.
|
2015
|
+
# * *Returns* - The converter object.
|
2016
|
+
def setHideWindowUi(value)
|
2017
|
+
@fields['hide_window_ui'] = value
|
2018
|
+
self
|
2019
|
+
end
|
2020
|
+
|
2021
|
+
# Specify whether to resize the document's window to fit the size of the first displayed page.
|
2022
|
+
#
|
2023
|
+
# * +value+ - Set to true to resize the window.
|
2024
|
+
# * *Returns* - The converter object.
|
2025
|
+
def setFitWindow(value)
|
2026
|
+
@fields['fit_window'] = value
|
2027
|
+
self
|
2028
|
+
end
|
2029
|
+
|
2030
|
+
# Specify whether to position the document's window in the center of the screen.
|
2031
|
+
#
|
2032
|
+
# * +value+ - Set to true to center the window.
|
2033
|
+
# * *Returns* - The converter object.
|
2034
|
+
def setCenterWindow(value)
|
2035
|
+
@fields['center_window'] = value
|
2036
|
+
self
|
2037
|
+
end
|
2038
|
+
|
2039
|
+
# Specify whether the window's title bar should display the document title. If false , the title bar should instead display the name of the PDF file containing the document.
|
2040
|
+
#
|
2041
|
+
# * +value+ - Set to true to display the title.
|
2042
|
+
# * *Returns* - The converter object.
|
2043
|
+
def setDisplayTitle(value)
|
2044
|
+
@fields['display_title'] = value
|
2045
|
+
self
|
2046
|
+
end
|
2047
|
+
|
2048
|
+
# 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
|
2049
|
+
#
|
2050
|
+
# * +value+ - Set to true to set right-to-left reading order.
|
2051
|
+
# * *Returns* - The converter object.
|
2052
|
+
def setRightToLeft(value)
|
2053
|
+
@fields['right_to_left'] = value
|
2054
|
+
self
|
2055
|
+
end
|
2056
|
+
|
2057
|
+
# Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
|
2058
|
+
#
|
2059
|
+
# * +data_string+ - The input data string.
|
2060
|
+
# * *Returns* - The converter object.
|
2061
|
+
def setDataString(data_string)
|
2062
|
+
@fields['data_string'] = data_string
|
2063
|
+
self
|
2064
|
+
end
|
2065
|
+
|
2066
|
+
# Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
|
2026
2067
|
#
|
2027
|
-
# * +
|
2068
|
+
# * +data_file+ - The file path to a local file containing the input data.
|
2028
2069
|
# * *Returns* - The converter object.
|
2029
|
-
def
|
2030
|
-
@
|
2070
|
+
def setDataFile(data_file)
|
2071
|
+
@files['data_file'] = data_file
|
2031
2072
|
self
|
2032
2073
|
end
|
2033
2074
|
|
2034
|
-
# Specify
|
2075
|
+
# Specify the input data format.
|
2035
2076
|
#
|
2036
|
-
# * +
|
2077
|
+
# * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
|
2037
2078
|
# * *Returns* - The converter object.
|
2038
|
-
def
|
2039
|
-
|
2079
|
+
def setDataFormat(data_format)
|
2080
|
+
unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
|
2081
|
+
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);
|
2082
|
+
end
|
2083
|
+
|
2084
|
+
@fields['data_format'] = data_format
|
2040
2085
|
self
|
2041
2086
|
end
|
2042
2087
|
|
2043
|
-
#
|
2088
|
+
# Set the encoding of the data file set by setDataFile.
|
2044
2089
|
#
|
2045
|
-
# * +
|
2090
|
+
# * +encoding+ - The data file encoding.
|
2046
2091
|
# * *Returns* - The converter object.
|
2047
|
-
def
|
2048
|
-
@fields['
|
2092
|
+
def setDataEncoding(encoding)
|
2093
|
+
@fields['data_encoding'] = encoding
|
2049
2094
|
self
|
2050
2095
|
end
|
2051
2096
|
|
2052
|
-
#
|
2097
|
+
# 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.
|
2053
2098
|
#
|
2054
|
-
# * +value+ - Set to true to
|
2099
|
+
# * +value+ - Set to true to ignore undefined variables.
|
2055
2100
|
# * *Returns* - The converter object.
|
2056
|
-
def
|
2057
|
-
@fields['
|
2101
|
+
def setDataIgnoreUndefined(value)
|
2102
|
+
@fields['data_ignore_undefined'] = value
|
2058
2103
|
self
|
2059
2104
|
end
|
2060
2105
|
|
2061
|
-
#
|
2106
|
+
# Auto escape HTML symbols in the input data before placing them into the output.
|
2062
2107
|
#
|
2063
|
-
# * +value+ - Set to true to
|
2108
|
+
# * +value+ - Set to true to turn auto escaping on.
|
2064
2109
|
# * *Returns* - The converter object.
|
2065
|
-
def
|
2066
|
-
@fields['
|
2110
|
+
def setDataAutoEscape(value)
|
2111
|
+
@fields['data_auto_escape'] = value
|
2067
2112
|
self
|
2068
2113
|
end
|
2069
2114
|
|
2070
|
-
#
|
2115
|
+
# Auto trim whitespace around each template command block.
|
2071
2116
|
#
|
2072
|
-
# * +value+ - Set to true to
|
2117
|
+
# * +value+ - Set to true to turn auto trimming on.
|
2073
2118
|
# * *Returns* - The converter object.
|
2074
|
-
def
|
2075
|
-
@fields['
|
2119
|
+
def setDataTrimBlocks(value)
|
2120
|
+
@fields['data_trim_blocks'] = value
|
2076
2121
|
self
|
2077
2122
|
end
|
2078
2123
|
|
2079
|
-
# Set the
|
2124
|
+
# 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.
|
2080
2125
|
#
|
2081
|
-
# * +
|
2126
|
+
# * +options+ - Comma separated list of options.
|
2082
2127
|
# * *Returns* - The converter object.
|
2083
|
-
def
|
2084
|
-
@fields['
|
2128
|
+
def setDataOptions(options)
|
2129
|
+
@fields['data_options'] = options
|
2085
2130
|
self
|
2086
2131
|
end
|
2087
2132
|
|
@@ -2487,27 +2532,27 @@ module Pdfcrowd
|
|
2487
2532
|
end
|
2488
2533
|
end
|
2489
2534
|
|
2490
|
-
# Convert an input stream.
|
2535
|
+
# Convert the contents of an input stream.
|
2491
2536
|
#
|
2492
|
-
# * +in_stream+ - The input stream with
|
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).
|
2493
2538
|
# * *Returns* - Byte array containing the conversion output.
|
2494
2539
|
def convertStream(in_stream)
|
2495
2540
|
@raw_data['stream'] = in_stream.read
|
2496
2541
|
@helper.post(@fields, @files, @raw_data)
|
2497
2542
|
end
|
2498
2543
|
|
2499
|
-
# Convert an input stream and write the result to an output stream.
|
2544
|
+
# Convert the contents of an input stream and write the result to an output stream.
|
2500
2545
|
#
|
2501
|
-
# * +in_stream+ - The input stream with
|
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).
|
2502
2547
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2503
2548
|
def convertStreamToStream(in_stream, out_stream)
|
2504
2549
|
@raw_data['stream'] = in_stream.read
|
2505
2550
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
2506
2551
|
end
|
2507
2552
|
|
2508
|
-
# Convert an input stream and write the result to a local file.
|
2553
|
+
# Convert the contents of an input stream and write the result to a local file.
|
2509
2554
|
#
|
2510
|
-
# * +in_stream+ - The input stream with
|
2555
|
+
# * +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).
|
2511
2556
|
# * +file_path+ - The output file path. The string must not be empty.
|
2512
2557
|
def convertStreamToFile(in_stream, file_path)
|
2513
2558
|
if (!(!file_path.nil? && !file_path.empty?))
|
@@ -2525,79 +2570,12 @@ module Pdfcrowd
|
|
2525
2570
|
end
|
2526
2571
|
end
|
2527
2572
|
|
2528
|
-
# Set the input
|
2529
|
-
#
|
2530
|
-
# * +data_string+ - The input data string.
|
2531
|
-
# * *Returns* - The converter object.
|
2532
|
-
def setDataString(data_string)
|
2533
|
-
@fields['data_string'] = data_string
|
2534
|
-
self
|
2535
|
-
end
|
2536
|
-
|
2537
|
-
# Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
|
2538
|
-
#
|
2539
|
-
# * +data_file+ - The file path to a local file containing the input data.
|
2540
|
-
# * *Returns* - The converter object.
|
2541
|
-
def setDataFile(data_file)
|
2542
|
-
@files['data_file'] = data_file
|
2543
|
-
self
|
2544
|
-
end
|
2545
|
-
|
2546
|
-
# Specify the input data format.
|
2547
|
-
#
|
2548
|
-
# * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
|
2549
|
-
# * *Returns* - The converter object.
|
2550
|
-
def setDataFormat(data_format)
|
2551
|
-
unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
|
2552
|
-
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);
|
2553
|
-
end
|
2554
|
-
|
2555
|
-
@fields['data_format'] = data_format
|
2556
|
-
self
|
2557
|
-
end
|
2558
|
-
|
2559
|
-
# Set the encoding of the data file set by setDataFile.
|
2560
|
-
#
|
2561
|
-
# * +encoding+ - The data file encoding.
|
2562
|
-
# * *Returns* - The converter object.
|
2563
|
-
def setDataEncoding(encoding)
|
2564
|
-
@fields['data_encoding'] = encoding
|
2565
|
-
self
|
2566
|
-
end
|
2567
|
-
|
2568
|
-
# 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.
|
2569
|
-
#
|
2570
|
-
# * +value+ - Set to true to ignore undefined variables.
|
2571
|
-
# * *Returns* - The converter object.
|
2572
|
-
def setDataIgnoreUndefined(value)
|
2573
|
-
@fields['data_ignore_undefined'] = value
|
2574
|
-
self
|
2575
|
-
end
|
2576
|
-
|
2577
|
-
# Auto escape HTML symbols in the input data before placing them into the output.
|
2578
|
-
#
|
2579
|
-
# * +value+ - Set to true to turn auto escaping on.
|
2580
|
-
# * *Returns* - The converter object.
|
2581
|
-
def setDataAutoEscape(value)
|
2582
|
-
@fields['data_auto_escape'] = value
|
2583
|
-
self
|
2584
|
-
end
|
2585
|
-
|
2586
|
-
# Auto trim whitespace around each template command block.
|
2587
|
-
#
|
2588
|
-
# * +value+ - Set to true to turn auto trimming on.
|
2589
|
-
# * *Returns* - The converter object.
|
2590
|
-
def setDataTrimBlocks(value)
|
2591
|
-
@fields['data_trim_blocks'] = value
|
2592
|
-
self
|
2593
|
-
end
|
2594
|
-
|
2595
|
-
# 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.
|
2573
|
+
# 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.
|
2596
2574
|
#
|
2597
|
-
# * +
|
2575
|
+
# * +filename+ - The file name.
|
2598
2576
|
# * *Returns* - The converter object.
|
2599
|
-
def
|
2600
|
-
@fields['
|
2577
|
+
def setZipMainFilename(filename)
|
2578
|
+
@fields['zip_main_filename'] = filename
|
2601
2579
|
self
|
2602
2580
|
end
|
2603
2581
|
|
@@ -2646,6 +2624,15 @@ module Pdfcrowd
|
|
2646
2624
|
self
|
2647
2625
|
end
|
2648
2626
|
|
2627
|
+
# Use a mobile user agent.
|
2628
|
+
#
|
2629
|
+
# * +value+ - Set to true to use a mobile user agent.
|
2630
|
+
# * *Returns* - The converter object.
|
2631
|
+
def setUseMobileUserAgent(value)
|
2632
|
+
@fields['use_mobile_user_agent'] = value
|
2633
|
+
self
|
2634
|
+
end
|
2635
|
+
|
2649
2636
|
# Specifies how iframes are handled.
|
2650
2637
|
#
|
2651
2638
|
# * +iframes+ - Allowed values are all, same-origin, none.
|
@@ -2825,7 +2812,7 @@ module Pdfcrowd
|
|
2825
2812
|
self
|
2826
2813
|
end
|
2827
2814
|
|
2828
|
-
# Specify the DOM handling when only a part of the document is converted.
|
2815
|
+
# Specify the DOM handling when only a part of the document is converted. This can affect the CSS rules used.
|
2829
2816
|
#
|
2830
2817
|
# * +mode+ - Allowed values are cut-out, remove-siblings, hide-siblings.
|
2831
2818
|
# * *Returns* - The converter object.
|
@@ -2903,6 +2890,82 @@ module Pdfcrowd
|
|
2903
2890
|
self
|
2904
2891
|
end
|
2905
2892
|
|
2893
|
+
# Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
|
2894
|
+
#
|
2895
|
+
# * +data_string+ - The input data string.
|
2896
|
+
# * *Returns* - The converter object.
|
2897
|
+
def setDataString(data_string)
|
2898
|
+
@fields['data_string'] = data_string
|
2899
|
+
self
|
2900
|
+
end
|
2901
|
+
|
2902
|
+
# Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
|
2903
|
+
#
|
2904
|
+
# * +data_file+ - The file path to a local file containing the input data.
|
2905
|
+
# * *Returns* - The converter object.
|
2906
|
+
def setDataFile(data_file)
|
2907
|
+
@files['data_file'] = data_file
|
2908
|
+
self
|
2909
|
+
end
|
2910
|
+
|
2911
|
+
# Specify the input data format.
|
2912
|
+
#
|
2913
|
+
# * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
|
2914
|
+
# * *Returns* - The converter object.
|
2915
|
+
def setDataFormat(data_format)
|
2916
|
+
unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
|
2917
|
+
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);
|
2918
|
+
end
|
2919
|
+
|
2920
|
+
@fields['data_format'] = data_format
|
2921
|
+
self
|
2922
|
+
end
|
2923
|
+
|
2924
|
+
# Set the encoding of the data file set by setDataFile.
|
2925
|
+
#
|
2926
|
+
# * +encoding+ - The data file encoding.
|
2927
|
+
# * *Returns* - The converter object.
|
2928
|
+
def setDataEncoding(encoding)
|
2929
|
+
@fields['data_encoding'] = encoding
|
2930
|
+
self
|
2931
|
+
end
|
2932
|
+
|
2933
|
+
# 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.
|
2934
|
+
#
|
2935
|
+
# * +value+ - Set to true to ignore undefined variables.
|
2936
|
+
# * *Returns* - The converter object.
|
2937
|
+
def setDataIgnoreUndefined(value)
|
2938
|
+
@fields['data_ignore_undefined'] = value
|
2939
|
+
self
|
2940
|
+
end
|
2941
|
+
|
2942
|
+
# Auto escape HTML symbols in the input data before placing them into the output.
|
2943
|
+
#
|
2944
|
+
# * +value+ - Set to true to turn auto escaping on.
|
2945
|
+
# * *Returns* - The converter object.
|
2946
|
+
def setDataAutoEscape(value)
|
2947
|
+
@fields['data_auto_escape'] = value
|
2948
|
+
self
|
2949
|
+
end
|
2950
|
+
|
2951
|
+
# Auto trim whitespace around each template command block.
|
2952
|
+
#
|
2953
|
+
# * +value+ - Set to true to turn auto trimming on.
|
2954
|
+
# * *Returns* - The converter object.
|
2955
|
+
def setDataTrimBlocks(value)
|
2956
|
+
@fields['data_trim_blocks'] = value
|
2957
|
+
self
|
2958
|
+
end
|
2959
|
+
|
2960
|
+
# 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.
|
2961
|
+
#
|
2962
|
+
# * +options+ - Comma separated list of options.
|
2963
|
+
# * *Returns* - The converter object.
|
2964
|
+
def setDataOptions(options)
|
2965
|
+
@fields['data_options'] = options
|
2966
|
+
self
|
2967
|
+
end
|
2968
|
+
|
2906
2969
|
# 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.
|
2907
2970
|
#
|
2908
2971
|
# * +value+ - Set to true to enable the debug logging.
|
@@ -3210,27 +3273,27 @@ module Pdfcrowd
|
|
3210
3273
|
end
|
3211
3274
|
end
|
3212
3275
|
|
3213
|
-
# Convert an input stream.
|
3276
|
+
# Convert the contents of an input stream.
|
3214
3277
|
#
|
3215
|
-
# * +in_stream+ - The input stream with
|
3278
|
+
# * +in_stream+ - The input stream with source data.
|
3216
3279
|
# * *Returns* - Byte array containing the conversion output.
|
3217
3280
|
def convertStream(in_stream)
|
3218
3281
|
@raw_data['stream'] = in_stream.read
|
3219
3282
|
@helper.post(@fields, @files, @raw_data)
|
3220
3283
|
end
|
3221
3284
|
|
3222
|
-
# Convert an input stream and write the result to an output stream.
|
3285
|
+
# Convert the contents of an input stream and write the result to an output stream.
|
3223
3286
|
#
|
3224
|
-
# * +in_stream+ - The input stream with
|
3287
|
+
# * +in_stream+ - The input stream with source data.
|
3225
3288
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
3226
3289
|
def convertStreamToStream(in_stream, out_stream)
|
3227
3290
|
@raw_data['stream'] = in_stream.read
|
3228
3291
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
3229
3292
|
end
|
3230
3293
|
|
3231
|
-
# Convert an input stream and write the result to a local file.
|
3294
|
+
# Convert the contents of an input stream and write the result to a local file.
|
3232
3295
|
#
|
3233
|
-
# * +in_stream+ - The input stream with
|
3296
|
+
# * +in_stream+ - The input stream with source data.
|
3234
3297
|
# * +file_path+ - The output file path. The string must not be empty.
|
3235
3298
|
def convertStreamToFile(in_stream, file_path)
|
3236
3299
|
if (!(!file_path.nil? && !file_path.empty?))
|
@@ -3668,6 +3731,55 @@ module Pdfcrowd
|
|
3668
3731
|
self
|
3669
3732
|
end
|
3670
3733
|
|
3734
|
+
# Set the title of the PDF.
|
3735
|
+
#
|
3736
|
+
# * +title+ - The title.
|
3737
|
+
# * *Returns* - The converter object.
|
3738
|
+
def setTitle(title)
|
3739
|
+
@fields['title'] = title
|
3740
|
+
self
|
3741
|
+
end
|
3742
|
+
|
3743
|
+
# Set the subject of the PDF.
|
3744
|
+
#
|
3745
|
+
# * +subject+ - The subject.
|
3746
|
+
# * *Returns* - The converter object.
|
3747
|
+
def setSubject(subject)
|
3748
|
+
@fields['subject'] = subject
|
3749
|
+
self
|
3750
|
+
end
|
3751
|
+
|
3752
|
+
# Set the author of the PDF.
|
3753
|
+
#
|
3754
|
+
# * +author+ - The author.
|
3755
|
+
# * *Returns* - The converter object.
|
3756
|
+
def setAuthor(author)
|
3757
|
+
@fields['author'] = author
|
3758
|
+
self
|
3759
|
+
end
|
3760
|
+
|
3761
|
+
# Associate keywords with the document.
|
3762
|
+
#
|
3763
|
+
# * +keywords+ - The string with the keywords.
|
3764
|
+
# * *Returns* - The converter object.
|
3765
|
+
def setKeywords(keywords)
|
3766
|
+
@fields['keywords'] = keywords
|
3767
|
+
self
|
3768
|
+
end
|
3769
|
+
|
3770
|
+
# Use metadata (title, subject, author and keywords) from the n-th input PDF.
|
3771
|
+
#
|
3772
|
+
# * +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.
|
3773
|
+
# * *Returns* - The converter object.
|
3774
|
+
def setUseMetadataFrom(index)
|
3775
|
+
if (!(Integer(index) >= 0))
|
3776
|
+
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);
|
3777
|
+
end
|
3778
|
+
|
3779
|
+
@fields['use_metadata_from'] = index
|
3780
|
+
self
|
3781
|
+
end
|
3782
|
+
|
3671
3783
|
# Specify the page layout to be used when the document is opened.
|
3672
3784
|
#
|
3673
3785
|
# * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
|
@@ -4061,27 +4173,27 @@ module Pdfcrowd
|
|
4061
4173
|
end
|
4062
4174
|
end
|
4063
4175
|
|
4064
|
-
# Convert an input stream.
|
4176
|
+
# Convert the contents of an input stream.
|
4065
4177
|
#
|
4066
|
-
# * +in_stream+ - The input stream with
|
4178
|
+
# * +in_stream+ - The input stream with source data.
|
4067
4179
|
# * *Returns* - Byte array containing the conversion output.
|
4068
4180
|
def convertStream(in_stream)
|
4069
4181
|
@raw_data['stream'] = in_stream.read
|
4070
4182
|
@helper.post(@fields, @files, @raw_data)
|
4071
4183
|
end
|
4072
4184
|
|
4073
|
-
# Convert an input stream and write the result to an output stream.
|
4185
|
+
# Convert the contents of an input stream and write the result to an output stream.
|
4074
4186
|
#
|
4075
|
-
# * +in_stream+ - The input stream with
|
4187
|
+
# * +in_stream+ - The input stream with source data.
|
4076
4188
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
4077
4189
|
def convertStreamToStream(in_stream, out_stream)
|
4078
4190
|
@raw_data['stream'] = in_stream.read
|
4079
4191
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
4080
4192
|
end
|
4081
4193
|
|
4082
|
-
# Convert an input stream and write the result to a local file.
|
4194
|
+
# Convert the contents of an input stream and write the result to a local file.
|
4083
4195
|
#
|
4084
|
-
# * +in_stream+ - The input stream with
|
4196
|
+
# * +in_stream+ - The input stream with source data.
|
4085
4197
|
# * +file_path+ - The output file path. The string must not be empty.
|
4086
4198
|
def convertStreamToFile(in_stream, file_path)
|
4087
4199
|
if (!(!file_path.nil? && !file_path.empty?))
|
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.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pdfcrowd Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-10 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.
|