pdfcrowd 5.9.0 → 5.11.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 +1371 -187
- metadata +2 -2
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.11.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.11.0 (https://pdfcrowd.com)')
|
545
545
|
|
546
546
|
@retry_count = 1
|
547
547
|
@converter_version = '20.10'
|
@@ -1783,11 +1783,11 @@ module Pdfcrowd
|
|
1783
1783
|
|
1784
1784
|
# Specifies the scaling mode used for fitting the HTML contents to the print area.
|
1785
1785
|
#
|
1786
|
-
# * +mode+ - The smart scaling mode. Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, mode1.
|
1786
|
+
# * +mode+ - The smart scaling mode. Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, single-page-fit-ex, mode1.
|
1787
1787
|
# * *Returns* - The converter object.
|
1788
1788
|
def setSmartScalingMode(mode)
|
1789
|
-
unless /(?i)^(default|disabled|viewport-fit|content-fit|single-page-fit|mode1)$/.match(mode)
|
1790
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setSmartScalingMode", "html-to-pdf", "Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, mode1.", "set_smart_scaling_mode"), 470);
|
1789
|
+
unless /(?i)^(default|disabled|viewport-fit|content-fit|single-page-fit|single-page-fit-ex|mode1)$/.match(mode)
|
1790
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setSmartScalingMode", "html-to-pdf", "Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, single-page-fit-ex, mode1.", "set_smart_scaling_mode"), 470);
|
1791
1791
|
end
|
1792
1792
|
|
1793
1793
|
@fields['smart_scaling_mode'] = mode
|
@@ -3407,6 +3407,184 @@ module Pdfcrowd
|
|
3407
3407
|
self
|
3408
3408
|
end
|
3409
3409
|
|
3410
|
+
# Set the output canvas size.
|
3411
|
+
#
|
3412
|
+
# * +size+ - Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.
|
3413
|
+
# * *Returns* - The converter object.
|
3414
|
+
def setCanvasSize(size)
|
3415
|
+
unless /(?i)^(A0|A1|A2|A3|A4|A5|A6|Letter)$/.match(size)
|
3416
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(size, "setCanvasSize", "image-to-image", "Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.", "set_canvas_size"), 470);
|
3417
|
+
end
|
3418
|
+
|
3419
|
+
@fields['canvas_size'] = size
|
3420
|
+
self
|
3421
|
+
end
|
3422
|
+
|
3423
|
+
# Set the output canvas width.
|
3424
|
+
#
|
3425
|
+
# * +width+ - The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
3426
|
+
# * *Returns* - The converter object.
|
3427
|
+
def setCanvasWidth(width)
|
3428
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
|
3429
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCanvasWidth", "image-to-image", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", or points \"pt\".", "set_canvas_width"), 470);
|
3430
|
+
end
|
3431
|
+
|
3432
|
+
@fields['canvas_width'] = width
|
3433
|
+
self
|
3434
|
+
end
|
3435
|
+
|
3436
|
+
# Set the output canvas height.
|
3437
|
+
#
|
3438
|
+
# * +height+ - The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
3439
|
+
# * *Returns* - The converter object.
|
3440
|
+
def setCanvasHeight(height)
|
3441
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
3442
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCanvasHeight", "image-to-image", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", or points \"pt\".", "set_canvas_height"), 470);
|
3443
|
+
end
|
3444
|
+
|
3445
|
+
@fields['canvas_height'] = height
|
3446
|
+
self
|
3447
|
+
end
|
3448
|
+
|
3449
|
+
# Set the output canvas dimensions. If no canvas size is specified, margins are applied as a border around the image.
|
3450
|
+
#
|
3451
|
+
# * +width+ - Set the output canvas width. The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
3452
|
+
# * +height+ - Set the output canvas height. The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
3453
|
+
# * *Returns* - The converter object.
|
3454
|
+
def setCanvasDimensions(width, height)
|
3455
|
+
setCanvasWidth(width)
|
3456
|
+
setCanvasHeight(height)
|
3457
|
+
self
|
3458
|
+
end
|
3459
|
+
|
3460
|
+
# Set the output canvas orientation.
|
3461
|
+
#
|
3462
|
+
# * +orientation+ - Allowed values are landscape, portrait.
|
3463
|
+
# * *Returns* - The converter object.
|
3464
|
+
def setOrientation(orientation)
|
3465
|
+
unless /(?i)^(landscape|portrait)$/.match(orientation)
|
3466
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(orientation, "setOrientation", "image-to-image", "Allowed values are landscape, portrait.", "set_orientation"), 470);
|
3467
|
+
end
|
3468
|
+
|
3469
|
+
@fields['orientation'] = orientation
|
3470
|
+
self
|
3471
|
+
end
|
3472
|
+
|
3473
|
+
# Set the image position on the page.
|
3474
|
+
#
|
3475
|
+
# * +position+ - Allowed values are center, top, bottom, left, right, top-left, top-right, bottom-left, bottom-right.
|
3476
|
+
# * *Returns* - The converter object.
|
3477
|
+
def setPosition(position)
|
3478
|
+
unless /(?i)^(center|top|bottom|left|right|top-left|top-right|bottom-left|bottom-right)$/.match(position)
|
3479
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(position, "setPosition", "image-to-image", "Allowed values are center, top, bottom, left, right, top-left, top-right, bottom-left, bottom-right.", "set_position"), 470);
|
3480
|
+
end
|
3481
|
+
|
3482
|
+
@fields['position'] = position
|
3483
|
+
self
|
3484
|
+
end
|
3485
|
+
|
3486
|
+
# Set the mode to print the image on the content area of the page.
|
3487
|
+
#
|
3488
|
+
# * +mode+ - Allowed values are default, fit, stretch.
|
3489
|
+
# * *Returns* - The converter object.
|
3490
|
+
def setPrintCanvasMode(mode)
|
3491
|
+
unless /(?i)^(default|fit|stretch)$/.match(mode)
|
3492
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setPrintCanvasMode", "image-to-image", "Allowed values are default, fit, stretch.", "set_print_canvas_mode"), 470);
|
3493
|
+
end
|
3494
|
+
|
3495
|
+
@fields['print_canvas_mode'] = mode
|
3496
|
+
self
|
3497
|
+
end
|
3498
|
+
|
3499
|
+
# Set the output canvas top margin.
|
3500
|
+
#
|
3501
|
+
# * +top+ - The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
3502
|
+
# * *Returns* - The converter object.
|
3503
|
+
def setMarginTop(top)
|
3504
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(top)
|
3505
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(top, "setMarginTop", "image-to-image", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", or points \"pt\".", "set_margin_top"), 470);
|
3506
|
+
end
|
3507
|
+
|
3508
|
+
@fields['margin_top'] = top
|
3509
|
+
self
|
3510
|
+
end
|
3511
|
+
|
3512
|
+
# Set the output canvas right margin.
|
3513
|
+
#
|
3514
|
+
# * +right+ - The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
3515
|
+
# * *Returns* - The converter object.
|
3516
|
+
def setMarginRight(right)
|
3517
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(right)
|
3518
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(right, "setMarginRight", "image-to-image", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", or points \"pt\".", "set_margin_right"), 470);
|
3519
|
+
end
|
3520
|
+
|
3521
|
+
@fields['margin_right'] = right
|
3522
|
+
self
|
3523
|
+
end
|
3524
|
+
|
3525
|
+
# Set the output canvas bottom margin.
|
3526
|
+
#
|
3527
|
+
# * +bottom+ - The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
3528
|
+
# * *Returns* - The converter object.
|
3529
|
+
def setMarginBottom(bottom)
|
3530
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(bottom)
|
3531
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(bottom, "setMarginBottom", "image-to-image", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", or points \"pt\".", "set_margin_bottom"), 470);
|
3532
|
+
end
|
3533
|
+
|
3534
|
+
@fields['margin_bottom'] = bottom
|
3535
|
+
self
|
3536
|
+
end
|
3537
|
+
|
3538
|
+
# Set the output canvas left margin.
|
3539
|
+
#
|
3540
|
+
# * +left+ - The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
3541
|
+
# * *Returns* - The converter object.
|
3542
|
+
def setMarginLeft(left)
|
3543
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(left)
|
3544
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(left, "setMarginLeft", "image-to-image", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", or points \"pt\".", "set_margin_left"), 470);
|
3545
|
+
end
|
3546
|
+
|
3547
|
+
@fields['margin_left'] = left
|
3548
|
+
self
|
3549
|
+
end
|
3550
|
+
|
3551
|
+
# Set the output canvas margins.
|
3552
|
+
#
|
3553
|
+
# * +top+ - Set the output canvas top margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
3554
|
+
# * +right+ - Set the output canvas right margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
3555
|
+
# * +bottom+ - Set the output canvas bottom margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
3556
|
+
# * +left+ - Set the output canvas left margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
3557
|
+
# * *Returns* - The converter object.
|
3558
|
+
def setMargins(top, right, bottom, left)
|
3559
|
+
setMarginTop(top)
|
3560
|
+
setMarginRight(right)
|
3561
|
+
setMarginBottom(bottom)
|
3562
|
+
setMarginLeft(left)
|
3563
|
+
self
|
3564
|
+
end
|
3565
|
+
|
3566
|
+
# The canvas background color in RGB or RGBA hexadecimal format. The color fills the entire canvas regardless of margins. If no canvas size is specified and the image format supports background (e.g. PDF, PNG), the background color is applied too.
|
3567
|
+
#
|
3568
|
+
# * +color+ - The value must be in RRGGBB or RRGGBBAA hexadecimal format.
|
3569
|
+
# * *Returns* - The converter object.
|
3570
|
+
def setCanvasBackgroundColor(color)
|
3571
|
+
unless /^[0-9a-fA-F]{6,8}$/.match(color)
|
3572
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(color, "setCanvasBackgroundColor", "image-to-image", "The value must be in RRGGBB or RRGGBBAA hexadecimal format.", "set_canvas_background_color"), 470);
|
3573
|
+
end
|
3574
|
+
|
3575
|
+
@fields['canvas_background_color'] = color
|
3576
|
+
self
|
3577
|
+
end
|
3578
|
+
|
3579
|
+
# Set the DPI resolution of the input image. The DPI affects margin options specified in points too (e.g. 1 point is equal to 1 pixel in 96 DPI).
|
3580
|
+
#
|
3581
|
+
# * +dpi+ - The DPI value.
|
3582
|
+
# * *Returns* - The converter object.
|
3583
|
+
def setDpi(dpi)
|
3584
|
+
@fields['dpi'] = dpi
|
3585
|
+
self
|
3586
|
+
end
|
3587
|
+
|
3410
3588
|
# 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.
|
3411
3589
|
#
|
3412
3590
|
# * +value+ - Set to true to enable the debug logging.
|
@@ -3564,11 +3742,11 @@ module Pdfcrowd
|
|
3564
3742
|
|
3565
3743
|
# Specifies the action to be performed on the input PDFs.
|
3566
3744
|
#
|
3567
|
-
# * +action+ - Allowed values are join, shuffle.
|
3745
|
+
# * +action+ - Allowed values are join, shuffle, extract, delete.
|
3568
3746
|
# * *Returns* - The converter object.
|
3569
3747
|
def setAction(action)
|
3570
|
-
unless /(?i)^(join|shuffle)$/.match(action)
|
3571
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(action, "setAction", "pdf-to-pdf", "Allowed values are join, shuffle.", "set_action"), 470);
|
3748
|
+
unless /(?i)^(join|shuffle|extract|delete)$/.match(action)
|
3749
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(action, "setAction", "pdf-to-pdf", "Allowed values are join, shuffle, extract, delete.", "set_action"), 470);
|
3572
3750
|
end
|
3573
3751
|
|
3574
3752
|
@fields['action'] = action
|
@@ -3638,6 +3816,19 @@ module Pdfcrowd
|
|
3638
3816
|
self
|
3639
3817
|
end
|
3640
3818
|
|
3819
|
+
# Set the page range for extract or delete action.
|
3820
|
+
#
|
3821
|
+
# * +pages+ - A comma separated list of page numbers or ranges.
|
3822
|
+
# * *Returns* - The converter object.
|
3823
|
+
def setPageRange(pages)
|
3824
|
+
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)
|
3825
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setPageRange", "pdf-to-pdf", "A comma separated list of page numbers or ranges.", "set_page_range"), 470);
|
3826
|
+
end
|
3827
|
+
|
3828
|
+
@fields['page_range'] = pages
|
3829
|
+
self
|
3830
|
+
end
|
3831
|
+
|
3641
3832
|
# Apply a watermark to each page of the output PDF file. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.
|
3642
3833
|
#
|
3643
3834
|
# * +watermark+ - The file path to a local file. The file must exist and not be empty.
|
@@ -4303,146 +4494,1109 @@ module Pdfcrowd
|
|
4303
4494
|
self
|
4304
4495
|
end
|
4305
4496
|
|
4306
|
-
#
|
4497
|
+
# Set the output page size.
|
4307
4498
|
#
|
4308
|
-
# * +
|
4499
|
+
# * +size+ - Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.
|
4309
4500
|
# * *Returns* - The converter object.
|
4310
|
-
def
|
4311
|
-
|
4501
|
+
def setPageSize(size)
|
4502
|
+
unless /(?i)^(A0|A1|A2|A3|A4|A5|A6|Letter)$/.match(size)
|
4503
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(size, "setPageSize", "image-to-pdf", "Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.", "set_page_size"), 470);
|
4504
|
+
end
|
4505
|
+
|
4506
|
+
@fields['page_size'] = size
|
4312
4507
|
self
|
4313
4508
|
end
|
4314
4509
|
|
4315
|
-
#
|
4316
|
-
# * *Returns* - The link to the debug log.
|
4317
|
-
def getDebugLogUrl()
|
4318
|
-
return @helper.getDebugLogUrl()
|
4319
|
-
end
|
4320
|
-
|
4321
|
-
# Get the number of conversion credits available in your account.
|
4322
|
-
# This method can only be called after a call to one of the convertXtoY methods.
|
4323
|
-
# The returned value can differ from the actual count if you run parallel conversions.
|
4324
|
-
# The special value 999999 is returned if the information is not available.
|
4325
|
-
# * *Returns* - The number of credits.
|
4326
|
-
def getRemainingCreditCount()
|
4327
|
-
return @helper.getRemainingCreditCount()
|
4328
|
-
end
|
4329
|
-
|
4330
|
-
# Get the number of credits consumed by the last conversion.
|
4331
|
-
# * *Returns* - The number of credits.
|
4332
|
-
def getConsumedCreditCount()
|
4333
|
-
return @helper.getConsumedCreditCount()
|
4334
|
-
end
|
4335
|
-
|
4336
|
-
# Get the job id.
|
4337
|
-
# * *Returns* - The unique job identifier.
|
4338
|
-
def getJobId()
|
4339
|
-
return @helper.getJobId()
|
4340
|
-
end
|
4341
|
-
|
4342
|
-
# Get the size of the output in bytes.
|
4343
|
-
# * *Returns* - The count of bytes.
|
4344
|
-
def getOutputSize()
|
4345
|
-
return @helper.getOutputSize()
|
4346
|
-
end
|
4347
|
-
|
4348
|
-
# Get the version details.
|
4349
|
-
# * *Returns* - API version, converter version, and client version.
|
4350
|
-
def getVersion()
|
4351
|
-
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
4352
|
-
end
|
4353
|
-
|
4354
|
-
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
4510
|
+
# Set the output page width.
|
4355
4511
|
#
|
4356
|
-
# * +
|
4512
|
+
# * +width+ - The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
4357
4513
|
# * *Returns* - The converter object.
|
4358
|
-
def
|
4359
|
-
|
4514
|
+
def setPageWidth(width)
|
4515
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
|
4516
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setPageWidth", "image-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", or points \"pt\".", "set_page_width"), 470);
|
4517
|
+
end
|
4518
|
+
|
4519
|
+
@fields['page_width'] = width
|
4360
4520
|
self
|
4361
4521
|
end
|
4362
4522
|
|
4363
|
-
#
|
4523
|
+
# Set the output page height.
|
4364
4524
|
#
|
4365
|
-
# * +
|
4525
|
+
# * +height+ - The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
4366
4526
|
# * *Returns* - The converter object.
|
4367
|
-
def
|
4368
|
-
unless /(?i)^
|
4369
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
4527
|
+
def setPageHeight(height)
|
4528
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
4529
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setPageHeight", "image-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", or points \"pt\".", "set_page_height"), 470);
|
4370
4530
|
end
|
4371
4531
|
|
4372
|
-
@fields['
|
4532
|
+
@fields['page_height'] = height
|
4373
4533
|
self
|
4374
4534
|
end
|
4375
4535
|
|
4376
|
-
#
|
4536
|
+
# Set the output page dimensions. If no page size is specified, margins are applied as a border around the image.
|
4377
4537
|
#
|
4378
|
-
# * +
|
4538
|
+
# * +width+ - Set the output page width. The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
4539
|
+
# * +height+ - Set the output page height. The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
4379
4540
|
# * *Returns* - The converter object.
|
4380
|
-
def
|
4381
|
-
|
4382
|
-
|
4383
|
-
end
|
4384
|
-
|
4385
|
-
@fields['https_proxy'] = proxy
|
4541
|
+
def setPageDimensions(width, height)
|
4542
|
+
setPageWidth(width)
|
4543
|
+
setPageHeight(height)
|
4386
4544
|
self
|
4387
4545
|
end
|
4388
4546
|
|
4389
|
-
# Set the
|
4547
|
+
# Set the output page orientation.
|
4390
4548
|
#
|
4391
|
-
# * +
|
4549
|
+
# * +orientation+ - Allowed values are landscape, portrait.
|
4392
4550
|
# * *Returns* - The converter object.
|
4393
|
-
def
|
4394
|
-
unless /(?i)^(
|
4395
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
4551
|
+
def setOrientation(orientation)
|
4552
|
+
unless /(?i)^(landscape|portrait)$/.match(orientation)
|
4553
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(orientation, "setOrientation", "image-to-pdf", "Allowed values are landscape, portrait.", "set_orientation"), 470);
|
4396
4554
|
end
|
4397
4555
|
|
4398
|
-
@
|
4556
|
+
@fields['orientation'] = orientation
|
4399
4557
|
self
|
4400
4558
|
end
|
4401
4559
|
|
4402
|
-
#
|
4403
|
-
# Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
|
4560
|
+
# Set the image position on the page.
|
4404
4561
|
#
|
4405
|
-
# * +
|
4562
|
+
# * +position+ - Allowed values are center, top, bottom, left, right, top-left, top-right, bottom-left, bottom-right.
|
4406
4563
|
# * *Returns* - The converter object.
|
4407
|
-
def
|
4408
|
-
|
4564
|
+
def setPosition(position)
|
4565
|
+
unless /(?i)^(center|top|bottom|left|right|top-left|top-right|bottom-left|bottom-right)$/.match(position)
|
4566
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(position, "setPosition", "image-to-pdf", "Allowed values are center, top, bottom, left, right, top-left, top-right, bottom-left, bottom-right.", "set_position"), 470);
|
4567
|
+
end
|
4568
|
+
|
4569
|
+
@fields['position'] = position
|
4409
4570
|
self
|
4410
4571
|
end
|
4411
4572
|
|
4412
|
-
# Set
|
4573
|
+
# Set the mode to print the image on the content area of the page.
|
4413
4574
|
#
|
4414
|
-
# * +
|
4575
|
+
# * +mode+ - Allowed values are default, fit, stretch.
|
4415
4576
|
# * *Returns* - The converter object.
|
4416
|
-
def
|
4417
|
-
|
4577
|
+
def setPrintPageMode(mode)
|
4578
|
+
unless /(?i)^(default|fit|stretch)$/.match(mode)
|
4579
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setPrintPageMode", "image-to-pdf", "Allowed values are default, fit, stretch.", "set_print_page_mode"), 470);
|
4580
|
+
end
|
4581
|
+
|
4582
|
+
@fields['print_page_mode'] = mode
|
4418
4583
|
self
|
4419
4584
|
end
|
4420
4585
|
|
4421
|
-
#
|
4586
|
+
# Set the output page top margin.
|
4422
4587
|
#
|
4423
|
-
# * +
|
4424
|
-
# * +port+ - The proxy port.
|
4425
|
-
# * +user_name+ - The username.
|
4426
|
-
# * +password+ - The password.
|
4588
|
+
# * +top+ - The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
4427
4589
|
# * *Returns* - The converter object.
|
4428
|
-
def
|
4429
|
-
|
4590
|
+
def setMarginTop(top)
|
4591
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(top)
|
4592
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(top, "setMarginTop", "image-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", or points \"pt\".", "set_margin_top"), 470);
|
4593
|
+
end
|
4594
|
+
|
4595
|
+
@fields['margin_top'] = top
|
4430
4596
|
self
|
4431
4597
|
end
|
4432
4598
|
|
4433
|
-
#
|
4599
|
+
# Set the output page right margin.
|
4434
4600
|
#
|
4435
|
-
# * +
|
4601
|
+
# * +right+ - The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
4602
|
+
# * *Returns* - The converter object.
|
4603
|
+
def setMarginRight(right)
|
4604
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(right)
|
4605
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(right, "setMarginRight", "image-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", or points \"pt\".", "set_margin_right"), 470);
|
4606
|
+
end
|
4607
|
+
|
4608
|
+
@fields['margin_right'] = right
|
4609
|
+
self
|
4610
|
+
end
|
4611
|
+
|
4612
|
+
# Set the output page bottom margin.
|
4613
|
+
#
|
4614
|
+
# * +bottom+ - The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
4615
|
+
# * *Returns* - The converter object.
|
4616
|
+
def setMarginBottom(bottom)
|
4617
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(bottom)
|
4618
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(bottom, "setMarginBottom", "image-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", or points \"pt\".", "set_margin_bottom"), 470);
|
4619
|
+
end
|
4620
|
+
|
4621
|
+
@fields['margin_bottom'] = bottom
|
4622
|
+
self
|
4623
|
+
end
|
4624
|
+
|
4625
|
+
# Set the output page left margin.
|
4626
|
+
#
|
4627
|
+
# * +left+ - The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
4628
|
+
# * *Returns* - The converter object.
|
4629
|
+
def setMarginLeft(left)
|
4630
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(left)
|
4631
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(left, "setMarginLeft", "image-to-pdf", "The value must be specified in inches \"in\", millimeters \"mm\", centimeters \"cm\", or points \"pt\".", "set_margin_left"), 470);
|
4632
|
+
end
|
4633
|
+
|
4634
|
+
@fields['margin_left'] = left
|
4635
|
+
self
|
4636
|
+
end
|
4637
|
+
|
4638
|
+
# Set the output page margins.
|
4639
|
+
#
|
4640
|
+
# * +top+ - Set the output page top margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
4641
|
+
# * +right+ - Set the output page right margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
4642
|
+
# * +bottom+ - Set the output page bottom margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
4643
|
+
# * +left+ - Set the output page left margin. The value must be specified in inches "in", millimeters "mm", centimeters "cm", or points "pt".
|
4644
|
+
# * *Returns* - The converter object.
|
4645
|
+
def setPageMargins(top, right, bottom, left)
|
4646
|
+
setMarginTop(top)
|
4647
|
+
setMarginRight(right)
|
4648
|
+
setMarginBottom(bottom)
|
4649
|
+
setMarginLeft(left)
|
4650
|
+
self
|
4651
|
+
end
|
4652
|
+
|
4653
|
+
# The page background color in RGB or RGBA hexadecimal format. The color fills the entire page regardless of the margins. If not page size is specified and the image format supports background (e.g. PDF, PNG), the background color is applied too.
|
4654
|
+
#
|
4655
|
+
# * +color+ - The value must be in RRGGBB or RRGGBBAA hexadecimal format.
|
4656
|
+
# * *Returns* - The converter object.
|
4657
|
+
def setPageBackgroundColor(color)
|
4658
|
+
unless /^[0-9a-fA-F]{6,8}$/.match(color)
|
4659
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(color, "setPageBackgroundColor", "image-to-pdf", "The value must be in RRGGBB or RRGGBBAA hexadecimal format.", "set_page_background_color"), 470);
|
4660
|
+
end
|
4661
|
+
|
4662
|
+
@fields['page_background_color'] = color
|
4663
|
+
self
|
4664
|
+
end
|
4665
|
+
|
4666
|
+
# Set the DPI resolution of the input image. The DPI affects margin options specified in points too (e.g. 1 point is equal to 1 pixel in 96 DPI).
|
4667
|
+
#
|
4668
|
+
# * +dpi+ - The DPI value.
|
4669
|
+
# * *Returns* - The converter object.
|
4670
|
+
def setDpi(dpi)
|
4671
|
+
@fields['dpi'] = dpi
|
4672
|
+
self
|
4673
|
+
end
|
4674
|
+
|
4675
|
+
# Apply a watermark to each page of the output PDF file. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.
|
4676
|
+
#
|
4677
|
+
# * +watermark+ - The file path to a local file. The file must exist and not be empty.
|
4678
|
+
# * *Returns* - The converter object.
|
4679
|
+
def setPageWatermark(watermark)
|
4680
|
+
if (!(File.file?(watermark) && !File.zero?(watermark)))
|
4681
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(watermark, "setPageWatermark", "image-to-pdf", "The file must exist and not be empty.", "set_page_watermark"), 470);
|
4682
|
+
end
|
4683
|
+
|
4684
|
+
@files['page_watermark'] = watermark
|
4685
|
+
self
|
4686
|
+
end
|
4687
|
+
|
4688
|
+
# Load a file from the specified URL and apply the file as a watermark to each page of the output PDF. A watermark can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the watermark.
|
4689
|
+
#
|
4690
|
+
# * +url+ - The supported protocols are http:// and https://.
|
4691
|
+
# * *Returns* - The converter object.
|
4692
|
+
def setPageWatermarkUrl(url)
|
4693
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
4694
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageWatermarkUrl", "image-to-pdf", "The supported protocols are http:// and https://.", "set_page_watermark_url"), 470);
|
4695
|
+
end
|
4696
|
+
|
4697
|
+
@fields['page_watermark_url'] = url
|
4698
|
+
self
|
4699
|
+
end
|
4700
|
+
|
4701
|
+
# Apply each page of a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.
|
4702
|
+
#
|
4703
|
+
# * +watermark+ - The file path to a local file. The file must exist and not be empty.
|
4704
|
+
# * *Returns* - The converter object.
|
4705
|
+
def setMultipageWatermark(watermark)
|
4706
|
+
if (!(File.file?(watermark) && !File.zero?(watermark)))
|
4707
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(watermark, "setMultipageWatermark", "image-to-pdf", "The file must exist and not be empty.", "set_multipage_watermark"), 470);
|
4708
|
+
end
|
4709
|
+
|
4710
|
+
@files['multipage_watermark'] = watermark
|
4711
|
+
self
|
4712
|
+
end
|
4713
|
+
|
4714
|
+
# Load a file from the specified URL and apply each page of the file as a watermark to the corresponding page of the output PDF. A watermark can be either a PDF or an image.
|
4715
|
+
#
|
4716
|
+
# * +url+ - The supported protocols are http:// and https://.
|
4717
|
+
# * *Returns* - The converter object.
|
4718
|
+
def setMultipageWatermarkUrl(url)
|
4719
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
4720
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageWatermarkUrl", "image-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_watermark_url"), 470);
|
4721
|
+
end
|
4722
|
+
|
4723
|
+
@fields['multipage_watermark_url'] = url
|
4724
|
+
self
|
4725
|
+
end
|
4726
|
+
|
4727
|
+
# Apply a background to each page of the output PDF file. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.
|
4728
|
+
#
|
4729
|
+
# * +background+ - The file path to a local file. The file must exist and not be empty.
|
4730
|
+
# * *Returns* - The converter object.
|
4731
|
+
def setPageBackground(background)
|
4732
|
+
if (!(File.file?(background) && !File.zero?(background)))
|
4733
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(background, "setPageBackground", "image-to-pdf", "The file must exist and not be empty.", "set_page_background"), 470);
|
4734
|
+
end
|
4735
|
+
|
4736
|
+
@files['page_background'] = background
|
4737
|
+
self
|
4738
|
+
end
|
4739
|
+
|
4740
|
+
# Load a file from the specified URL and apply the file as a background to each page of the output PDF. A background can be either a PDF or an image. If a multi-page file (PDF or TIFF) is used, the first page is used as the background.
|
4741
|
+
#
|
4742
|
+
# * +url+ - The supported protocols are http:// and https://.
|
4743
|
+
# * *Returns* - The converter object.
|
4744
|
+
def setPageBackgroundUrl(url)
|
4745
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
4746
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageBackgroundUrl", "image-to-pdf", "The supported protocols are http:// and https://.", "set_page_background_url"), 470);
|
4747
|
+
end
|
4748
|
+
|
4749
|
+
@fields['page_background_url'] = url
|
4750
|
+
self
|
4751
|
+
end
|
4752
|
+
|
4753
|
+
# Apply each page of a background to the corresponding page of the output PDF. A background can be either a PDF or an image.
|
4754
|
+
#
|
4755
|
+
# * +background+ - The file path to a local file. The file must exist and not be empty.
|
4756
|
+
# * *Returns* - The converter object.
|
4757
|
+
def setMultipageBackground(background)
|
4758
|
+
if (!(File.file?(background) && !File.zero?(background)))
|
4759
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(background, "setMultipageBackground", "image-to-pdf", "The file must exist and not be empty.", "set_multipage_background"), 470);
|
4760
|
+
end
|
4761
|
+
|
4762
|
+
@files['multipage_background'] = background
|
4763
|
+
self
|
4764
|
+
end
|
4765
|
+
|
4766
|
+
# Load a file from the specified URL and apply each page of the file as a background to the corresponding page of the output PDF. A background can be either a PDF or an image.
|
4767
|
+
#
|
4768
|
+
# * +url+ - The supported protocols are http:// and https://.
|
4769
|
+
# * *Returns* - The converter object.
|
4770
|
+
def setMultipageBackgroundUrl(url)
|
4771
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
4772
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageBackgroundUrl", "image-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_background_url"), 470);
|
4773
|
+
end
|
4774
|
+
|
4775
|
+
@fields['multipage_background_url'] = url
|
4776
|
+
self
|
4777
|
+
end
|
4778
|
+
|
4779
|
+
# Create linearized PDF. This is also known as Fast Web View.
|
4780
|
+
#
|
4781
|
+
# * +value+ - Set to true to create linearized PDF.
|
4782
|
+
# * *Returns* - The converter object.
|
4783
|
+
def setLinearize(value)
|
4784
|
+
@fields['linearize'] = value
|
4785
|
+
self
|
4786
|
+
end
|
4787
|
+
|
4788
|
+
# Encrypt the PDF. This prevents search engines from indexing the contents.
|
4789
|
+
#
|
4790
|
+
# * +value+ - Set to true to enable PDF encryption.
|
4791
|
+
# * *Returns* - The converter object.
|
4792
|
+
def setEncrypt(value)
|
4793
|
+
@fields['encrypt'] = value
|
4794
|
+
self
|
4795
|
+
end
|
4796
|
+
|
4797
|
+
# Protect the PDF with a user password. When a PDF has a user password, it must be supplied in order to view the document and to perform operations allowed by the access permissions.
|
4798
|
+
#
|
4799
|
+
# * +password+ - The user password.
|
4800
|
+
# * *Returns* - The converter object.
|
4801
|
+
def setUserPassword(password)
|
4802
|
+
@fields['user_password'] = password
|
4803
|
+
self
|
4804
|
+
end
|
4805
|
+
|
4806
|
+
# Protect the PDF with an owner password. Supplying an owner password grants unlimited access to the PDF including changing the passwords and access permissions.
|
4807
|
+
#
|
4808
|
+
# * +password+ - The owner password.
|
4809
|
+
# * *Returns* - The converter object.
|
4810
|
+
def setOwnerPassword(password)
|
4811
|
+
@fields['owner_password'] = password
|
4812
|
+
self
|
4813
|
+
end
|
4814
|
+
|
4815
|
+
# Disallow printing of the output PDF.
|
4816
|
+
#
|
4817
|
+
# * +value+ - Set to true to set the no-print flag in the output PDF.
|
4818
|
+
# * *Returns* - The converter object.
|
4819
|
+
def setNoPrint(value)
|
4820
|
+
@fields['no_print'] = value
|
4821
|
+
self
|
4822
|
+
end
|
4823
|
+
|
4824
|
+
# Disallow modification of the output PDF.
|
4825
|
+
#
|
4826
|
+
# * +value+ - Set to true to set the read-only only flag in the output PDF.
|
4827
|
+
# * *Returns* - The converter object.
|
4828
|
+
def setNoModify(value)
|
4829
|
+
@fields['no_modify'] = value
|
4830
|
+
self
|
4831
|
+
end
|
4832
|
+
|
4833
|
+
# Disallow text and graphics extraction from the output PDF.
|
4834
|
+
#
|
4835
|
+
# * +value+ - Set to true to set the no-copy flag in the output PDF.
|
4836
|
+
# * *Returns* - The converter object.
|
4837
|
+
def setNoCopy(value)
|
4838
|
+
@fields['no_copy'] = value
|
4839
|
+
self
|
4840
|
+
end
|
4841
|
+
|
4842
|
+
# Set the title of the PDF.
|
4843
|
+
#
|
4844
|
+
# * +title+ - The title.
|
4845
|
+
# * *Returns* - The converter object.
|
4846
|
+
def setTitle(title)
|
4847
|
+
@fields['title'] = title
|
4848
|
+
self
|
4849
|
+
end
|
4850
|
+
|
4851
|
+
# Set the subject of the PDF.
|
4852
|
+
#
|
4853
|
+
# * +subject+ - The subject.
|
4854
|
+
# * *Returns* - The converter object.
|
4855
|
+
def setSubject(subject)
|
4856
|
+
@fields['subject'] = subject
|
4857
|
+
self
|
4858
|
+
end
|
4859
|
+
|
4860
|
+
# Set the author of the PDF.
|
4861
|
+
#
|
4862
|
+
# * +author+ - The author.
|
4863
|
+
# * *Returns* - The converter object.
|
4864
|
+
def setAuthor(author)
|
4865
|
+
@fields['author'] = author
|
4866
|
+
self
|
4867
|
+
end
|
4868
|
+
|
4869
|
+
# Associate keywords with the document.
|
4870
|
+
#
|
4871
|
+
# * +keywords+ - The string with the keywords.
|
4872
|
+
# * *Returns* - The converter object.
|
4873
|
+
def setKeywords(keywords)
|
4874
|
+
@fields['keywords'] = keywords
|
4875
|
+
self
|
4876
|
+
end
|
4877
|
+
|
4878
|
+
# Specify the page layout to be used when the document is opened.
|
4879
|
+
#
|
4880
|
+
# * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
|
4881
|
+
# * *Returns* - The converter object.
|
4882
|
+
def setPageLayout(layout)
|
4883
|
+
unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout)
|
4884
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(layout, "setPageLayout", "image-to-pdf", "Allowed values are single-page, one-column, two-column-left, two-column-right.", "set_page_layout"), 470);
|
4885
|
+
end
|
4886
|
+
|
4887
|
+
@fields['page_layout'] = layout
|
4888
|
+
self
|
4889
|
+
end
|
4890
|
+
|
4891
|
+
# Specify how the document should be displayed when opened.
|
4892
|
+
#
|
4893
|
+
# * +mode+ - Allowed values are full-screen, thumbnails, outlines.
|
4894
|
+
# * *Returns* - The converter object.
|
4895
|
+
def setPageMode(mode)
|
4896
|
+
unless /(?i)^(full-screen|thumbnails|outlines)$/.match(mode)
|
4897
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setPageMode", "image-to-pdf", "Allowed values are full-screen, thumbnails, outlines.", "set_page_mode"), 470);
|
4898
|
+
end
|
4899
|
+
|
4900
|
+
@fields['page_mode'] = mode
|
4901
|
+
self
|
4902
|
+
end
|
4903
|
+
|
4904
|
+
# Specify how the page should be displayed when opened.
|
4905
|
+
#
|
4906
|
+
# * +zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
|
4907
|
+
# * *Returns* - The converter object.
|
4908
|
+
def setInitialZoomType(zoom_type)
|
4909
|
+
unless /(?i)^(fit-width|fit-height|fit-page)$/.match(zoom_type)
|
4910
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom_type, "setInitialZoomType", "image-to-pdf", "Allowed values are fit-width, fit-height, fit-page.", "set_initial_zoom_type"), 470);
|
4911
|
+
end
|
4912
|
+
|
4913
|
+
@fields['initial_zoom_type'] = zoom_type
|
4914
|
+
self
|
4915
|
+
end
|
4916
|
+
|
4917
|
+
# Display the specified page when the document is opened.
|
4918
|
+
#
|
4919
|
+
# * +page+ - Must be a positive integer number.
|
4920
|
+
# * *Returns* - The converter object.
|
4921
|
+
def setInitialPage(page)
|
4922
|
+
if (!(Integer(page) > 0))
|
4923
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "image-to-pdf", "Must be a positive integer number.", "set_initial_page"), 470);
|
4924
|
+
end
|
4925
|
+
|
4926
|
+
@fields['initial_page'] = page
|
4927
|
+
self
|
4928
|
+
end
|
4929
|
+
|
4930
|
+
# Specify the initial page zoom in percents when the document is opened.
|
4931
|
+
#
|
4932
|
+
# * +zoom+ - Must be a positive integer number.
|
4933
|
+
# * *Returns* - The converter object.
|
4934
|
+
def setInitialZoom(zoom)
|
4935
|
+
if (!(Integer(zoom) > 0))
|
4936
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "image-to-pdf", "Must be a positive integer number.", "set_initial_zoom"), 470);
|
4937
|
+
end
|
4938
|
+
|
4939
|
+
@fields['initial_zoom'] = zoom
|
4940
|
+
self
|
4941
|
+
end
|
4942
|
+
|
4943
|
+
# Specify whether to hide the viewer application's tool bars when the document is active.
|
4944
|
+
#
|
4945
|
+
# * +value+ - Set to true to hide tool bars.
|
4946
|
+
# * *Returns* - The converter object.
|
4947
|
+
def setHideToolbar(value)
|
4948
|
+
@fields['hide_toolbar'] = value
|
4949
|
+
self
|
4950
|
+
end
|
4951
|
+
|
4952
|
+
# Specify whether to hide the viewer application's menu bar when the document is active.
|
4953
|
+
#
|
4954
|
+
# * +value+ - Set to true to hide the menu bar.
|
4955
|
+
# * *Returns* - The converter object.
|
4956
|
+
def setHideMenubar(value)
|
4957
|
+
@fields['hide_menubar'] = value
|
4958
|
+
self
|
4959
|
+
end
|
4960
|
+
|
4961
|
+
# 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.
|
4962
|
+
#
|
4963
|
+
# * +value+ - Set to true to hide ui elements.
|
4964
|
+
# * *Returns* - The converter object.
|
4965
|
+
def setHideWindowUi(value)
|
4966
|
+
@fields['hide_window_ui'] = value
|
4967
|
+
self
|
4968
|
+
end
|
4969
|
+
|
4970
|
+
# Specify whether to resize the document's window to fit the size of the first displayed page.
|
4971
|
+
#
|
4972
|
+
# * +value+ - Set to true to resize the window.
|
4973
|
+
# * *Returns* - The converter object.
|
4974
|
+
def setFitWindow(value)
|
4975
|
+
@fields['fit_window'] = value
|
4976
|
+
self
|
4977
|
+
end
|
4978
|
+
|
4979
|
+
# Specify whether to position the document's window in the center of the screen.
|
4980
|
+
#
|
4981
|
+
# * +value+ - Set to true to center the window.
|
4982
|
+
# * *Returns* - The converter object.
|
4983
|
+
def setCenterWindow(value)
|
4984
|
+
@fields['center_window'] = value
|
4985
|
+
self
|
4986
|
+
end
|
4987
|
+
|
4988
|
+
# 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.
|
4989
|
+
#
|
4990
|
+
# * +value+ - Set to true to display the title.
|
4991
|
+
# * *Returns* - The converter object.
|
4992
|
+
def setDisplayTitle(value)
|
4993
|
+
@fields['display_title'] = value
|
4994
|
+
self
|
4995
|
+
end
|
4996
|
+
|
4997
|
+
# 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.
|
4998
|
+
#
|
4999
|
+
# * +value+ - Set to true to enable the debug logging.
|
5000
|
+
# * *Returns* - The converter object.
|
5001
|
+
def setDebugLog(value)
|
5002
|
+
@fields['debug_log'] = value
|
5003
|
+
self
|
5004
|
+
end
|
5005
|
+
|
5006
|
+
# Get the URL of the debug log for the last conversion.
|
5007
|
+
# * *Returns* - The link to the debug log.
|
5008
|
+
def getDebugLogUrl()
|
5009
|
+
return @helper.getDebugLogUrl()
|
5010
|
+
end
|
5011
|
+
|
5012
|
+
# Get the number of conversion credits available in your account.
|
5013
|
+
# This method can only be called after a call to one of the convertXtoY methods.
|
5014
|
+
# The returned value can differ from the actual count if you run parallel conversions.
|
5015
|
+
# The special value 999999 is returned if the information is not available.
|
5016
|
+
# * *Returns* - The number of credits.
|
5017
|
+
def getRemainingCreditCount()
|
5018
|
+
return @helper.getRemainingCreditCount()
|
5019
|
+
end
|
5020
|
+
|
5021
|
+
# Get the number of credits consumed by the last conversion.
|
5022
|
+
# * *Returns* - The number of credits.
|
5023
|
+
def getConsumedCreditCount()
|
5024
|
+
return @helper.getConsumedCreditCount()
|
5025
|
+
end
|
5026
|
+
|
5027
|
+
# Get the job id.
|
5028
|
+
# * *Returns* - The unique job identifier.
|
5029
|
+
def getJobId()
|
5030
|
+
return @helper.getJobId()
|
5031
|
+
end
|
5032
|
+
|
5033
|
+
# Get the size of the output in bytes.
|
5034
|
+
# * *Returns* - The count of bytes.
|
5035
|
+
def getOutputSize()
|
5036
|
+
return @helper.getOutputSize()
|
5037
|
+
end
|
5038
|
+
|
5039
|
+
# Get the version details.
|
5040
|
+
# * *Returns* - API version, converter version, and client version.
|
5041
|
+
def getVersion()
|
5042
|
+
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
5043
|
+
end
|
5044
|
+
|
5045
|
+
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
5046
|
+
#
|
5047
|
+
# * +tag+ - A string with the custom tag.
|
5048
|
+
# * *Returns* - The converter object.
|
5049
|
+
def setTag(tag)
|
5050
|
+
@fields['tag'] = tag
|
5051
|
+
self
|
5052
|
+
end
|
5053
|
+
|
5054
|
+
# 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.
|
5055
|
+
#
|
5056
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
5057
|
+
# * *Returns* - The converter object.
|
5058
|
+
def setHttpProxy(proxy)
|
5059
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
5060
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "image-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
|
5061
|
+
end
|
5062
|
+
|
5063
|
+
@fields['http_proxy'] = proxy
|
5064
|
+
self
|
5065
|
+
end
|
5066
|
+
|
5067
|
+
# 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.
|
5068
|
+
#
|
5069
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
5070
|
+
# * *Returns* - The converter object.
|
5071
|
+
def setHttpsProxy(proxy)
|
5072
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
5073
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "image-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
|
5074
|
+
end
|
5075
|
+
|
5076
|
+
@fields['https_proxy'] = proxy
|
5077
|
+
self
|
5078
|
+
end
|
5079
|
+
|
5080
|
+
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
5081
|
+
#
|
5082
|
+
# * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
|
5083
|
+
# * *Returns* - The converter object.
|
5084
|
+
def setConverterVersion(version)
|
5085
|
+
unless /(?i)^(latest|20.10|18.10)$/.match(version)
|
5086
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "image-to-pdf", "Allowed values are latest, 20.10, 18.10.", "set_converter_version"), 470);
|
5087
|
+
end
|
5088
|
+
|
5089
|
+
@helper.setConverterVersion(version)
|
5090
|
+
self
|
5091
|
+
end
|
5092
|
+
|
5093
|
+
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
5094
|
+
# Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
|
5095
|
+
#
|
5096
|
+
# * +value+ - Set to true to use HTTP.
|
5097
|
+
# * *Returns* - The converter object.
|
5098
|
+
def setUseHttp(value)
|
5099
|
+
@helper.setUseHttp(value)
|
5100
|
+
self
|
5101
|
+
end
|
5102
|
+
|
5103
|
+
# Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
|
5104
|
+
#
|
5105
|
+
# * +agent+ - The user agent string.
|
5106
|
+
# * *Returns* - The converter object.
|
5107
|
+
def setUserAgent(agent)
|
5108
|
+
@helper.setUserAgent(agent)
|
5109
|
+
self
|
5110
|
+
end
|
5111
|
+
|
5112
|
+
# Specifies an HTTP proxy that the API client library will use to connect to the internet.
|
5113
|
+
#
|
5114
|
+
# * +host+ - The proxy hostname.
|
5115
|
+
# * +port+ - The proxy port.
|
5116
|
+
# * +user_name+ - The username.
|
5117
|
+
# * +password+ - The password.
|
5118
|
+
# * *Returns* - The converter object.
|
5119
|
+
def setProxy(host, port, user_name, password)
|
5120
|
+
@helper.setProxy(host, port, user_name, password)
|
5121
|
+
self
|
5122
|
+
end
|
5123
|
+
|
5124
|
+
# Specifies the number of automatic retries when the 502 HTTP status code is received. The 502 status code indicates a temporary network issue. This feature can be disabled by setting to 0.
|
5125
|
+
#
|
5126
|
+
# * +count+ - Number of retries.
|
5127
|
+
# * *Returns* - The converter object.
|
5128
|
+
def setRetryCount(count)
|
5129
|
+
@helper.setRetryCount(count)
|
5130
|
+
self
|
5131
|
+
end
|
5132
|
+
|
5133
|
+
end
|
5134
|
+
|
5135
|
+
# Conversion from PDF to HTML.
|
5136
|
+
class PdfToHtmlClient
|
5137
|
+
# Constructor for the Pdfcrowd API client.
|
5138
|
+
#
|
5139
|
+
# * +user_name+ - Your username at Pdfcrowd.
|
5140
|
+
# * +api_key+ - Your API key.
|
5141
|
+
def initialize(user_name, api_key)
|
5142
|
+
@helper = ConnectionHelper.new(user_name, api_key)
|
5143
|
+
@fields = {
|
5144
|
+
'input_format'=>'pdf',
|
5145
|
+
'output_format'=>'html'
|
5146
|
+
}
|
5147
|
+
@file_id = 1
|
5148
|
+
@files = {}
|
5149
|
+
@raw_data = {}
|
5150
|
+
end
|
5151
|
+
|
5152
|
+
# Convert a PDF.
|
5153
|
+
#
|
5154
|
+
# * +url+ - The address of the PDF to convert. The supported protocols are http:// and https://.
|
5155
|
+
# * *Returns* - Byte array containing the conversion output.
|
5156
|
+
def convertUrl(url)
|
5157
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
5158
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-html", "The supported protocols are http:// and https://.", "convert_url"), 470);
|
5159
|
+
end
|
5160
|
+
|
5161
|
+
@fields['url'] = url
|
5162
|
+
@helper.post(@fields, @files, @raw_data)
|
5163
|
+
end
|
5164
|
+
|
5165
|
+
# Convert a PDF and write the result to an output stream.
|
5166
|
+
#
|
5167
|
+
# * +url+ - The address of the PDF to convert. The supported protocols are http:// and https://.
|
5168
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
5169
|
+
def convertUrlToStream(url, out_stream)
|
5170
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
5171
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "pdf-to-html", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
5172
|
+
end
|
5173
|
+
|
5174
|
+
@fields['url'] = url
|
5175
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
5176
|
+
end
|
5177
|
+
|
5178
|
+
# Convert a PDF and write the result to a local file.
|
5179
|
+
#
|
5180
|
+
# * +url+ - The address of the PDF to convert. The supported protocols are http:// and https://.
|
5181
|
+
# * +file_path+ - The output file path. The string must not be empty. The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.
|
5182
|
+
def convertUrlToFile(url, file_path)
|
5183
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
5184
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "pdf-to-html", "The string must not be empty.", "convert_url_to_file"), 470);
|
5185
|
+
end
|
5186
|
+
|
5187
|
+
if (!(isOutputTypeValid(file_path)))
|
5188
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "pdf-to-html", "The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.", "convert_url_to_file"), 470);
|
5189
|
+
end
|
5190
|
+
|
5191
|
+
output_file = open(file_path, "wb")
|
5192
|
+
begin
|
5193
|
+
convertUrlToStream(url, output_file)
|
5194
|
+
output_file.close()
|
5195
|
+
rescue Error => why
|
5196
|
+
output_file.close()
|
5197
|
+
FileUtils.rm(file_path)
|
5198
|
+
raise
|
5199
|
+
end
|
5200
|
+
end
|
5201
|
+
|
5202
|
+
# Convert a local file.
|
5203
|
+
#
|
5204
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
5205
|
+
# * *Returns* - Byte array containing the conversion output.
|
5206
|
+
def convertFile(file)
|
5207
|
+
if (!(File.file?(file) && !File.zero?(file)))
|
5208
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "pdf-to-html", "The file must exist and not be empty.", "convert_file"), 470);
|
5209
|
+
end
|
5210
|
+
|
5211
|
+
@files['file'] = file
|
5212
|
+
@helper.post(@fields, @files, @raw_data)
|
5213
|
+
end
|
5214
|
+
|
5215
|
+
# Convert a local file and write the result to an output stream.
|
5216
|
+
#
|
5217
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
5218
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
5219
|
+
def convertFileToStream(file, out_stream)
|
5220
|
+
if (!(File.file?(file) && !File.zero?(file)))
|
5221
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "pdf-to-html", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
|
5222
|
+
end
|
5223
|
+
|
5224
|
+
@files['file'] = file
|
5225
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
5226
|
+
end
|
5227
|
+
|
5228
|
+
# Convert a local file and write the result to a local file.
|
5229
|
+
#
|
5230
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
5231
|
+
# * +file_path+ - The output file path. The string must not be empty. The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.
|
5232
|
+
def convertFileToFile(file, file_path)
|
5233
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
5234
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "pdf-to-html", "The string must not be empty.", "convert_file_to_file"), 470);
|
5235
|
+
end
|
5236
|
+
|
5237
|
+
if (!(isOutputTypeValid(file_path)))
|
5238
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "pdf-to-html", "The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.", "convert_file_to_file"), 470);
|
5239
|
+
end
|
5240
|
+
|
5241
|
+
output_file = open(file_path, "wb")
|
5242
|
+
begin
|
5243
|
+
convertFileToStream(file, output_file)
|
5244
|
+
output_file.close()
|
5245
|
+
rescue Error => why
|
5246
|
+
output_file.close()
|
5247
|
+
FileUtils.rm(file_path)
|
5248
|
+
raise
|
5249
|
+
end
|
5250
|
+
end
|
5251
|
+
|
5252
|
+
# Convert raw data.
|
5253
|
+
#
|
5254
|
+
# * +data+ - The raw content to be converted.
|
5255
|
+
# * *Returns* - Byte array with the output.
|
5256
|
+
def convertRawData(data)
|
5257
|
+
@raw_data['file'] = data
|
5258
|
+
@helper.post(@fields, @files, @raw_data)
|
5259
|
+
end
|
5260
|
+
|
5261
|
+
# Convert raw data and write the result to an output stream.
|
5262
|
+
#
|
5263
|
+
# * +data+ - The raw content to be converted.
|
5264
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
5265
|
+
def convertRawDataToStream(data, out_stream)
|
5266
|
+
@raw_data['file'] = data
|
5267
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
5268
|
+
end
|
5269
|
+
|
5270
|
+
# Convert raw data to a file.
|
5271
|
+
#
|
5272
|
+
# * +data+ - The raw content to be converted.
|
5273
|
+
# * +file_path+ - The output file path. The string must not be empty. The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.
|
5274
|
+
def convertRawDataToFile(data, file_path)
|
5275
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
5276
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertRawDataToFile::file_path", "pdf-to-html", "The string must not be empty.", "convert_raw_data_to_file"), 470);
|
5277
|
+
end
|
5278
|
+
|
5279
|
+
if (!(isOutputTypeValid(file_path)))
|
5280
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertRawDataToFile::file_path", "pdf-to-html", "The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.", "convert_raw_data_to_file"), 470);
|
5281
|
+
end
|
5282
|
+
|
5283
|
+
output_file = open(file_path, "wb")
|
5284
|
+
begin
|
5285
|
+
convertRawDataToStream(data, output_file)
|
5286
|
+
output_file.close()
|
5287
|
+
rescue Error => why
|
5288
|
+
output_file.close()
|
5289
|
+
FileUtils.rm(file_path)
|
5290
|
+
raise
|
5291
|
+
end
|
5292
|
+
end
|
5293
|
+
|
5294
|
+
# Convert the contents of an input stream.
|
5295
|
+
#
|
5296
|
+
# * +in_stream+ - The input stream with source data.
|
5297
|
+
# * *Returns* - Byte array containing the conversion output.
|
5298
|
+
def convertStream(in_stream)
|
5299
|
+
@raw_data['stream'] = in_stream.read
|
5300
|
+
@helper.post(@fields, @files, @raw_data)
|
5301
|
+
end
|
5302
|
+
|
5303
|
+
# Convert the contents of an input stream and write the result to an output stream.
|
5304
|
+
#
|
5305
|
+
# * +in_stream+ - The input stream with source data.
|
5306
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
5307
|
+
def convertStreamToStream(in_stream, out_stream)
|
5308
|
+
@raw_data['stream'] = in_stream.read
|
5309
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
5310
|
+
end
|
5311
|
+
|
5312
|
+
# Convert the contents of an input stream and write the result to a local file.
|
5313
|
+
#
|
5314
|
+
# * +in_stream+ - The input stream with source data.
|
5315
|
+
# * +file_path+ - The output file path. The string must not be empty. The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.
|
5316
|
+
def convertStreamToFile(in_stream, file_path)
|
5317
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
5318
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "pdf-to-html", "The string must not be empty.", "convert_stream_to_file"), 470);
|
5319
|
+
end
|
5320
|
+
|
5321
|
+
if (!(isOutputTypeValid(file_path)))
|
5322
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "pdf-to-html", "The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.", "convert_stream_to_file"), 470);
|
5323
|
+
end
|
5324
|
+
|
5325
|
+
output_file = open(file_path, "wb")
|
5326
|
+
begin
|
5327
|
+
convertStreamToStream(in_stream, output_file)
|
5328
|
+
output_file.close()
|
5329
|
+
rescue Error => why
|
5330
|
+
output_file.close()
|
5331
|
+
FileUtils.rm(file_path)
|
5332
|
+
raise
|
5333
|
+
end
|
5334
|
+
end
|
5335
|
+
|
5336
|
+
# Password to open the encrypted PDF file.
|
5337
|
+
#
|
5338
|
+
# * +password+ - The input PDF password.
|
5339
|
+
# * *Returns* - The converter object.
|
5340
|
+
def setPdfPassword(password)
|
5341
|
+
@fields['pdf_password'] = password
|
5342
|
+
self
|
5343
|
+
end
|
5344
|
+
|
5345
|
+
# Set the scaling factor (zoom) for the main page area.
|
5346
|
+
#
|
5347
|
+
# * +factor+ - The percentage value. Must be a positive integer number.
|
5348
|
+
# * *Returns* - The converter object.
|
5349
|
+
def setScaleFactor(factor)
|
5350
|
+
if (!(Integer(factor) > 0))
|
5351
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "pdf-to-html", "Must be a positive integer number.", "set_scale_factor"), 470);
|
5352
|
+
end
|
5353
|
+
|
5354
|
+
@fields['scale_factor'] = factor
|
5355
|
+
self
|
5356
|
+
end
|
5357
|
+
|
5358
|
+
# Set the page range to print.
|
5359
|
+
#
|
5360
|
+
# * +pages+ - A comma separated list of page numbers or ranges.
|
5361
|
+
# * *Returns* - The converter object.
|
5362
|
+
def setPrintPageRange(pages)
|
5363
|
+
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)
|
5364
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setPrintPageRange", "pdf-to-html", "A comma separated list of page numbers or ranges.", "set_print_page_range"), 470);
|
5365
|
+
end
|
5366
|
+
|
5367
|
+
@fields['print_page_range'] = pages
|
5368
|
+
self
|
5369
|
+
end
|
5370
|
+
|
5371
|
+
# Specifies where the images are stored.
|
5372
|
+
#
|
5373
|
+
# * +mode+ - The image storage mode. Allowed values are embed, separate.
|
5374
|
+
# * *Returns* - The converter object.
|
5375
|
+
def setImageMode(mode)
|
5376
|
+
unless /(?i)^(embed|separate)$/.match(mode)
|
5377
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setImageMode", "pdf-to-html", "Allowed values are embed, separate.", "set_image_mode"), 470);
|
5378
|
+
end
|
5379
|
+
|
5380
|
+
@fields['image_mode'] = mode
|
5381
|
+
self
|
5382
|
+
end
|
5383
|
+
|
5384
|
+
# Specifies where the style sheets are stored.
|
5385
|
+
#
|
5386
|
+
# * +mode+ - The style sheet storage mode. Allowed values are embed, separate.
|
5387
|
+
# * *Returns* - The converter object.
|
5388
|
+
def setCssMode(mode)
|
5389
|
+
unless /(?i)^(embed|separate)$/.match(mode)
|
5390
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setCssMode", "pdf-to-html", "Allowed values are embed, separate.", "set_css_mode"), 470);
|
5391
|
+
end
|
5392
|
+
|
5393
|
+
@fields['css_mode'] = mode
|
5394
|
+
self
|
5395
|
+
end
|
5396
|
+
|
5397
|
+
# Specifies where the fonts are stored.
|
5398
|
+
#
|
5399
|
+
# * +mode+ - The font storage mode. Allowed values are embed, separate.
|
5400
|
+
# * *Returns* - The converter object.
|
5401
|
+
def setFontMode(mode)
|
5402
|
+
unless /(?i)^(embed|separate)$/.match(mode)
|
5403
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setFontMode", "pdf-to-html", "Allowed values are embed, separate.", "set_font_mode"), 470);
|
5404
|
+
end
|
5405
|
+
|
5406
|
+
@fields['font_mode'] = mode
|
5407
|
+
self
|
5408
|
+
end
|
5409
|
+
|
5410
|
+
# A helper method to determine if the output file is a zip archive. The output of the conversion may be either an HTML file or a zip file containing the HTML and its external assets.
|
5411
|
+
# * *Returns* - True if the conversion output is a zip file, otherwise False.
|
5412
|
+
def isZippedOutput()
|
5413
|
+
@fields.fetch('image_mode', '') == 'separate' || @fields.fetch('css_mode', '') == 'separate' || @fields.fetch('font_mode', '') == 'separate' || @fields.fetch('force_zip', false) == true
|
5414
|
+
end
|
5415
|
+
|
5416
|
+
# Enforces the zip output format.
|
5417
|
+
#
|
5418
|
+
# * +value+ - Set to true to get the output as a zip archive.
|
5419
|
+
# * *Returns* - The converter object.
|
5420
|
+
def setForceZip(value)
|
5421
|
+
@fields['force_zip'] = value
|
5422
|
+
self
|
5423
|
+
end
|
5424
|
+
|
5425
|
+
# Set the HTML title. The title from the input PDF is used by default.
|
5426
|
+
#
|
5427
|
+
# * +title+ - The HTML title.
|
5428
|
+
# * *Returns* - The converter object.
|
5429
|
+
def setTitle(title)
|
5430
|
+
@fields['title'] = title
|
5431
|
+
self
|
5432
|
+
end
|
5433
|
+
|
5434
|
+
# Set the HTML subject. The subject from the input PDF is used by default.
|
5435
|
+
#
|
5436
|
+
# * +subject+ - The HTML subject.
|
5437
|
+
# * *Returns* - The converter object.
|
5438
|
+
def setSubject(subject)
|
5439
|
+
@fields['subject'] = subject
|
5440
|
+
self
|
5441
|
+
end
|
5442
|
+
|
5443
|
+
# Set the HTML author. The author from the input PDF is used by default.
|
5444
|
+
#
|
5445
|
+
# * +author+ - The HTML author.
|
5446
|
+
# * *Returns* - The converter object.
|
5447
|
+
def setAuthor(author)
|
5448
|
+
@fields['author'] = author
|
5449
|
+
self
|
5450
|
+
end
|
5451
|
+
|
5452
|
+
# Associate keywords with the HTML document. Keywords from the input PDF are used by default.
|
5453
|
+
#
|
5454
|
+
# * +keywords+ - The string containing the keywords.
|
5455
|
+
# * *Returns* - The converter object.
|
5456
|
+
def setKeywords(keywords)
|
5457
|
+
@fields['keywords'] = keywords
|
5458
|
+
self
|
5459
|
+
end
|
5460
|
+
|
5461
|
+
# 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.
|
5462
|
+
#
|
5463
|
+
# * +value+ - Set to true to enable the debug logging.
|
5464
|
+
# * *Returns* - The converter object.
|
5465
|
+
def setDebugLog(value)
|
5466
|
+
@fields['debug_log'] = value
|
5467
|
+
self
|
5468
|
+
end
|
5469
|
+
|
5470
|
+
# Get the URL of the debug log for the last conversion.
|
5471
|
+
# * *Returns* - The link to the debug log.
|
5472
|
+
def getDebugLogUrl()
|
5473
|
+
return @helper.getDebugLogUrl()
|
5474
|
+
end
|
5475
|
+
|
5476
|
+
# Get the number of conversion credits available in your account.
|
5477
|
+
# This method can only be called after a call to one of the convertXtoY methods.
|
5478
|
+
# The returned value can differ from the actual count if you run parallel conversions.
|
5479
|
+
# The special value 999999 is returned if the information is not available.
|
5480
|
+
# * *Returns* - The number of credits.
|
5481
|
+
def getRemainingCreditCount()
|
5482
|
+
return @helper.getRemainingCreditCount()
|
5483
|
+
end
|
5484
|
+
|
5485
|
+
# Get the number of credits consumed by the last conversion.
|
5486
|
+
# * *Returns* - The number of credits.
|
5487
|
+
def getConsumedCreditCount()
|
5488
|
+
return @helper.getConsumedCreditCount()
|
5489
|
+
end
|
5490
|
+
|
5491
|
+
# Get the job id.
|
5492
|
+
# * *Returns* - The unique job identifier.
|
5493
|
+
def getJobId()
|
5494
|
+
return @helper.getJobId()
|
5495
|
+
end
|
5496
|
+
|
5497
|
+
# Get the number of pages in the output document.
|
5498
|
+
# * *Returns* - The page count.
|
5499
|
+
def getPageCount()
|
5500
|
+
return @helper.getPageCount()
|
5501
|
+
end
|
5502
|
+
|
5503
|
+
# Get the size of the output in bytes.
|
5504
|
+
# * *Returns* - The count of bytes.
|
5505
|
+
def getOutputSize()
|
5506
|
+
return @helper.getOutputSize()
|
5507
|
+
end
|
5508
|
+
|
5509
|
+
# Get the version details.
|
5510
|
+
# * *Returns* - API version, converter version, and client version.
|
5511
|
+
def getVersion()
|
5512
|
+
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
5513
|
+
end
|
5514
|
+
|
5515
|
+
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
5516
|
+
#
|
5517
|
+
# * +tag+ - A string with the custom tag.
|
5518
|
+
# * *Returns* - The converter object.
|
5519
|
+
def setTag(tag)
|
5520
|
+
@fields['tag'] = tag
|
5521
|
+
self
|
5522
|
+
end
|
5523
|
+
|
5524
|
+
# 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.
|
5525
|
+
#
|
5526
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
5527
|
+
# * *Returns* - The converter object.
|
5528
|
+
def setHttpProxy(proxy)
|
5529
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
5530
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "pdf-to-html", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
|
5531
|
+
end
|
5532
|
+
|
5533
|
+
@fields['http_proxy'] = proxy
|
5534
|
+
self
|
5535
|
+
end
|
5536
|
+
|
5537
|
+
# 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.
|
5538
|
+
#
|
5539
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
5540
|
+
# * *Returns* - The converter object.
|
5541
|
+
def setHttpsProxy(proxy)
|
5542
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
5543
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "pdf-to-html", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
|
5544
|
+
end
|
5545
|
+
|
5546
|
+
@fields['https_proxy'] = proxy
|
5547
|
+
self
|
5548
|
+
end
|
5549
|
+
|
5550
|
+
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
5551
|
+
# Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
|
5552
|
+
#
|
5553
|
+
# * +value+ - Set to true to use HTTP.
|
5554
|
+
# * *Returns* - The converter object.
|
5555
|
+
def setUseHttp(value)
|
5556
|
+
@helper.setUseHttp(value)
|
5557
|
+
self
|
5558
|
+
end
|
5559
|
+
|
5560
|
+
# Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
|
5561
|
+
#
|
5562
|
+
# * +agent+ - The user agent string.
|
5563
|
+
# * *Returns* - The converter object.
|
5564
|
+
def setUserAgent(agent)
|
5565
|
+
@helper.setUserAgent(agent)
|
5566
|
+
self
|
5567
|
+
end
|
5568
|
+
|
5569
|
+
# Specifies an HTTP proxy that the API client library will use to connect to the internet.
|
5570
|
+
#
|
5571
|
+
# * +host+ - The proxy hostname.
|
5572
|
+
# * +port+ - The proxy port.
|
5573
|
+
# * +user_name+ - The username.
|
5574
|
+
# * +password+ - The password.
|
5575
|
+
# * *Returns* - The converter object.
|
5576
|
+
def setProxy(host, port, user_name, password)
|
5577
|
+
@helper.setProxy(host, port, user_name, password)
|
5578
|
+
self
|
5579
|
+
end
|
5580
|
+
|
5581
|
+
# Specifies the number of automatic retries when the 502 HTTP status code is received. The 502 status code indicates a temporary network issue. This feature can be disabled by setting to 0.
|
5582
|
+
#
|
5583
|
+
# * +count+ - Number of retries.
|
4436
5584
|
# * *Returns* - The converter object.
|
4437
5585
|
def setRetryCount(count)
|
4438
5586
|
@helper.setRetryCount(count)
|
4439
5587
|
self
|
4440
5588
|
end
|
4441
5589
|
|
5590
|
+
private
|
5591
|
+
|
5592
|
+
def isOutputTypeValid(file_path)
|
5593
|
+
extension = File.extname(file_path).downcase
|
5594
|
+
(extension == '.zip') == isZippedOutput()
|
5595
|
+
end
|
4442
5596
|
end
|
4443
5597
|
|
4444
|
-
# Conversion from PDF to
|
4445
|
-
class
|
5598
|
+
# Conversion from PDF to text.
|
5599
|
+
class PdfToTextClient
|
4446
5600
|
# Constructor for the Pdfcrowd API client.
|
4447
5601
|
#
|
4448
5602
|
# * +user_name+ - Your username at Pdfcrowd.
|
@@ -4451,7 +5605,7 @@ module Pdfcrowd
|
|
4451
5605
|
@helper = ConnectionHelper.new(user_name, api_key)
|
4452
5606
|
@fields = {
|
4453
5607
|
'input_format'=>'pdf',
|
4454
|
-
'output_format'=>'
|
5608
|
+
'output_format'=>'txt'
|
4455
5609
|
}
|
4456
5610
|
@file_id = 1
|
4457
5611
|
@files = {}
|
@@ -4464,7 +5618,7 @@ module Pdfcrowd
|
|
4464
5618
|
# * *Returns* - Byte array containing the conversion output.
|
4465
5619
|
def convertUrl(url)
|
4466
5620
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
4467
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-
|
5621
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-text", "The supported protocols are http:// and https://.", "convert_url"), 470);
|
4468
5622
|
end
|
4469
5623
|
|
4470
5624
|
@fields['url'] = url
|
@@ -4477,7 +5631,7 @@ module Pdfcrowd
|
|
4477
5631
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
4478
5632
|
def convertUrlToStream(url, out_stream)
|
4479
5633
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
4480
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "pdf-to-
|
5634
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "pdf-to-text", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
4481
5635
|
end
|
4482
5636
|
|
4483
5637
|
@fields['url'] = url
|
@@ -4487,14 +5641,10 @@ module Pdfcrowd
|
|
4487
5641
|
# Convert a PDF and write the result to a local file.
|
4488
5642
|
#
|
4489
5643
|
# * +url+ - The address of the PDF to convert. The supported protocols are http:// and https://.
|
4490
|
-
# * +file_path+ - The output file path. The string must not be empty.
|
5644
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
4491
5645
|
def convertUrlToFile(url, file_path)
|
4492
5646
|
if (!(!file_path.nil? && !file_path.empty?))
|
4493
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "pdf-to-
|
4494
|
-
end
|
4495
|
-
|
4496
|
-
if (!(isOutputTypeValid(file_path)))
|
4497
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "pdf-to-html", "The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.", "convert_url_to_file"), 470);
|
5647
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "pdf-to-text", "The string must not be empty.", "convert_url_to_file"), 470);
|
4498
5648
|
end
|
4499
5649
|
|
4500
5650
|
output_file = open(file_path, "wb")
|
@@ -4514,7 +5664,7 @@ module Pdfcrowd
|
|
4514
5664
|
# * *Returns* - Byte array containing the conversion output.
|
4515
5665
|
def convertFile(file)
|
4516
5666
|
if (!(File.file?(file) && !File.zero?(file)))
|
4517
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "pdf-to-
|
5667
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "pdf-to-text", "The file must exist and not be empty.", "convert_file"), 470);
|
4518
5668
|
end
|
4519
5669
|
|
4520
5670
|
@files['file'] = file
|
@@ -4527,7 +5677,7 @@ module Pdfcrowd
|
|
4527
5677
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
4528
5678
|
def convertFileToStream(file, out_stream)
|
4529
5679
|
if (!(File.file?(file) && !File.zero?(file)))
|
4530
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "pdf-to-
|
5680
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "pdf-to-text", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
|
4531
5681
|
end
|
4532
5682
|
|
4533
5683
|
@files['file'] = file
|
@@ -4537,14 +5687,10 @@ module Pdfcrowd
|
|
4537
5687
|
# Convert a local file and write the result to a local file.
|
4538
5688
|
#
|
4539
5689
|
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
4540
|
-
# * +file_path+ - The output file path. The string must not be empty.
|
5690
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
4541
5691
|
def convertFileToFile(file, file_path)
|
4542
5692
|
if (!(!file_path.nil? && !file_path.empty?))
|
4543
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "pdf-to-
|
4544
|
-
end
|
4545
|
-
|
4546
|
-
if (!(isOutputTypeValid(file_path)))
|
4547
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "pdf-to-html", "The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.", "convert_file_to_file"), 470);
|
5693
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "pdf-to-text", "The string must not be empty.", "convert_file_to_file"), 470);
|
4548
5694
|
end
|
4549
5695
|
|
4550
5696
|
output_file = open(file_path, "wb")
|
@@ -4579,14 +5725,10 @@ module Pdfcrowd
|
|
4579
5725
|
# Convert raw data to a file.
|
4580
5726
|
#
|
4581
5727
|
# * +data+ - The raw content to be converted.
|
4582
|
-
# * +file_path+ - The output file path. The string must not be empty.
|
5728
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
4583
5729
|
def convertRawDataToFile(data, file_path)
|
4584
5730
|
if (!(!file_path.nil? && !file_path.empty?))
|
4585
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertRawDataToFile::file_path", "pdf-to-
|
4586
|
-
end
|
4587
|
-
|
4588
|
-
if (!(isOutputTypeValid(file_path)))
|
4589
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertRawDataToFile::file_path", "pdf-to-html", "The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.", "convert_raw_data_to_file"), 470);
|
5731
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertRawDataToFile::file_path", "pdf-to-text", "The string must not be empty.", "convert_raw_data_to_file"), 470);
|
4590
5732
|
end
|
4591
5733
|
|
4592
5734
|
output_file = open(file_path, "wb")
|
@@ -4621,14 +5763,10 @@ module Pdfcrowd
|
|
4621
5763
|
# Convert the contents of an input stream and write the result to a local file.
|
4622
5764
|
#
|
4623
5765
|
# * +in_stream+ - The input stream with source data.
|
4624
|
-
# * +file_path+ - The output file path. The string must not be empty.
|
5766
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
4625
5767
|
def convertStreamToFile(in_stream, file_path)
|
4626
5768
|
if (!(!file_path.nil? && !file_path.empty?))
|
4627
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "pdf-to-
|
4628
|
-
end
|
4629
|
-
|
4630
|
-
if (!(isOutputTypeValid(file_path)))
|
4631
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "pdf-to-html", "The converter generates an HTML or ZIP file. If ZIP file is generated, the file path must have a ZIP or zip extension.", "convert_stream_to_file"), 470);
|
5769
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "pdf-to-text", "The string must not be empty.", "convert_stream_to_file"), 470);
|
4632
5770
|
end
|
4633
5771
|
|
4634
5772
|
output_file = open(file_path, "wb")
|
@@ -4642,7 +5780,7 @@ module Pdfcrowd
|
|
4642
5780
|
end
|
4643
5781
|
end
|
4644
5782
|
|
4645
|
-
#
|
5783
|
+
# The password to open the encrypted PDF file.
|
4646
5784
|
#
|
4647
5785
|
# * +password+ - The input PDF password.
|
4648
5786
|
# * *Returns* - The converter object.
|
@@ -4651,119 +5789,171 @@ module Pdfcrowd
|
|
4651
5789
|
self
|
4652
5790
|
end
|
4653
5791
|
|
4654
|
-
# Set the
|
5792
|
+
# Set the page range to print.
|
4655
5793
|
#
|
4656
|
-
# * +
|
5794
|
+
# * +pages+ - A comma separated list of page numbers or ranges.
|
4657
5795
|
# * *Returns* - The converter object.
|
4658
|
-
def
|
4659
|
-
|
4660
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
5796
|
+
def setPrintPageRange(pages)
|
5797
|
+
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)
|
5798
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setPrintPageRange", "pdf-to-text", "A comma separated list of page numbers or ranges.", "set_print_page_range"), 470);
|
4661
5799
|
end
|
4662
5800
|
|
4663
|
-
@fields['
|
5801
|
+
@fields['print_page_range'] = pages
|
4664
5802
|
self
|
4665
5803
|
end
|
4666
5804
|
|
4667
|
-
#
|
5805
|
+
# Ignore the original PDF layout.
|
4668
5806
|
#
|
4669
|
-
# * +
|
5807
|
+
# * +value+ - Set to true to ignore the layout.
|
4670
5808
|
# * *Returns* - The converter object.
|
4671
|
-
def
|
4672
|
-
|
4673
|
-
|
5809
|
+
def setNoLayout(value)
|
5810
|
+
@fields['no_layout'] = value
|
5811
|
+
self
|
5812
|
+
end
|
5813
|
+
|
5814
|
+
# The end-of-line convention for the text output.
|
5815
|
+
#
|
5816
|
+
# * +eol+ - Allowed values are unix, dos, mac.
|
5817
|
+
# * *Returns* - The converter object.
|
5818
|
+
def setEol(eol)
|
5819
|
+
unless /(?i)^(unix|dos|mac)$/.match(eol)
|
5820
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(eol, "setEol", "pdf-to-text", "Allowed values are unix, dos, mac.", "set_eol"), 470);
|
4674
5821
|
end
|
4675
5822
|
|
4676
|
-
@fields['
|
5823
|
+
@fields['eol'] = eol
|
4677
5824
|
self
|
4678
5825
|
end
|
4679
5826
|
|
4680
|
-
#
|
5827
|
+
# Specify the page break mode for the text output.
|
4681
5828
|
#
|
4682
|
-
# * +mode+ -
|
5829
|
+
# * +mode+ - Allowed values are none, default, custom.
|
4683
5830
|
# * *Returns* - The converter object.
|
4684
|
-
def
|
4685
|
-
unless /(?i)^(
|
4686
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "
|
5831
|
+
def setPageBreakMode(mode)
|
5832
|
+
unless /(?i)^(none|default|custom)$/.match(mode)
|
5833
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setPageBreakMode", "pdf-to-text", "Allowed values are none, default, custom.", "set_page_break_mode"), 470);
|
4687
5834
|
end
|
4688
5835
|
|
4689
|
-
@fields['
|
5836
|
+
@fields['page_break_mode'] = mode
|
4690
5837
|
self
|
4691
5838
|
end
|
4692
5839
|
|
4693
|
-
#
|
5840
|
+
# Specify the custom page break.
|
4694
5841
|
#
|
4695
|
-
# * +
|
5842
|
+
# * +page_break+ - String to insert between the pages.
|
4696
5843
|
# * *Returns* - The converter object.
|
4697
|
-
def
|
4698
|
-
|
4699
|
-
|
5844
|
+
def setCustomPageBreak(page_break)
|
5845
|
+
@fields['custom_page_break'] = page_break
|
5846
|
+
self
|
5847
|
+
end
|
5848
|
+
|
5849
|
+
# Specify the paragraph detection mode.
|
5850
|
+
#
|
5851
|
+
# * +mode+ - Allowed values are none, bounding-box, characters.
|
5852
|
+
# * *Returns* - The converter object.
|
5853
|
+
def setParagraphMode(mode)
|
5854
|
+
unless /(?i)^(none|bounding-box|characters)$/.match(mode)
|
5855
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setParagraphMode", "pdf-to-text", "Allowed values are none, bounding-box, characters.", "set_paragraph_mode"), 470);
|
4700
5856
|
end
|
4701
5857
|
|
4702
|
-
@fields['
|
5858
|
+
@fields['paragraph_mode'] = mode
|
4703
5859
|
self
|
4704
5860
|
end
|
4705
5861
|
|
4706
|
-
#
|
5862
|
+
# Set the maximum line spacing when the paragraph detection mode is enabled.
|
4707
5863
|
#
|
4708
|
-
# * +
|
5864
|
+
# * +threshold+ - The value must be a positive integer percentage.
|
4709
5865
|
# * *Returns* - The converter object.
|
4710
|
-
def
|
4711
|
-
unless /(?i)^
|
4712
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
5866
|
+
def setLineSpacingThreshold(threshold)
|
5867
|
+
unless /(?i)^0$|^[0-9]+%$/.match(threshold)
|
5868
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(threshold, "setLineSpacingThreshold", "pdf-to-text", "The value must be a positive integer percentage.", "set_line_spacing_threshold"), 470);
|
4713
5869
|
end
|
4714
5870
|
|
4715
|
-
@fields['
|
5871
|
+
@fields['line_spacing_threshold'] = threshold
|
4716
5872
|
self
|
4717
5873
|
end
|
4718
5874
|
|
4719
|
-
#
|
4720
|
-
#
|
4721
|
-
|
4722
|
-
|
5875
|
+
# Remove the hyphen character from the end of lines.
|
5876
|
+
#
|
5877
|
+
# * +value+ - Set to true to remove hyphens.
|
5878
|
+
# * *Returns* - The converter object.
|
5879
|
+
def setRemoveHyphenation(value)
|
5880
|
+
@fields['remove_hyphenation'] = value
|
5881
|
+
self
|
4723
5882
|
end
|
4724
5883
|
|
4725
|
-
#
|
5884
|
+
# Remove empty lines from the text output.
|
4726
5885
|
#
|
4727
|
-
# * +value+ - Set to true to
|
5886
|
+
# * +value+ - Set to true to remove empty lines.
|
4728
5887
|
# * *Returns* - The converter object.
|
4729
|
-
def
|
4730
|
-
@fields['
|
5888
|
+
def setRemoveEmptyLines(value)
|
5889
|
+
@fields['remove_empty_lines'] = value
|
4731
5890
|
self
|
4732
5891
|
end
|
4733
5892
|
|
4734
|
-
# Set the
|
5893
|
+
# Set the top left X coordinate of the crop area in points.
|
4735
5894
|
#
|
4736
|
-
# * +
|
5895
|
+
# * +x+ - Must be a positive integer number or 0.
|
4737
5896
|
# * *Returns* - The converter object.
|
4738
|
-
def
|
4739
|
-
|
5897
|
+
def setCropAreaX(x)
|
5898
|
+
if (!(Integer(x) >= 0))
|
5899
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setCropAreaX", "pdf-to-text", "Must be a positive integer number or 0.", "set_crop_area_x"), 470);
|
5900
|
+
end
|
5901
|
+
|
5902
|
+
@fields['crop_area_x'] = x
|
4740
5903
|
self
|
4741
5904
|
end
|
4742
5905
|
|
4743
|
-
# Set the
|
5906
|
+
# Set the top left Y coordinate of the crop area in points.
|
4744
5907
|
#
|
4745
|
-
# * +
|
5908
|
+
# * +y+ - Must be a positive integer number or 0.
|
4746
5909
|
# * *Returns* - The converter object.
|
4747
|
-
def
|
4748
|
-
|
5910
|
+
def setCropAreaY(y)
|
5911
|
+
if (!(Integer(y) >= 0))
|
5912
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setCropAreaY", "pdf-to-text", "Must be a positive integer number or 0.", "set_crop_area_y"), 470);
|
5913
|
+
end
|
5914
|
+
|
5915
|
+
@fields['crop_area_y'] = y
|
4749
5916
|
self
|
4750
5917
|
end
|
4751
5918
|
|
4752
|
-
# Set the
|
5919
|
+
# Set the width of the crop area in points.
|
4753
5920
|
#
|
4754
|
-
# * +
|
5921
|
+
# * +width+ - Must be a positive integer number or 0.
|
4755
5922
|
# * *Returns* - The converter object.
|
4756
|
-
def
|
4757
|
-
|
5923
|
+
def setCropAreaWidth(width)
|
5924
|
+
if (!(Integer(width) >= 0))
|
5925
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setCropAreaWidth", "pdf-to-text", "Must be a positive integer number or 0.", "set_crop_area_width"), 470);
|
5926
|
+
end
|
5927
|
+
|
5928
|
+
@fields['crop_area_width'] = width
|
4758
5929
|
self
|
4759
5930
|
end
|
4760
5931
|
|
4761
|
-
#
|
5932
|
+
# Set the height of the crop area in points.
|
4762
5933
|
#
|
4763
|
-
# * +
|
5934
|
+
# * +height+ - Must be a positive integer number or 0.
|
4764
5935
|
# * *Returns* - The converter object.
|
4765
|
-
def
|
4766
|
-
|
5936
|
+
def setCropAreaHeight(height)
|
5937
|
+
if (!(Integer(height) >= 0))
|
5938
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setCropAreaHeight", "pdf-to-text", "Must be a positive integer number or 0.", "set_crop_area_height"), 470);
|
5939
|
+
end
|
5940
|
+
|
5941
|
+
@fields['crop_area_height'] = height
|
5942
|
+
self
|
5943
|
+
end
|
5944
|
+
|
5945
|
+
# Set the crop area. It allows to extract just a part of a PDF page.
|
5946
|
+
#
|
5947
|
+
# * +x+ - Set the top left X coordinate of the crop area in points. Must be a positive integer number or 0.
|
5948
|
+
# * +y+ - Set the top left Y coordinate of the crop area in points. Must be a positive integer number or 0.
|
5949
|
+
# * +width+ - Set the width of the crop area in points. Must be a positive integer number or 0.
|
5950
|
+
# * +height+ - Set the height of the crop area in points. Must be a positive integer number or 0.
|
5951
|
+
# * *Returns* - The converter object.
|
5952
|
+
def setCropArea(x, y, width, height)
|
5953
|
+
setCropAreaX(x)
|
5954
|
+
setCropAreaY(y)
|
5955
|
+
setCropAreaWidth(width)
|
5956
|
+
setCropAreaHeight(height)
|
4767
5957
|
self
|
4768
5958
|
end
|
4769
5959
|
|
@@ -4836,7 +6026,7 @@ module Pdfcrowd
|
|
4836
6026
|
# * *Returns* - The converter object.
|
4837
6027
|
def setHttpProxy(proxy)
|
4838
6028
|
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
4839
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "pdf-to-
|
6029
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "pdf-to-text", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
|
4840
6030
|
end
|
4841
6031
|
|
4842
6032
|
@fields['http_proxy'] = proxy
|
@@ -4849,7 +6039,7 @@ module Pdfcrowd
|
|
4849
6039
|
# * *Returns* - The converter object.
|
4850
6040
|
def setHttpsProxy(proxy)
|
4851
6041
|
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
4852
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "pdf-to-
|
6042
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "pdf-to-text", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
|
4853
6043
|
end
|
4854
6044
|
|
4855
6045
|
@fields['https_proxy'] = proxy
|
@@ -4896,12 +6086,6 @@ module Pdfcrowd
|
|
4896
6086
|
self
|
4897
6087
|
end
|
4898
6088
|
|
4899
|
-
private
|
4900
|
-
|
4901
|
-
def isOutputTypeValid(file_path)
|
4902
|
-
extension = File.extname(file_path).downcase
|
4903
|
-
(extension == '.zip') == isZippedOutput()
|
4904
|
-
end
|
4905
6089
|
end
|
4906
6090
|
|
4907
6091
|
end
|