pdfcrowd 6.6.0 → 6.7.1
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 +640 -172
- metadata +2 -2
data/lib/pdfcrowd.rb
CHANGED
|
@@ -558,7 +558,7 @@ end
|
|
|
558
558
|
module Pdfcrowd
|
|
559
559
|
HOST = ENV["PDFCROWD_HOST"] || 'api.pdfcrowd.com'
|
|
560
560
|
MULTIPART_BOUNDARY = '----------ThIs_Is_tHe_bOUnDary_$'
|
|
561
|
-
CLIENT_VERSION = '6.
|
|
561
|
+
CLIENT_VERSION = '6.7.1'
|
|
562
562
|
|
|
563
563
|
class ConnectionHelper
|
|
564
564
|
def initialize(user_name, api_key)
|
|
@@ -569,12 +569,21 @@ module Pdfcrowd
|
|
|
569
569
|
|
|
570
570
|
setProxy(nil, nil, nil, nil)
|
|
571
571
|
setUseHttp(false)
|
|
572
|
-
setUserAgent('pdfcrowd_ruby_client/6.
|
|
572
|
+
setUserAgent('pdfcrowd_ruby_client/6.7.1 (https://pdfcrowd.com)')
|
|
573
573
|
|
|
574
574
|
@retry_count = 1
|
|
575
575
|
@converter_version = '24.04'
|
|
576
576
|
end
|
|
577
577
|
|
|
578
|
+
def reset_input(fields, files, raw_data)
|
|
579
|
+
# Preserve conversion options and auxiliary files between requests.
|
|
580
|
+
fields.delete('url')
|
|
581
|
+
fields.delete('text')
|
|
582
|
+
files.delete('file')
|
|
583
|
+
raw_data.delete('file')
|
|
584
|
+
raw_data.delete('stream')
|
|
585
|
+
end
|
|
586
|
+
|
|
578
587
|
def post(fields, files, raw_data, out_stream = nil)
|
|
579
588
|
request = create_request()
|
|
580
589
|
request.body = ConnectionHelper.encode_multipart_post_data(fields, files, raw_data)
|
|
@@ -792,6 +801,7 @@ module Pdfcrowd
|
|
|
792
801
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "html-to-pdf", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
|
793
802
|
end
|
|
794
803
|
|
|
804
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
795
805
|
@fields['url'] = url
|
|
796
806
|
@helper.post(@fields, @files, @raw_data)
|
|
797
807
|
end
|
|
@@ -802,6 +812,7 @@ module Pdfcrowd
|
|
|
802
812
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "html-to-pdf", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
|
803
813
|
end
|
|
804
814
|
|
|
815
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
805
816
|
@fields['url'] = url
|
|
806
817
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
807
818
|
end
|
|
@@ -813,13 +824,25 @@ module Pdfcrowd
|
|
|
813
824
|
end
|
|
814
825
|
|
|
815
826
|
output_file = open(file_path, "wb")
|
|
827
|
+
succeeded = false
|
|
816
828
|
begin
|
|
817
|
-
convertUrlToStream(url,
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
829
|
+
convertUrlToStream(url,output_file)
|
|
830
|
+
succeeded = true
|
|
831
|
+
ensure
|
|
832
|
+
if succeeded
|
|
833
|
+
output_file.close()
|
|
834
|
+
else
|
|
835
|
+
begin
|
|
836
|
+
output_file.close()
|
|
837
|
+
rescue Exception
|
|
838
|
+
# Preserve the conversion failure.
|
|
839
|
+
end
|
|
840
|
+
begin
|
|
841
|
+
FileUtils.rm(file_path)
|
|
842
|
+
rescue Exception
|
|
843
|
+
# Removing a failed output must not mask the original failure.
|
|
844
|
+
end
|
|
845
|
+
end
|
|
823
846
|
end
|
|
824
847
|
end
|
|
825
848
|
|
|
@@ -829,6 +852,7 @@ module Pdfcrowd
|
|
|
829
852
|
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "html-to-pdf", "The file must exist and not be empty.", "convert_file"), 470);
|
|
830
853
|
end
|
|
831
854
|
|
|
855
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
832
856
|
@files['file'] = file
|
|
833
857
|
@helper.post(@fields, @files, @raw_data)
|
|
834
858
|
end
|
|
@@ -839,6 +863,7 @@ module Pdfcrowd
|
|
|
839
863
|
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "html-to-pdf", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
|
|
840
864
|
end
|
|
841
865
|
|
|
866
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
842
867
|
@files['file'] = file
|
|
843
868
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
844
869
|
end
|
|
@@ -850,13 +875,25 @@ module Pdfcrowd
|
|
|
850
875
|
end
|
|
851
876
|
|
|
852
877
|
output_file = open(file_path, "wb")
|
|
878
|
+
succeeded = false
|
|
853
879
|
begin
|
|
854
|
-
convertFileToStream(file,
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
880
|
+
convertFileToStream(file,output_file)
|
|
881
|
+
succeeded = true
|
|
882
|
+
ensure
|
|
883
|
+
if succeeded
|
|
884
|
+
output_file.close()
|
|
885
|
+
else
|
|
886
|
+
begin
|
|
887
|
+
output_file.close()
|
|
888
|
+
rescue Exception
|
|
889
|
+
# Preserve the conversion failure.
|
|
890
|
+
end
|
|
891
|
+
begin
|
|
892
|
+
FileUtils.rm(file_path)
|
|
893
|
+
rescue Exception
|
|
894
|
+
# Removing a failed output must not mask the original failure.
|
|
895
|
+
end
|
|
896
|
+
end
|
|
860
897
|
end
|
|
861
898
|
end
|
|
862
899
|
|
|
@@ -866,6 +903,7 @@ module Pdfcrowd
|
|
|
866
903
|
raise Error.new(Pdfcrowd.create_invalid_value_message(text, "convertString", "html-to-pdf", "The string must not be empty.", "convert_string"), 470);
|
|
867
904
|
end
|
|
868
905
|
|
|
906
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
869
907
|
@fields['text'] = text
|
|
870
908
|
@helper.post(@fields, @files, @raw_data)
|
|
871
909
|
end
|
|
@@ -876,6 +914,7 @@ module Pdfcrowd
|
|
|
876
914
|
raise Error.new(Pdfcrowd.create_invalid_value_message(text, "convertStringToStream::text", "html-to-pdf", "The string must not be empty.", "convert_string_to_stream"), 470);
|
|
877
915
|
end
|
|
878
916
|
|
|
917
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
879
918
|
@fields['text'] = text
|
|
880
919
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
881
920
|
end
|
|
@@ -887,24 +926,38 @@ module Pdfcrowd
|
|
|
887
926
|
end
|
|
888
927
|
|
|
889
928
|
output_file = open(file_path, "wb")
|
|
929
|
+
succeeded = false
|
|
890
930
|
begin
|
|
891
|
-
convertStringToStream(text,
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
931
|
+
convertStringToStream(text,output_file)
|
|
932
|
+
succeeded = true
|
|
933
|
+
ensure
|
|
934
|
+
if succeeded
|
|
935
|
+
output_file.close()
|
|
936
|
+
else
|
|
937
|
+
begin
|
|
938
|
+
output_file.close()
|
|
939
|
+
rescue Exception
|
|
940
|
+
# Preserve the conversion failure.
|
|
941
|
+
end
|
|
942
|
+
begin
|
|
943
|
+
FileUtils.rm(file_path)
|
|
944
|
+
rescue Exception
|
|
945
|
+
# Removing a failed output must not mask the original failure.
|
|
946
|
+
end
|
|
947
|
+
end
|
|
897
948
|
end
|
|
898
949
|
end
|
|
899
950
|
|
|
900
951
|
# @see https://pdfcrowd.com/api/html-to-pdf-ruby/ref/#convert_stream
|
|
901
952
|
def convertStream(in_stream)
|
|
953
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
902
954
|
@raw_data['stream'] = in_stream.read
|
|
903
955
|
@helper.post(@fields, @files, @raw_data)
|
|
904
956
|
end
|
|
905
957
|
|
|
906
958
|
# @see https://pdfcrowd.com/api/html-to-pdf-ruby/ref/#convert_stream_to_stream
|
|
907
959
|
def convertStreamToStream(in_stream, out_stream)
|
|
960
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
908
961
|
@raw_data['stream'] = in_stream.read
|
|
909
962
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
910
963
|
end
|
|
@@ -916,13 +969,25 @@ module Pdfcrowd
|
|
|
916
969
|
end
|
|
917
970
|
|
|
918
971
|
output_file = open(file_path, "wb")
|
|
972
|
+
succeeded = false
|
|
919
973
|
begin
|
|
920
|
-
convertStreamToStream(in_stream,
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
974
|
+
convertStreamToStream(in_stream,output_file)
|
|
975
|
+
succeeded = true
|
|
976
|
+
ensure
|
|
977
|
+
if succeeded
|
|
978
|
+
output_file.close()
|
|
979
|
+
else
|
|
980
|
+
begin
|
|
981
|
+
output_file.close()
|
|
982
|
+
rescue Exception
|
|
983
|
+
# Preserve the conversion failure.
|
|
984
|
+
end
|
|
985
|
+
begin
|
|
986
|
+
FileUtils.rm(file_path)
|
|
987
|
+
rescue Exception
|
|
988
|
+
# Removing a failed output must not mask the original failure.
|
|
989
|
+
end
|
|
990
|
+
end
|
|
926
991
|
end
|
|
927
992
|
end
|
|
928
993
|
|
|
@@ -1672,6 +1737,33 @@ module Pdfcrowd
|
|
|
1672
1737
|
self
|
|
1673
1738
|
end
|
|
1674
1739
|
|
|
1740
|
+
# @see https://pdfcrowd.com/api/html-to-pdf-ruby/ref/#set_conformance
|
|
1741
|
+
def setConformance(conformance)
|
|
1742
|
+
unless /(?i)^(PDF\/A-2a|PDF\/A-2b|PDF\/A-2u|PDF\/A-3a|PDF\/A-3b|PDF\/A-3u|PDF\/A-4|PDF\/A-4e|PDF\/A-4f)$/.match(conformance)
|
|
1743
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(conformance, "setConformance", "html-to-pdf", "Allowed values are PDF/A-2a, PDF/A-2b, PDF/A-2u, PDF/A-3a, PDF/A-3b, PDF/A-3u, PDF/A-4, PDF/A-4e, PDF/A-4f.", "set_conformance"), 470);
|
|
1744
|
+
end
|
|
1745
|
+
|
|
1746
|
+
@fields['conformance'] = conformance
|
|
1747
|
+
self
|
|
1748
|
+
end
|
|
1749
|
+
|
|
1750
|
+
# @see https://pdfcrowd.com/api/html-to-pdf-ruby/ref/#set_tagged_pdf
|
|
1751
|
+
def setTaggedPdf(value)
|
|
1752
|
+
@fields['tagged_pdf'] = value
|
|
1753
|
+
self
|
|
1754
|
+
end
|
|
1755
|
+
|
|
1756
|
+
# @see https://pdfcrowd.com/api/html-to-pdf-ruby/ref/#add_attachment
|
|
1757
|
+
def addAttachment(attachment)
|
|
1758
|
+
if (!(File.file?(attachment) && !File.zero?(attachment)))
|
|
1759
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(attachment, "addAttachment", "html-to-pdf", "The file must exist and not be empty.", "add_attachment"), 470);
|
|
1760
|
+
end
|
|
1761
|
+
|
|
1762
|
+
@files['attachment_%s' % @file_id] = attachment
|
|
1763
|
+
@file_id += 1
|
|
1764
|
+
self
|
|
1765
|
+
end
|
|
1766
|
+
|
|
1675
1767
|
# @see https://pdfcrowd.com/api/html-to-pdf-ruby/ref/#set_page_layout
|
|
1676
1768
|
def setPageLayout(layout)
|
|
1677
1769
|
unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout)
|
|
@@ -2121,6 +2213,7 @@ module Pdfcrowd
|
|
|
2121
2213
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "html-to-image", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
|
2122
2214
|
end
|
|
2123
2215
|
|
|
2216
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2124
2217
|
@fields['url'] = url
|
|
2125
2218
|
@helper.post(@fields, @files, @raw_data)
|
|
2126
2219
|
end
|
|
@@ -2131,6 +2224,7 @@ module Pdfcrowd
|
|
|
2131
2224
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "html-to-image", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
|
2132
2225
|
end
|
|
2133
2226
|
|
|
2227
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2134
2228
|
@fields['url'] = url
|
|
2135
2229
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
2136
2230
|
end
|
|
@@ -2142,13 +2236,25 @@ module Pdfcrowd
|
|
|
2142
2236
|
end
|
|
2143
2237
|
|
|
2144
2238
|
output_file = open(file_path, "wb")
|
|
2239
|
+
succeeded = false
|
|
2145
2240
|
begin
|
|
2146
|
-
convertUrlToStream(url,
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2241
|
+
convertUrlToStream(url,output_file)
|
|
2242
|
+
succeeded = true
|
|
2243
|
+
ensure
|
|
2244
|
+
if succeeded
|
|
2245
|
+
output_file.close()
|
|
2246
|
+
else
|
|
2247
|
+
begin
|
|
2248
|
+
output_file.close()
|
|
2249
|
+
rescue Exception
|
|
2250
|
+
# Preserve the conversion failure.
|
|
2251
|
+
end
|
|
2252
|
+
begin
|
|
2253
|
+
FileUtils.rm(file_path)
|
|
2254
|
+
rescue Exception
|
|
2255
|
+
# Removing a failed output must not mask the original failure.
|
|
2256
|
+
end
|
|
2257
|
+
end
|
|
2152
2258
|
end
|
|
2153
2259
|
end
|
|
2154
2260
|
|
|
@@ -2158,6 +2264,7 @@ module Pdfcrowd
|
|
|
2158
2264
|
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "html-to-image", "The file must exist and not be empty.", "convert_file"), 470);
|
|
2159
2265
|
end
|
|
2160
2266
|
|
|
2267
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2161
2268
|
@files['file'] = file
|
|
2162
2269
|
@helper.post(@fields, @files, @raw_data)
|
|
2163
2270
|
end
|
|
@@ -2168,6 +2275,7 @@ module Pdfcrowd
|
|
|
2168
2275
|
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "html-to-image", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
|
|
2169
2276
|
end
|
|
2170
2277
|
|
|
2278
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2171
2279
|
@files['file'] = file
|
|
2172
2280
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
2173
2281
|
end
|
|
@@ -2179,13 +2287,25 @@ module Pdfcrowd
|
|
|
2179
2287
|
end
|
|
2180
2288
|
|
|
2181
2289
|
output_file = open(file_path, "wb")
|
|
2290
|
+
succeeded = false
|
|
2182
2291
|
begin
|
|
2183
|
-
convertFileToStream(file,
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2292
|
+
convertFileToStream(file,output_file)
|
|
2293
|
+
succeeded = true
|
|
2294
|
+
ensure
|
|
2295
|
+
if succeeded
|
|
2296
|
+
output_file.close()
|
|
2297
|
+
else
|
|
2298
|
+
begin
|
|
2299
|
+
output_file.close()
|
|
2300
|
+
rescue Exception
|
|
2301
|
+
# Preserve the conversion failure.
|
|
2302
|
+
end
|
|
2303
|
+
begin
|
|
2304
|
+
FileUtils.rm(file_path)
|
|
2305
|
+
rescue Exception
|
|
2306
|
+
# Removing a failed output must not mask the original failure.
|
|
2307
|
+
end
|
|
2308
|
+
end
|
|
2189
2309
|
end
|
|
2190
2310
|
end
|
|
2191
2311
|
|
|
@@ -2195,6 +2315,7 @@ module Pdfcrowd
|
|
|
2195
2315
|
raise Error.new(Pdfcrowd.create_invalid_value_message(text, "convertString", "html-to-image", "The string must not be empty.", "convert_string"), 470);
|
|
2196
2316
|
end
|
|
2197
2317
|
|
|
2318
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2198
2319
|
@fields['text'] = text
|
|
2199
2320
|
@helper.post(@fields, @files, @raw_data)
|
|
2200
2321
|
end
|
|
@@ -2205,6 +2326,7 @@ module Pdfcrowd
|
|
|
2205
2326
|
raise Error.new(Pdfcrowd.create_invalid_value_message(text, "convertStringToStream::text", "html-to-image", "The string must not be empty.", "convert_string_to_stream"), 470);
|
|
2206
2327
|
end
|
|
2207
2328
|
|
|
2329
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2208
2330
|
@fields['text'] = text
|
|
2209
2331
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
2210
2332
|
end
|
|
@@ -2216,24 +2338,38 @@ module Pdfcrowd
|
|
|
2216
2338
|
end
|
|
2217
2339
|
|
|
2218
2340
|
output_file = open(file_path, "wb")
|
|
2341
|
+
succeeded = false
|
|
2219
2342
|
begin
|
|
2220
|
-
convertStringToStream(text,
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2343
|
+
convertStringToStream(text,output_file)
|
|
2344
|
+
succeeded = true
|
|
2345
|
+
ensure
|
|
2346
|
+
if succeeded
|
|
2347
|
+
output_file.close()
|
|
2348
|
+
else
|
|
2349
|
+
begin
|
|
2350
|
+
output_file.close()
|
|
2351
|
+
rescue Exception
|
|
2352
|
+
# Preserve the conversion failure.
|
|
2353
|
+
end
|
|
2354
|
+
begin
|
|
2355
|
+
FileUtils.rm(file_path)
|
|
2356
|
+
rescue Exception
|
|
2357
|
+
# Removing a failed output must not mask the original failure.
|
|
2358
|
+
end
|
|
2359
|
+
end
|
|
2226
2360
|
end
|
|
2227
2361
|
end
|
|
2228
2362
|
|
|
2229
2363
|
# @see https://pdfcrowd.com/api/html-to-image-ruby/ref/#convert_stream
|
|
2230
2364
|
def convertStream(in_stream)
|
|
2365
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2231
2366
|
@raw_data['stream'] = in_stream.read
|
|
2232
2367
|
@helper.post(@fields, @files, @raw_data)
|
|
2233
2368
|
end
|
|
2234
2369
|
|
|
2235
2370
|
# @see https://pdfcrowd.com/api/html-to-image-ruby/ref/#convert_stream_to_stream
|
|
2236
2371
|
def convertStreamToStream(in_stream, out_stream)
|
|
2372
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2237
2373
|
@raw_data['stream'] = in_stream.read
|
|
2238
2374
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
2239
2375
|
end
|
|
@@ -2245,13 +2381,25 @@ module Pdfcrowd
|
|
|
2245
2381
|
end
|
|
2246
2382
|
|
|
2247
2383
|
output_file = open(file_path, "wb")
|
|
2384
|
+
succeeded = false
|
|
2248
2385
|
begin
|
|
2249
|
-
convertStreamToStream(in_stream,
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
|
|
2254
|
-
|
|
2386
|
+
convertStreamToStream(in_stream,output_file)
|
|
2387
|
+
succeeded = true
|
|
2388
|
+
ensure
|
|
2389
|
+
if succeeded
|
|
2390
|
+
output_file.close()
|
|
2391
|
+
else
|
|
2392
|
+
begin
|
|
2393
|
+
output_file.close()
|
|
2394
|
+
rescue Exception
|
|
2395
|
+
# Preserve the conversion failure.
|
|
2396
|
+
end
|
|
2397
|
+
begin
|
|
2398
|
+
FileUtils.rm(file_path)
|
|
2399
|
+
rescue Exception
|
|
2400
|
+
# Removing a failed output must not mask the original failure.
|
|
2401
|
+
end
|
|
2402
|
+
end
|
|
2255
2403
|
end
|
|
2256
2404
|
end
|
|
2257
2405
|
|
|
@@ -2736,6 +2884,7 @@ module Pdfcrowd
|
|
|
2736
2884
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-image", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
|
2737
2885
|
end
|
|
2738
2886
|
|
|
2887
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2739
2888
|
@fields['url'] = url
|
|
2740
2889
|
@helper.post(@fields, @files, @raw_data)
|
|
2741
2890
|
end
|
|
@@ -2746,6 +2895,7 @@ module Pdfcrowd
|
|
|
2746
2895
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "image-to-image", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
|
2747
2896
|
end
|
|
2748
2897
|
|
|
2898
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2749
2899
|
@fields['url'] = url
|
|
2750
2900
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
2751
2901
|
end
|
|
@@ -2757,13 +2907,25 @@ module Pdfcrowd
|
|
|
2757
2907
|
end
|
|
2758
2908
|
|
|
2759
2909
|
output_file = open(file_path, "wb")
|
|
2910
|
+
succeeded = false
|
|
2760
2911
|
begin
|
|
2761
|
-
convertUrlToStream(url,
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2912
|
+
convertUrlToStream(url,output_file)
|
|
2913
|
+
succeeded = true
|
|
2914
|
+
ensure
|
|
2915
|
+
if succeeded
|
|
2916
|
+
output_file.close()
|
|
2917
|
+
else
|
|
2918
|
+
begin
|
|
2919
|
+
output_file.close()
|
|
2920
|
+
rescue Exception
|
|
2921
|
+
# Preserve the conversion failure.
|
|
2922
|
+
end
|
|
2923
|
+
begin
|
|
2924
|
+
FileUtils.rm(file_path)
|
|
2925
|
+
rescue Exception
|
|
2926
|
+
# Removing a failed output must not mask the original failure.
|
|
2927
|
+
end
|
|
2928
|
+
end
|
|
2767
2929
|
end
|
|
2768
2930
|
end
|
|
2769
2931
|
|
|
@@ -2773,6 +2935,7 @@ module Pdfcrowd
|
|
|
2773
2935
|
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "image-to-image", "The file must exist and not be empty.", "convert_file"), 470);
|
|
2774
2936
|
end
|
|
2775
2937
|
|
|
2938
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2776
2939
|
@files['file'] = file
|
|
2777
2940
|
@helper.post(@fields, @files, @raw_data)
|
|
2778
2941
|
end
|
|
@@ -2783,6 +2946,7 @@ module Pdfcrowd
|
|
|
2783
2946
|
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "image-to-image", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
|
|
2784
2947
|
end
|
|
2785
2948
|
|
|
2949
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2786
2950
|
@files['file'] = file
|
|
2787
2951
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
2788
2952
|
end
|
|
@@ -2794,24 +2958,38 @@ module Pdfcrowd
|
|
|
2794
2958
|
end
|
|
2795
2959
|
|
|
2796
2960
|
output_file = open(file_path, "wb")
|
|
2961
|
+
succeeded = false
|
|
2797
2962
|
begin
|
|
2798
|
-
convertFileToStream(file,
|
|
2799
|
-
|
|
2800
|
-
|
|
2801
|
-
|
|
2802
|
-
|
|
2803
|
-
|
|
2963
|
+
convertFileToStream(file,output_file)
|
|
2964
|
+
succeeded = true
|
|
2965
|
+
ensure
|
|
2966
|
+
if succeeded
|
|
2967
|
+
output_file.close()
|
|
2968
|
+
else
|
|
2969
|
+
begin
|
|
2970
|
+
output_file.close()
|
|
2971
|
+
rescue Exception
|
|
2972
|
+
# Preserve the conversion failure.
|
|
2973
|
+
end
|
|
2974
|
+
begin
|
|
2975
|
+
FileUtils.rm(file_path)
|
|
2976
|
+
rescue Exception
|
|
2977
|
+
# Removing a failed output must not mask the original failure.
|
|
2978
|
+
end
|
|
2979
|
+
end
|
|
2804
2980
|
end
|
|
2805
2981
|
end
|
|
2806
2982
|
|
|
2807
2983
|
# @see https://pdfcrowd.com/api/image-to-image-ruby/ref/#convert_raw_data
|
|
2808
2984
|
def convertRawData(data)
|
|
2985
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2809
2986
|
@raw_data['file'] = data
|
|
2810
2987
|
@helper.post(@fields, @files, @raw_data)
|
|
2811
2988
|
end
|
|
2812
2989
|
|
|
2813
2990
|
# @see https://pdfcrowd.com/api/image-to-image-ruby/ref/#convert_raw_data_to_stream
|
|
2814
2991
|
def convertRawDataToStream(data, out_stream)
|
|
2992
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2815
2993
|
@raw_data['file'] = data
|
|
2816
2994
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
2817
2995
|
end
|
|
@@ -2823,24 +3001,38 @@ module Pdfcrowd
|
|
|
2823
3001
|
end
|
|
2824
3002
|
|
|
2825
3003
|
output_file = open(file_path, "wb")
|
|
3004
|
+
succeeded = false
|
|
2826
3005
|
begin
|
|
2827
|
-
convertRawDataToStream(data,
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
3006
|
+
convertRawDataToStream(data,output_file)
|
|
3007
|
+
succeeded = true
|
|
3008
|
+
ensure
|
|
3009
|
+
if succeeded
|
|
3010
|
+
output_file.close()
|
|
3011
|
+
else
|
|
3012
|
+
begin
|
|
3013
|
+
output_file.close()
|
|
3014
|
+
rescue Exception
|
|
3015
|
+
# Preserve the conversion failure.
|
|
3016
|
+
end
|
|
3017
|
+
begin
|
|
3018
|
+
FileUtils.rm(file_path)
|
|
3019
|
+
rescue Exception
|
|
3020
|
+
# Removing a failed output must not mask the original failure.
|
|
3021
|
+
end
|
|
3022
|
+
end
|
|
2833
3023
|
end
|
|
2834
3024
|
end
|
|
2835
3025
|
|
|
2836
3026
|
# @see https://pdfcrowd.com/api/image-to-image-ruby/ref/#convert_stream
|
|
2837
3027
|
def convertStream(in_stream)
|
|
3028
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2838
3029
|
@raw_data['stream'] = in_stream.read
|
|
2839
3030
|
@helper.post(@fields, @files, @raw_data)
|
|
2840
3031
|
end
|
|
2841
3032
|
|
|
2842
3033
|
# @see https://pdfcrowd.com/api/image-to-image-ruby/ref/#convert_stream_to_stream
|
|
2843
3034
|
def convertStreamToStream(in_stream, out_stream)
|
|
3035
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
2844
3036
|
@raw_data['stream'] = in_stream.read
|
|
2845
3037
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
2846
3038
|
end
|
|
@@ -2852,13 +3044,25 @@ module Pdfcrowd
|
|
|
2852
3044
|
end
|
|
2853
3045
|
|
|
2854
3046
|
output_file = open(file_path, "wb")
|
|
3047
|
+
succeeded = false
|
|
2855
3048
|
begin
|
|
2856
|
-
convertStreamToStream(in_stream,
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
|
|
3049
|
+
convertStreamToStream(in_stream,output_file)
|
|
3050
|
+
succeeded = true
|
|
3051
|
+
ensure
|
|
3052
|
+
if succeeded
|
|
3053
|
+
output_file.close()
|
|
3054
|
+
else
|
|
3055
|
+
begin
|
|
3056
|
+
output_file.close()
|
|
3057
|
+
rescue Exception
|
|
3058
|
+
# Preserve the conversion failure.
|
|
3059
|
+
end
|
|
3060
|
+
begin
|
|
3061
|
+
FileUtils.rm(file_path)
|
|
3062
|
+
rescue Exception
|
|
3063
|
+
# Removing a failed output must not mask the original failure.
|
|
3064
|
+
end
|
|
3065
|
+
end
|
|
2862
3066
|
end
|
|
2863
3067
|
end
|
|
2864
3068
|
|
|
@@ -3218,8 +3422,26 @@ module Pdfcrowd
|
|
|
3218
3422
|
end
|
|
3219
3423
|
|
|
3220
3424
|
output_file = open(file_path, "wb")
|
|
3221
|
-
|
|
3222
|
-
|
|
3425
|
+
succeeded = false
|
|
3426
|
+
begin
|
|
3427
|
+
convertToStream(output_file)
|
|
3428
|
+
succeeded = true
|
|
3429
|
+
ensure
|
|
3430
|
+
if succeeded
|
|
3431
|
+
output_file.close()
|
|
3432
|
+
else
|
|
3433
|
+
begin
|
|
3434
|
+
output_file.close()
|
|
3435
|
+
rescue Exception
|
|
3436
|
+
# Preserve the conversion failure.
|
|
3437
|
+
end
|
|
3438
|
+
begin
|
|
3439
|
+
FileUtils.rm(file_path)
|
|
3440
|
+
rescue Exception
|
|
3441
|
+
# Removing a failed output must not mask the original failure.
|
|
3442
|
+
end
|
|
3443
|
+
end
|
|
3444
|
+
end
|
|
3223
3445
|
end
|
|
3224
3446
|
|
|
3225
3447
|
# @see https://pdfcrowd.com/api/pdf-to-pdf-ruby/ref/#add_pdf_file
|
|
@@ -3416,6 +3638,17 @@ module Pdfcrowd
|
|
|
3416
3638
|
self
|
|
3417
3639
|
end
|
|
3418
3640
|
|
|
3641
|
+
# @see https://pdfcrowd.com/api/pdf-to-pdf-ruby/ref/#add_attachment
|
|
3642
|
+
def addAttachment(attachment)
|
|
3643
|
+
if (!(File.file?(attachment) && !File.zero?(attachment)))
|
|
3644
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(attachment, "addAttachment", "pdf-to-pdf", "The file must exist and not be empty.", "add_attachment"), 470);
|
|
3645
|
+
end
|
|
3646
|
+
|
|
3647
|
+
@files['attachment_%s' % @file_id] = attachment
|
|
3648
|
+
@file_id += 1
|
|
3649
|
+
self
|
|
3650
|
+
end
|
|
3651
|
+
|
|
3419
3652
|
# @see https://pdfcrowd.com/api/pdf-to-pdf-ruby/ref/#set_page_layout
|
|
3420
3653
|
def setPageLayout(layout)
|
|
3421
3654
|
unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout)
|
|
@@ -3619,6 +3852,7 @@ module Pdfcrowd
|
|
|
3619
3852
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-pdf", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
|
3620
3853
|
end
|
|
3621
3854
|
|
|
3855
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
3622
3856
|
@fields['url'] = url
|
|
3623
3857
|
@helper.post(@fields, @files, @raw_data)
|
|
3624
3858
|
end
|
|
@@ -3629,6 +3863,7 @@ module Pdfcrowd
|
|
|
3629
3863
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "image-to-pdf", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
|
3630
3864
|
end
|
|
3631
3865
|
|
|
3866
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
3632
3867
|
@fields['url'] = url
|
|
3633
3868
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
3634
3869
|
end
|
|
@@ -3640,13 +3875,25 @@ module Pdfcrowd
|
|
|
3640
3875
|
end
|
|
3641
3876
|
|
|
3642
3877
|
output_file = open(file_path, "wb")
|
|
3878
|
+
succeeded = false
|
|
3643
3879
|
begin
|
|
3644
|
-
convertUrlToStream(url,
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3880
|
+
convertUrlToStream(url,output_file)
|
|
3881
|
+
succeeded = true
|
|
3882
|
+
ensure
|
|
3883
|
+
if succeeded
|
|
3884
|
+
output_file.close()
|
|
3885
|
+
else
|
|
3886
|
+
begin
|
|
3887
|
+
output_file.close()
|
|
3888
|
+
rescue Exception
|
|
3889
|
+
# Preserve the conversion failure.
|
|
3890
|
+
end
|
|
3891
|
+
begin
|
|
3892
|
+
FileUtils.rm(file_path)
|
|
3893
|
+
rescue Exception
|
|
3894
|
+
# Removing a failed output must not mask the original failure.
|
|
3895
|
+
end
|
|
3896
|
+
end
|
|
3650
3897
|
end
|
|
3651
3898
|
end
|
|
3652
3899
|
|
|
@@ -3656,6 +3903,7 @@ module Pdfcrowd
|
|
|
3656
3903
|
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "image-to-pdf", "The file must exist and not be empty.", "convert_file"), 470);
|
|
3657
3904
|
end
|
|
3658
3905
|
|
|
3906
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
3659
3907
|
@files['file'] = file
|
|
3660
3908
|
@helper.post(@fields, @files, @raw_data)
|
|
3661
3909
|
end
|
|
@@ -3666,6 +3914,7 @@ module Pdfcrowd
|
|
|
3666
3914
|
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "image-to-pdf", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
|
|
3667
3915
|
end
|
|
3668
3916
|
|
|
3917
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
3669
3918
|
@files['file'] = file
|
|
3670
3919
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
3671
3920
|
end
|
|
@@ -3677,24 +3926,38 @@ module Pdfcrowd
|
|
|
3677
3926
|
end
|
|
3678
3927
|
|
|
3679
3928
|
output_file = open(file_path, "wb")
|
|
3929
|
+
succeeded = false
|
|
3680
3930
|
begin
|
|
3681
|
-
convertFileToStream(file,
|
|
3682
|
-
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
|
-
|
|
3686
|
-
|
|
3931
|
+
convertFileToStream(file,output_file)
|
|
3932
|
+
succeeded = true
|
|
3933
|
+
ensure
|
|
3934
|
+
if succeeded
|
|
3935
|
+
output_file.close()
|
|
3936
|
+
else
|
|
3937
|
+
begin
|
|
3938
|
+
output_file.close()
|
|
3939
|
+
rescue Exception
|
|
3940
|
+
# Preserve the conversion failure.
|
|
3941
|
+
end
|
|
3942
|
+
begin
|
|
3943
|
+
FileUtils.rm(file_path)
|
|
3944
|
+
rescue Exception
|
|
3945
|
+
# Removing a failed output must not mask the original failure.
|
|
3946
|
+
end
|
|
3947
|
+
end
|
|
3687
3948
|
end
|
|
3688
3949
|
end
|
|
3689
3950
|
|
|
3690
3951
|
# @see https://pdfcrowd.com/api/image-to-pdf-ruby/ref/#convert_raw_data
|
|
3691
3952
|
def convertRawData(data)
|
|
3953
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
3692
3954
|
@raw_data['file'] = data
|
|
3693
3955
|
@helper.post(@fields, @files, @raw_data)
|
|
3694
3956
|
end
|
|
3695
3957
|
|
|
3696
3958
|
# @see https://pdfcrowd.com/api/image-to-pdf-ruby/ref/#convert_raw_data_to_stream
|
|
3697
3959
|
def convertRawDataToStream(data, out_stream)
|
|
3960
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
3698
3961
|
@raw_data['file'] = data
|
|
3699
3962
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
3700
3963
|
end
|
|
@@ -3706,24 +3969,38 @@ module Pdfcrowd
|
|
|
3706
3969
|
end
|
|
3707
3970
|
|
|
3708
3971
|
output_file = open(file_path, "wb")
|
|
3972
|
+
succeeded = false
|
|
3709
3973
|
begin
|
|
3710
|
-
convertRawDataToStream(data,
|
|
3711
|
-
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3974
|
+
convertRawDataToStream(data,output_file)
|
|
3975
|
+
succeeded = true
|
|
3976
|
+
ensure
|
|
3977
|
+
if succeeded
|
|
3978
|
+
output_file.close()
|
|
3979
|
+
else
|
|
3980
|
+
begin
|
|
3981
|
+
output_file.close()
|
|
3982
|
+
rescue Exception
|
|
3983
|
+
# Preserve the conversion failure.
|
|
3984
|
+
end
|
|
3985
|
+
begin
|
|
3986
|
+
FileUtils.rm(file_path)
|
|
3987
|
+
rescue Exception
|
|
3988
|
+
# Removing a failed output must not mask the original failure.
|
|
3989
|
+
end
|
|
3990
|
+
end
|
|
3716
3991
|
end
|
|
3717
3992
|
end
|
|
3718
3993
|
|
|
3719
3994
|
# @see https://pdfcrowd.com/api/image-to-pdf-ruby/ref/#convert_stream
|
|
3720
3995
|
def convertStream(in_stream)
|
|
3996
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
3721
3997
|
@raw_data['stream'] = in_stream.read
|
|
3722
3998
|
@helper.post(@fields, @files, @raw_data)
|
|
3723
3999
|
end
|
|
3724
4000
|
|
|
3725
4001
|
# @see https://pdfcrowd.com/api/image-to-pdf-ruby/ref/#convert_stream_to_stream
|
|
3726
4002
|
def convertStreamToStream(in_stream, out_stream)
|
|
4003
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
3727
4004
|
@raw_data['stream'] = in_stream.read
|
|
3728
4005
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
3729
4006
|
end
|
|
@@ -3735,13 +4012,25 @@ module Pdfcrowd
|
|
|
3735
4012
|
end
|
|
3736
4013
|
|
|
3737
4014
|
output_file = open(file_path, "wb")
|
|
4015
|
+
succeeded = false
|
|
3738
4016
|
begin
|
|
3739
|
-
convertStreamToStream(in_stream,
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
|
|
3743
|
-
|
|
3744
|
-
|
|
4017
|
+
convertStreamToStream(in_stream,output_file)
|
|
4018
|
+
succeeded = true
|
|
4019
|
+
ensure
|
|
4020
|
+
if succeeded
|
|
4021
|
+
output_file.close()
|
|
4022
|
+
else
|
|
4023
|
+
begin
|
|
4024
|
+
output_file.close()
|
|
4025
|
+
rescue Exception
|
|
4026
|
+
# Preserve the conversion failure.
|
|
4027
|
+
end
|
|
4028
|
+
begin
|
|
4029
|
+
FileUtils.rm(file_path)
|
|
4030
|
+
rescue Exception
|
|
4031
|
+
# Removing a failed output must not mask the original failure.
|
|
4032
|
+
end
|
|
4033
|
+
end
|
|
3745
4034
|
end
|
|
3746
4035
|
end
|
|
3747
4036
|
|
|
@@ -4090,6 +4379,17 @@ module Pdfcrowd
|
|
|
4090
4379
|
self
|
|
4091
4380
|
end
|
|
4092
4381
|
|
|
4382
|
+
# @see https://pdfcrowd.com/api/image-to-pdf-ruby/ref/#add_attachment
|
|
4383
|
+
def addAttachment(attachment)
|
|
4384
|
+
if (!(File.file?(attachment) && !File.zero?(attachment)))
|
|
4385
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(attachment, "addAttachment", "image-to-pdf", "The file must exist and not be empty.", "add_attachment"), 470);
|
|
4386
|
+
end
|
|
4387
|
+
|
|
4388
|
+
@files['attachment_%s' % @file_id] = attachment
|
|
4389
|
+
@file_id += 1
|
|
4390
|
+
self
|
|
4391
|
+
end
|
|
4392
|
+
|
|
4093
4393
|
# @see https://pdfcrowd.com/api/image-to-pdf-ruby/ref/#set_page_layout
|
|
4094
4394
|
def setPageLayout(layout)
|
|
4095
4395
|
unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout)
|
|
@@ -4302,6 +4602,7 @@ module Pdfcrowd
|
|
|
4302
4602
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-html", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
|
4303
4603
|
end
|
|
4304
4604
|
|
|
4605
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4305
4606
|
@fields['url'] = url
|
|
4306
4607
|
@helper.post(@fields, @files, @raw_data)
|
|
4307
4608
|
end
|
|
@@ -4312,6 +4613,7 @@ module Pdfcrowd
|
|
|
4312
4613
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "pdf-to-html", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
|
4313
4614
|
end
|
|
4314
4615
|
|
|
4616
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4315
4617
|
@fields['url'] = url
|
|
4316
4618
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
4317
4619
|
end
|
|
@@ -4327,13 +4629,25 @@ module Pdfcrowd
|
|
|
4327
4629
|
end
|
|
4328
4630
|
|
|
4329
4631
|
output_file = open(file_path, "wb")
|
|
4632
|
+
succeeded = false
|
|
4330
4633
|
begin
|
|
4331
|
-
convertUrlToStream(url,
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4634
|
+
convertUrlToStream(url,output_file)
|
|
4635
|
+
succeeded = true
|
|
4636
|
+
ensure
|
|
4637
|
+
if succeeded
|
|
4638
|
+
output_file.close()
|
|
4639
|
+
else
|
|
4640
|
+
begin
|
|
4641
|
+
output_file.close()
|
|
4642
|
+
rescue Exception
|
|
4643
|
+
# Preserve the conversion failure.
|
|
4644
|
+
end
|
|
4645
|
+
begin
|
|
4646
|
+
FileUtils.rm(file_path)
|
|
4647
|
+
rescue Exception
|
|
4648
|
+
# Removing a failed output must not mask the original failure.
|
|
4649
|
+
end
|
|
4650
|
+
end
|
|
4337
4651
|
end
|
|
4338
4652
|
end
|
|
4339
4653
|
|
|
@@ -4343,6 +4657,7 @@ module Pdfcrowd
|
|
|
4343
4657
|
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "pdf-to-html", "The file must exist and not be empty.", "convert_file"), 470);
|
|
4344
4658
|
end
|
|
4345
4659
|
|
|
4660
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4346
4661
|
@files['file'] = file
|
|
4347
4662
|
@helper.post(@fields, @files, @raw_data)
|
|
4348
4663
|
end
|
|
@@ -4353,6 +4668,7 @@ module Pdfcrowd
|
|
|
4353
4668
|
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);
|
|
4354
4669
|
end
|
|
4355
4670
|
|
|
4671
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4356
4672
|
@files['file'] = file
|
|
4357
4673
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
4358
4674
|
end
|
|
@@ -4368,24 +4684,38 @@ module Pdfcrowd
|
|
|
4368
4684
|
end
|
|
4369
4685
|
|
|
4370
4686
|
output_file = open(file_path, "wb")
|
|
4687
|
+
succeeded = false
|
|
4371
4688
|
begin
|
|
4372
|
-
convertFileToStream(file,
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4689
|
+
convertFileToStream(file,output_file)
|
|
4690
|
+
succeeded = true
|
|
4691
|
+
ensure
|
|
4692
|
+
if succeeded
|
|
4693
|
+
output_file.close()
|
|
4694
|
+
else
|
|
4695
|
+
begin
|
|
4696
|
+
output_file.close()
|
|
4697
|
+
rescue Exception
|
|
4698
|
+
# Preserve the conversion failure.
|
|
4699
|
+
end
|
|
4700
|
+
begin
|
|
4701
|
+
FileUtils.rm(file_path)
|
|
4702
|
+
rescue Exception
|
|
4703
|
+
# Removing a failed output must not mask the original failure.
|
|
4704
|
+
end
|
|
4705
|
+
end
|
|
4378
4706
|
end
|
|
4379
4707
|
end
|
|
4380
4708
|
|
|
4381
4709
|
# @see https://pdfcrowd.com/api/pdf-to-html-ruby/ref/#convert_raw_data
|
|
4382
4710
|
def convertRawData(data)
|
|
4711
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4383
4712
|
@raw_data['file'] = data
|
|
4384
4713
|
@helper.post(@fields, @files, @raw_data)
|
|
4385
4714
|
end
|
|
4386
4715
|
|
|
4387
4716
|
# @see https://pdfcrowd.com/api/pdf-to-html-ruby/ref/#convert_raw_data_to_stream
|
|
4388
4717
|
def convertRawDataToStream(data, out_stream)
|
|
4718
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4389
4719
|
@raw_data['file'] = data
|
|
4390
4720
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
4391
4721
|
end
|
|
@@ -4401,24 +4731,38 @@ module Pdfcrowd
|
|
|
4401
4731
|
end
|
|
4402
4732
|
|
|
4403
4733
|
output_file = open(file_path, "wb")
|
|
4734
|
+
succeeded = false
|
|
4404
4735
|
begin
|
|
4405
|
-
convertRawDataToStream(data,
|
|
4406
|
-
|
|
4407
|
-
|
|
4408
|
-
|
|
4409
|
-
|
|
4410
|
-
|
|
4736
|
+
convertRawDataToStream(data,output_file)
|
|
4737
|
+
succeeded = true
|
|
4738
|
+
ensure
|
|
4739
|
+
if succeeded
|
|
4740
|
+
output_file.close()
|
|
4741
|
+
else
|
|
4742
|
+
begin
|
|
4743
|
+
output_file.close()
|
|
4744
|
+
rescue Exception
|
|
4745
|
+
# Preserve the conversion failure.
|
|
4746
|
+
end
|
|
4747
|
+
begin
|
|
4748
|
+
FileUtils.rm(file_path)
|
|
4749
|
+
rescue Exception
|
|
4750
|
+
# Removing a failed output must not mask the original failure.
|
|
4751
|
+
end
|
|
4752
|
+
end
|
|
4411
4753
|
end
|
|
4412
4754
|
end
|
|
4413
4755
|
|
|
4414
4756
|
# @see https://pdfcrowd.com/api/pdf-to-html-ruby/ref/#convert_stream
|
|
4415
4757
|
def convertStream(in_stream)
|
|
4758
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4416
4759
|
@raw_data['stream'] = in_stream.read
|
|
4417
4760
|
@helper.post(@fields, @files, @raw_data)
|
|
4418
4761
|
end
|
|
4419
4762
|
|
|
4420
4763
|
# @see https://pdfcrowd.com/api/pdf-to-html-ruby/ref/#convert_stream_to_stream
|
|
4421
4764
|
def convertStreamToStream(in_stream, out_stream)
|
|
4765
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4422
4766
|
@raw_data['stream'] = in_stream.read
|
|
4423
4767
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
4424
4768
|
end
|
|
@@ -4434,13 +4778,25 @@ module Pdfcrowd
|
|
|
4434
4778
|
end
|
|
4435
4779
|
|
|
4436
4780
|
output_file = open(file_path, "wb")
|
|
4781
|
+
succeeded = false
|
|
4437
4782
|
begin
|
|
4438
|
-
convertStreamToStream(in_stream,
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4783
|
+
convertStreamToStream(in_stream,output_file)
|
|
4784
|
+
succeeded = true
|
|
4785
|
+
ensure
|
|
4786
|
+
if succeeded
|
|
4787
|
+
output_file.close()
|
|
4788
|
+
else
|
|
4789
|
+
begin
|
|
4790
|
+
output_file.close()
|
|
4791
|
+
rescue Exception
|
|
4792
|
+
# Preserve the conversion failure.
|
|
4793
|
+
end
|
|
4794
|
+
begin
|
|
4795
|
+
FileUtils.rm(file_path)
|
|
4796
|
+
rescue Exception
|
|
4797
|
+
# Removing a failed output must not mask the original failure.
|
|
4798
|
+
end
|
|
4799
|
+
end
|
|
4444
4800
|
end
|
|
4445
4801
|
end
|
|
4446
4802
|
|
|
@@ -4724,6 +5080,7 @@ module Pdfcrowd
|
|
|
4724
5080
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-text", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
|
4725
5081
|
end
|
|
4726
5082
|
|
|
5083
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4727
5084
|
@fields['url'] = url
|
|
4728
5085
|
@helper.post(@fields, @files, @raw_data)
|
|
4729
5086
|
end
|
|
@@ -4734,6 +5091,7 @@ module Pdfcrowd
|
|
|
4734
5091
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "pdf-to-text", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
|
4735
5092
|
end
|
|
4736
5093
|
|
|
5094
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4737
5095
|
@fields['url'] = url
|
|
4738
5096
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
4739
5097
|
end
|
|
@@ -4745,13 +5103,25 @@ module Pdfcrowd
|
|
|
4745
5103
|
end
|
|
4746
5104
|
|
|
4747
5105
|
output_file = open(file_path, "wb")
|
|
5106
|
+
succeeded = false
|
|
4748
5107
|
begin
|
|
4749
|
-
convertUrlToStream(url,
|
|
4750
|
-
|
|
4751
|
-
|
|
4752
|
-
|
|
4753
|
-
|
|
4754
|
-
|
|
5108
|
+
convertUrlToStream(url,output_file)
|
|
5109
|
+
succeeded = true
|
|
5110
|
+
ensure
|
|
5111
|
+
if succeeded
|
|
5112
|
+
output_file.close()
|
|
5113
|
+
else
|
|
5114
|
+
begin
|
|
5115
|
+
output_file.close()
|
|
5116
|
+
rescue Exception
|
|
5117
|
+
# Preserve the conversion failure.
|
|
5118
|
+
end
|
|
5119
|
+
begin
|
|
5120
|
+
FileUtils.rm(file_path)
|
|
5121
|
+
rescue Exception
|
|
5122
|
+
# Removing a failed output must not mask the original failure.
|
|
5123
|
+
end
|
|
5124
|
+
end
|
|
4755
5125
|
end
|
|
4756
5126
|
end
|
|
4757
5127
|
|
|
@@ -4761,6 +5131,7 @@ module Pdfcrowd
|
|
|
4761
5131
|
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "pdf-to-text", "The file must exist and not be empty.", "convert_file"), 470);
|
|
4762
5132
|
end
|
|
4763
5133
|
|
|
5134
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4764
5135
|
@files['file'] = file
|
|
4765
5136
|
@helper.post(@fields, @files, @raw_data)
|
|
4766
5137
|
end
|
|
@@ -4771,6 +5142,7 @@ module Pdfcrowd
|
|
|
4771
5142
|
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);
|
|
4772
5143
|
end
|
|
4773
5144
|
|
|
5145
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4774
5146
|
@files['file'] = file
|
|
4775
5147
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
4776
5148
|
end
|
|
@@ -4782,24 +5154,38 @@ module Pdfcrowd
|
|
|
4782
5154
|
end
|
|
4783
5155
|
|
|
4784
5156
|
output_file = open(file_path, "wb")
|
|
5157
|
+
succeeded = false
|
|
4785
5158
|
begin
|
|
4786
|
-
convertFileToStream(file,
|
|
4787
|
-
|
|
4788
|
-
|
|
4789
|
-
|
|
4790
|
-
|
|
4791
|
-
|
|
5159
|
+
convertFileToStream(file,output_file)
|
|
5160
|
+
succeeded = true
|
|
5161
|
+
ensure
|
|
5162
|
+
if succeeded
|
|
5163
|
+
output_file.close()
|
|
5164
|
+
else
|
|
5165
|
+
begin
|
|
5166
|
+
output_file.close()
|
|
5167
|
+
rescue Exception
|
|
5168
|
+
# Preserve the conversion failure.
|
|
5169
|
+
end
|
|
5170
|
+
begin
|
|
5171
|
+
FileUtils.rm(file_path)
|
|
5172
|
+
rescue Exception
|
|
5173
|
+
# Removing a failed output must not mask the original failure.
|
|
5174
|
+
end
|
|
5175
|
+
end
|
|
4792
5176
|
end
|
|
4793
5177
|
end
|
|
4794
5178
|
|
|
4795
5179
|
# @see https://pdfcrowd.com/api/pdf-to-text-ruby/ref/#convert_raw_data
|
|
4796
5180
|
def convertRawData(data)
|
|
5181
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4797
5182
|
@raw_data['file'] = data
|
|
4798
5183
|
@helper.post(@fields, @files, @raw_data)
|
|
4799
5184
|
end
|
|
4800
5185
|
|
|
4801
5186
|
# @see https://pdfcrowd.com/api/pdf-to-text-ruby/ref/#convert_raw_data_to_stream
|
|
4802
5187
|
def convertRawDataToStream(data, out_stream)
|
|
5188
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4803
5189
|
@raw_data['file'] = data
|
|
4804
5190
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
4805
5191
|
end
|
|
@@ -4811,24 +5197,38 @@ module Pdfcrowd
|
|
|
4811
5197
|
end
|
|
4812
5198
|
|
|
4813
5199
|
output_file = open(file_path, "wb")
|
|
5200
|
+
succeeded = false
|
|
4814
5201
|
begin
|
|
4815
|
-
convertRawDataToStream(data,
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
5202
|
+
convertRawDataToStream(data,output_file)
|
|
5203
|
+
succeeded = true
|
|
5204
|
+
ensure
|
|
5205
|
+
if succeeded
|
|
5206
|
+
output_file.close()
|
|
5207
|
+
else
|
|
5208
|
+
begin
|
|
5209
|
+
output_file.close()
|
|
5210
|
+
rescue Exception
|
|
5211
|
+
# Preserve the conversion failure.
|
|
5212
|
+
end
|
|
5213
|
+
begin
|
|
5214
|
+
FileUtils.rm(file_path)
|
|
5215
|
+
rescue Exception
|
|
5216
|
+
# Removing a failed output must not mask the original failure.
|
|
5217
|
+
end
|
|
5218
|
+
end
|
|
4821
5219
|
end
|
|
4822
5220
|
end
|
|
4823
5221
|
|
|
4824
5222
|
# @see https://pdfcrowd.com/api/pdf-to-text-ruby/ref/#convert_stream
|
|
4825
5223
|
def convertStream(in_stream)
|
|
5224
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4826
5225
|
@raw_data['stream'] = in_stream.read
|
|
4827
5226
|
@helper.post(@fields, @files, @raw_data)
|
|
4828
5227
|
end
|
|
4829
5228
|
|
|
4830
5229
|
# @see https://pdfcrowd.com/api/pdf-to-text-ruby/ref/#convert_stream_to_stream
|
|
4831
5230
|
def convertStreamToStream(in_stream, out_stream)
|
|
5231
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
4832
5232
|
@raw_data['stream'] = in_stream.read
|
|
4833
5233
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
4834
5234
|
end
|
|
@@ -4840,13 +5240,25 @@ module Pdfcrowd
|
|
|
4840
5240
|
end
|
|
4841
5241
|
|
|
4842
5242
|
output_file = open(file_path, "wb")
|
|
5243
|
+
succeeded = false
|
|
4843
5244
|
begin
|
|
4844
|
-
convertStreamToStream(in_stream,
|
|
4845
|
-
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
5245
|
+
convertStreamToStream(in_stream,output_file)
|
|
5246
|
+
succeeded = true
|
|
5247
|
+
ensure
|
|
5248
|
+
if succeeded
|
|
5249
|
+
output_file.close()
|
|
5250
|
+
else
|
|
5251
|
+
begin
|
|
5252
|
+
output_file.close()
|
|
5253
|
+
rescue Exception
|
|
5254
|
+
# Preserve the conversion failure.
|
|
5255
|
+
end
|
|
5256
|
+
begin
|
|
5257
|
+
FileUtils.rm(file_path)
|
|
5258
|
+
rescue Exception
|
|
5259
|
+
# Removing a failed output must not mask the original failure.
|
|
5260
|
+
end
|
|
5261
|
+
end
|
|
4850
5262
|
end
|
|
4851
5263
|
end
|
|
4852
5264
|
|
|
@@ -5100,6 +5512,7 @@ module Pdfcrowd
|
|
|
5100
5512
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "pdf-to-image", "Supported protocols are http:// and https://.", "convert_url"), 470);
|
|
5101
5513
|
end
|
|
5102
5514
|
|
|
5515
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
5103
5516
|
@fields['url'] = url
|
|
5104
5517
|
@helper.post(@fields, @files, @raw_data)
|
|
5105
5518
|
end
|
|
@@ -5110,6 +5523,7 @@ module Pdfcrowd
|
|
|
5110
5523
|
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "pdf-to-image", "Supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
|
5111
5524
|
end
|
|
5112
5525
|
|
|
5526
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
5113
5527
|
@fields['url'] = url
|
|
5114
5528
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
5115
5529
|
end
|
|
@@ -5121,13 +5535,25 @@ module Pdfcrowd
|
|
|
5121
5535
|
end
|
|
5122
5536
|
|
|
5123
5537
|
output_file = open(file_path, "wb")
|
|
5538
|
+
succeeded = false
|
|
5124
5539
|
begin
|
|
5125
|
-
convertUrlToStream(url,
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5129
|
-
|
|
5130
|
-
|
|
5540
|
+
convertUrlToStream(url,output_file)
|
|
5541
|
+
succeeded = true
|
|
5542
|
+
ensure
|
|
5543
|
+
if succeeded
|
|
5544
|
+
output_file.close()
|
|
5545
|
+
else
|
|
5546
|
+
begin
|
|
5547
|
+
output_file.close()
|
|
5548
|
+
rescue Exception
|
|
5549
|
+
# Preserve the conversion failure.
|
|
5550
|
+
end
|
|
5551
|
+
begin
|
|
5552
|
+
FileUtils.rm(file_path)
|
|
5553
|
+
rescue Exception
|
|
5554
|
+
# Removing a failed output must not mask the original failure.
|
|
5555
|
+
end
|
|
5556
|
+
end
|
|
5131
5557
|
end
|
|
5132
5558
|
end
|
|
5133
5559
|
|
|
@@ -5137,6 +5563,7 @@ module Pdfcrowd
|
|
|
5137
5563
|
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "pdf-to-image", "The file must exist and not be empty.", "convert_file"), 470);
|
|
5138
5564
|
end
|
|
5139
5565
|
|
|
5566
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
5140
5567
|
@files['file'] = file
|
|
5141
5568
|
@helper.post(@fields, @files, @raw_data)
|
|
5142
5569
|
end
|
|
@@ -5147,6 +5574,7 @@ module Pdfcrowd
|
|
|
5147
5574
|
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFileToStream::file", "pdf-to-image", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
|
|
5148
5575
|
end
|
|
5149
5576
|
|
|
5577
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
5150
5578
|
@files['file'] = file
|
|
5151
5579
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
5152
5580
|
end
|
|
@@ -5158,24 +5586,38 @@ module Pdfcrowd
|
|
|
5158
5586
|
end
|
|
5159
5587
|
|
|
5160
5588
|
output_file = open(file_path, "wb")
|
|
5589
|
+
succeeded = false
|
|
5161
5590
|
begin
|
|
5162
|
-
convertFileToStream(file,
|
|
5163
|
-
|
|
5164
|
-
|
|
5165
|
-
|
|
5166
|
-
|
|
5167
|
-
|
|
5591
|
+
convertFileToStream(file,output_file)
|
|
5592
|
+
succeeded = true
|
|
5593
|
+
ensure
|
|
5594
|
+
if succeeded
|
|
5595
|
+
output_file.close()
|
|
5596
|
+
else
|
|
5597
|
+
begin
|
|
5598
|
+
output_file.close()
|
|
5599
|
+
rescue Exception
|
|
5600
|
+
# Preserve the conversion failure.
|
|
5601
|
+
end
|
|
5602
|
+
begin
|
|
5603
|
+
FileUtils.rm(file_path)
|
|
5604
|
+
rescue Exception
|
|
5605
|
+
# Removing a failed output must not mask the original failure.
|
|
5606
|
+
end
|
|
5607
|
+
end
|
|
5168
5608
|
end
|
|
5169
5609
|
end
|
|
5170
5610
|
|
|
5171
5611
|
# @see https://pdfcrowd.com/api/pdf-to-image-ruby/ref/#convert_raw_data
|
|
5172
5612
|
def convertRawData(data)
|
|
5613
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
5173
5614
|
@raw_data['file'] = data
|
|
5174
5615
|
@helper.post(@fields, @files, @raw_data)
|
|
5175
5616
|
end
|
|
5176
5617
|
|
|
5177
5618
|
# @see https://pdfcrowd.com/api/pdf-to-image-ruby/ref/#convert_raw_data_to_stream
|
|
5178
5619
|
def convertRawDataToStream(data, out_stream)
|
|
5620
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
5179
5621
|
@raw_data['file'] = data
|
|
5180
5622
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
5181
5623
|
end
|
|
@@ -5187,24 +5629,38 @@ module Pdfcrowd
|
|
|
5187
5629
|
end
|
|
5188
5630
|
|
|
5189
5631
|
output_file = open(file_path, "wb")
|
|
5632
|
+
succeeded = false
|
|
5190
5633
|
begin
|
|
5191
|
-
convertRawDataToStream(data,
|
|
5192
|
-
|
|
5193
|
-
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5634
|
+
convertRawDataToStream(data,output_file)
|
|
5635
|
+
succeeded = true
|
|
5636
|
+
ensure
|
|
5637
|
+
if succeeded
|
|
5638
|
+
output_file.close()
|
|
5639
|
+
else
|
|
5640
|
+
begin
|
|
5641
|
+
output_file.close()
|
|
5642
|
+
rescue Exception
|
|
5643
|
+
# Preserve the conversion failure.
|
|
5644
|
+
end
|
|
5645
|
+
begin
|
|
5646
|
+
FileUtils.rm(file_path)
|
|
5647
|
+
rescue Exception
|
|
5648
|
+
# Removing a failed output must not mask the original failure.
|
|
5649
|
+
end
|
|
5650
|
+
end
|
|
5197
5651
|
end
|
|
5198
5652
|
end
|
|
5199
5653
|
|
|
5200
5654
|
# @see https://pdfcrowd.com/api/pdf-to-image-ruby/ref/#convert_stream
|
|
5201
5655
|
def convertStream(in_stream)
|
|
5656
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
5202
5657
|
@raw_data['stream'] = in_stream.read
|
|
5203
5658
|
@helper.post(@fields, @files, @raw_data)
|
|
5204
5659
|
end
|
|
5205
5660
|
|
|
5206
5661
|
# @see https://pdfcrowd.com/api/pdf-to-image-ruby/ref/#convert_stream_to_stream
|
|
5207
5662
|
def convertStreamToStream(in_stream, out_stream)
|
|
5663
|
+
@helper.reset_input(@fields, @files, @raw_data)
|
|
5208
5664
|
@raw_data['stream'] = in_stream.read
|
|
5209
5665
|
@helper.post(@fields, @files, @raw_data, out_stream)
|
|
5210
5666
|
end
|
|
@@ -5216,13 +5672,25 @@ module Pdfcrowd
|
|
|
5216
5672
|
end
|
|
5217
5673
|
|
|
5218
5674
|
output_file = open(file_path, "wb")
|
|
5675
|
+
succeeded = false
|
|
5219
5676
|
begin
|
|
5220
|
-
convertStreamToStream(in_stream,
|
|
5221
|
-
|
|
5222
|
-
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5677
|
+
convertStreamToStream(in_stream,output_file)
|
|
5678
|
+
succeeded = true
|
|
5679
|
+
ensure
|
|
5680
|
+
if succeeded
|
|
5681
|
+
output_file.close()
|
|
5682
|
+
else
|
|
5683
|
+
begin
|
|
5684
|
+
output_file.close()
|
|
5685
|
+
rescue Exception
|
|
5686
|
+
# Preserve the conversion failure.
|
|
5687
|
+
end
|
|
5688
|
+
begin
|
|
5689
|
+
FileUtils.rm(file_path)
|
|
5690
|
+
rescue Exception
|
|
5691
|
+
# Removing a failed output must not mask the original failure.
|
|
5692
|
+
end
|
|
5693
|
+
end
|
|
5226
5694
|
end
|
|
5227
5695
|
end
|
|
5228
5696
|
|