pdfcrowd 5.19.0 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pdfcrowd.rb +520 -21
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34762c61f54d6cc17ab834a37ad6cc4e8e3849b29bfcc432b493ea0fb97bb5b5
|
4
|
+
data.tar.gz: 6def76bbb1426182fbd92d45b13148f01785190eb58a6c3dd6cbe726ab16d162
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d43f03b05750ecee2d0b4843d8cdee07d522c38be060431dfc5da8a89149d3d838711b3fb034fbaaa7612d813d49681853b7acf10b951050b4d441c7f17e1080
|
7
|
+
data.tar.gz: 60377a449017ce359cc8d4de32d3fe2f200042aafc481a1d2ce04c6c667126517c330cc0b06261e847f91ddba31498f704a57caab642018406e2b1061116f0c9
|
data/lib/pdfcrowd.rb
CHANGED
@@ -530,7 +530,7 @@ end
|
|
530
530
|
module Pdfcrowd
|
531
531
|
HOST = ENV["PDFCROWD_HOST"] || 'api.pdfcrowd.com'
|
532
532
|
MULTIPART_BOUNDARY = '----------ThIs_Is_tHe_bOUnDary_$'
|
533
|
-
CLIENT_VERSION = '
|
533
|
+
CLIENT_VERSION = '6.0.0'
|
534
534
|
|
535
535
|
class ConnectionHelper
|
536
536
|
def initialize(user_name, api_key)
|
@@ -541,10 +541,10 @@ module Pdfcrowd
|
|
541
541
|
|
542
542
|
setProxy(nil, nil, nil, nil)
|
543
543
|
setUseHttp(false)
|
544
|
-
setUserAgent('pdfcrowd_ruby_client/
|
544
|
+
setUserAgent('pdfcrowd_ruby_client/6.0.0 (https://pdfcrowd.com)')
|
545
545
|
|
546
546
|
@retry_count = 1
|
547
|
-
@converter_version = '
|
547
|
+
@converter_version = '24.04'
|
548
548
|
end
|
549
549
|
|
550
550
|
def post(fields, files, raw_data, out_stream = nil)
|
@@ -1105,6 +1105,45 @@ module Pdfcrowd
|
|
1105
1105
|
self
|
1106
1106
|
end
|
1107
1107
|
|
1108
|
+
# Set the viewport width for formatting the HTML content when generating a PDF. By specifying a viewport width, you can control how the content is rendered, ensuring it mimics the appearance on various devices or matches specific design requirements.
|
1109
|
+
#
|
1110
|
+
# * +width+ - The width of the viewport. The value must be "balanced", "small", "medium", "large", "extra-large", or a number in the range 96-65000.
|
1111
|
+
# * *Returns* - The converter object.
|
1112
|
+
def setContentViewportWidth(width)
|
1113
|
+
unless /(?i)^(balanced|small|medium|large|extra-large|[0-9]+)$/.match(width)
|
1114
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setContentViewportWidth", "html-to-pdf", "The value must be \"balanced\", \"small\", \"medium\", \"large\", \"extra-large\", or a number in the range 96-65000.", "set_content_viewport_width"), 470);
|
1115
|
+
end
|
1116
|
+
|
1117
|
+
@fields['content_viewport_width'] = width
|
1118
|
+
self
|
1119
|
+
end
|
1120
|
+
|
1121
|
+
# Set the viewport height for formatting the HTML content when generating a PDF. By specifying a viewport height, you can enforce loading of lazy-loaded images and also affect vertical positioning of absolutely positioned elements within the content.
|
1122
|
+
#
|
1123
|
+
# * +height+ - The viewport height. The value must be "auto", "large", or a number.
|
1124
|
+
# * *Returns* - The converter object.
|
1125
|
+
def setContentViewportHeight(height)
|
1126
|
+
unless /(?i)^(auto|large|[0-9]+)$/.match(height)
|
1127
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setContentViewportHeight", "html-to-pdf", "The value must be \"auto\", \"large\", or a number.", "set_content_viewport_height"), 470);
|
1128
|
+
end
|
1129
|
+
|
1130
|
+
@fields['content_viewport_height'] = height
|
1131
|
+
self
|
1132
|
+
end
|
1133
|
+
|
1134
|
+
# Specifies the mode for fitting the HTML content to the print area by upscaling or downscaling it.
|
1135
|
+
#
|
1136
|
+
# * +mode+ - The fitting mode. Allowed values are auto, smart-scaling, no-scaling, viewport-width, content-width, single-page, single-page-ratio.
|
1137
|
+
# * *Returns* - The converter object.
|
1138
|
+
def setContentFitMode(mode)
|
1139
|
+
unless /(?i)^(auto|smart-scaling|no-scaling|viewport-width|content-width|single-page|single-page-ratio)$/.match(mode)
|
1140
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setContentFitMode", "html-to-pdf", "Allowed values are auto, smart-scaling, no-scaling, viewport-width, content-width, single-page, single-page-ratio.", "set_content_fit_mode"), 470);
|
1141
|
+
end
|
1142
|
+
|
1143
|
+
@fields['content_fit_mode'] = mode
|
1144
|
+
self
|
1145
|
+
end
|
1146
|
+
|
1108
1147
|
# Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
|
1109
1148
|
#
|
1110
1149
|
# * +x+ - The value must be specified in inches "in", millimeters "mm", centimeters "cm", pixels "px", or points "pt". It may contain a negative value.
|
@@ -1187,11 +1226,11 @@ module Pdfcrowd
|
|
1187
1226
|
|
1188
1227
|
# Specifies which blank pages to exclude from the output document.
|
1189
1228
|
#
|
1190
|
-
# * +pages+ - The empty page behavior. Allowed values are trailing, none.
|
1229
|
+
# * +pages+ - The empty page behavior. Allowed values are trailing, all, none.
|
1191
1230
|
# * *Returns* - The converter object.
|
1192
1231
|
def setRemoveBlankPages(pages)
|
1193
|
-
unless /(?i)^(trailing|none)$/.match(pages)
|
1194
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setRemoveBlankPages", "html-to-pdf", "Allowed values are trailing, none.", "set_remove_blank_pages"), 470);
|
1232
|
+
unless /(?i)^(trailing|all|none)$/.match(pages)
|
1233
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setRemoveBlankPages", "html-to-pdf", "Allowed values are trailing, all, none.", "set_remove_blank_pages"), 470);
|
1195
1234
|
end
|
1196
1235
|
|
1197
1236
|
@fields['remove_blank_pages'] = pages
|
@@ -2389,11 +2428,11 @@ module Pdfcrowd
|
|
2389
2428
|
|
2390
2429
|
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
2391
2430
|
#
|
2392
|
-
# * +version+ - The version identifier. Allowed values are
|
2431
|
+
# * +version+ - The version identifier. Allowed values are 24.04, 20.10, 18.10, latest.
|
2393
2432
|
# * *Returns* - The converter object.
|
2394
2433
|
def setConverterVersion(version)
|
2395
|
-
unless /(?i)^(
|
2396
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "html-to-pdf", "Allowed values are
|
2434
|
+
unless /(?i)^(24.04|20.10|18.10|latest)$/.match(version)
|
2435
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "html-to-pdf", "Allowed values are 24.04, 20.10, 18.10, latest.", "set_converter_version"), 470);
|
2397
2436
|
end
|
2398
2437
|
|
2399
2438
|
@helper.setConverterVersion(version)
|
@@ -3199,11 +3238,11 @@ module Pdfcrowd
|
|
3199
3238
|
|
3200
3239
|
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
3201
3240
|
#
|
3202
|
-
# * +version+ - The version identifier. Allowed values are
|
3241
|
+
# * +version+ - The version identifier. Allowed values are 24.04, 20.10, 18.10, latest.
|
3203
3242
|
# * *Returns* - The converter object.
|
3204
3243
|
def setConverterVersion(version)
|
3205
|
-
unless /(?i)^(
|
3206
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "html-to-image", "Allowed values are
|
3244
|
+
unless /(?i)^(24.04|20.10|18.10|latest)$/.match(version)
|
3245
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "html-to-image", "Allowed values are 24.04, 20.10, 18.10, latest.", "set_converter_version"), 470);
|
3207
3246
|
end
|
3208
3247
|
|
3209
3248
|
@helper.setConverterVersion(version)
|
@@ -3807,11 +3846,11 @@ module Pdfcrowd
|
|
3807
3846
|
|
3808
3847
|
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
3809
3848
|
#
|
3810
|
-
# * +version+ - The version identifier. Allowed values are
|
3849
|
+
# * +version+ - The version identifier. Allowed values are 24.04, 20.10, 18.10, latest.
|
3811
3850
|
# * *Returns* - The converter object.
|
3812
3851
|
def setConverterVersion(version)
|
3813
|
-
unless /(?i)^(
|
3814
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "image-to-image", "Allowed values are
|
3852
|
+
unless /(?i)^(24.04|20.10|18.10|latest)$/.match(version)
|
3853
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "image-to-image", "Allowed values are 24.04, 20.10, 18.10, latest.", "set_converter_version"), 470);
|
3815
3854
|
end
|
3816
3855
|
|
3817
3856
|
@helper.setConverterVersion(version)
|
@@ -4375,11 +4414,11 @@ module Pdfcrowd
|
|
4375
4414
|
|
4376
4415
|
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
4377
4416
|
#
|
4378
|
-
# * +version+ - The version identifier. Allowed values are
|
4417
|
+
# * +version+ - The version identifier. Allowed values are 24.04, 20.10, 18.10, latest.
|
4379
4418
|
# * *Returns* - The converter object.
|
4380
4419
|
def setConverterVersion(version)
|
4381
|
-
unless /(?i)^(
|
4382
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "pdf-to-pdf", "Allowed values are
|
4420
|
+
unless /(?i)^(24.04|20.10|18.10|latest)$/.match(version)
|
4421
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "pdf-to-pdf", "Allowed values are 24.04, 20.10, 18.10, latest.", "set_converter_version"), 470);
|
4383
4422
|
end
|
4384
4423
|
|
4385
4424
|
@helper.setConverterVersion(version)
|
@@ -5292,11 +5331,11 @@ module Pdfcrowd
|
|
5292
5331
|
|
5293
5332
|
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
5294
5333
|
#
|
5295
|
-
# * +version+ - The version identifier. Allowed values are
|
5334
|
+
# * +version+ - The version identifier. Allowed values are 24.04, 20.10, 18.10, latest.
|
5296
5335
|
# * *Returns* - The converter object.
|
5297
5336
|
def setConverterVersion(version)
|
5298
|
-
unless /(?i)^(
|
5299
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "image-to-pdf", "Allowed values are
|
5337
|
+
unless /(?i)^(24.04|20.10|18.10|latest)$/.match(version)
|
5338
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "image-to-pdf", "Allowed values are 24.04, 20.10, 18.10, latest.", "set_converter_version"), 470);
|
5300
5339
|
end
|
5301
5340
|
|
5302
5341
|
@helper.setConverterVersion(version)
|
@@ -6332,4 +6371,464 @@ module Pdfcrowd
|
|
6332
6371
|
|
6333
6372
|
end
|
6334
6373
|
|
6374
|
+
# Conversion from PDF to image.
|
6375
|
+
class PdfToImageClient
|
6376
|
+
# Constructor for the Pdfcrowd API client.
|
6377
|
+
#
|
6378
|
+
# * +user_name+ - Your username at Pdfcrowd.
|
6379
|
+
# * +api_key+ - Your API key.
|
6380
|
+
def initialize(user_name, api_key)
|
6381
|
+
@helper = ConnectionHelper.new(user_name, api_key)
|
6382
|
+
@fields = {
|
6383
|
+
'input_format'=>'pdf',
|
6384
|
+
'output_format'=>'png'
|
6385
|
+
}
|
6386
|
+
@file_id = 1
|
6387
|
+
@files = {}
|
6388
|
+
@raw_data = {}
|
6389
|
+
end
|
6390
|
+
|
6391
|
+
# Convert an image.
|
6392
|
+
#
|
6393
|
+
# * +url+ - The address of the image to convert. The supported protocols are http:// and https://.
|
6394
|
+
# * *Returns* - Byte array containing the conversion output.
|
6395
|
+
def convertUrl(url)
|
6396
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
6397
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
|
6398
|
+
end
|
6399
|
+
|
6400
|
+
@fields['url'] = url
|
6401
|
+
@helper.post(@fields, @files, @raw_data)
|
6402
|
+
end
|
6403
|
+
|
6404
|
+
# Convert an image and write the result to an output stream.
|
6405
|
+
#
|
6406
|
+
# * +url+ - The address of the image to convert. The supported protocols are http:// and https://.
|
6407
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
6408
|
+
def convertUrlToStream(url, out_stream)
|
6409
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
6410
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "pdf-to-image", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
6411
|
+
end
|
6412
|
+
|
6413
|
+
@fields['url'] = url
|
6414
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
6415
|
+
end
|
6416
|
+
|
6417
|
+
# Convert an image and write the result to a local file.
|
6418
|
+
#
|
6419
|
+
# * +url+ - The address of the image to convert. The supported protocols are http:// and https://.
|
6420
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
6421
|
+
def convertUrlToFile(url, file_path)
|
6422
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
6423
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "pdf-to-image", "The string must not be empty.", "convert_url_to_file"), 470);
|
6424
|
+
end
|
6425
|
+
|
6426
|
+
output_file = open(file_path, "wb")
|
6427
|
+
begin
|
6428
|
+
convertUrlToStream(url, output_file)
|
6429
|
+
output_file.close()
|
6430
|
+
rescue Error => why
|
6431
|
+
output_file.close()
|
6432
|
+
FileUtils.rm(file_path)
|
6433
|
+
raise
|
6434
|
+
end
|
6435
|
+
end
|
6436
|
+
|
6437
|
+
# Convert a local file.
|
6438
|
+
#
|
6439
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
6440
|
+
# * *Returns* - Byte array containing the conversion output.
|
6441
|
+
def convertFile(file)
|
6442
|
+
if (!(File.file?(file) && !File.zero?(file)))
|
6443
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "pdf-to-image", "The file must exist and not be empty.", "convert_file"), 470);
|
6444
|
+
end
|
6445
|
+
|
6446
|
+
@files['file'] = file
|
6447
|
+
@helper.post(@fields, @files, @raw_data)
|
6448
|
+
end
|
6449
|
+
|
6450
|
+
# Convert a local file and write the result to an output stream.
|
6451
|
+
#
|
6452
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
6453
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
6454
|
+
def convertFileToStream(file, out_stream)
|
6455
|
+
if (!(File.file?(file) && !File.zero?(file)))
|
6456
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "pdf-to-image", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
|
6457
|
+
end
|
6458
|
+
|
6459
|
+
@files['file'] = file
|
6460
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
6461
|
+
end
|
6462
|
+
|
6463
|
+
# Convert a local file and write the result to a local file.
|
6464
|
+
#
|
6465
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
6466
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
6467
|
+
def convertFileToFile(file, file_path)
|
6468
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
6469
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "pdf-to-image", "The string must not be empty.", "convert_file_to_file"), 470);
|
6470
|
+
end
|
6471
|
+
|
6472
|
+
output_file = open(file_path, "wb")
|
6473
|
+
begin
|
6474
|
+
convertFileToStream(file, output_file)
|
6475
|
+
output_file.close()
|
6476
|
+
rescue Error => why
|
6477
|
+
output_file.close()
|
6478
|
+
FileUtils.rm(file_path)
|
6479
|
+
raise
|
6480
|
+
end
|
6481
|
+
end
|
6482
|
+
|
6483
|
+
# Convert raw data.
|
6484
|
+
#
|
6485
|
+
# * +data+ - The raw content to be converted.
|
6486
|
+
# * *Returns* - Byte array with the output.
|
6487
|
+
def convertRawData(data)
|
6488
|
+
@raw_data['file'] = data
|
6489
|
+
@helper.post(@fields, @files, @raw_data)
|
6490
|
+
end
|
6491
|
+
|
6492
|
+
# Convert raw data and write the result to an output stream.
|
6493
|
+
#
|
6494
|
+
# * +data+ - The raw content to be converted.
|
6495
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
6496
|
+
def convertRawDataToStream(data, out_stream)
|
6497
|
+
@raw_data['file'] = data
|
6498
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
6499
|
+
end
|
6500
|
+
|
6501
|
+
# Convert raw data to a file.
|
6502
|
+
#
|
6503
|
+
# * +data+ - The raw content to be converted.
|
6504
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
6505
|
+
def convertRawDataToFile(data, file_path)
|
6506
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
6507
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertRawDataToFile::file_path", "pdf-to-image", "The string must not be empty.", "convert_raw_data_to_file"), 470);
|
6508
|
+
end
|
6509
|
+
|
6510
|
+
output_file = open(file_path, "wb")
|
6511
|
+
begin
|
6512
|
+
convertRawDataToStream(data, output_file)
|
6513
|
+
output_file.close()
|
6514
|
+
rescue Error => why
|
6515
|
+
output_file.close()
|
6516
|
+
FileUtils.rm(file_path)
|
6517
|
+
raise
|
6518
|
+
end
|
6519
|
+
end
|
6520
|
+
|
6521
|
+
# Convert the contents of an input stream.
|
6522
|
+
#
|
6523
|
+
# * +in_stream+ - The input stream with source data.
|
6524
|
+
# * *Returns* - Byte array containing the conversion output.
|
6525
|
+
def convertStream(in_stream)
|
6526
|
+
@raw_data['stream'] = in_stream.read
|
6527
|
+
@helper.post(@fields, @files, @raw_data)
|
6528
|
+
end
|
6529
|
+
|
6530
|
+
# Convert the contents of an input stream and write the result to an output stream.
|
6531
|
+
#
|
6532
|
+
# * +in_stream+ - The input stream with source data.
|
6533
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
6534
|
+
def convertStreamToStream(in_stream, out_stream)
|
6535
|
+
@raw_data['stream'] = in_stream.read
|
6536
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
6537
|
+
end
|
6538
|
+
|
6539
|
+
# Convert the contents of an input stream and write the result to a local file.
|
6540
|
+
#
|
6541
|
+
# * +in_stream+ - The input stream with source data.
|
6542
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
6543
|
+
def convertStreamToFile(in_stream, file_path)
|
6544
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
6545
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "pdf-to-image", "The string must not be empty.", "convert_stream_to_file"), 470);
|
6546
|
+
end
|
6547
|
+
|
6548
|
+
output_file = open(file_path, "wb")
|
6549
|
+
begin
|
6550
|
+
convertStreamToStream(in_stream, output_file)
|
6551
|
+
output_file.close()
|
6552
|
+
rescue Error => why
|
6553
|
+
output_file.close()
|
6554
|
+
FileUtils.rm(file_path)
|
6555
|
+
raise
|
6556
|
+
end
|
6557
|
+
end
|
6558
|
+
|
6559
|
+
# The format of the output file.
|
6560
|
+
#
|
6561
|
+
# * +output_format+ - Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.
|
6562
|
+
# * *Returns* - The converter object.
|
6563
|
+
def setOutputFormat(output_format)
|
6564
|
+
unless /(?i)^(png|jpg|gif|tiff|bmp|ico|ppm|pgm|pbm|pnm|psb|pct|ras|tga|sgi|sun|webp)$/.match(output_format)
|
6565
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(output_format, "setOutputFormat", "pdf-to-image", "Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.", "set_output_format"), 470);
|
6566
|
+
end
|
6567
|
+
|
6568
|
+
@fields['output_format'] = output_format
|
6569
|
+
self
|
6570
|
+
end
|
6571
|
+
|
6572
|
+
# Password to open the encrypted PDF file.
|
6573
|
+
#
|
6574
|
+
# * +password+ - The input PDF password.
|
6575
|
+
# * *Returns* - The converter object.
|
6576
|
+
def setPdfPassword(password)
|
6577
|
+
@fields['pdf_password'] = password
|
6578
|
+
self
|
6579
|
+
end
|
6580
|
+
|
6581
|
+
# Set the page range to print.
|
6582
|
+
#
|
6583
|
+
# * +pages+ - A comma separated list of page numbers or ranges.
|
6584
|
+
# * *Returns* - The converter object.
|
6585
|
+
def setPrintPageRange(pages)
|
6586
|
+
unless /^(?:\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*))\s*,\s*)*\s*(?:\d+|(?:\d*\s*\-\s*\d+)|(?:\d+\s*\-\s*\d*))\s*$/.match(pages)
|
6587
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setPrintPageRange", "pdf-to-image", "A comma separated list of page numbers or ranges.", "set_print_page_range"), 470);
|
6588
|
+
end
|
6589
|
+
|
6590
|
+
@fields['print_page_range'] = pages
|
6591
|
+
self
|
6592
|
+
end
|
6593
|
+
|
6594
|
+
# Set the output graphics DPI.
|
6595
|
+
#
|
6596
|
+
# * +dpi+ - The DPI value.
|
6597
|
+
# * *Returns* - The converter object.
|
6598
|
+
def setDpi(dpi)
|
6599
|
+
@fields['dpi'] = dpi
|
6600
|
+
self
|
6601
|
+
end
|
6602
|
+
|
6603
|
+
# A helper method to determine if the output file from a conversion process is a zip archive. The conversion output can be either a single image file or a zip file containing one or more image files. This method should be called after the conversion has been successfully completed.
|
6604
|
+
# * *Returns* - True if the conversion output is a zip archive, otherwise False.
|
6605
|
+
def isZippedOutput()
|
6606
|
+
@fields.fetch('force_zip', false) == true || getPageCount() > 1
|
6607
|
+
end
|
6608
|
+
|
6609
|
+
# Enforces the zip output format.
|
6610
|
+
#
|
6611
|
+
# * +value+ - Set to true to get the output as a zip archive.
|
6612
|
+
# * *Returns* - The converter object.
|
6613
|
+
def setForceZip(value)
|
6614
|
+
@fields['force_zip'] = value
|
6615
|
+
self
|
6616
|
+
end
|
6617
|
+
|
6618
|
+
# Use the crop box rather than media box.
|
6619
|
+
#
|
6620
|
+
# * +value+ - Set to true to use crop box.
|
6621
|
+
# * *Returns* - The converter object.
|
6622
|
+
def setUseCropbox(value)
|
6623
|
+
@fields['use_cropbox'] = value
|
6624
|
+
self
|
6625
|
+
end
|
6626
|
+
|
6627
|
+
# Set the top left X coordinate of the crop area in points.
|
6628
|
+
#
|
6629
|
+
# * +x+ - Must be a positive integer number or 0.
|
6630
|
+
# * *Returns* - The converter object.
|
6631
|
+
def setCropAreaX(x)
|
6632
|
+
if (!(Integer(x) >= 0))
|
6633
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setCropAreaX", "pdf-to-image", "Must be a positive integer number or 0.", "set_crop_area_x"), 470);
|
6634
|
+
end
|
6635
|
+
|
6636
|
+
@fields['crop_area_x'] = x
|
6637
|
+
self
|
6638
|
+
end
|
6639
|
+
|
6640
|
+
# Set the top left Y coordinate of the crop area in points.
|
6641
|
+
#
|
6642
|
+
# * +y+ - Must be a positive integer number or 0.
|
6643
|
+
# * *Returns* - The converter object.
|
6644
|
+
def setCropAreaY(y)
|
6645
|
+
if (!(Integer(y) >= 0))
|
6646
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setCropAreaY", "pdf-to-image", "Must be a positive integer number or 0.", "set_crop_area_y"), 470);
|
6647
|
+
end
|
6648
|
+
|
6649
|
+
@fields['crop_area_y'] = y
|
6650
|
+
self
|
6651
|
+
end
|
6652
|
+
|
6653
|
+
# Set the width of the crop area in points.
|
6654
|
+
#
|
6655
|
+
# * +width+ - Must be a positive integer number or 0.
|
6656
|
+
# * *Returns* - The converter object.
|
6657
|
+
def setCropAreaWidth(width)
|
6658
|
+
if (!(Integer(width) >= 0))
|
6659
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCropAreaWidth", "pdf-to-image", "Must be a positive integer number or 0.", "set_crop_area_width"), 470);
|
6660
|
+
end
|
6661
|
+
|
6662
|
+
@fields['crop_area_width'] = width
|
6663
|
+
self
|
6664
|
+
end
|
6665
|
+
|
6666
|
+
# Set the height of the crop area in points.
|
6667
|
+
#
|
6668
|
+
# * +height+ - Must be a positive integer number or 0.
|
6669
|
+
# * *Returns* - The converter object.
|
6670
|
+
def setCropAreaHeight(height)
|
6671
|
+
if (!(Integer(height) >= 0))
|
6672
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCropAreaHeight", "pdf-to-image", "Must be a positive integer number or 0.", "set_crop_area_height"), 470);
|
6673
|
+
end
|
6674
|
+
|
6675
|
+
@fields['crop_area_height'] = height
|
6676
|
+
self
|
6677
|
+
end
|
6678
|
+
|
6679
|
+
# Set the crop area. It allows to extract just a part of a PDF page.
|
6680
|
+
#
|
6681
|
+
# * +x+ - Set the top left X coordinate of the crop area in points. Must be a positive integer number or 0.
|
6682
|
+
# * +y+ - Set the top left Y coordinate of the crop area in points. Must be a positive integer number or 0.
|
6683
|
+
# * +width+ - Set the width of the crop area in points. Must be a positive integer number or 0.
|
6684
|
+
# * +height+ - Set the height of the crop area in points. Must be a positive integer number or 0.
|
6685
|
+
# * *Returns* - The converter object.
|
6686
|
+
def setCropArea(x, y, width, height)
|
6687
|
+
setCropAreaX(x)
|
6688
|
+
setCropAreaY(y)
|
6689
|
+
setCropAreaWidth(width)
|
6690
|
+
setCropAreaHeight(height)
|
6691
|
+
self
|
6692
|
+
end
|
6693
|
+
|
6694
|
+
# Generate a grayscale image.
|
6695
|
+
#
|
6696
|
+
# * +value+ - Set to true to generate a grayscale image.
|
6697
|
+
# * *Returns* - The converter object.
|
6698
|
+
def setUseGrayscale(value)
|
6699
|
+
@fields['use_grayscale'] = value
|
6700
|
+
self
|
6701
|
+
end
|
6702
|
+
|
6703
|
+
# 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.
|
6704
|
+
#
|
6705
|
+
# * +value+ - Set to true to enable the debug logging.
|
6706
|
+
# * *Returns* - The converter object.
|
6707
|
+
def setDebugLog(value)
|
6708
|
+
@fields['debug_log'] = value
|
6709
|
+
self
|
6710
|
+
end
|
6711
|
+
|
6712
|
+
# Get the URL of the debug log for the last conversion.
|
6713
|
+
# * *Returns* - The link to the debug log.
|
6714
|
+
def getDebugLogUrl()
|
6715
|
+
return @helper.getDebugLogUrl()
|
6716
|
+
end
|
6717
|
+
|
6718
|
+
# Get the number of conversion credits available in your account.
|
6719
|
+
# This method can only be called after a call to one of the convertXtoY methods.
|
6720
|
+
# The returned value can differ from the actual count if you run parallel conversions.
|
6721
|
+
# The special value 999999 is returned if the information is not available.
|
6722
|
+
# * *Returns* - The number of credits.
|
6723
|
+
def getRemainingCreditCount()
|
6724
|
+
return @helper.getRemainingCreditCount()
|
6725
|
+
end
|
6726
|
+
|
6727
|
+
# Get the number of credits consumed by the last conversion.
|
6728
|
+
# * *Returns* - The number of credits.
|
6729
|
+
def getConsumedCreditCount()
|
6730
|
+
return @helper.getConsumedCreditCount()
|
6731
|
+
end
|
6732
|
+
|
6733
|
+
# Get the job id.
|
6734
|
+
# * *Returns* - The unique job identifier.
|
6735
|
+
def getJobId()
|
6736
|
+
return @helper.getJobId()
|
6737
|
+
end
|
6738
|
+
|
6739
|
+
# Get the number of pages in the output document.
|
6740
|
+
# * *Returns* - The page count.
|
6741
|
+
def getPageCount()
|
6742
|
+
return @helper.getPageCount()
|
6743
|
+
end
|
6744
|
+
|
6745
|
+
# Get the size of the output in bytes.
|
6746
|
+
# * *Returns* - The count of bytes.
|
6747
|
+
def getOutputSize()
|
6748
|
+
return @helper.getOutputSize()
|
6749
|
+
end
|
6750
|
+
|
6751
|
+
# Get the version details.
|
6752
|
+
# * *Returns* - API version, converter version, and client version.
|
6753
|
+
def getVersion()
|
6754
|
+
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
6755
|
+
end
|
6756
|
+
|
6757
|
+
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
6758
|
+
#
|
6759
|
+
# * +tag+ - A string with the custom tag.
|
6760
|
+
# * *Returns* - The converter object.
|
6761
|
+
def setTag(tag)
|
6762
|
+
@fields['tag'] = tag
|
6763
|
+
self
|
6764
|
+
end
|
6765
|
+
|
6766
|
+
# A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTP scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
|
6767
|
+
#
|
6768
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
6769
|
+
# * *Returns* - The converter object.
|
6770
|
+
def setHttpProxy(proxy)
|
6771
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
6772
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "pdf-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
|
6773
|
+
end
|
6774
|
+
|
6775
|
+
@fields['http_proxy'] = proxy
|
6776
|
+
self
|
6777
|
+
end
|
6778
|
+
|
6779
|
+
# A proxy server used by Pdfcrowd conversion process for accessing the source URLs with HTTPS scheme. It can help to circumvent regional restrictions or provide limited access to your intranet.
|
6780
|
+
#
|
6781
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
6782
|
+
# * *Returns* - The converter object.
|
6783
|
+
def setHttpsProxy(proxy)
|
6784
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
6785
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "pdf-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
|
6786
|
+
end
|
6787
|
+
|
6788
|
+
@fields['https_proxy'] = proxy
|
6789
|
+
self
|
6790
|
+
end
|
6791
|
+
|
6792
|
+
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
6793
|
+
# Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
|
6794
|
+
#
|
6795
|
+
# * +value+ - Set to true to use HTTP.
|
6796
|
+
# * *Returns* - The converter object.
|
6797
|
+
def setUseHttp(value)
|
6798
|
+
@helper.setUseHttp(value)
|
6799
|
+
self
|
6800
|
+
end
|
6801
|
+
|
6802
|
+
# Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
|
6803
|
+
#
|
6804
|
+
# * +agent+ - The user agent string.
|
6805
|
+
# * *Returns* - The converter object.
|
6806
|
+
def setUserAgent(agent)
|
6807
|
+
@helper.setUserAgent(agent)
|
6808
|
+
self
|
6809
|
+
end
|
6810
|
+
|
6811
|
+
# Specifies an HTTP proxy that the API client library will use to connect to the internet.
|
6812
|
+
#
|
6813
|
+
# * +host+ - The proxy hostname.
|
6814
|
+
# * +port+ - The proxy port.
|
6815
|
+
# * +user_name+ - The username.
|
6816
|
+
# * +password+ - The password.
|
6817
|
+
# * *Returns* - The converter object.
|
6818
|
+
def setProxy(host, port, user_name, password)
|
6819
|
+
@helper.setProxy(host, port, user_name, password)
|
6820
|
+
self
|
6821
|
+
end
|
6822
|
+
|
6823
|
+
# Specifies the number of automatic retries when the 502 or 503 HTTP status code is received. The status code indicates a temporary network issue. This feature can be disabled by setting to 0.
|
6824
|
+
#
|
6825
|
+
# * +count+ - Number of retries.
|
6826
|
+
# * *Returns* - The converter object.
|
6827
|
+
def setRetryCount(count)
|
6828
|
+
@helper.setRetryCount(count)
|
6829
|
+
self
|
6830
|
+
end
|
6831
|
+
|
6832
|
+
end
|
6833
|
+
|
6335
6834
|
end
|
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:
|
4
|
+
version: 6.0.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: 2024-
|
11
|
+
date: 2024-07-01 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.
|