pdfcrowd 5.1.1 → 5.4.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pdfcrowd.rb +616 -32
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ce783233a9cfb07981027de99484b52696c70ac36865066e263cb4524fc3aa8
4
- data.tar.gz: 8af414bdd2dd8822fcd83c02cf52837baa32449c46270aa19be1c2799c503ada
3
+ metadata.gz: 3d5e4aae437d0c4993770eb539bcd6ec2ead0c8e825e3c3722be116d3b8547aa
4
+ data.tar.gz: 0dfb6bd06a801af12961879abf6f7fb2b0abe641612c53c064479fd7bd484b03
5
5
  SHA512:
6
- metadata.gz: ea0a791e71eedbb2145fb754f9fb39a86583c5b5c7e4e00be87bc622a3299eca1267f1d111ee995fca6093cc5939643dda74c317aab13d067a420cf2b6e851c5
7
- data.tar.gz: 110f85f489157e5db520340ca0d7ce68a14933566dbd2be2e2d5b338b4bdeb03dad99b143fbaee388a09e4c99e00477cbe51004fcb20aa14eec30145a4d2657b
6
+ metadata.gz: c7fbfa74285c6e038ec517bbd084b2d0022939233be6b639d9c412a4c9a40018029c7a82b86c34f2a957b5c44914ecd54b3326d5381f101764b9055088fdc86d
7
+ data.tar.gz: b076d3ea8b2766b5668f36fcafc895e597e47beb0a64c0237ace8ff25e121f934a0ec54c53456578f60b39611a2c2d29617fc805ab5a397b87d8f0fd8f7b7161
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.1.1'
533
+ CLIENT_VERSION = '5.4.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.1.1 (https://pdfcrowd.com)')
544
+ setUserAgent('pdfcrowd_ruby_client/5.4.0 (https://pdfcrowd.com)')
545
545
 
546
546
  @retry_count = 1
547
547
  @converter_version = '20.10'
@@ -626,7 +626,7 @@ module Pdfcrowd
626
626
  body << 'Content-Disposition: form-data; name="%s"; filename="%s"' % [name, file_name]
627
627
  body << 'Content-Type: application/octet-stream'
628
628
  body << ''
629
- body << data
629
+ body << data.force_encoding('UTF-8')
630
630
  end
631
631
 
632
632
  def self.encode_multipart_post_data(fields, files, raw_data)
@@ -735,7 +735,7 @@ module Pdfcrowd
735
735
  def self.create_invalid_value_message(value, field, converter, hint, id)
736
736
  message = "Invalid value '%s' for %s." % [value, field]
737
737
  message += " " + hint if hint
738
- return message + " " + "Details: https://www.pdfcrowd.com/doc/api/%s/ruby/#%s" % [converter, id]
738
+ return message + " " + "Details: https://www.pdfcrowd.com/doc/api/%s/ruby/ref/#%s" % [converter, id]
739
739
  end
740
740
 
741
741
  # generated code
@@ -933,6 +933,15 @@ module Pdfcrowd
933
933
  end
934
934
  end
935
935
 
936
+ # Set the file name of the main HTML document stored in the input archive. If not specified, the first HTML file in the archive is used for conversion. Use this method if the input archive contains multiple HTML documents.
937
+ #
938
+ # * +filename+ - The file name.
939
+ # * *Returns* - The converter object.
940
+ def setZipMainFilename(filename)
941
+ @fields['zip_main_filename'] = filename
942
+ self
943
+ end
944
+
936
945
  # Set the output page size.
937
946
  #
938
947
  # * +size+ - Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.
@@ -1174,7 +1183,7 @@ module Pdfcrowd
1174
1183
  self
1175
1184
  end
1176
1185
 
1177
- # Load an HTML code from the specified URL and use it as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
1186
+ # Load an HTML code from the specified URL and use it as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
1178
1187
  #
1179
1188
  # * +url+ - The supported protocols are http:// and https://.
1180
1189
  # * *Returns* - The converter object.
@@ -1187,7 +1196,7 @@ module Pdfcrowd
1187
1196
  self
1188
1197
  end
1189
1198
 
1190
- # Use the specified HTML code as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
1199
+ # Use the specified HTML code as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
1191
1200
  #
1192
1201
  # * +html+ - The string must not be empty.
1193
1202
  # * *Returns* - The converter object.
@@ -1213,7 +1222,16 @@ module Pdfcrowd
1213
1222
  self
1214
1223
  end
1215
1224
 
1216
- # Load an HTML code from the specified URL and use it as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
1225
+ # Set the file name of the header HTML document stored in the input archive. Use this method if the input archive contains multiple HTML documents.
1226
+ #
1227
+ # * +filename+ - The file name.
1228
+ # * *Returns* - The converter object.
1229
+ def setZipHeaderFilename(filename)
1230
+ @fields['zip_header_filename'] = filename
1231
+ self
1232
+ end
1233
+
1234
+ # Load an HTML code from the specified URL and use it as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
1217
1235
  #
1218
1236
  # * +url+ - The supported protocols are http:// and https://.
1219
1237
  # * *Returns* - The converter object.
@@ -1226,7 +1244,7 @@ module Pdfcrowd
1226
1244
  self
1227
1245
  end
1228
1246
 
1229
- # Use the specified HTML as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
1247
+ # Use the specified HTML as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals. Allowed values: arabic - Arabic numerals, they are used by default roman - Roman numerals eastern-arabic - Eastern Arabic numerals bengali - Bengali numerals devanagari - Devanagari numerals thai - Thai numerals east-asia - Chinese, Vietnamese, Japanese and Korean numerals chinese-formal - Chinese formal numerals Please contact us if you need another type of numerals. Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL. Allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
1230
1248
  #
1231
1249
  # * +html+ - The string must not be empty.
1232
1250
  # * *Returns* - The converter object.
@@ -1252,6 +1270,15 @@ module Pdfcrowd
1252
1270
  self
1253
1271
  end
1254
1272
 
1273
+ # Set the file name of the footer HTML document stored in the input archive. Use this method if the input archive contains multiple HTML documents.
1274
+ #
1275
+ # * +filename+ - The file name.
1276
+ # * *Returns* - The converter object.
1277
+ def setZipFooterFilename(filename)
1278
+ @fields['zip_footer_filename'] = filename
1279
+ self
1280
+ end
1281
+
1255
1282
  # Disable horizontal page margins for header and footer. The header/footer contents width will be equal to the physical page width.
1256
1283
  #
1257
1284
  # * +value+ - Set to true to disable horizontal margins for header and footer.
@@ -1462,6 +1489,15 @@ module Pdfcrowd
1462
1489
  self
1463
1490
  end
1464
1491
 
1492
+ # Use a mobile user agent.
1493
+ #
1494
+ # * +value+ - Set to true to use a mobile user agent.
1495
+ # * *Returns* - The converter object.
1496
+ def setUseMobileUserAgent(value)
1497
+ @fields['use_mobile_user_agent'] = value
1498
+ self
1499
+ end
1500
+
1465
1501
  # Specifies how iframes are handled.
1466
1502
  #
1467
1503
  # * +iframes+ - Allowed values are all, same-origin, none.
@@ -1641,7 +1677,7 @@ module Pdfcrowd
1641
1677
  self
1642
1678
  end
1643
1679
 
1644
- # Specify the DOM handling when only a part of the document is converted.
1680
+ # Specify the DOM handling when only a part of the document is converted. This can affect the CSS rules used.
1645
1681
  #
1646
1682
  # * +mode+ - Allowed values are cut-out, remove-siblings, hide-siblings.
1647
1683
  # * *Returns* - The converter object.
@@ -1680,7 +1716,7 @@ module Pdfcrowd
1680
1716
  self
1681
1717
  end
1682
1718
 
1683
- # Set the viewport height in pixels. The viewport is the user's visible area of the page.
1719
+ # Set the viewport height in pixels. The viewport is the user's visible area of the page. If the input HTML uses lazily loaded images, try using a large value that covers the entire height of the HTML, e.g. 100000.
1684
1720
  #
1685
1721
  # * +height+ - Must be a positive integer number.
1686
1722
  # * *Returns* - The converter object.
@@ -1696,7 +1732,7 @@ module Pdfcrowd
1696
1732
  # Set the viewport size. The viewport is the user's visible area of the page.
1697
1733
  #
1698
1734
  # * +width+ - Set the viewport width in pixels. The viewport is the user's visible area of the page. The value must be in the range 96-65000.
1699
- # * +height+ - Set the viewport height in pixels. The viewport is the user's visible area of the page. Must be a positive integer number.
1735
+ # * +height+ - Set the viewport height in pixels. The viewport is the user's visible area of the page. If the input HTML uses lazily loaded images, try using a large value that covers the entire height of the HTML, e.g. 100000. Must be a positive integer number.
1700
1736
  # * *Returns* - The converter object.
1701
1737
  def setViewport(width, height)
1702
1738
  setViewportWidth(width)
@@ -1881,6 +1917,15 @@ module Pdfcrowd
1881
1917
  self
1882
1918
  end
1883
1919
 
1920
+ # Extract meta tags (author, keywords and description) from the input HTML and use them in the output PDF.
1921
+ #
1922
+ # * +value+ - Set to true to extract meta tags.
1923
+ # * *Returns* - The converter object.
1924
+ def setExtractMetaTags(value)
1925
+ @fields['extract_meta_tags'] = value
1926
+ self
1927
+ end
1928
+
1884
1929
  # Specify the page layout to be used when the document is opened.
1885
1930
  #
1886
1931
  # * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
@@ -2101,7 +2146,7 @@ module Pdfcrowd
2101
2146
  end
2102
2147
 
2103
2148
  # Get the number of conversion credits available in your account.
2104
- # This method can only be called after a call to one of the convertXYZ methods.
2149
+ # This method can only be called after a call to one of the convertXtoY methods.
2105
2150
  # The returned value can differ from the actual count if you run parallel conversions.
2106
2151
  # The special value 999999 is returned if the information is not available.
2107
2152
  # * *Returns* - The number of credits.
@@ -2287,7 +2332,7 @@ module Pdfcrowd
2287
2332
  self
2288
2333
  end
2289
2334
 
2290
- # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
2335
+ # Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
2291
2336
  #
2292
2337
  # * +agent+ - The user agent string.
2293
2338
  # * *Returns* - The converter object.
@@ -2308,9 +2353,9 @@ module Pdfcrowd
2308
2353
  self
2309
2354
  end
2310
2355
 
2311
- # Specifies the number of 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.
2356
+ # 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.
2312
2357
  #
2313
- # * +count+ - Number of retries wanted.
2358
+ # * +count+ - Number of retries.
2314
2359
  # * *Returns* - The converter object.
2315
2360
  def setRetryCount(count)
2316
2361
  @helper.setRetryCount(count)
@@ -2525,6 +2570,15 @@ module Pdfcrowd
2525
2570
  end
2526
2571
  end
2527
2572
 
2573
+ # Set the file name of the main HTML document stored in the input archive. If not specified, the first HTML file in the archive is used for conversion. Use this method if the input archive contains multiple HTML documents.
2574
+ #
2575
+ # * +filename+ - The file name.
2576
+ # * *Returns* - The converter object.
2577
+ def setZipMainFilename(filename)
2578
+ @fields['zip_main_filename'] = filename
2579
+ self
2580
+ end
2581
+
2528
2582
  # Use the print version of the page if available (@media print).
2529
2583
  #
2530
2584
  # * +value+ - Set to true to use the print version of the page.
@@ -2570,6 +2624,15 @@ module Pdfcrowd
2570
2624
  self
2571
2625
  end
2572
2626
 
2627
+ # Use a mobile user agent.
2628
+ #
2629
+ # * +value+ - Set to true to use a mobile user agent.
2630
+ # * *Returns* - The converter object.
2631
+ def setUseMobileUserAgent(value)
2632
+ @fields['use_mobile_user_agent'] = value
2633
+ self
2634
+ end
2635
+
2573
2636
  # Specifies how iframes are handled.
2574
2637
  #
2575
2638
  # * +iframes+ - Allowed values are all, same-origin, none.
@@ -2749,7 +2812,7 @@ module Pdfcrowd
2749
2812
  self
2750
2813
  end
2751
2814
 
2752
- # Specify the DOM handling when only a part of the document is converted.
2815
+ # Specify the DOM handling when only a part of the document is converted. This can affect the CSS rules used.
2753
2816
  #
2754
2817
  # * +mode+ - Allowed values are cut-out, remove-siblings, hide-siblings.
2755
2818
  # * *Returns* - The converter object.
@@ -2919,7 +2982,7 @@ module Pdfcrowd
2919
2982
  end
2920
2983
 
2921
2984
  # Get the number of conversion credits available in your account.
2922
- # This method can only be called after a call to one of the convertXYZ methods.
2985
+ # This method can only be called after a call to one of the convertXtoY methods.
2923
2986
  # The returned value can differ from the actual count if you run parallel conversions.
2924
2987
  # The special value 999999 is returned if the information is not available.
2925
2988
  # * *Returns* - The number of credits.
@@ -3031,7 +3094,7 @@ module Pdfcrowd
3031
3094
  self
3032
3095
  end
3033
3096
 
3034
- # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
3097
+ # Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
3035
3098
  #
3036
3099
  # * +agent+ - The user agent string.
3037
3100
  # * *Returns* - The converter object.
@@ -3052,9 +3115,9 @@ module Pdfcrowd
3052
3115
  self
3053
3116
  end
3054
3117
 
3055
- # Specifies the number of 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.
3118
+ # 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.
3056
3119
  #
3057
- # * +count+ - Number of retries wanted.
3120
+ # * +count+ - Number of retries.
3058
3121
  # * *Returns* - The converter object.
3059
3122
  def setRetryCount(count)
3060
3123
  @helper.setRetryCount(count)
@@ -3295,7 +3358,7 @@ module Pdfcrowd
3295
3358
  end
3296
3359
 
3297
3360
  # Get the number of conversion credits available in your account.
3298
- # This method can only be called after a call to one of the convertXYZ methods.
3361
+ # This method can only be called after a call to one of the convertXtoY methods.
3299
3362
  # The returned value can differ from the actual count if you run parallel conversions.
3300
3363
  # The special value 999999 is returned if the information is not available.
3301
3364
  # * *Returns* - The number of credits.
@@ -3385,7 +3448,7 @@ module Pdfcrowd
3385
3448
  self
3386
3449
  end
3387
3450
 
3388
- # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
3451
+ # Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
3389
3452
  #
3390
3453
  # * +agent+ - The user agent string.
3391
3454
  # * *Returns* - The converter object.
@@ -3406,9 +3469,9 @@ module Pdfcrowd
3406
3469
  self
3407
3470
  end
3408
3471
 
3409
- # Specifies the number of 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.
3472
+ # 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.
3410
3473
  #
3411
- # * +count+ - Number of retries wanted.
3474
+ # * +count+ - Number of retries.
3412
3475
  # * *Returns* - The converter object.
3413
3476
  def setRetryCount(count)
3414
3477
  @helper.setRetryCount(count)
@@ -3501,6 +3564,15 @@ module Pdfcrowd
3501
3564
  self
3502
3565
  end
3503
3566
 
3567
+ # Password to open the encrypted PDF file.
3568
+ #
3569
+ # * +password+ - The input PDF password.
3570
+ # * *Returns* - The converter object.
3571
+ def setInputPdfPassword(password)
3572
+ @fields['input_pdf_password'] = password
3573
+ self
3574
+ end
3575
+
3504
3576
  # Apply the first page of the watermark PDF to every page of the output PDF.
3505
3577
  #
3506
3578
  # * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
@@ -3668,6 +3740,55 @@ module Pdfcrowd
3668
3740
  self
3669
3741
  end
3670
3742
 
3743
+ # Set the title of the PDF.
3744
+ #
3745
+ # * +title+ - The title.
3746
+ # * *Returns* - The converter object.
3747
+ def setTitle(title)
3748
+ @fields['title'] = title
3749
+ self
3750
+ end
3751
+
3752
+ # Set the subject of the PDF.
3753
+ #
3754
+ # * +subject+ - The subject.
3755
+ # * *Returns* - The converter object.
3756
+ def setSubject(subject)
3757
+ @fields['subject'] = subject
3758
+ self
3759
+ end
3760
+
3761
+ # Set the author of the PDF.
3762
+ #
3763
+ # * +author+ - The author.
3764
+ # * *Returns* - The converter object.
3765
+ def setAuthor(author)
3766
+ @fields['author'] = author
3767
+ self
3768
+ end
3769
+
3770
+ # Associate keywords with the document.
3771
+ #
3772
+ # * +keywords+ - The string with the keywords.
3773
+ # * *Returns* - The converter object.
3774
+ def setKeywords(keywords)
3775
+ @fields['keywords'] = keywords
3776
+ self
3777
+ end
3778
+
3779
+ # Use metadata (title, subject, author and keywords) from the n-th input PDF.
3780
+ #
3781
+ # * +index+ - Set the index of the input PDF file from which to use the metadata. 0 means no metadata. Must be a positive integer number or 0.
3782
+ # * *Returns* - The converter object.
3783
+ def setUseMetadataFrom(index)
3784
+ if (!(Integer(index) >= 0))
3785
+ raise Error.new(Pdfcrowd.create_invalid_value_message(index, "setUseMetadataFrom", "pdf-to-pdf", "Must be a positive integer number or 0.", "set_use_metadata_from"), 470);
3786
+ end
3787
+
3788
+ @fields['use_metadata_from'] = index
3789
+ self
3790
+ end
3791
+
3671
3792
  # Specify the page layout to be used when the document is opened.
3672
3793
  #
3673
3794
  # * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
@@ -3812,7 +3933,7 @@ module Pdfcrowd
3812
3933
  end
3813
3934
 
3814
3935
  # Get the number of conversion credits available in your account.
3815
- # This method can only be called after a call to one of the convertXYZ methods.
3936
+ # This method can only be called after a call to one of the convertXtoY methods.
3816
3937
  # The returned value can differ from the actual count if you run parallel conversions.
3817
3938
  # The special value 999999 is returned if the information is not available.
3818
3939
  # * *Returns* - The number of credits.
@@ -3882,7 +4003,7 @@ module Pdfcrowd
3882
4003
  self
3883
4004
  end
3884
4005
 
3885
- # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
4006
+ # Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
3886
4007
  #
3887
4008
  # * +agent+ - The user agent string.
3888
4009
  # * *Returns* - The converter object.
@@ -3903,9 +4024,9 @@ module Pdfcrowd
3903
4024
  self
3904
4025
  end
3905
4026
 
3906
- # Specifies the number of 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.
4027
+ # 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.
3907
4028
  #
3908
- # * +count+ - Number of retries wanted.
4029
+ # * +count+ - Number of retries.
3909
4030
  # * *Returns* - The converter object.
3910
4031
  def setRetryCount(count)
3911
4032
  @helper.setRetryCount(count)
@@ -4133,7 +4254,7 @@ module Pdfcrowd
4133
4254
  end
4134
4255
 
4135
4256
  # Get the number of conversion credits available in your account.
4136
- # This method can only be called after a call to one of the convertXYZ methods.
4257
+ # This method can only be called after a call to one of the convertXtoY methods.
4137
4258
  # The returned value can differ from the actual count if you run parallel conversions.
4138
4259
  # The special value 999999 is returned if the information is not available.
4139
4260
  # * *Returns* - The number of credits.
@@ -4223,7 +4344,464 @@ module Pdfcrowd
4223
4344
  self
4224
4345
  end
4225
4346
 
4226
- # Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
4347
+ # Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
4348
+ #
4349
+ # * +agent+ - The user agent string.
4350
+ # * *Returns* - The converter object.
4351
+ def setUserAgent(agent)
4352
+ @helper.setUserAgent(agent)
4353
+ self
4354
+ end
4355
+
4356
+ # Specifies an HTTP proxy that the API client library will use to connect to the internet.
4357
+ #
4358
+ # * +host+ - The proxy hostname.
4359
+ # * +port+ - The proxy port.
4360
+ # * +user_name+ - The username.
4361
+ # * +password+ - The password.
4362
+ # * *Returns* - The converter object.
4363
+ def setProxy(host, port, user_name, password)
4364
+ @helper.setProxy(host, port, user_name, password)
4365
+ self
4366
+ end
4367
+
4368
+ # 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.
4369
+ #
4370
+ # * +count+ - Number of retries.
4371
+ # * *Returns* - The converter object.
4372
+ def setRetryCount(count)
4373
+ @helper.setRetryCount(count)
4374
+ self
4375
+ end
4376
+
4377
+ end
4378
+
4379
+ # Conversion from PDF to HTML.
4380
+ class PdfToHtmlClient
4381
+ # Constructor for the Pdfcrowd API client.
4382
+ #
4383
+ # * +user_name+ - Your username at Pdfcrowd.
4384
+ # * +api_key+ - Your API key.
4385
+ def initialize(user_name, api_key)
4386
+ @helper = ConnectionHelper.new(user_name, api_key)
4387
+ @fields = {
4388
+ 'input_format'=>'pdf',
4389
+ 'output_format'=>'html'
4390
+ }
4391
+ @file_id = 1
4392
+ @files = {}
4393
+ @raw_data = {}
4394
+ end
4395
+
4396
+ # Convert a PDF.
4397
+ #
4398
+ # * +url+ - The address of the PDF to convert. The supported protocols are http:// and https://.
4399
+ # * *Returns* - Byte array containing the conversion output.
4400
+ def convertUrl(url)
4401
+ unless /(?i)^https?:\/\/.*$/.match(url)
4402
+ raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-html", "The supported protocols are http:// and https://.", "convert_url"), 470);
4403
+ end
4404
+
4405
+ @fields['url'] = url
4406
+ @helper.post(@fields, @files, @raw_data)
4407
+ end
4408
+
4409
+ # Convert a PDF and write the result to an output stream.
4410
+ #
4411
+ # * +url+ - The address of the PDF to convert. The supported protocols are http:// and https://.
4412
+ # * +out_stream+ - The output stream that will contain the conversion output.
4413
+ def convertUrlToStream(url, out_stream)
4414
+ unless /(?i)^https?:\/\/.*$/.match(url)
4415
+ 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);
4416
+ end
4417
+
4418
+ @fields['url'] = url
4419
+ @helper.post(@fields, @files, @raw_data, out_stream)
4420
+ end
4421
+
4422
+ # Convert a PDF and write the result to a local file.
4423
+ #
4424
+ # * +url+ - The address of the PDF to convert. The supported protocols are http:// and https://.
4425
+ # * +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.
4426
+ def convertUrlToFile(url, file_path)
4427
+ if (!(!file_path.nil? && !file_path.empty?))
4428
+ 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);
4429
+ end
4430
+
4431
+ if (!(isOutputTypeValid(file_path)))
4432
+ 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);
4433
+ end
4434
+
4435
+ output_file = open(file_path, "wb")
4436
+ begin
4437
+ convertUrlToStream(url, output_file)
4438
+ output_file.close()
4439
+ rescue Error => why
4440
+ output_file.close()
4441
+ FileUtils.rm(file_path)
4442
+ raise
4443
+ end
4444
+ end
4445
+
4446
+ # Convert a local file.
4447
+ #
4448
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
4449
+ # * *Returns* - Byte array containing the conversion output.
4450
+ def convertFile(file)
4451
+ if (!(File.file?(file) && !File.zero?(file)))
4452
+ raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "pdf-to-html", "The file must exist and not be empty.", "convert_file"), 470);
4453
+ end
4454
+
4455
+ @files['file'] = file
4456
+ @helper.post(@fields, @files, @raw_data)
4457
+ end
4458
+
4459
+ # Convert a local file and write the result to an output stream.
4460
+ #
4461
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
4462
+ # * +out_stream+ - The output stream that will contain the conversion output.
4463
+ def convertFileToStream(file, out_stream)
4464
+ if (!(File.file?(file) && !File.zero?(file)))
4465
+ 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);
4466
+ end
4467
+
4468
+ @files['file'] = file
4469
+ @helper.post(@fields, @files, @raw_data, out_stream)
4470
+ end
4471
+
4472
+ # Convert a local file and write the result to a local file.
4473
+ #
4474
+ # * +file+ - The path to a local file to convert. The file must exist and not be empty.
4475
+ # * +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.
4476
+ def convertFileToFile(file, file_path)
4477
+ if (!(!file_path.nil? && !file_path.empty?))
4478
+ 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);
4479
+ end
4480
+
4481
+ if (!(isOutputTypeValid(file_path)))
4482
+ 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);
4483
+ end
4484
+
4485
+ output_file = open(file_path, "wb")
4486
+ begin
4487
+ convertFileToStream(file, output_file)
4488
+ output_file.close()
4489
+ rescue Error => why
4490
+ output_file.close()
4491
+ FileUtils.rm(file_path)
4492
+ raise
4493
+ end
4494
+ end
4495
+
4496
+ # Convert raw data.
4497
+ #
4498
+ # * +data+ - The raw content to be converted.
4499
+ # * *Returns* - Byte array with the output.
4500
+ def convertRawData(data)
4501
+ @raw_data['file'] = data
4502
+ @helper.post(@fields, @files, @raw_data)
4503
+ end
4504
+
4505
+ # Convert raw data and write the result to an output stream.
4506
+ #
4507
+ # * +data+ - The raw content to be converted.
4508
+ # * +out_stream+ - The output stream that will contain the conversion output.
4509
+ def convertRawDataToStream(data, out_stream)
4510
+ @raw_data['file'] = data
4511
+ @helper.post(@fields, @files, @raw_data, out_stream)
4512
+ end
4513
+
4514
+ # Convert raw data to a file.
4515
+ #
4516
+ # * +data+ - The raw content to be converted.
4517
+ # * +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.
4518
+ def convertRawDataToFile(data, file_path)
4519
+ if (!(!file_path.nil? && !file_path.empty?))
4520
+ 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);
4521
+ end
4522
+
4523
+ if (!(isOutputTypeValid(file_path)))
4524
+ 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);
4525
+ end
4526
+
4527
+ output_file = open(file_path, "wb")
4528
+ begin
4529
+ convertRawDataToStream(data, output_file)
4530
+ output_file.close()
4531
+ rescue Error => why
4532
+ output_file.close()
4533
+ FileUtils.rm(file_path)
4534
+ raise
4535
+ end
4536
+ end
4537
+
4538
+ # Convert the contents of an input stream.
4539
+ #
4540
+ # * +in_stream+ - The input stream with source data.
4541
+ # * *Returns* - Byte array containing the conversion output.
4542
+ def convertStream(in_stream)
4543
+ @raw_data['stream'] = in_stream.read
4544
+ @helper.post(@fields, @files, @raw_data)
4545
+ end
4546
+
4547
+ # Convert the contents of an input stream and write the result to an output stream.
4548
+ #
4549
+ # * +in_stream+ - The input stream with source data.
4550
+ # * +out_stream+ - The output stream that will contain the conversion output.
4551
+ def convertStreamToStream(in_stream, out_stream)
4552
+ @raw_data['stream'] = in_stream.read
4553
+ @helper.post(@fields, @files, @raw_data, out_stream)
4554
+ end
4555
+
4556
+ # Convert the contents of an input stream and write the result to a local file.
4557
+ #
4558
+ # * +in_stream+ - The input stream with source data.
4559
+ # * +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.
4560
+ def convertStreamToFile(in_stream, file_path)
4561
+ if (!(!file_path.nil? && !file_path.empty?))
4562
+ 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);
4563
+ end
4564
+
4565
+ if (!(isOutputTypeValid(file_path)))
4566
+ 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);
4567
+ end
4568
+
4569
+ output_file = open(file_path, "wb")
4570
+ begin
4571
+ convertStreamToStream(in_stream, output_file)
4572
+ output_file.close()
4573
+ rescue Error => why
4574
+ output_file.close()
4575
+ FileUtils.rm(file_path)
4576
+ raise
4577
+ end
4578
+ end
4579
+
4580
+ # Password to open the encrypted PDF file.
4581
+ #
4582
+ # * +password+ - The input PDF password.
4583
+ # * *Returns* - The converter object.
4584
+ def setPdfPassword(password)
4585
+ @fields['pdf_password'] = password
4586
+ self
4587
+ end
4588
+
4589
+ # Set the scaling factor (zoom) for the main page area.
4590
+ #
4591
+ # * +factor+ - The percentage value. Must be a positive integer number.
4592
+ # * *Returns* - The converter object.
4593
+ def setScaleFactor(factor)
4594
+ if (!(Integer(factor) > 0))
4595
+ raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "pdf-to-html", "Must be a positive integer number.", "set_scale_factor"), 470);
4596
+ end
4597
+
4598
+ @fields['scale_factor'] = factor
4599
+ self
4600
+ end
4601
+
4602
+ # Set the page range to print.
4603
+ #
4604
+ # * +pages+ - A comma separated list of page numbers or ranges.
4605
+ # * *Returns* - The converter object.
4606
+ def setPrintPageRange(pages)
4607
+ 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)
4608
+ 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);
4609
+ end
4610
+
4611
+ @fields['print_page_range'] = pages
4612
+ self
4613
+ end
4614
+
4615
+ # Specifies where the images are stored.
4616
+ #
4617
+ # * +mode+ - The image storage mode. Allowed values are embed, separate.
4618
+ # * *Returns* - The converter object.
4619
+ def setImageMode(mode)
4620
+ unless /(?i)^(embed|separate)$/.match(mode)
4621
+ raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setImageMode", "pdf-to-html", "Allowed values are embed, separate.", "set_image_mode"), 470);
4622
+ end
4623
+
4624
+ @fields['image_mode'] = mode
4625
+ self
4626
+ end
4627
+
4628
+ # Specifies where the style sheets are stored.
4629
+ #
4630
+ # * +mode+ - The style sheet storage mode. Allowed values are embed, separate.
4631
+ # * *Returns* - The converter object.
4632
+ def setCssMode(mode)
4633
+ unless /(?i)^(embed|separate)$/.match(mode)
4634
+ raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setCssMode", "pdf-to-html", "Allowed values are embed, separate.", "set_css_mode"), 470);
4635
+ end
4636
+
4637
+ @fields['css_mode'] = mode
4638
+ self
4639
+ end
4640
+
4641
+ # Specifies where the fonts are stored.
4642
+ #
4643
+ # * +mode+ - The font storage mode. Allowed values are embed, separate.
4644
+ # * *Returns* - The converter object.
4645
+ def setFontMode(mode)
4646
+ unless /(?i)^(embed|separate)$/.match(mode)
4647
+ raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setFontMode", "pdf-to-html", "Allowed values are embed, separate.", "set_font_mode"), 470);
4648
+ end
4649
+
4650
+ @fields['font_mode'] = mode
4651
+ self
4652
+ end
4653
+
4654
+ # 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.
4655
+ # * *Returns* - True if the conversion output is a zip file, otherwise False.
4656
+ def isZippedOutput()
4657
+ @fields.fetch('image_mode', '') == 'separate' || @fields.fetch('css_mode', '') == 'separate' || @fields.fetch('font_mode', '') == 'separate' || @fields.fetch('force_zip', false) == true
4658
+ end
4659
+
4660
+ # Enforces the zip output format.
4661
+ #
4662
+ # * +value+ - Set to true to get the output as a zip archive.
4663
+ # * *Returns* - The converter object.
4664
+ def setForceZip(value)
4665
+ @fields['force_zip'] = value
4666
+ self
4667
+ end
4668
+
4669
+ # Set the HTML title. The title from the input PDF is used by default.
4670
+ #
4671
+ # * +title+ - The HTML title.
4672
+ # * *Returns* - The converter object.
4673
+ def setTitle(title)
4674
+ @fields['title'] = title
4675
+ self
4676
+ end
4677
+
4678
+ # Set the HTML subject. The subject from the input PDF is used by default.
4679
+ #
4680
+ # * +subject+ - The HTML subject.
4681
+ # * *Returns* - The converter object.
4682
+ def setSubject(subject)
4683
+ @fields['subject'] = subject
4684
+ self
4685
+ end
4686
+
4687
+ # Set the HTML author. The author from the input PDF is used by default.
4688
+ #
4689
+ # * +author+ - The HTML author.
4690
+ # * *Returns* - The converter object.
4691
+ def setAuthor(author)
4692
+ @fields['author'] = author
4693
+ self
4694
+ end
4695
+
4696
+ # Associate keywords with the HTML document. Keywords from the input PDF are used by default.
4697
+ #
4698
+ # * +keywords+ - The string containing the keywords.
4699
+ # * *Returns* - The converter object.
4700
+ def setKeywords(keywords)
4701
+ @fields['keywords'] = keywords
4702
+ self
4703
+ end
4704
+
4705
+ # 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.
4706
+ #
4707
+ # * +value+ - Set to true to enable the debug logging.
4708
+ # * *Returns* - The converter object.
4709
+ def setDebugLog(value)
4710
+ @fields['debug_log'] = value
4711
+ self
4712
+ end
4713
+
4714
+ # Get the URL of the debug log for the last conversion.
4715
+ # * *Returns* - The link to the debug log.
4716
+ def getDebugLogUrl()
4717
+ return @helper.getDebugLogUrl()
4718
+ end
4719
+
4720
+ # Get the number of conversion credits available in your account.
4721
+ # This method can only be called after a call to one of the convertXtoY methods.
4722
+ # The returned value can differ from the actual count if you run parallel conversions.
4723
+ # The special value 999999 is returned if the information is not available.
4724
+ # * *Returns* - The number of credits.
4725
+ def getRemainingCreditCount()
4726
+ return @helper.getRemainingCreditCount()
4727
+ end
4728
+
4729
+ # Get the number of credits consumed by the last conversion.
4730
+ # * *Returns* - The number of credits.
4731
+ def getConsumedCreditCount()
4732
+ return @helper.getConsumedCreditCount()
4733
+ end
4734
+
4735
+ # Get the job id.
4736
+ # * *Returns* - The unique job identifier.
4737
+ def getJobId()
4738
+ return @helper.getJobId()
4739
+ end
4740
+
4741
+ # Get the total number of pages in the output document.
4742
+ # * *Returns* - The page count.
4743
+ def getPageCount()
4744
+ return @helper.getPageCount()
4745
+ end
4746
+
4747
+ # Get the size of the output in bytes.
4748
+ # * *Returns* - The count of bytes.
4749
+ def getOutputSize()
4750
+ return @helper.getOutputSize()
4751
+ end
4752
+
4753
+ # Get the version details.
4754
+ # * *Returns* - API version, converter version, and client version.
4755
+ def getVersion()
4756
+ return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
4757
+ end
4758
+
4759
+ # Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
4760
+ #
4761
+ # * +tag+ - A string with the custom tag.
4762
+ # * *Returns* - The converter object.
4763
+ def setTag(tag)
4764
+ @fields['tag'] = tag
4765
+ self
4766
+ end
4767
+
4768
+ # 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.
4769
+ #
4770
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
4771
+ # * *Returns* - The converter object.
4772
+ def setHttpProxy(proxy)
4773
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
4774
+ 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);
4775
+ end
4776
+
4777
+ @fields['http_proxy'] = proxy
4778
+ self
4779
+ end
4780
+
4781
+ # 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.
4782
+ #
4783
+ # * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
4784
+ # * *Returns* - The converter object.
4785
+ def setHttpsProxy(proxy)
4786
+ unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
4787
+ 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);
4788
+ end
4789
+
4790
+ @fields['https_proxy'] = proxy
4791
+ self
4792
+ end
4793
+
4794
+ # Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
4795
+ # Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
4796
+ #
4797
+ # * +value+ - Set to true to use HTTP.
4798
+ # * *Returns* - The converter object.
4799
+ def setUseHttp(value)
4800
+ @helper.setUseHttp(value)
4801
+ self
4802
+ end
4803
+
4804
+ # Set a custom user agent HTTP header. It can be useful if you are behind a proxy or a firewall.
4227
4805
  #
4228
4806
  # * +agent+ - The user agent string.
4229
4807
  # * *Returns* - The converter object.
@@ -4244,15 +4822,21 @@ module Pdfcrowd
4244
4822
  self
4245
4823
  end
4246
4824
 
4247
- # Specifies the number of 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.
4825
+ # 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.
4248
4826
  #
4249
- # * +count+ - Number of retries wanted.
4827
+ # * +count+ - Number of retries.
4250
4828
  # * *Returns* - The converter object.
4251
4829
  def setRetryCount(count)
4252
4830
  @helper.setRetryCount(count)
4253
4831
  self
4254
4832
  end
4255
4833
 
4834
+ private
4835
+
4836
+ def isOutputTypeValid(file_path)
4837
+ extension = File.extname(file_path).downcase
4838
+ (extension == '.zip') == isZippedOutput()
4839
+ end
4256
4840
  end
4257
4841
 
4258
4842
  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: 5.1.1
4
+ version: 5.4.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: 2021-05-12 00:00:00.000000000 Z
11
+ date: 2022-02-08 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.