pdfcrowd 4.9.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/pdfcrowd.rb +1311 -671
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b7043c685a1f94d4f4fc908be622607de34e3bc83df6c9b5c100baa6851e88b9
|
4
|
+
data.tar.gz: 940c31501059ef749182c3162f81309747684f43299b2f2c0ce32cc5efff345a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26430785af23b2f5a1002dd3b5b58958297379cdf19fef474f8e772ae903834476d481bd0f5b97c83fc2694410fd8709ead4b74300036326b926a46a2d846b3c
|
7
|
+
data.tar.gz: 6372a0b8df9c3631110dab9fbcec8a42904503b15f3f6d43c6767b63b4f21232f4fed6e068a2dd8cd97094ebd1a5ca6e20ca02ccd84f44ff254bcafc81c136ab
|
data/lib/pdfcrowd.rb
CHANGED
@@ -530,7 +530,7 @@ end
|
|
530
530
|
module Pdfcrowd
|
531
531
|
HOST = ENV["PDFCROWD_HOST"] || 'api.pdfcrowd.com'
|
532
532
|
MULTIPART_BOUNDARY = '----------ThIs_Is_tHe_bOUnDary_$'
|
533
|
-
CLIENT_VERSION = '
|
533
|
+
CLIENT_VERSION = '5.1.0'
|
534
534
|
|
535
535
|
class ConnectionHelper
|
536
536
|
def initialize(user_name, api_key)
|
@@ -541,13 +541,14 @@ module Pdfcrowd
|
|
541
541
|
|
542
542
|
setProxy(nil, nil, nil, nil)
|
543
543
|
setUseHttp(false)
|
544
|
-
setUserAgent('pdfcrowd_ruby_client/
|
544
|
+
setUserAgent('pdfcrowd_ruby_client/5.1.0 (https://pdfcrowd.com)')
|
545
545
|
|
546
546
|
@retry_count = 1
|
547
|
+
@converter_version = '20.10'
|
547
548
|
end
|
548
549
|
|
549
550
|
def post(fields, files, raw_data, out_stream = nil)
|
550
|
-
request =
|
551
|
+
request = create_request()
|
551
552
|
request.body = ConnectionHelper.encode_multipart_post_data(fields, files, raw_data)
|
552
553
|
request.content_type = 'multipart/form-data; boundary=' + MULTIPART_BOUNDARY
|
553
554
|
do_post(request, out_stream)
|
@@ -565,6 +566,10 @@ module Pdfcrowd
|
|
565
566
|
@retry_count = retry_count
|
566
567
|
end
|
567
568
|
|
569
|
+
def setConverterVersion(converter_version)
|
570
|
+
@converter_version = converter_version
|
571
|
+
end
|
572
|
+
|
568
573
|
def setProxy(host, port, user_name, password)
|
569
574
|
@proxy_host = host
|
570
575
|
@proxy_port = port
|
@@ -596,6 +601,10 @@ module Pdfcrowd
|
|
596
601
|
@output_size
|
597
602
|
end
|
598
603
|
|
604
|
+
def getConverterVersion()
|
605
|
+
@converter_version
|
606
|
+
end
|
607
|
+
|
599
608
|
private
|
600
609
|
|
601
610
|
def reset_response_data()
|
@@ -608,8 +617,8 @@ module Pdfcrowd
|
|
608
617
|
@retry = 0
|
609
618
|
end
|
610
619
|
|
611
|
-
def
|
612
|
-
Net::HTTP::Post.new('/convert/')
|
620
|
+
def create_request()
|
621
|
+
Net::HTTP::Post.new('/convert/%s/' % @converter_version)
|
613
622
|
end
|
614
623
|
|
615
624
|
def self.add_file_field(name, file_name, data, body)
|
@@ -683,6 +692,7 @@ module Pdfcrowd
|
|
683
692
|
|
684
693
|
begin
|
685
694
|
http.start {|conn|
|
695
|
+
conn.read_timeout = 300
|
686
696
|
conn.request(request) {|response|
|
687
697
|
@debug_log_url = response["X-Pdfcrowd-Debug-Log"] || ''
|
688
698
|
@credits = (response["X-Pdfcrowd-Remaining-Credits"] || 999999).to_i
|
@@ -723,7 +733,7 @@ module Pdfcrowd
|
|
723
733
|
end
|
724
734
|
|
725
735
|
def self.create_invalid_value_message(value, field, converter, hint, id)
|
726
|
-
message = "Invalid value '%s' for
|
736
|
+
message = "Invalid value '%s' for %s." % [value, field]
|
727
737
|
message += " " + hint if hint
|
728
738
|
return message + " " + "Details: https://www.pdfcrowd.com/doc/api/%s/ruby/#%s" % [converter, id]
|
729
739
|
end
|
@@ -753,7 +763,7 @@ module Pdfcrowd
|
|
753
763
|
# * *Returns* - Byte array containing the conversion output.
|
754
764
|
def convertUrl(url)
|
755
765
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
756
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "
|
766
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "convert_url"), 470);
|
757
767
|
end
|
758
768
|
|
759
769
|
@fields['url'] = url
|
@@ -766,7 +776,7 @@ module Pdfcrowd
|
|
766
776
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
767
777
|
def convertUrlToStream(url, out_stream)
|
768
778
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
769
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "html-to-pdf", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
779
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "html-to-pdf", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
770
780
|
end
|
771
781
|
|
772
782
|
@fields['url'] = url
|
@@ -779,7 +789,7 @@ module Pdfcrowd
|
|
779
789
|
# * +file_path+ - The output file path. The string must not be empty.
|
780
790
|
def convertUrlToFile(url, file_path)
|
781
791
|
if (!(!file_path.nil? && !file_path.empty?))
|
782
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-pdf", "The string must not be empty.", "convert_url_to_file"), 470);
|
792
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "html-to-pdf", "The string must not be empty.", "convert_url_to_file"), 470);
|
783
793
|
end
|
784
794
|
|
785
795
|
output_file = open(file_path, "wb")
|
@@ -799,11 +809,7 @@ module Pdfcrowd
|
|
799
809
|
# * *Returns* - Byte array containing the conversion output.
|
800
810
|
def convertFile(file)
|
801
811
|
if (!(File.file?(file) && !File.zero?(file)))
|
802
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "
|
803
|
-
end
|
804
|
-
|
805
|
-
if (!(File.file?(file) && !File.zero?(file)))
|
806
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-pdf", "The file name must have a valid extension.", "convert_file"), 470);
|
812
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "html-to-pdf", "The file must exist and not be empty.", "convert_file"), 470);
|
807
813
|
end
|
808
814
|
|
809
815
|
@files['file'] = file
|
@@ -816,11 +822,7 @@ module Pdfcrowd
|
|
816
822
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
817
823
|
def convertFileToStream(file, out_stream)
|
818
824
|
if (!(File.file?(file) && !File.zero?(file)))
|
819
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-pdf", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
|
820
|
-
end
|
821
|
-
|
822
|
-
if (!(File.file?(file) && !File.zero?(file)))
|
823
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-pdf", "The file name must have a valid extension.", "convert_file_to_stream"), 470);
|
825
|
+
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);
|
824
826
|
end
|
825
827
|
|
826
828
|
@files['file'] = file
|
@@ -833,7 +835,7 @@ module Pdfcrowd
|
|
833
835
|
# * +file_path+ - The output file path. The string must not be empty.
|
834
836
|
def convertFileToFile(file, file_path)
|
835
837
|
if (!(!file_path.nil? && !file_path.empty?))
|
836
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-pdf", "The string must not be empty.", "convert_file_to_file"), 470);
|
838
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "html-to-pdf", "The string must not be empty.", "convert_file_to_file"), 470);
|
837
839
|
end
|
838
840
|
|
839
841
|
output_file = open(file_path, "wb")
|
@@ -853,7 +855,7 @@ module Pdfcrowd
|
|
853
855
|
# * *Returns* - Byte array containing the conversion output.
|
854
856
|
def convertString(text)
|
855
857
|
if (!(!text.nil? && !text.empty?))
|
856
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(text, "
|
858
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(text, "convertString", "html-to-pdf", "The string must not be empty.", "convert_string"), 470);
|
857
859
|
end
|
858
860
|
|
859
861
|
@fields['text'] = text
|
@@ -866,7 +868,7 @@ module Pdfcrowd
|
|
866
868
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
867
869
|
def convertStringToStream(text, out_stream)
|
868
870
|
if (!(!text.nil? && !text.empty?))
|
869
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(text, "text", "html-to-pdf", "The string must not be empty.", "convert_string_to_stream"), 470);
|
871
|
+
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);
|
870
872
|
end
|
871
873
|
|
872
874
|
@fields['text'] = text
|
@@ -879,7 +881,7 @@ module Pdfcrowd
|
|
879
881
|
# * +file_path+ - The output file path. The string must not be empty.
|
880
882
|
def convertStringToFile(text, file_path)
|
881
883
|
if (!(!file_path.nil? && !file_path.empty?))
|
882
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-pdf", "The string must not be empty.", "convert_string_to_file"), 470);
|
884
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStringToFile::file_path", "html-to-pdf", "The string must not be empty.", "convert_string_to_file"), 470);
|
883
885
|
end
|
884
886
|
|
885
887
|
output_file = open(file_path, "wb")
|
@@ -893,42 +895,80 @@ module Pdfcrowd
|
|
893
895
|
end
|
894
896
|
end
|
895
897
|
|
898
|
+
# Convert an input stream.
|
899
|
+
#
|
900
|
+
# * +in_stream+ - The input stream with the source data.
|
901
|
+
# * *Returns* - Byte array containing the conversion output.
|
902
|
+
def convertStream(in_stream)
|
903
|
+
@raw_data['stream'] = in_stream.read
|
904
|
+
@helper.post(@fields, @files, @raw_data)
|
905
|
+
end
|
906
|
+
|
907
|
+
# Convert an input stream and write the result to an output stream.
|
908
|
+
#
|
909
|
+
# * +in_stream+ - The input stream with the source data.
|
910
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
911
|
+
def convertStreamToStream(in_stream, out_stream)
|
912
|
+
@raw_data['stream'] = in_stream.read
|
913
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
914
|
+
end
|
915
|
+
|
916
|
+
# Convert an input stream and write the result to a local file.
|
917
|
+
#
|
918
|
+
# * +in_stream+ - The input stream with the source data.
|
919
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
920
|
+
def convertStreamToFile(in_stream, file_path)
|
921
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
922
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "html-to-pdf", "The string must not be empty.", "convert_stream_to_file"), 470);
|
923
|
+
end
|
924
|
+
|
925
|
+
output_file = open(file_path, "wb")
|
926
|
+
begin
|
927
|
+
convertStreamToStream(in_stream, output_file)
|
928
|
+
output_file.close()
|
929
|
+
rescue Error => why
|
930
|
+
output_file.close()
|
931
|
+
FileUtils.rm(file_path)
|
932
|
+
raise
|
933
|
+
end
|
934
|
+
end
|
935
|
+
|
896
936
|
# Set the output page size.
|
897
937
|
#
|
898
|
-
# * +
|
938
|
+
# * +size+ - Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.
|
899
939
|
# * *Returns* - The converter object.
|
900
|
-
def setPageSize(
|
901
|
-
unless /(?i)^(A2|A3|A4|A5|A6|Letter)$/.match(
|
902
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
940
|
+
def setPageSize(size)
|
941
|
+
unless /(?i)^(A0|A1|A2|A3|A4|A5|A6|Letter)$/.match(size)
|
942
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(size, "setPageSize", "html-to-pdf", "Allowed values are A0, A1, A2, A3, A4, A5, A6, Letter.", "set_page_size"), 470);
|
903
943
|
end
|
904
944
|
|
905
|
-
@fields['page_size'] =
|
945
|
+
@fields['page_size'] = size
|
906
946
|
self
|
907
947
|
end
|
908
948
|
|
909
949
|
# Set the output page width. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
|
910
950
|
#
|
911
|
-
# * +
|
951
|
+
# * +width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
912
952
|
# * *Returns* - The converter object.
|
913
|
-
def setPageWidth(
|
914
|
-
unless /(?i)^[0-9]
|
915
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
953
|
+
def setPageWidth(width)
|
954
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
|
955
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setPageWidth", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_page_width"), 470);
|
916
956
|
end
|
917
957
|
|
918
|
-
@fields['page_width'] =
|
958
|
+
@fields['page_width'] = width
|
919
959
|
self
|
920
960
|
end
|
921
961
|
|
922
962
|
# Set the output page height. Use -1 for a single page PDF. The safe maximum is 200in otherwise some PDF viewers may be unable to open the PDF.
|
923
963
|
#
|
924
|
-
# * +
|
964
|
+
# * +height+ - Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
925
965
|
# * *Returns* - The converter object.
|
926
|
-
def setPageHeight(
|
927
|
-
unless /(?i)
|
928
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
966
|
+
def setPageHeight(height)
|
967
|
+
unless /(?i)^0$|^\-1$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
968
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setPageHeight", "html-to-pdf", "Can be -1 or specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_page_height"), 470);
|
929
969
|
end
|
930
970
|
|
931
|
-
@fields['page_height'] =
|
971
|
+
@fields['page_height'] = height
|
932
972
|
self
|
933
973
|
end
|
934
974
|
|
@@ -949,7 +989,7 @@ module Pdfcrowd
|
|
949
989
|
# * *Returns* - The converter object.
|
950
990
|
def setOrientation(orientation)
|
951
991
|
unless /(?i)^(landscape|portrait)$/.match(orientation)
|
952
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(orientation, "
|
992
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(orientation, "setOrientation", "html-to-pdf", "Allowed values are landscape, portrait.", "set_orientation"), 470);
|
953
993
|
end
|
954
994
|
|
955
995
|
@fields['orientation'] = orientation
|
@@ -958,62 +998,62 @@ module Pdfcrowd
|
|
958
998
|
|
959
999
|
# Set the output page top margin.
|
960
1000
|
#
|
961
|
-
# * +
|
1001
|
+
# * +top+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
962
1002
|
# * *Returns* - The converter object.
|
963
|
-
def setMarginTop(
|
964
|
-
unless /(?i)^[0-9]
|
965
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1003
|
+
def setMarginTop(top)
|
1004
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(top)
|
1005
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(top, "setMarginTop", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_top"), 470);
|
966
1006
|
end
|
967
1007
|
|
968
|
-
@fields['margin_top'] =
|
1008
|
+
@fields['margin_top'] = top
|
969
1009
|
self
|
970
1010
|
end
|
971
1011
|
|
972
1012
|
# Set the output page right margin.
|
973
1013
|
#
|
974
|
-
# * +
|
1014
|
+
# * +right+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
975
1015
|
# * *Returns* - The converter object.
|
976
|
-
def setMarginRight(
|
977
|
-
unless /(?i)^[0-9]
|
978
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1016
|
+
def setMarginRight(right)
|
1017
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(right)
|
1018
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(right, "setMarginRight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_right"), 470);
|
979
1019
|
end
|
980
1020
|
|
981
|
-
@fields['margin_right'] =
|
1021
|
+
@fields['margin_right'] = right
|
982
1022
|
self
|
983
1023
|
end
|
984
1024
|
|
985
1025
|
# Set the output page bottom margin.
|
986
1026
|
#
|
987
|
-
# * +
|
1027
|
+
# * +bottom+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
988
1028
|
# * *Returns* - The converter object.
|
989
|
-
def setMarginBottom(
|
990
|
-
unless /(?i)^[0-9]
|
991
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1029
|
+
def setMarginBottom(bottom)
|
1030
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(bottom)
|
1031
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(bottom, "setMarginBottom", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_bottom"), 470);
|
992
1032
|
end
|
993
1033
|
|
994
|
-
@fields['margin_bottom'] =
|
1034
|
+
@fields['margin_bottom'] = bottom
|
995
1035
|
self
|
996
1036
|
end
|
997
1037
|
|
998
1038
|
# Set the output page left margin.
|
999
1039
|
#
|
1000
|
-
# * +
|
1040
|
+
# * +left+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1001
1041
|
# * *Returns* - The converter object.
|
1002
|
-
def setMarginLeft(
|
1003
|
-
unless /(?i)^[0-9]
|
1004
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1042
|
+
def setMarginLeft(left)
|
1043
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(left)
|
1044
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(left, "setMarginLeft", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_margin_left"), 470);
|
1005
1045
|
end
|
1006
1046
|
|
1007
|
-
@fields['margin_left'] =
|
1047
|
+
@fields['margin_left'] = left
|
1008
1048
|
self
|
1009
1049
|
end
|
1010
1050
|
|
1011
|
-
# Disable margins.
|
1051
|
+
# Disable page margins.
|
1012
1052
|
#
|
1013
|
-
# * +
|
1053
|
+
# * +value+ - Set to true to disable margins.
|
1014
1054
|
# * *Returns* - The converter object.
|
1015
|
-
def setNoMargins(
|
1016
|
-
@fields['no_margins'] =
|
1055
|
+
def setNoMargins(value)
|
1056
|
+
@fields['no_margins'] = value
|
1017
1057
|
self
|
1018
1058
|
end
|
1019
1059
|
|
@@ -1034,89 +1074,98 @@ module Pdfcrowd
|
|
1034
1074
|
|
1035
1075
|
# Load an HTML code from the specified URL and use it as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1036
1076
|
#
|
1037
|
-
# * +
|
1077
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1038
1078
|
# * *Returns* - The converter object.
|
1039
|
-
def setHeaderUrl(
|
1040
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
1041
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1079
|
+
def setHeaderUrl(url)
|
1080
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1081
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setHeaderUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_header_url"), 470);
|
1042
1082
|
end
|
1043
1083
|
|
1044
|
-
@fields['header_url'] =
|
1084
|
+
@fields['header_url'] = url
|
1045
1085
|
self
|
1046
1086
|
end
|
1047
1087
|
|
1048
1088
|
# Use the specified HTML code as the page header. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1049
1089
|
#
|
1050
|
-
# * +
|
1090
|
+
# * +html+ - The string must not be empty.
|
1051
1091
|
# * *Returns* - The converter object.
|
1052
|
-
def setHeaderHtml(
|
1053
|
-
if (!(!
|
1054
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1092
|
+
def setHeaderHtml(html)
|
1093
|
+
if (!(!html.nil? && !html.empty?))
|
1094
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setHeaderHtml", "html-to-pdf", "The string must not be empty.", "set_header_html"), 470);
|
1055
1095
|
end
|
1056
1096
|
|
1057
|
-
@fields['header_html'] =
|
1097
|
+
@fields['header_html'] = html
|
1058
1098
|
self
|
1059
1099
|
end
|
1060
1100
|
|
1061
1101
|
# Set the header height.
|
1062
1102
|
#
|
1063
|
-
# * +
|
1103
|
+
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1064
1104
|
# * *Returns* - The converter object.
|
1065
|
-
def setHeaderHeight(
|
1066
|
-
unless /(?i)^[0-9]
|
1067
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1105
|
+
def setHeaderHeight(height)
|
1106
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1107
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setHeaderHeight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_header_height"), 470);
|
1068
1108
|
end
|
1069
1109
|
|
1070
|
-
@fields['header_height'] =
|
1110
|
+
@fields['header_height'] = height
|
1071
1111
|
self
|
1072
1112
|
end
|
1073
1113
|
|
1074
1114
|
# Load an HTML code from the specified URL and use it as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1075
1115
|
#
|
1076
|
-
# * +
|
1116
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1077
1117
|
# * *Returns* - The converter object.
|
1078
|
-
def setFooterUrl(
|
1079
|
-
unless /(?i)^https?:\/\/.*$/.match(
|
1080
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1118
|
+
def setFooterUrl(url)
|
1119
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1120
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setFooterUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_footer_url"), 470);
|
1081
1121
|
end
|
1082
1122
|
|
1083
|
-
@fields['footer_url'] =
|
1123
|
+
@fields['footer_url'] = url
|
1084
1124
|
self
|
1085
1125
|
end
|
1086
1126
|
|
1087
1127
|
# Use the specified HTML as the page footer. The following classes can be used in the HTML. The content of the respective elements will be expanded as follows: pdfcrowd-page-count - the total page count of printed pages pdfcrowd-page-number - the current page number pdfcrowd-source-url - the source URL of a converted document The following attributes can be used: data-pdfcrowd-number-format - specifies the type of the used numerals Arabic numerals are used by default. Roman numerals can be generated by the roman and roman-lowercase values Example: <span class='pdfcrowd-page-number' data-pdfcrowd-number-format='roman'></span> data-pdfcrowd-placement - specifies where to place the source URL, allowed values: The URL is inserted to the content Example: <span class='pdfcrowd-source-url'></span> will produce <span>http://example.com</span> href - the URL is set to the href attribute Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href'>Link to source</a> will produce <a href='http://example.com'>Link to source</a> href-and-content - the URL is set to the href attribute and to the content Example: <a class='pdfcrowd-source-url' data-pdfcrowd-placement='href-and-content'></a> will produce <a href='http://example.com'>http://example.com</a>
|
1088
1128
|
#
|
1089
|
-
# * +
|
1129
|
+
# * +html+ - The string must not be empty.
|
1090
1130
|
# * *Returns* - The converter object.
|
1091
|
-
def setFooterHtml(
|
1092
|
-
if (!(!
|
1093
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1131
|
+
def setFooterHtml(html)
|
1132
|
+
if (!(!html.nil? && !html.empty?))
|
1133
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(html, "setFooterHtml", "html-to-pdf", "The string must not be empty.", "set_footer_html"), 470);
|
1094
1134
|
end
|
1095
1135
|
|
1096
|
-
@fields['footer_html'] =
|
1136
|
+
@fields['footer_html'] = html
|
1097
1137
|
self
|
1098
1138
|
end
|
1099
1139
|
|
1100
1140
|
# Set the footer height.
|
1101
1141
|
#
|
1102
|
-
# * +
|
1142
|
+
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1103
1143
|
# * *Returns* - The converter object.
|
1104
|
-
def setFooterHeight(
|
1105
|
-
unless /(?i)^[0-9]
|
1106
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1144
|
+
def setFooterHeight(height)
|
1145
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1146
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setFooterHeight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_footer_height"), 470);
|
1107
1147
|
end
|
1108
1148
|
|
1109
|
-
@fields['footer_height'] =
|
1149
|
+
@fields['footer_height'] = height
|
1150
|
+
self
|
1151
|
+
end
|
1152
|
+
|
1153
|
+
# Disable horizontal page margins for header and footer. The header/footer contents width will be equal to the physical page width.
|
1154
|
+
#
|
1155
|
+
# * +value+ - Set to true to disable horizontal margins for header and footer.
|
1156
|
+
# * *Returns* - The converter object.
|
1157
|
+
def setNoHeaderFooterHorizontalMargins(value)
|
1158
|
+
@fields['no_header_footer_horizontal_margins'] = value
|
1110
1159
|
self
|
1111
1160
|
end
|
1112
1161
|
|
1113
1162
|
# Set the page range to print.
|
1114
1163
|
#
|
1115
|
-
# * +pages+ - A comma
|
1164
|
+
# * +pages+ - A comma separated list of page numbers or ranges.
|
1116
1165
|
# * *Returns* - The converter object.
|
1117
1166
|
def setPrintPageRange(pages)
|
1118
1167
|
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)
|
1119
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "
|
1168
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setPrintPageRange", "html-to-pdf", "A comma separated list of page numbers or ranges.", "set_print_page_range"), 470);
|
1120
1169
|
end
|
1121
1170
|
|
1122
1171
|
@fields['print_page_range'] = pages
|
@@ -1125,11 +1174,11 @@ module Pdfcrowd
|
|
1125
1174
|
|
1126
1175
|
# The page header is not printed on the specified pages.
|
1127
1176
|
#
|
1128
|
-
# * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma
|
1177
|
+
# * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma separated list of page numbers.
|
1129
1178
|
# * *Returns* - The converter object.
|
1130
1179
|
def setExcludeHeaderOnPages(pages)
|
1131
1180
|
unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
|
1132
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "
|
1181
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setExcludeHeaderOnPages", "html-to-pdf", "A comma separated list of page numbers.", "set_exclude_header_on_pages"), 470);
|
1133
1182
|
end
|
1134
1183
|
|
1135
1184
|
@fields['exclude_header_on_pages'] = pages
|
@@ -1138,11 +1187,11 @@ module Pdfcrowd
|
|
1138
1187
|
|
1139
1188
|
# The page footer is not printed on the specified pages.
|
1140
1189
|
#
|
1141
|
-
# * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma
|
1190
|
+
# * +pages+ - List of physical page numbers. Negative numbers count backwards from the last page: -1 is the last page, -2 is the last but one page, and so on. A comma separated list of page numbers.
|
1142
1191
|
# * *Returns* - The converter object.
|
1143
1192
|
def setExcludeFooterOnPages(pages)
|
1144
1193
|
unless /^(?:\s*\-?\d+\s*,)*\s*\-?\d+\s*$/.match(pages)
|
1145
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "
|
1194
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(pages, "setExcludeFooterOnPages", "html-to-pdf", "A comma separated list of page numbers.", "set_exclude_footer_on_pages"), 470);
|
1146
1195
|
end
|
1147
1196
|
|
1148
1197
|
@fields['exclude_footer_on_pages'] = pages
|
@@ -1158,62 +1207,62 @@ module Pdfcrowd
|
|
1158
1207
|
self
|
1159
1208
|
end
|
1160
1209
|
|
1161
|
-
# Set the top left X coordinate of the content area. It
|
1210
|
+
# Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area.
|
1162
1211
|
#
|
1163
|
-
# * +
|
1212
|
+
# * +x+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
|
1164
1213
|
# * *Returns* - The converter object.
|
1165
|
-
def setContentAreaX(
|
1166
|
-
unless /(?i)
|
1167
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1214
|
+
def setContentAreaX(x)
|
1215
|
+
unless /(?i)^0$|^\-?[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(x)
|
1216
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(x, "setContentAreaX", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.", "set_content_area_x"), 470);
|
1168
1217
|
end
|
1169
1218
|
|
1170
|
-
@fields['content_area_x'] =
|
1219
|
+
@fields['content_area_x'] = x
|
1171
1220
|
self
|
1172
1221
|
end
|
1173
1222
|
|
1174
|
-
# Set the top left Y coordinate of the content area. It
|
1223
|
+
# Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area.
|
1175
1224
|
#
|
1176
|
-
# * +
|
1225
|
+
# * +y+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
|
1177
1226
|
# * *Returns* - The converter object.
|
1178
|
-
def setContentAreaY(
|
1179
|
-
unless /(?i)
|
1180
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1227
|
+
def setContentAreaY(y)
|
1228
|
+
unless /(?i)^0$|^\-?[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(y)
|
1229
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(y, "setContentAreaY", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.", "set_content_area_y"), 470);
|
1181
1230
|
end
|
1182
1231
|
|
1183
|
-
@fields['content_area_y'] =
|
1232
|
+
@fields['content_area_y'] = y
|
1184
1233
|
self
|
1185
1234
|
end
|
1186
1235
|
|
1187
1236
|
# Set the width of the content area. It should be at least 1 inch.
|
1188
1237
|
#
|
1189
|
-
# * +
|
1238
|
+
# * +width+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1190
1239
|
# * *Returns* - The converter object.
|
1191
|
-
def setContentAreaWidth(
|
1192
|
-
unless /(?i)^[0-9]
|
1193
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1240
|
+
def setContentAreaWidth(width)
|
1241
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(width)
|
1242
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setContentAreaWidth", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_content_area_width"), 470);
|
1194
1243
|
end
|
1195
1244
|
|
1196
|
-
@fields['content_area_width'] =
|
1245
|
+
@fields['content_area_width'] = width
|
1197
1246
|
self
|
1198
1247
|
end
|
1199
1248
|
|
1200
1249
|
# Set the height of the content area. It should be at least 1 inch.
|
1201
1250
|
#
|
1202
|
-
# * +
|
1251
|
+
# * +height+ - Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1203
1252
|
# * *Returns* - The converter object.
|
1204
|
-
def setContentAreaHeight(
|
1205
|
-
unless /(?i)^[0-9]
|
1206
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1253
|
+
def setContentAreaHeight(height)
|
1254
|
+
unless /(?i)^0$|^[0-9]*\.?[0-9]+(pt|px|mm|cm|in)$/.match(height)
|
1255
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setContentAreaHeight", "html-to-pdf", "Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).", "set_content_area_height"), 470);
|
1207
1256
|
end
|
1208
1257
|
|
1209
|
-
@fields['content_area_height'] =
|
1258
|
+
@fields['content_area_height'] = height
|
1210
1259
|
self
|
1211
1260
|
end
|
1212
1261
|
|
1213
1262
|
# Set the content area position and size. The content area enables to specify a web page area to be converted.
|
1214
1263
|
#
|
1215
|
-
# * +x+ - Set the top left X coordinate of the content area. It
|
1216
|
-
# * +y+ - Set the top left Y coordinate of the content area. It
|
1264
|
+
# * +x+ - Set the top left X coordinate of the content area. It is relative to the top left X coordinate of the print area. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
|
1265
|
+
# * +y+ - Set the top left Y coordinate of the content area. It is relative to the top left Y coordinate of the print area. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt). It may contain a negative value.
|
1217
1266
|
# * +width+ - Set the width of the content area. It should be at least 1 inch. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1218
1267
|
# * +height+ - Set the height of the content area. It should be at least 1 inch. Can be specified in inches (in), millimeters (mm), centimeters (cm), or points (pt).
|
1219
1268
|
# * *Returns* - The converter object.
|
@@ -1225,122 +1274,294 @@ module Pdfcrowd
|
|
1225
1274
|
self
|
1226
1275
|
end
|
1227
1276
|
|
1277
|
+
# Specifies behavior in presence of CSS @page rules. It may affect the page size, margins and orientation.
|
1278
|
+
#
|
1279
|
+
# * +mode+ - The page rule mode. Allowed values are default, mode1, mode2.
|
1280
|
+
# * *Returns* - The converter object.
|
1281
|
+
def setCssPageRuleMode(mode)
|
1282
|
+
unless /(?i)^(default|mode1|mode2)$/.match(mode)
|
1283
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setCssPageRuleMode", "html-to-pdf", "Allowed values are default, mode1, mode2.", "set_css_page_rule_mode"), 470);
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
@fields['css_page_rule_mode'] = mode
|
1287
|
+
self
|
1288
|
+
end
|
1289
|
+
|
1290
|
+
# Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
|
1291
|
+
#
|
1292
|
+
# * +data_string+ - The input data string.
|
1293
|
+
# * *Returns* - The converter object.
|
1294
|
+
def setDataString(data_string)
|
1295
|
+
@fields['data_string'] = data_string
|
1296
|
+
self
|
1297
|
+
end
|
1298
|
+
|
1299
|
+
# Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
|
1300
|
+
#
|
1301
|
+
# * +data_file+ - The file path to a local file containing the input data.
|
1302
|
+
# * *Returns* - The converter object.
|
1303
|
+
def setDataFile(data_file)
|
1304
|
+
@files['data_file'] = data_file
|
1305
|
+
self
|
1306
|
+
end
|
1307
|
+
|
1308
|
+
# Specify the input data format.
|
1309
|
+
#
|
1310
|
+
# * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
|
1311
|
+
# * *Returns* - The converter object.
|
1312
|
+
def setDataFormat(data_format)
|
1313
|
+
unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
|
1314
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(data_format, "setDataFormat", "html-to-pdf", "Allowed values are auto, json, xml, yaml, csv.", "set_data_format"), 470);
|
1315
|
+
end
|
1316
|
+
|
1317
|
+
@fields['data_format'] = data_format
|
1318
|
+
self
|
1319
|
+
end
|
1320
|
+
|
1321
|
+
# Set the encoding of the data file set by setDataFile.
|
1322
|
+
#
|
1323
|
+
# * +encoding+ - The data file encoding.
|
1324
|
+
# * *Returns* - The converter object.
|
1325
|
+
def setDataEncoding(encoding)
|
1326
|
+
@fields['data_encoding'] = encoding
|
1327
|
+
self
|
1328
|
+
end
|
1329
|
+
|
1330
|
+
# Ignore undefined variables in the HTML template. The default mode is strict so any undefined variable causes the conversion to fail. You can use {% if variable is defined %} to check if the variable is defined.
|
1331
|
+
#
|
1332
|
+
# * +value+ - Set to true to ignore undefined variables.
|
1333
|
+
# * *Returns* - The converter object.
|
1334
|
+
def setDataIgnoreUndefined(value)
|
1335
|
+
@fields['data_ignore_undefined'] = value
|
1336
|
+
self
|
1337
|
+
end
|
1338
|
+
|
1339
|
+
# Auto escape HTML symbols in the input data before placing them into the output.
|
1340
|
+
#
|
1341
|
+
# * +value+ - Set to true to turn auto escaping on.
|
1342
|
+
# * *Returns* - The converter object.
|
1343
|
+
def setDataAutoEscape(value)
|
1344
|
+
@fields['data_auto_escape'] = value
|
1345
|
+
self
|
1346
|
+
end
|
1347
|
+
|
1348
|
+
# Auto trim whitespace around each template command block.
|
1349
|
+
#
|
1350
|
+
# * +value+ - Set to true to turn auto trimming on.
|
1351
|
+
# * *Returns* - The converter object.
|
1352
|
+
def setDataTrimBlocks(value)
|
1353
|
+
@fields['data_trim_blocks'] = value
|
1354
|
+
self
|
1355
|
+
end
|
1356
|
+
|
1357
|
+
# Set the advanced data options:csv_delimiter - The CSV data delimiter, the default is ,.xml_remove_root - Remove the root XML element from the input data.data_root - The name of the root element inserted into the input data without a root node (e.g. CSV), the default is data.
|
1358
|
+
#
|
1359
|
+
# * +options+ - Comma separated list of options.
|
1360
|
+
# * *Returns* - The converter object.
|
1361
|
+
def setDataOptions(options)
|
1362
|
+
@fields['data_options'] = options
|
1363
|
+
self
|
1364
|
+
end
|
1365
|
+
|
1228
1366
|
# Apply the first page of the watermark PDF to every page of the output PDF.
|
1229
1367
|
#
|
1230
|
-
# * +
|
1368
|
+
# * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
|
1369
|
+
# * *Returns* - The converter object.
|
1370
|
+
def setPageWatermark(watermark)
|
1371
|
+
if (!(File.file?(watermark) && !File.zero?(watermark)))
|
1372
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(watermark, "setPageWatermark", "html-to-pdf", "The file must exist and not be empty.", "set_page_watermark"), 470);
|
1373
|
+
end
|
1374
|
+
|
1375
|
+
@files['page_watermark'] = watermark
|
1376
|
+
self
|
1377
|
+
end
|
1378
|
+
|
1379
|
+
# Load a watermark PDF from the specified URL and apply the first page of the watermark PDF to every page of the output PDF.
|
1380
|
+
#
|
1381
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1231
1382
|
# * *Returns* - The converter object.
|
1232
|
-
def
|
1233
|
-
|
1234
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1383
|
+
def setPageWatermarkUrl(url)
|
1384
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1385
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageWatermarkUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_page_watermark_url"), 470);
|
1235
1386
|
end
|
1236
1387
|
|
1237
|
-
@
|
1388
|
+
@fields['page_watermark_url'] = url
|
1238
1389
|
self
|
1239
1390
|
end
|
1240
1391
|
|
1241
1392
|
# Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
|
1242
1393
|
#
|
1243
|
-
# * +
|
1394
|
+
# * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
|
1395
|
+
# * *Returns* - The converter object.
|
1396
|
+
def setMultipageWatermark(watermark)
|
1397
|
+
if (!(File.file?(watermark) && !File.zero?(watermark)))
|
1398
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(watermark, "setMultipageWatermark", "html-to-pdf", "The file must exist and not be empty.", "set_multipage_watermark"), 470);
|
1399
|
+
end
|
1400
|
+
|
1401
|
+
@files['multipage_watermark'] = watermark
|
1402
|
+
self
|
1403
|
+
end
|
1404
|
+
|
1405
|
+
# Load a watermark PDF from the specified URL and apply each page of the specified watermark PDF to the corresponding page of the output PDF.
|
1406
|
+
#
|
1407
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1244
1408
|
# * *Returns* - The converter object.
|
1245
|
-
def
|
1246
|
-
|
1247
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1409
|
+
def setMultipageWatermarkUrl(url)
|
1410
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1411
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageWatermarkUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_watermark_url"), 470);
|
1248
1412
|
end
|
1249
1413
|
|
1250
|
-
@
|
1414
|
+
@fields['multipage_watermark_url'] = url
|
1251
1415
|
self
|
1252
1416
|
end
|
1253
1417
|
|
1254
1418
|
# Apply the first page of the specified PDF to the background of every page of the output PDF.
|
1255
1419
|
#
|
1256
|
-
# * +
|
1420
|
+
# * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
|
1421
|
+
# * *Returns* - The converter object.
|
1422
|
+
def setPageBackground(background)
|
1423
|
+
if (!(File.file?(background) && !File.zero?(background)))
|
1424
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(background, "setPageBackground", "html-to-pdf", "The file must exist and not be empty.", "set_page_background"), 470);
|
1425
|
+
end
|
1426
|
+
|
1427
|
+
@files['page_background'] = background
|
1428
|
+
self
|
1429
|
+
end
|
1430
|
+
|
1431
|
+
# Load a background PDF from the specified URL and apply the first page of the background PDF to every page of the output PDF.
|
1432
|
+
#
|
1433
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1257
1434
|
# * *Returns* - The converter object.
|
1258
|
-
def
|
1259
|
-
|
1260
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1435
|
+
def setPageBackgroundUrl(url)
|
1436
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1437
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageBackgroundUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_page_background_url"), 470);
|
1261
1438
|
end
|
1262
1439
|
|
1263
|
-
@
|
1440
|
+
@fields['page_background_url'] = url
|
1264
1441
|
self
|
1265
1442
|
end
|
1266
1443
|
|
1267
1444
|
# Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
|
1268
1445
|
#
|
1269
|
-
# * +
|
1446
|
+
# * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
|
1270
1447
|
# * *Returns* - The converter object.
|
1271
|
-
def setMultipageBackground(
|
1272
|
-
if (!(File.file?(
|
1273
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1448
|
+
def setMultipageBackground(background)
|
1449
|
+
if (!(File.file?(background) && !File.zero?(background)))
|
1450
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(background, "setMultipageBackground", "html-to-pdf", "The file must exist and not be empty.", "set_multipage_background"), 470);
|
1274
1451
|
end
|
1275
1452
|
|
1276
|
-
@files['multipage_background'] =
|
1453
|
+
@files['multipage_background'] = background
|
1454
|
+
self
|
1455
|
+
end
|
1456
|
+
|
1457
|
+
# Load a background PDF from the specified URL and apply each page of the specified background PDF to the corresponding page of the output PDF.
|
1458
|
+
#
|
1459
|
+
# * +url+ - The supported protocols are http:// and https://.
|
1460
|
+
# * *Returns* - The converter object.
|
1461
|
+
def setMultipageBackgroundUrl(url)
|
1462
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
1463
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageBackgroundUrl", "html-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_background_url"), 470);
|
1464
|
+
end
|
1465
|
+
|
1466
|
+
@fields['multipage_background_url'] = url
|
1277
1467
|
self
|
1278
1468
|
end
|
1279
1469
|
|
1280
1470
|
# The page background color in RGB or RGBA hexadecimal format. The color fills the entire page regardless of the margins.
|
1281
1471
|
#
|
1282
|
-
# * +
|
1472
|
+
# * +color+ - The value must be in RRGGBB or RRGGBBAA hexadecimal format.
|
1283
1473
|
# * *Returns* - The converter object.
|
1284
|
-
def setPageBackgroundColor(
|
1285
|
-
unless /^[0-9a-fA-F]{6,8}$/.match(
|
1286
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1474
|
+
def setPageBackgroundColor(color)
|
1475
|
+
unless /^[0-9a-fA-F]{6,8}$/.match(color)
|
1476
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(color, "setPageBackgroundColor", "html-to-pdf", "The value must be in RRGGBB or RRGGBBAA hexadecimal format.", "set_page_background_color"), 470);
|
1287
1477
|
end
|
1288
1478
|
|
1289
|
-
@fields['page_background_color'] =
|
1479
|
+
@fields['page_background_color'] = color
|
1480
|
+
self
|
1481
|
+
end
|
1482
|
+
|
1483
|
+
# Use the print version of the page if available (@media print).
|
1484
|
+
#
|
1485
|
+
# * +value+ - Set to true to use the print version of the page.
|
1486
|
+
# * *Returns* - The converter object.
|
1487
|
+
def setUsePrintMedia(value)
|
1488
|
+
@fields['use_print_media'] = value
|
1290
1489
|
self
|
1291
1490
|
end
|
1292
1491
|
|
1293
1492
|
# Do not print the background graphics.
|
1294
1493
|
#
|
1295
|
-
# * +
|
1494
|
+
# * +value+ - Set to true to disable the background graphics.
|
1296
1495
|
# * *Returns* - The converter object.
|
1297
|
-
def setNoBackground(
|
1298
|
-
@fields['no_background'] =
|
1496
|
+
def setNoBackground(value)
|
1497
|
+
@fields['no_background'] = value
|
1299
1498
|
self
|
1300
1499
|
end
|
1301
1500
|
|
1302
1501
|
# Do not execute JavaScript.
|
1303
1502
|
#
|
1304
|
-
# * +
|
1503
|
+
# * +value+ - Set to true to disable JavaScript in web pages.
|
1305
1504
|
# * *Returns* - The converter object.
|
1306
|
-
def setDisableJavascript(
|
1307
|
-
@fields['disable_javascript'] =
|
1505
|
+
def setDisableJavascript(value)
|
1506
|
+
@fields['disable_javascript'] = value
|
1308
1507
|
self
|
1309
1508
|
end
|
1310
1509
|
|
1311
1510
|
# Do not load images.
|
1312
1511
|
#
|
1313
|
-
# * +
|
1512
|
+
# * +value+ - Set to true to disable loading of images.
|
1314
1513
|
# * *Returns* - The converter object.
|
1315
|
-
def setDisableImageLoading(
|
1316
|
-
@fields['disable_image_loading'] =
|
1514
|
+
def setDisableImageLoading(value)
|
1515
|
+
@fields['disable_image_loading'] = value
|
1317
1516
|
self
|
1318
1517
|
end
|
1319
1518
|
|
1320
1519
|
# Disable loading fonts from remote sources.
|
1321
1520
|
#
|
1322
|
-
# * +
|
1521
|
+
# * +value+ - Set to true disable loading remote fonts.
|
1323
1522
|
# * *Returns* - The converter object.
|
1324
|
-
def setDisableRemoteFonts(
|
1325
|
-
@fields['disable_remote_fonts'] =
|
1523
|
+
def setDisableRemoteFonts(value)
|
1524
|
+
@fields['disable_remote_fonts'] = value
|
1525
|
+
self
|
1526
|
+
end
|
1527
|
+
|
1528
|
+
# Specifies how iframes are handled.
|
1529
|
+
#
|
1530
|
+
# * +iframes+ - Allowed values are all, same-origin, none.
|
1531
|
+
# * *Returns* - The converter object.
|
1532
|
+
def setLoadIframes(iframes)
|
1533
|
+
unless /(?i)^(all|same-origin|none)$/.match(iframes)
|
1534
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(iframes, "setLoadIframes", "html-to-pdf", "Allowed values are all, same-origin, none.", "set_load_iframes"), 470);
|
1535
|
+
end
|
1536
|
+
|
1537
|
+
@fields['load_iframes'] = iframes
|
1326
1538
|
self
|
1327
1539
|
end
|
1328
1540
|
|
1329
1541
|
# Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
|
1330
1542
|
#
|
1331
|
-
# * +
|
1543
|
+
# * +value+ - Set to true to block ads in web pages.
|
1332
1544
|
# * *Returns* - The converter object.
|
1333
|
-
def setBlockAds(
|
1334
|
-
@fields['block_ads'] =
|
1545
|
+
def setBlockAds(value)
|
1546
|
+
@fields['block_ads'] = value
|
1335
1547
|
self
|
1336
1548
|
end
|
1337
1549
|
|
1338
1550
|
# Set the default HTML content text encoding.
|
1339
1551
|
#
|
1340
|
-
# * +
|
1552
|
+
# * +encoding+ - The text encoding of the HTML content.
|
1553
|
+
# * *Returns* - The converter object.
|
1554
|
+
def setDefaultEncoding(encoding)
|
1555
|
+
@fields['default_encoding'] = encoding
|
1556
|
+
self
|
1557
|
+
end
|
1558
|
+
|
1559
|
+
# Set the locale for the conversion. This may affect the output format of dates, times and numbers.
|
1560
|
+
#
|
1561
|
+
# * +locale+ - The locale code according to ISO 639.
|
1341
1562
|
# * *Returns* - The converter object.
|
1342
|
-
def
|
1343
|
-
@fields['
|
1563
|
+
def setLocale(locale)
|
1564
|
+
@fields['locale'] = locale
|
1344
1565
|
self
|
1345
1566
|
end
|
1346
1567
|
|
@@ -1373,24 +1594,6 @@ module Pdfcrowd
|
|
1373
1594
|
self
|
1374
1595
|
end
|
1375
1596
|
|
1376
|
-
# Use the print version of the page if available (@media print).
|
1377
|
-
#
|
1378
|
-
# * +use_print_media+ - Set to true to use the print version of the page.
|
1379
|
-
# * *Returns* - The converter object.
|
1380
|
-
def setUsePrintMedia(use_print_media)
|
1381
|
-
@fields['use_print_media'] = use_print_media
|
1382
|
-
self
|
1383
|
-
end
|
1384
|
-
|
1385
|
-
# Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
|
1386
|
-
#
|
1387
|
-
# * +no_xpdfcrowd_header+ - Set to true to disable sending X-Pdfcrowd HTTP header.
|
1388
|
-
# * *Returns* - The converter object.
|
1389
|
-
def setNoXpdfcrowdHeader(no_xpdfcrowd_header)
|
1390
|
-
@fields['no_xpdfcrowd_header'] = no_xpdfcrowd_header
|
1391
|
-
self
|
1392
|
-
end
|
1393
|
-
|
1394
1597
|
# Set cookies that are sent in Pdfcrowd HTTP requests.
|
1395
1598
|
#
|
1396
1599
|
# * +cookies+ - The cookie string.
|
@@ -1402,10 +1605,10 @@ module Pdfcrowd
|
|
1402
1605
|
|
1403
1606
|
# Do not allow insecure HTTPS connections.
|
1404
1607
|
#
|
1405
|
-
# * +
|
1608
|
+
# * +value+ - Set to true to enable SSL certificate verification.
|
1406
1609
|
# * *Returns* - The converter object.
|
1407
|
-
def setVerifySslCertificates(
|
1408
|
-
@fields['verify_ssl_certificates'] =
|
1610
|
+
def setVerifySslCertificates(value)
|
1611
|
+
@fields['verify_ssl_certificates'] = value
|
1409
1612
|
self
|
1410
1613
|
end
|
1411
1614
|
|
@@ -1427,55 +1630,64 @@ module Pdfcrowd
|
|
1427
1630
|
self
|
1428
1631
|
end
|
1429
1632
|
|
1633
|
+
# Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
|
1634
|
+
#
|
1635
|
+
# * +value+ - Set to true to disable sending X-Pdfcrowd HTTP header.
|
1636
|
+
# * *Returns* - The converter object.
|
1637
|
+
def setNoXpdfcrowdHeader(value)
|
1638
|
+
@fields['no_xpdfcrowd_header'] = value
|
1639
|
+
self
|
1640
|
+
end
|
1641
|
+
|
1430
1642
|
# Run a custom JavaScript after the document is loaded and ready to print. The script is intended for post-load DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
|
1431
1643
|
#
|
1432
|
-
# * +
|
1644
|
+
# * +javascript+ - A string containing a JavaScript code. The string must not be empty.
|
1433
1645
|
# * *Returns* - The converter object.
|
1434
|
-
def setCustomJavascript(
|
1435
|
-
if (!(!
|
1436
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1646
|
+
def setCustomJavascript(javascript)
|
1647
|
+
if (!(!javascript.nil? && !javascript.empty?))
|
1648
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setCustomJavascript", "html-to-pdf", "The string must not be empty.", "set_custom_javascript"), 470);
|
1437
1649
|
end
|
1438
1650
|
|
1439
|
-
@fields['custom_javascript'] =
|
1651
|
+
@fields['custom_javascript'] = javascript
|
1440
1652
|
self
|
1441
1653
|
end
|
1442
1654
|
|
1443
1655
|
# Run a custom JavaScript right after the document is loaded. The script is intended for early DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
|
1444
1656
|
#
|
1445
|
-
# * +
|
1657
|
+
# * +javascript+ - A string containing a JavaScript code. The string must not be empty.
|
1446
1658
|
# * *Returns* - The converter object.
|
1447
|
-
def setOnLoadJavascript(
|
1448
|
-
if (!(!
|
1449
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1659
|
+
def setOnLoadJavascript(javascript)
|
1660
|
+
if (!(!javascript.nil? && !javascript.empty?))
|
1661
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setOnLoadJavascript", "html-to-pdf", "The string must not be empty.", "set_on_load_javascript"), 470);
|
1450
1662
|
end
|
1451
1663
|
|
1452
|
-
@fields['on_load_javascript'] =
|
1664
|
+
@fields['on_load_javascript'] = javascript
|
1453
1665
|
self
|
1454
1666
|
end
|
1455
1667
|
|
1456
1668
|
# Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
|
1457
1669
|
#
|
1458
|
-
# * +
|
1670
|
+
# * +header+ - A string containing the header name and value separated by a colon.
|
1459
1671
|
# * *Returns* - The converter object.
|
1460
|
-
def setCustomHttpHeader(
|
1461
|
-
unless /^.+:.+$/.match(
|
1462
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1672
|
+
def setCustomHttpHeader(header)
|
1673
|
+
unless /^.+:.+$/.match(header)
|
1674
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(header, "setCustomHttpHeader", "html-to-pdf", "A string containing the header name and value separated by a colon.", "set_custom_http_header"), 470);
|
1463
1675
|
end
|
1464
1676
|
|
1465
|
-
@fields['custom_http_header'] =
|
1677
|
+
@fields['custom_http_header'] = header
|
1466
1678
|
self
|
1467
1679
|
end
|
1468
1680
|
|
1469
|
-
# Wait the specified number of milliseconds to finish all JavaScript after the document is loaded.
|
1681
|
+
# Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. Your API license defines the maximum wait time by "Max Delay" parameter.
|
1470
1682
|
#
|
1471
|
-
# * +
|
1683
|
+
# * +delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
|
1472
1684
|
# * *Returns* - The converter object.
|
1473
|
-
def setJavascriptDelay(
|
1474
|
-
if (!(Integer(
|
1475
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1685
|
+
def setJavascriptDelay(delay)
|
1686
|
+
if (!(Integer(delay) >= 0))
|
1687
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(delay, "setJavascriptDelay", "html-to-pdf", "Must be a positive integer number or 0.", "set_javascript_delay"), 470);
|
1476
1688
|
end
|
1477
1689
|
|
1478
|
-
@fields['javascript_delay'] =
|
1690
|
+
@fields['javascript_delay'] = delay
|
1479
1691
|
self
|
1480
1692
|
end
|
1481
1693
|
|
@@ -1485,7 +1697,7 @@ module Pdfcrowd
|
|
1485
1697
|
# * *Returns* - The converter object.
|
1486
1698
|
def setElementToConvert(selectors)
|
1487
1699
|
if (!(!selectors.nil? && !selectors.empty?))
|
1488
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "
|
1700
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setElementToConvert", "html-to-pdf", "The string must not be empty.", "set_element_to_convert"), 470);
|
1489
1701
|
end
|
1490
1702
|
|
1491
1703
|
@fields['element_to_convert'] = selectors
|
@@ -1498,7 +1710,7 @@ module Pdfcrowd
|
|
1498
1710
|
# * *Returns* - The converter object.
|
1499
1711
|
def setElementToConvertMode(mode)
|
1500
1712
|
unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode)
|
1501
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "
|
1713
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setElementToConvertMode", "html-to-pdf", "Allowed values are cut-out, remove-siblings, hide-siblings.", "set_element_to_convert_mode"), 470);
|
1502
1714
|
end
|
1503
1715
|
|
1504
1716
|
@fields['element_to_convert_mode'] = mode
|
@@ -1511,7 +1723,7 @@ module Pdfcrowd
|
|
1511
1723
|
# * *Returns* - The converter object.
|
1512
1724
|
def setWaitForElement(selectors)
|
1513
1725
|
if (!(!selectors.nil? && !selectors.empty?))
|
1514
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "
|
1726
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setWaitForElement", "html-to-pdf", "The string must not be empty.", "set_wait_for_element"), 470);
|
1515
1727
|
end
|
1516
1728
|
|
1517
1729
|
@fields['wait_for_element'] = selectors
|
@@ -1520,33 +1732,33 @@ module Pdfcrowd
|
|
1520
1732
|
|
1521
1733
|
# Set the viewport width in pixels. The viewport is the user's visible area of the page.
|
1522
1734
|
#
|
1523
|
-
# * +
|
1735
|
+
# * +width+ - The value must be in the range 96-65000.
|
1524
1736
|
# * *Returns* - The converter object.
|
1525
|
-
def setViewportWidth(
|
1526
|
-
if (!(Integer(
|
1527
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1737
|
+
def setViewportWidth(width)
|
1738
|
+
if (!(Integer(width) >= 96 && Integer(width) <= 65000))
|
1739
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setViewportWidth", "html-to-pdf", "The value must be in the range 96-65000.", "set_viewport_width"), 470);
|
1528
1740
|
end
|
1529
1741
|
|
1530
|
-
@fields['viewport_width'] =
|
1742
|
+
@fields['viewport_width'] = width
|
1531
1743
|
self
|
1532
1744
|
end
|
1533
1745
|
|
1534
1746
|
# Set the viewport height in pixels. The viewport is the user's visible area of the page.
|
1535
1747
|
#
|
1536
|
-
# * +
|
1748
|
+
# * +height+ - Must be a positive integer number.
|
1537
1749
|
# * *Returns* - The converter object.
|
1538
|
-
def setViewportHeight(
|
1539
|
-
if (!(Integer(
|
1540
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1750
|
+
def setViewportHeight(height)
|
1751
|
+
if (!(Integer(height) > 0))
|
1752
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setViewportHeight", "html-to-pdf", "Must be a positive integer number.", "set_viewport_height"), 470);
|
1541
1753
|
end
|
1542
1754
|
|
1543
|
-
@fields['viewport_height'] =
|
1755
|
+
@fields['viewport_height'] = height
|
1544
1756
|
self
|
1545
1757
|
end
|
1546
1758
|
|
1547
1759
|
# Set the viewport size. The viewport is the user's visible area of the page.
|
1548
1760
|
#
|
1549
|
-
# * +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-
|
1761
|
+
# * +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.
|
1550
1762
|
# * +height+ - Set the viewport height in pixels. The viewport is the user's visible area of the page. Must be a positive integer number.
|
1551
1763
|
# * *Returns* - The converter object.
|
1552
1764
|
def setViewport(width, height)
|
@@ -1557,164 +1769,155 @@ module Pdfcrowd
|
|
1557
1769
|
|
1558
1770
|
# Set the rendering mode.
|
1559
1771
|
#
|
1560
|
-
# * +
|
1772
|
+
# * +mode+ - The rendering mode. Allowed values are default, viewport.
|
1561
1773
|
# * *Returns* - The converter object.
|
1562
|
-
def setRenderingMode(
|
1563
|
-
unless /(?i)^(default|viewport)$/.match(
|
1564
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1774
|
+
def setRenderingMode(mode)
|
1775
|
+
unless /(?i)^(default|viewport)$/.match(mode)
|
1776
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setRenderingMode", "html-to-pdf", "Allowed values are default, viewport.", "set_rendering_mode"), 470);
|
1565
1777
|
end
|
1566
1778
|
|
1567
|
-
@fields['rendering_mode'] =
|
1779
|
+
@fields['rendering_mode'] = mode
|
1568
1780
|
self
|
1569
1781
|
end
|
1570
1782
|
|
1571
1783
|
# Specifies the scaling mode used for fitting the HTML contents to the print area.
|
1572
1784
|
#
|
1573
|
-
# * +
|
1785
|
+
# * +mode+ - The smart scaling mode. Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, mode1.
|
1574
1786
|
# * *Returns* - The converter object.
|
1575
|
-
def setSmartScalingMode(
|
1576
|
-
unless /(?i)^(default|disabled|viewport-fit|content-fit|single-page-fit)$/.match(
|
1577
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1787
|
+
def setSmartScalingMode(mode)
|
1788
|
+
unless /(?i)^(default|disabled|viewport-fit|content-fit|single-page-fit|mode1)$/.match(mode)
|
1789
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setSmartScalingMode", "html-to-pdf", "Allowed values are default, disabled, viewport-fit, content-fit, single-page-fit, mode1.", "set_smart_scaling_mode"), 470);
|
1578
1790
|
end
|
1579
1791
|
|
1580
|
-
@fields['smart_scaling_mode'] =
|
1792
|
+
@fields['smart_scaling_mode'] = mode
|
1581
1793
|
self
|
1582
1794
|
end
|
1583
1795
|
|
1584
1796
|
# Set the scaling factor (zoom) for the main page area.
|
1585
1797
|
#
|
1586
|
-
# * +
|
1798
|
+
# * +factor+ - The percentage value. The value must be in the range 10-500.
|
1587
1799
|
# * *Returns* - The converter object.
|
1588
|
-
def setScaleFactor(
|
1589
|
-
if (!(Integer(
|
1590
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1800
|
+
def setScaleFactor(factor)
|
1801
|
+
if (!(Integer(factor) >= 10 && Integer(factor) <= 500))
|
1802
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "html-to-pdf", "The value must be in the range 10-500.", "set_scale_factor"), 470);
|
1591
1803
|
end
|
1592
1804
|
|
1593
|
-
@fields['scale_factor'] =
|
1805
|
+
@fields['scale_factor'] = factor
|
1594
1806
|
self
|
1595
1807
|
end
|
1596
1808
|
|
1597
1809
|
# Set the scaling factor (zoom) for the header and footer.
|
1598
1810
|
#
|
1599
|
-
# * +
|
1811
|
+
# * +factor+ - The percentage value. The value must be in the range 10-500.
|
1600
1812
|
# * *Returns* - The converter object.
|
1601
|
-
def setHeaderFooterScaleFactor(
|
1602
|
-
if (!(Integer(
|
1603
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1813
|
+
def setHeaderFooterScaleFactor(factor)
|
1814
|
+
if (!(Integer(factor) >= 10 && Integer(factor) <= 500))
|
1815
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setHeaderFooterScaleFactor", "html-to-pdf", "The value must be in the range 10-500.", "set_header_footer_scale_factor"), 470);
|
1604
1816
|
end
|
1605
1817
|
|
1606
|
-
@fields['header_footer_scale_factor'] =
|
1607
|
-
self
|
1608
|
-
end
|
1609
|
-
|
1610
|
-
# Disable the intelligent shrinking strategy that tries to optimally fit the HTML contents to a PDF page.
|
1611
|
-
#
|
1612
|
-
# * +disable_smart_shrinking+ - Set to true to disable the intelligent shrinking strategy.
|
1613
|
-
# * *Returns* - The converter object.
|
1614
|
-
def setDisableSmartShrinking(disable_smart_shrinking)
|
1615
|
-
@fields['disable_smart_shrinking'] = disable_smart_shrinking
|
1818
|
+
@fields['header_footer_scale_factor'] = factor
|
1616
1819
|
self
|
1617
1820
|
end
|
1618
1821
|
|
1619
1822
|
# Set the quality of embedded JPEG images. A lower quality results in a smaller PDF file but can lead to compression artifacts.
|
1620
1823
|
#
|
1621
|
-
# * +
|
1824
|
+
# * +quality+ - The percentage value. The value must be in the range 1-100.
|
1622
1825
|
# * *Returns* - The converter object.
|
1623
|
-
def setJpegQuality(
|
1624
|
-
if (!(Integer(
|
1625
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1826
|
+
def setJpegQuality(quality)
|
1827
|
+
if (!(Integer(quality) >= 1 && Integer(quality) <= 100))
|
1828
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(quality, "setJpegQuality", "html-to-pdf", "The value must be in the range 1-100.", "set_jpeg_quality"), 470);
|
1626
1829
|
end
|
1627
1830
|
|
1628
|
-
@fields['jpeg_quality'] =
|
1831
|
+
@fields['jpeg_quality'] = quality
|
1629
1832
|
self
|
1630
1833
|
end
|
1631
1834
|
|
1632
1835
|
# Specify which image types will be converted to JPEG. Converting lossless compression image formats (PNG, GIF, ...) to JPEG may result in a smaller PDF file.
|
1633
1836
|
#
|
1634
|
-
# * +
|
1837
|
+
# * +images+ - The image category. Allowed values are none, opaque, all.
|
1635
1838
|
# * *Returns* - The converter object.
|
1636
|
-
def setConvertImagesToJpeg(
|
1637
|
-
unless /(?i)^(none|opaque|all)$/.match(
|
1638
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1839
|
+
def setConvertImagesToJpeg(images)
|
1840
|
+
unless /(?i)^(none|opaque|all)$/.match(images)
|
1841
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(images, "setConvertImagesToJpeg", "html-to-pdf", "Allowed values are none, opaque, all.", "set_convert_images_to_jpeg"), 470);
|
1639
1842
|
end
|
1640
1843
|
|
1641
|
-
@fields['convert_images_to_jpeg'] =
|
1844
|
+
@fields['convert_images_to_jpeg'] = images
|
1642
1845
|
self
|
1643
1846
|
end
|
1644
1847
|
|
1645
1848
|
# Set the DPI of images in PDF. A lower DPI may result in a smaller PDF file. If the specified DPI is higher than the actual image DPI, the original image DPI is retained (no upscaling is performed). Use 0 to leave the images unaltered.
|
1646
1849
|
#
|
1647
|
-
# * +
|
1850
|
+
# * +dpi+ - The DPI value. Must be a positive integer number or 0.
|
1648
1851
|
# * *Returns* - The converter object.
|
1649
|
-
def setImageDpi(
|
1650
|
-
if (!(Integer(
|
1651
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1852
|
+
def setImageDpi(dpi)
|
1853
|
+
if (!(Integer(dpi) >= 0))
|
1854
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(dpi, "setImageDpi", "html-to-pdf", "Must be a positive integer number or 0.", "set_image_dpi"), 470);
|
1652
1855
|
end
|
1653
1856
|
|
1654
|
-
@fields['image_dpi'] =
|
1857
|
+
@fields['image_dpi'] = dpi
|
1655
1858
|
self
|
1656
1859
|
end
|
1657
1860
|
|
1658
1861
|
# Create linearized PDF. This is also known as Fast Web View.
|
1659
1862
|
#
|
1660
|
-
# * +
|
1863
|
+
# * +value+ - Set to true to create linearized PDF.
|
1661
1864
|
# * *Returns* - The converter object.
|
1662
|
-
def setLinearize(
|
1663
|
-
@fields['linearize'] =
|
1865
|
+
def setLinearize(value)
|
1866
|
+
@fields['linearize'] = value
|
1664
1867
|
self
|
1665
1868
|
end
|
1666
1869
|
|
1667
1870
|
# Encrypt the PDF. This prevents search engines from indexing the contents.
|
1668
1871
|
#
|
1669
|
-
# * +
|
1872
|
+
# * +value+ - Set to true to enable PDF encryption.
|
1670
1873
|
# * *Returns* - The converter object.
|
1671
|
-
def setEncrypt(
|
1672
|
-
@fields['encrypt'] =
|
1874
|
+
def setEncrypt(value)
|
1875
|
+
@fields['encrypt'] = value
|
1673
1876
|
self
|
1674
1877
|
end
|
1675
1878
|
|
1676
1879
|
# Protect the PDF with a user password. When a PDF has a user password, it must be supplied in order to view the document and to perform operations allowed by the access permissions.
|
1677
1880
|
#
|
1678
|
-
# * +
|
1881
|
+
# * +password+ - The user password.
|
1679
1882
|
# * *Returns* - The converter object.
|
1680
|
-
def setUserPassword(
|
1681
|
-
@fields['user_password'] =
|
1883
|
+
def setUserPassword(password)
|
1884
|
+
@fields['user_password'] = password
|
1682
1885
|
self
|
1683
1886
|
end
|
1684
1887
|
|
1685
1888
|
# Protect the PDF with an owner password. Supplying an owner password grants unlimited access to the PDF including changing the passwords and access permissions.
|
1686
1889
|
#
|
1687
|
-
# * +
|
1890
|
+
# * +password+ - The owner password.
|
1688
1891
|
# * *Returns* - The converter object.
|
1689
|
-
def setOwnerPassword(
|
1690
|
-
@fields['owner_password'] =
|
1892
|
+
def setOwnerPassword(password)
|
1893
|
+
@fields['owner_password'] = password
|
1691
1894
|
self
|
1692
1895
|
end
|
1693
1896
|
|
1694
1897
|
# Disallow printing of the output PDF.
|
1695
1898
|
#
|
1696
|
-
# * +
|
1899
|
+
# * +value+ - Set to true to set the no-print flag in the output PDF.
|
1697
1900
|
# * *Returns* - The converter object.
|
1698
|
-
def setNoPrint(
|
1699
|
-
@fields['no_print'] =
|
1901
|
+
def setNoPrint(value)
|
1902
|
+
@fields['no_print'] = value
|
1700
1903
|
self
|
1701
1904
|
end
|
1702
1905
|
|
1703
|
-
# Disallow modification of the
|
1906
|
+
# Disallow modification of the output PDF.
|
1704
1907
|
#
|
1705
|
-
# * +
|
1908
|
+
# * +value+ - Set to true to set the read-only only flag in the output PDF.
|
1706
1909
|
# * *Returns* - The converter object.
|
1707
|
-
def setNoModify(
|
1708
|
-
@fields['no_modify'] =
|
1910
|
+
def setNoModify(value)
|
1911
|
+
@fields['no_modify'] = value
|
1709
1912
|
self
|
1710
1913
|
end
|
1711
1914
|
|
1712
1915
|
# Disallow text and graphics extraction from the output PDF.
|
1713
1916
|
#
|
1714
|
-
# * +
|
1917
|
+
# * +value+ - Set to true to set the no-copy flag in the output PDF.
|
1715
1918
|
# * *Returns* - The converter object.
|
1716
|
-
def setNoCopy(
|
1717
|
-
@fields['no_copy'] =
|
1919
|
+
def setNoCopy(value)
|
1920
|
+
@fields['no_copy'] = value
|
1718
1921
|
self
|
1719
1922
|
end
|
1720
1923
|
|
@@ -1756,138 +1959,138 @@ module Pdfcrowd
|
|
1756
1959
|
|
1757
1960
|
# Specify the page layout to be used when the document is opened.
|
1758
1961
|
#
|
1759
|
-
# * +
|
1962
|
+
# * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
|
1760
1963
|
# * *Returns* - The converter object.
|
1761
|
-
def setPageLayout(
|
1762
|
-
unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(
|
1763
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1964
|
+
def setPageLayout(layout)
|
1965
|
+
unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout)
|
1966
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(layout, "setPageLayout", "html-to-pdf", "Allowed values are single-page, one-column, two-column-left, two-column-right.", "set_page_layout"), 470);
|
1764
1967
|
end
|
1765
1968
|
|
1766
|
-
@fields['page_layout'] =
|
1969
|
+
@fields['page_layout'] = layout
|
1767
1970
|
self
|
1768
1971
|
end
|
1769
1972
|
|
1770
1973
|
# Specify how the document should be displayed when opened.
|
1771
1974
|
#
|
1772
|
-
# * +
|
1975
|
+
# * +mode+ - Allowed values are full-screen, thumbnails, outlines.
|
1773
1976
|
# * *Returns* - The converter object.
|
1774
|
-
def setPageMode(
|
1775
|
-
unless /(?i)^(full-screen|thumbnails|outlines)$/.match(
|
1776
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1977
|
+
def setPageMode(mode)
|
1978
|
+
unless /(?i)^(full-screen|thumbnails|outlines)$/.match(mode)
|
1979
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setPageMode", "html-to-pdf", "Allowed values are full-screen, thumbnails, outlines.", "set_page_mode"), 470);
|
1777
1980
|
end
|
1778
1981
|
|
1779
|
-
@fields['page_mode'] =
|
1982
|
+
@fields['page_mode'] = mode
|
1780
1983
|
self
|
1781
1984
|
end
|
1782
1985
|
|
1783
1986
|
# Specify how the page should be displayed when opened.
|
1784
1987
|
#
|
1785
|
-
# * +
|
1988
|
+
# * +zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
|
1786
1989
|
# * *Returns* - The converter object.
|
1787
|
-
def setInitialZoomType(
|
1788
|
-
unless /(?i)^(fit-width|fit-height|fit-page)$/.match(
|
1789
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
1990
|
+
def setInitialZoomType(zoom_type)
|
1991
|
+
unless /(?i)^(fit-width|fit-height|fit-page)$/.match(zoom_type)
|
1992
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom_type, "setInitialZoomType", "html-to-pdf", "Allowed values are fit-width, fit-height, fit-page.", "set_initial_zoom_type"), 470);
|
1790
1993
|
end
|
1791
1994
|
|
1792
|
-
@fields['initial_zoom_type'] =
|
1995
|
+
@fields['initial_zoom_type'] = zoom_type
|
1793
1996
|
self
|
1794
1997
|
end
|
1795
1998
|
|
1796
1999
|
# Display the specified page when the document is opened.
|
1797
2000
|
#
|
1798
|
-
# * +
|
2001
|
+
# * +page+ - Must be a positive integer number.
|
1799
2002
|
# * *Returns* - The converter object.
|
1800
|
-
def setInitialPage(
|
1801
|
-
if (!(Integer(
|
1802
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2003
|
+
def setInitialPage(page)
|
2004
|
+
if (!(Integer(page) > 0))
|
2005
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "html-to-pdf", "Must be a positive integer number.", "set_initial_page"), 470);
|
1803
2006
|
end
|
1804
2007
|
|
1805
|
-
@fields['initial_page'] =
|
2008
|
+
@fields['initial_page'] = page
|
1806
2009
|
self
|
1807
2010
|
end
|
1808
2011
|
|
1809
2012
|
# Specify the initial page zoom in percents when the document is opened.
|
1810
2013
|
#
|
1811
|
-
# * +
|
2014
|
+
# * +zoom+ - Must be a positive integer number.
|
1812
2015
|
# * *Returns* - The converter object.
|
1813
|
-
def setInitialZoom(
|
1814
|
-
if (!(Integer(
|
1815
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2016
|
+
def setInitialZoom(zoom)
|
2017
|
+
if (!(Integer(zoom) > 0))
|
2018
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "html-to-pdf", "Must be a positive integer number.", "set_initial_zoom"), 470);
|
1816
2019
|
end
|
1817
2020
|
|
1818
|
-
@fields['initial_zoom'] =
|
2021
|
+
@fields['initial_zoom'] = zoom
|
1819
2022
|
self
|
1820
2023
|
end
|
1821
2024
|
|
1822
2025
|
# Specify whether to hide the viewer application's tool bars when the document is active.
|
1823
2026
|
#
|
1824
|
-
# * +
|
2027
|
+
# * +value+ - Set to true to hide tool bars.
|
1825
2028
|
# * *Returns* - The converter object.
|
1826
|
-
def setHideToolbar(
|
1827
|
-
@fields['hide_toolbar'] =
|
2029
|
+
def setHideToolbar(value)
|
2030
|
+
@fields['hide_toolbar'] = value
|
1828
2031
|
self
|
1829
2032
|
end
|
1830
2033
|
|
1831
2034
|
# Specify whether to hide the viewer application's menu bar when the document is active.
|
1832
2035
|
#
|
1833
|
-
# * +
|
2036
|
+
# * +value+ - Set to true to hide the menu bar.
|
1834
2037
|
# * *Returns* - The converter object.
|
1835
|
-
def setHideMenubar(
|
1836
|
-
@fields['hide_menubar'] =
|
2038
|
+
def setHideMenubar(value)
|
2039
|
+
@fields['hide_menubar'] = value
|
1837
2040
|
self
|
1838
2041
|
end
|
1839
2042
|
|
1840
2043
|
# Specify whether to hide user interface elements in the document's window (such as scroll bars and navigation controls), leaving only the document's contents displayed.
|
1841
2044
|
#
|
1842
|
-
# * +
|
2045
|
+
# * +value+ - Set to true to hide ui elements.
|
1843
2046
|
# * *Returns* - The converter object.
|
1844
|
-
def setHideWindowUi(
|
1845
|
-
@fields['hide_window_ui'] =
|
2047
|
+
def setHideWindowUi(value)
|
2048
|
+
@fields['hide_window_ui'] = value
|
1846
2049
|
self
|
1847
2050
|
end
|
1848
2051
|
|
1849
2052
|
# Specify whether to resize the document's window to fit the size of the first displayed page.
|
1850
2053
|
#
|
1851
|
-
# * +
|
2054
|
+
# * +value+ - Set to true to resize the window.
|
1852
2055
|
# * *Returns* - The converter object.
|
1853
|
-
def setFitWindow(
|
1854
|
-
@fields['fit_window'] =
|
2056
|
+
def setFitWindow(value)
|
2057
|
+
@fields['fit_window'] = value
|
1855
2058
|
self
|
1856
2059
|
end
|
1857
2060
|
|
1858
2061
|
# Specify whether to position the document's window in the center of the screen.
|
1859
2062
|
#
|
1860
|
-
# * +
|
2063
|
+
# * +value+ - Set to true to center the window.
|
1861
2064
|
# * *Returns* - The converter object.
|
1862
|
-
def setCenterWindow(
|
1863
|
-
@fields['center_window'] =
|
2065
|
+
def setCenterWindow(value)
|
2066
|
+
@fields['center_window'] = value
|
1864
2067
|
self
|
1865
2068
|
end
|
1866
2069
|
|
1867
2070
|
# Specify whether the window's title bar should display the document title. If false , the title bar should instead display the name of the PDF file containing the document.
|
1868
2071
|
#
|
1869
|
-
# * +
|
2072
|
+
# * +value+ - Set to true to display the title.
|
1870
2073
|
# * *Returns* - The converter object.
|
1871
|
-
def setDisplayTitle(
|
1872
|
-
@fields['display_title'] =
|
2074
|
+
def setDisplayTitle(value)
|
2075
|
+
@fields['display_title'] = value
|
1873
2076
|
self
|
1874
2077
|
end
|
1875
2078
|
|
1876
2079
|
# Set the predominant reading order for text to right-to-left. This option has no direct effect on the document's contents or page numbering but can be used to determine the relative positioning of pages when displayed side by side or printed n-up
|
1877
2080
|
#
|
1878
|
-
# * +
|
2081
|
+
# * +value+ - Set to true to set right-to-left reading order.
|
1879
2082
|
# * *Returns* - The converter object.
|
1880
|
-
def setRightToLeft(
|
1881
|
-
@fields['right_to_left'] =
|
2083
|
+
def setRightToLeft(value)
|
2084
|
+
@fields['right_to_left'] = value
|
1882
2085
|
self
|
1883
2086
|
end
|
1884
2087
|
|
1885
2088
|
# 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.
|
1886
2089
|
#
|
1887
|
-
# * +
|
2090
|
+
# * +value+ - Set to true to enable the debug logging.
|
1888
2091
|
# * *Returns* - The converter object.
|
1889
|
-
def setDebugLog(
|
1890
|
-
@fields['debug_log'] =
|
2092
|
+
def setDebugLog(value)
|
2093
|
+
@fields['debug_log'] = value
|
1891
2094
|
self
|
1892
2095
|
end
|
1893
2096
|
|
@@ -1930,6 +2133,12 @@ module Pdfcrowd
|
|
1930
2133
|
return @helper.getOutputSize()
|
1931
2134
|
end
|
1932
2135
|
|
2136
|
+
# Get the version details.
|
2137
|
+
# * *Returns* - API version, converter version, and client version.
|
2138
|
+
def getVersion()
|
2139
|
+
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
2140
|
+
end
|
2141
|
+
|
1933
2142
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
1934
2143
|
#
|
1935
2144
|
# * +tag+ - A string with the custom tag.
|
@@ -1941,67 +2150,149 @@ module Pdfcrowd
|
|
1941
2150
|
|
1942
2151
|
# 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.
|
1943
2152
|
#
|
1944
|
-
# * +
|
2153
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
1945
2154
|
# * *Returns* - The converter object.
|
1946
|
-
def setHttpProxy(
|
1947
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
1948
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2155
|
+
def setHttpProxy(proxy)
|
2156
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
2157
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "html-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
|
1949
2158
|
end
|
1950
2159
|
|
1951
|
-
@fields['http_proxy'] =
|
2160
|
+
@fields['http_proxy'] = proxy
|
1952
2161
|
self
|
1953
2162
|
end
|
1954
2163
|
|
1955
2164
|
# 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.
|
1956
2165
|
#
|
1957
|
-
# * +
|
2166
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
1958
2167
|
# * *Returns* - The converter object.
|
1959
|
-
def setHttpsProxy(
|
1960
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
1961
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2168
|
+
def setHttpsProxy(proxy)
|
2169
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
2170
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "html-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
|
1962
2171
|
end
|
1963
2172
|
|
1964
|
-
@fields['https_proxy'] =
|
2173
|
+
@fields['https_proxy'] = proxy
|
1965
2174
|
self
|
1966
2175
|
end
|
1967
2176
|
|
1968
2177
|
# A client certificate to authenticate Pdfcrowd converter on your web server. The certificate is used for two-way SSL/TLS authentication and adds extra security.
|
1969
2178
|
#
|
1970
|
-
# * +
|
2179
|
+
# * +certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
|
1971
2180
|
# * *Returns* - The converter object.
|
1972
|
-
def setClientCertificate(
|
1973
|
-
if (!(File.file?(
|
1974
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2181
|
+
def setClientCertificate(certificate)
|
2182
|
+
if (!(File.file?(certificate) && !File.zero?(certificate)))
|
2183
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(certificate, "setClientCertificate", "html-to-pdf", "The file must exist and not be empty.", "set_client_certificate"), 470);
|
1975
2184
|
end
|
1976
2185
|
|
1977
|
-
@files['client_certificate'] =
|
2186
|
+
@files['client_certificate'] = certificate
|
1978
2187
|
self
|
1979
2188
|
end
|
1980
2189
|
|
1981
|
-
# A password for PKCS12 file with a client certificate if it
|
2190
|
+
# A password for PKCS12 file with a client certificate if it is needed.
|
1982
2191
|
#
|
1983
|
-
# * +
|
2192
|
+
# * +password+ -
|
1984
2193
|
# * *Returns* - The converter object.
|
1985
|
-
def setClientCertificatePassword(
|
1986
|
-
@fields['client_certificate_password'] =
|
2194
|
+
def setClientCertificatePassword(password)
|
2195
|
+
@fields['client_certificate_password'] = password
|
2196
|
+
self
|
2197
|
+
end
|
2198
|
+
|
2199
|
+
# Set the internal DPI resolution used for positioning of PDF contents. It can help in situations when there are small inaccuracies in the PDF. It is recommended to use values that are a multiple of 72, such as 288 or 360.
|
2200
|
+
#
|
2201
|
+
# * +dpi+ - The DPI value. The value must be in the range of 72-600.
|
2202
|
+
# * *Returns* - The converter object.
|
2203
|
+
def setLayoutDpi(dpi)
|
2204
|
+
if (!(Integer(dpi) >= 72 && Integer(dpi) <= 600))
|
2205
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(dpi, "setLayoutDpi", "html-to-pdf", "The value must be in the range of 72-600.", "set_layout_dpi"), 470);
|
2206
|
+
end
|
2207
|
+
|
2208
|
+
@fields['layout_dpi'] = dpi
|
2209
|
+
self
|
2210
|
+
end
|
2211
|
+
|
2212
|
+
# A 2D transformation matrix applied to the main contents on each page. The origin [0,0] is located at the top-left corner of the contents. The resolution is 72 dpi.
|
2213
|
+
#
|
2214
|
+
# * +matrix+ - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"
|
2215
|
+
# * *Returns* - The converter object.
|
2216
|
+
def setContentsMatrix(matrix)
|
2217
|
+
@fields['contents_matrix'] = matrix
|
2218
|
+
self
|
2219
|
+
end
|
2220
|
+
|
2221
|
+
# A 2D transformation matrix applied to the page header contents. The origin [0,0] is located at the top-left corner of the header. The resolution is 72 dpi.
|
2222
|
+
#
|
2223
|
+
# * +matrix+ - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"
|
2224
|
+
# * *Returns* - The converter object.
|
2225
|
+
def setHeaderMatrix(matrix)
|
2226
|
+
@fields['header_matrix'] = matrix
|
2227
|
+
self
|
2228
|
+
end
|
2229
|
+
|
2230
|
+
# A 2D transformation matrix applied to the page footer contents. The origin [0,0] is located at the top-left corner of the footer. The resolution is 72 dpi.
|
2231
|
+
#
|
2232
|
+
# * +matrix+ - A comma separated string of matrix elements: "scaleX,skewX,transX,skewY,scaleY,transY"
|
2233
|
+
# * *Returns* - The converter object.
|
2234
|
+
def setFooterMatrix(matrix)
|
2235
|
+
@fields['footer_matrix'] = matrix
|
2236
|
+
self
|
2237
|
+
end
|
2238
|
+
|
2239
|
+
# Disable automatic height adjustment that compensates for pixel to point rounding errors.
|
2240
|
+
#
|
2241
|
+
# * +value+ - Set to true to disable automatic height scale.
|
2242
|
+
# * *Returns* - The converter object.
|
2243
|
+
def setDisablePageHeightOptimization(value)
|
2244
|
+
@fields['disable_page_height_optimization'] = value
|
2245
|
+
self
|
2246
|
+
end
|
2247
|
+
|
2248
|
+
# Add special CSS classes to the main document's body element. This allows applying custom styling based on these classes: pdfcrowd-page-X - where X is the current page number pdfcrowd-page-odd - odd page pdfcrowd-page-even - even page
|
2249
|
+
# Warning: If your custom styling affects the contents area size (e.g. by using different margins, padding, border width), the resulting PDF may contain duplicit contents or some contents may be missing.
|
2250
|
+
#
|
2251
|
+
# * +value+ - Set to true to add the special CSS classes.
|
2252
|
+
# * *Returns* - The converter object.
|
2253
|
+
def setMainDocumentCssAnnotation(value)
|
2254
|
+
@fields['main_document_css_annotation'] = value
|
2255
|
+
self
|
2256
|
+
end
|
2257
|
+
|
2258
|
+
# Add special CSS classes to the header/footer's body element. This allows applying custom styling based on these classes: pdfcrowd-page-X - where X is the current page number pdfcrowd-page-count-X - where X is the total page count pdfcrowd-page-first - the first page pdfcrowd-page-last - the last page pdfcrowd-page-odd - odd page pdfcrowd-page-even - even page
|
2259
|
+
#
|
2260
|
+
# * +value+ - Set to true to add the special CSS classes.
|
2261
|
+
# * *Returns* - The converter object.
|
2262
|
+
def setHeaderFooterCssAnnotation(value)
|
2263
|
+
@fields['header_footer_css_annotation'] = value
|
2264
|
+
self
|
2265
|
+
end
|
2266
|
+
|
2267
|
+
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
2268
|
+
#
|
2269
|
+
# * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
|
2270
|
+
# * *Returns* - The converter object.
|
2271
|
+
def setConverterVersion(version)
|
2272
|
+
unless /(?i)^(latest|20.10|18.10)$/.match(version)
|
2273
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "html-to-pdf", "Allowed values are latest, 20.10, 18.10.", "set_converter_version"), 470);
|
2274
|
+
end
|
2275
|
+
|
2276
|
+
@helper.setConverterVersion(version)
|
1987
2277
|
self
|
1988
2278
|
end
|
1989
2279
|
|
1990
2280
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
2281
|
+
# Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
|
1991
2282
|
#
|
1992
|
-
# * +
|
2283
|
+
# * +value+ - Set to true to use HTTP.
|
1993
2284
|
# * *Returns* - The converter object.
|
1994
|
-
def setUseHttp(
|
1995
|
-
@helper.setUseHttp(
|
2285
|
+
def setUseHttp(value)
|
2286
|
+
@helper.setUseHttp(value)
|
1996
2287
|
self
|
1997
2288
|
end
|
1998
2289
|
|
1999
|
-
# Set a custom user agent HTTP header. It can be
|
2290
|
+
# Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
|
2000
2291
|
#
|
2001
|
-
# * +
|
2292
|
+
# * +agent+ - The user agent string.
|
2002
2293
|
# * *Returns* - The converter object.
|
2003
|
-
def setUserAgent(
|
2004
|
-
@helper.setUserAgent(
|
2294
|
+
def setUserAgent(agent)
|
2295
|
+
@helper.setUserAgent(agent)
|
2005
2296
|
self
|
2006
2297
|
end
|
2007
2298
|
|
@@ -2019,10 +2310,10 @@ module Pdfcrowd
|
|
2019
2310
|
|
2020
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.
|
2021
2312
|
#
|
2022
|
-
# * +
|
2313
|
+
# * +count+ - Number of retries wanted.
|
2023
2314
|
# * *Returns* - The converter object.
|
2024
|
-
def setRetryCount(
|
2025
|
-
@helper.setRetryCount(
|
2315
|
+
def setRetryCount(count)
|
2316
|
+
@helper.setRetryCount(count)
|
2026
2317
|
self
|
2027
2318
|
end
|
2028
2319
|
|
@@ -2051,7 +2342,7 @@ module Pdfcrowd
|
|
2051
2342
|
# * *Returns* - The converter object.
|
2052
2343
|
def setOutputFormat(output_format)
|
2053
2344
|
unless /(?i)^(png|jpg|gif|tiff|bmp|ico|ppm|pgm|pbm|pnm|psb|pct|ras|tga|sgi|sun|webp)$/.match(output_format)
|
2054
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(output_format, "
|
2345
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(output_format, "setOutputFormat", "html-to-image", "Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.", "set_output_format"), 470);
|
2055
2346
|
end
|
2056
2347
|
|
2057
2348
|
@fields['output_format'] = output_format
|
@@ -2064,7 +2355,7 @@ module Pdfcrowd
|
|
2064
2355
|
# * *Returns* - Byte array containing the conversion output.
|
2065
2356
|
def convertUrl(url)
|
2066
2357
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
2067
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "
|
2358
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "html-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
|
2068
2359
|
end
|
2069
2360
|
|
2070
2361
|
@fields['url'] = url
|
@@ -2077,7 +2368,7 @@ module Pdfcrowd
|
|
2077
2368
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2078
2369
|
def convertUrlToStream(url, out_stream)
|
2079
2370
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
2080
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "html-to-image", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
2371
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "html-to-image", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
2081
2372
|
end
|
2082
2373
|
|
2083
2374
|
@fields['url'] = url
|
@@ -2090,7 +2381,7 @@ module Pdfcrowd
|
|
2090
2381
|
# * +file_path+ - The output file path. The string must not be empty.
|
2091
2382
|
def convertUrlToFile(url, file_path)
|
2092
2383
|
if (!(!file_path.nil? && !file_path.empty?))
|
2093
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-image", "The string must not be empty.", "convert_url_to_file"), 470);
|
2384
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "html-to-image", "The string must not be empty.", "convert_url_to_file"), 470);
|
2094
2385
|
end
|
2095
2386
|
|
2096
2387
|
output_file = open(file_path, "wb")
|
@@ -2110,11 +2401,7 @@ module Pdfcrowd
|
|
2110
2401
|
# * *Returns* - Byte array containing the conversion output.
|
2111
2402
|
def convertFile(file)
|
2112
2403
|
if (!(File.file?(file) && !File.zero?(file)))
|
2113
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "
|
2114
|
-
end
|
2115
|
-
|
2116
|
-
if (!(File.file?(file) && !File.zero?(file)))
|
2117
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-image", "The file name must have a valid extension.", "convert_file"), 470);
|
2404
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "html-to-image", "The file must exist and not be empty.", "convert_file"), 470);
|
2118
2405
|
end
|
2119
2406
|
|
2120
2407
|
@files['file'] = file
|
@@ -2127,11 +2414,7 @@ module Pdfcrowd
|
|
2127
2414
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2128
2415
|
def convertFileToStream(file, out_stream)
|
2129
2416
|
if (!(File.file?(file) && !File.zero?(file)))
|
2130
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-image", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
|
2131
|
-
end
|
2132
|
-
|
2133
|
-
if (!(File.file?(file) && !File.zero?(file)))
|
2134
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "html-to-image", "The file name must have a valid extension.", "convert_file_to_stream"), 470);
|
2417
|
+
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);
|
2135
2418
|
end
|
2136
2419
|
|
2137
2420
|
@files['file'] = file
|
@@ -2144,7 +2427,7 @@ module Pdfcrowd
|
|
2144
2427
|
# * +file_path+ - The output file path. The string must not be empty.
|
2145
2428
|
def convertFileToFile(file, file_path)
|
2146
2429
|
if (!(!file_path.nil? && !file_path.empty?))
|
2147
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-image", "The string must not be empty.", "convert_file_to_file"), 470);
|
2430
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "html-to-image", "The string must not be empty.", "convert_file_to_file"), 470);
|
2148
2431
|
end
|
2149
2432
|
|
2150
2433
|
output_file = open(file_path, "wb")
|
@@ -2164,7 +2447,7 @@ module Pdfcrowd
|
|
2164
2447
|
# * *Returns* - Byte array containing the conversion output.
|
2165
2448
|
def convertString(text)
|
2166
2449
|
if (!(!text.nil? && !text.empty?))
|
2167
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(text, "
|
2450
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(text, "convertString", "html-to-image", "The string must not be empty.", "convert_string"), 470);
|
2168
2451
|
end
|
2169
2452
|
|
2170
2453
|
@fields['text'] = text
|
@@ -2177,7 +2460,7 @@ module Pdfcrowd
|
|
2177
2460
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2178
2461
|
def convertStringToStream(text, out_stream)
|
2179
2462
|
if (!(!text.nil? && !text.empty?))
|
2180
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(text, "text", "html-to-image", "The string must not be empty.", "convert_string_to_stream"), 470);
|
2463
|
+
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);
|
2181
2464
|
end
|
2182
2465
|
|
2183
2466
|
@fields['text'] = text
|
@@ -2190,7 +2473,7 @@ module Pdfcrowd
|
|
2190
2473
|
# * +file_path+ - The output file path. The string must not be empty.
|
2191
2474
|
def convertStringToFile(text, file_path)
|
2192
2475
|
if (!(!file_path.nil? && !file_path.empty?))
|
2193
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "html-to-image", "The string must not be empty.", "convert_string_to_file"), 470);
|
2476
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStringToFile::file_path", "html-to-image", "The string must not be empty.", "convert_string_to_file"), 470);
|
2194
2477
|
end
|
2195
2478
|
|
2196
2479
|
output_file = open(file_path, "wb")
|
@@ -2204,57 +2487,202 @@ module Pdfcrowd
|
|
2204
2487
|
end
|
2205
2488
|
end
|
2206
2489
|
|
2490
|
+
# Convert an input stream.
|
2491
|
+
#
|
2492
|
+
# * +in_stream+ - The input stream with the source data.
|
2493
|
+
# * *Returns* - Byte array containing the conversion output.
|
2494
|
+
def convertStream(in_stream)
|
2495
|
+
@raw_data['stream'] = in_stream.read
|
2496
|
+
@helper.post(@fields, @files, @raw_data)
|
2497
|
+
end
|
2498
|
+
|
2499
|
+
# Convert an input stream and write the result to an output stream.
|
2500
|
+
#
|
2501
|
+
# * +in_stream+ - The input stream with the source data.
|
2502
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
2503
|
+
def convertStreamToStream(in_stream, out_stream)
|
2504
|
+
@raw_data['stream'] = in_stream.read
|
2505
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
2506
|
+
end
|
2507
|
+
|
2508
|
+
# Convert an input stream and write the result to a local file.
|
2509
|
+
#
|
2510
|
+
# * +in_stream+ - The input stream with the source data.
|
2511
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
2512
|
+
def convertStreamToFile(in_stream, file_path)
|
2513
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
2514
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "html-to-image", "The string must not be empty.", "convert_stream_to_file"), 470);
|
2515
|
+
end
|
2516
|
+
|
2517
|
+
output_file = open(file_path, "wb")
|
2518
|
+
begin
|
2519
|
+
convertStreamToStream(in_stream, output_file)
|
2520
|
+
output_file.close()
|
2521
|
+
rescue Error => why
|
2522
|
+
output_file.close()
|
2523
|
+
FileUtils.rm(file_path)
|
2524
|
+
raise
|
2525
|
+
end
|
2526
|
+
end
|
2527
|
+
|
2528
|
+
# Set the input data for template rendering. The data format can be JSON, XML, YAML or CSV.
|
2529
|
+
#
|
2530
|
+
# * +data_string+ - The input data string.
|
2531
|
+
# * *Returns* - The converter object.
|
2532
|
+
def setDataString(data_string)
|
2533
|
+
@fields['data_string'] = data_string
|
2534
|
+
self
|
2535
|
+
end
|
2536
|
+
|
2537
|
+
# Load the input data for template rendering from the specified file. The data format can be JSON, XML, YAML or CSV.
|
2538
|
+
#
|
2539
|
+
# * +data_file+ - The file path to a local file containing the input data.
|
2540
|
+
# * *Returns* - The converter object.
|
2541
|
+
def setDataFile(data_file)
|
2542
|
+
@files['data_file'] = data_file
|
2543
|
+
self
|
2544
|
+
end
|
2545
|
+
|
2546
|
+
# Specify the input data format.
|
2547
|
+
#
|
2548
|
+
# * +data_format+ - The data format. Allowed values are auto, json, xml, yaml, csv.
|
2549
|
+
# * *Returns* - The converter object.
|
2550
|
+
def setDataFormat(data_format)
|
2551
|
+
unless /(?i)^(auto|json|xml|yaml|csv)$/.match(data_format)
|
2552
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(data_format, "setDataFormat", "html-to-image", "Allowed values are auto, json, xml, yaml, csv.", "set_data_format"), 470);
|
2553
|
+
end
|
2554
|
+
|
2555
|
+
@fields['data_format'] = data_format
|
2556
|
+
self
|
2557
|
+
end
|
2558
|
+
|
2559
|
+
# Set the encoding of the data file set by setDataFile.
|
2560
|
+
#
|
2561
|
+
# * +encoding+ - The data file encoding.
|
2562
|
+
# * *Returns* - The converter object.
|
2563
|
+
def setDataEncoding(encoding)
|
2564
|
+
@fields['data_encoding'] = encoding
|
2565
|
+
self
|
2566
|
+
end
|
2567
|
+
|
2568
|
+
# Ignore undefined variables in the HTML template. The default mode is strict so any undefined variable causes the conversion to fail. You can use {% if variable is defined %} to check if the variable is defined.
|
2569
|
+
#
|
2570
|
+
# * +value+ - Set to true to ignore undefined variables.
|
2571
|
+
# * *Returns* - The converter object.
|
2572
|
+
def setDataIgnoreUndefined(value)
|
2573
|
+
@fields['data_ignore_undefined'] = value
|
2574
|
+
self
|
2575
|
+
end
|
2576
|
+
|
2577
|
+
# Auto escape HTML symbols in the input data before placing them into the output.
|
2578
|
+
#
|
2579
|
+
# * +value+ - Set to true to turn auto escaping on.
|
2580
|
+
# * *Returns* - The converter object.
|
2581
|
+
def setDataAutoEscape(value)
|
2582
|
+
@fields['data_auto_escape'] = value
|
2583
|
+
self
|
2584
|
+
end
|
2585
|
+
|
2586
|
+
# Auto trim whitespace around each template command block.
|
2587
|
+
#
|
2588
|
+
# * +value+ - Set to true to turn auto trimming on.
|
2589
|
+
# * *Returns* - The converter object.
|
2590
|
+
def setDataTrimBlocks(value)
|
2591
|
+
@fields['data_trim_blocks'] = value
|
2592
|
+
self
|
2593
|
+
end
|
2594
|
+
|
2595
|
+
# Set the advanced data options:csv_delimiter - The CSV data delimiter, the default is ,.xml_remove_root - Remove the root XML element from the input data.data_root - The name of the root element inserted into the input data without a root node (e.g. CSV), the default is data.
|
2596
|
+
#
|
2597
|
+
# * +options+ - Comma separated list of options.
|
2598
|
+
# * *Returns* - The converter object.
|
2599
|
+
def setDataOptions(options)
|
2600
|
+
@fields['data_options'] = options
|
2601
|
+
self
|
2602
|
+
end
|
2603
|
+
|
2604
|
+
# Use the print version of the page if available (@media print).
|
2605
|
+
#
|
2606
|
+
# * +value+ - Set to true to use the print version of the page.
|
2607
|
+
# * *Returns* - The converter object.
|
2608
|
+
def setUsePrintMedia(value)
|
2609
|
+
@fields['use_print_media'] = value
|
2610
|
+
self
|
2611
|
+
end
|
2612
|
+
|
2207
2613
|
# Do not print the background graphics.
|
2208
2614
|
#
|
2209
|
-
# * +
|
2615
|
+
# * +value+ - Set to true to disable the background graphics.
|
2210
2616
|
# * *Returns* - The converter object.
|
2211
|
-
def setNoBackground(
|
2212
|
-
@fields['no_background'] =
|
2617
|
+
def setNoBackground(value)
|
2618
|
+
@fields['no_background'] = value
|
2213
2619
|
self
|
2214
2620
|
end
|
2215
2621
|
|
2216
2622
|
# Do not execute JavaScript.
|
2217
2623
|
#
|
2218
|
-
# * +
|
2624
|
+
# * +value+ - Set to true to disable JavaScript in web pages.
|
2219
2625
|
# * *Returns* - The converter object.
|
2220
|
-
def setDisableJavascript(
|
2221
|
-
@fields['disable_javascript'] =
|
2626
|
+
def setDisableJavascript(value)
|
2627
|
+
@fields['disable_javascript'] = value
|
2222
2628
|
self
|
2223
2629
|
end
|
2224
2630
|
|
2225
2631
|
# Do not load images.
|
2226
2632
|
#
|
2227
|
-
# * +
|
2633
|
+
# * +value+ - Set to true to disable loading of images.
|
2228
2634
|
# * *Returns* - The converter object.
|
2229
|
-
def setDisableImageLoading(
|
2230
|
-
@fields['disable_image_loading'] =
|
2635
|
+
def setDisableImageLoading(value)
|
2636
|
+
@fields['disable_image_loading'] = value
|
2231
2637
|
self
|
2232
2638
|
end
|
2233
2639
|
|
2234
2640
|
# Disable loading fonts from remote sources.
|
2235
2641
|
#
|
2236
|
-
# * +
|
2642
|
+
# * +value+ - Set to true disable loading remote fonts.
|
2237
2643
|
# * *Returns* - The converter object.
|
2238
|
-
def setDisableRemoteFonts(
|
2239
|
-
@fields['disable_remote_fonts'] =
|
2644
|
+
def setDisableRemoteFonts(value)
|
2645
|
+
@fields['disable_remote_fonts'] = value
|
2646
|
+
self
|
2647
|
+
end
|
2648
|
+
|
2649
|
+
# Specifies how iframes are handled.
|
2650
|
+
#
|
2651
|
+
# * +iframes+ - Allowed values are all, same-origin, none.
|
2652
|
+
# * *Returns* - The converter object.
|
2653
|
+
def setLoadIframes(iframes)
|
2654
|
+
unless /(?i)^(all|same-origin|none)$/.match(iframes)
|
2655
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(iframes, "setLoadIframes", "html-to-image", "Allowed values are all, same-origin, none.", "set_load_iframes"), 470);
|
2656
|
+
end
|
2657
|
+
|
2658
|
+
@fields['load_iframes'] = iframes
|
2240
2659
|
self
|
2241
2660
|
end
|
2242
2661
|
|
2243
2662
|
# Try to block ads. Enabling this option can produce smaller output and speed up the conversion.
|
2244
2663
|
#
|
2245
|
-
# * +
|
2664
|
+
# * +value+ - Set to true to block ads in web pages.
|
2246
2665
|
# * *Returns* - The converter object.
|
2247
|
-
def setBlockAds(
|
2248
|
-
@fields['block_ads'] =
|
2666
|
+
def setBlockAds(value)
|
2667
|
+
@fields['block_ads'] = value
|
2249
2668
|
self
|
2250
2669
|
end
|
2251
2670
|
|
2252
2671
|
# Set the default HTML content text encoding.
|
2253
2672
|
#
|
2254
|
-
# * +
|
2673
|
+
# * +encoding+ - The text encoding of the HTML content.
|
2255
2674
|
# * *Returns* - The converter object.
|
2256
|
-
def setDefaultEncoding(
|
2257
|
-
@fields['default_encoding'] =
|
2675
|
+
def setDefaultEncoding(encoding)
|
2676
|
+
@fields['default_encoding'] = encoding
|
2677
|
+
self
|
2678
|
+
end
|
2679
|
+
|
2680
|
+
# Set the locale for the conversion. This may affect the output format of dates, times and numbers.
|
2681
|
+
#
|
2682
|
+
# * +locale+ - The locale code according to ISO 639.
|
2683
|
+
# * *Returns* - The converter object.
|
2684
|
+
def setLocale(locale)
|
2685
|
+
@fields['locale'] = locale
|
2258
2686
|
self
|
2259
2687
|
end
|
2260
2688
|
|
@@ -2287,24 +2715,6 @@ module Pdfcrowd
|
|
2287
2715
|
self
|
2288
2716
|
end
|
2289
2717
|
|
2290
|
-
# Use the print version of the page if available (@media print).
|
2291
|
-
#
|
2292
|
-
# * +use_print_media+ - Set to true to use the print version of the page.
|
2293
|
-
# * *Returns* - The converter object.
|
2294
|
-
def setUsePrintMedia(use_print_media)
|
2295
|
-
@fields['use_print_media'] = use_print_media
|
2296
|
-
self
|
2297
|
-
end
|
2298
|
-
|
2299
|
-
# Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
|
2300
|
-
#
|
2301
|
-
# * +no_xpdfcrowd_header+ - Set to true to disable sending X-Pdfcrowd HTTP header.
|
2302
|
-
# * *Returns* - The converter object.
|
2303
|
-
def setNoXpdfcrowdHeader(no_xpdfcrowd_header)
|
2304
|
-
@fields['no_xpdfcrowd_header'] = no_xpdfcrowd_header
|
2305
|
-
self
|
2306
|
-
end
|
2307
|
-
|
2308
2718
|
# Set cookies that are sent in Pdfcrowd HTTP requests.
|
2309
2719
|
#
|
2310
2720
|
# * +cookies+ - The cookie string.
|
@@ -2316,10 +2726,10 @@ module Pdfcrowd
|
|
2316
2726
|
|
2317
2727
|
# Do not allow insecure HTTPS connections.
|
2318
2728
|
#
|
2319
|
-
# * +
|
2729
|
+
# * +value+ - Set to true to enable SSL certificate verification.
|
2320
2730
|
# * *Returns* - The converter object.
|
2321
|
-
def setVerifySslCertificates(
|
2322
|
-
@fields['verify_ssl_certificates'] =
|
2731
|
+
def setVerifySslCertificates(value)
|
2732
|
+
@fields['verify_ssl_certificates'] = value
|
2323
2733
|
self
|
2324
2734
|
end
|
2325
2735
|
|
@@ -2341,55 +2751,64 @@ module Pdfcrowd
|
|
2341
2751
|
self
|
2342
2752
|
end
|
2343
2753
|
|
2754
|
+
# Do not send the X-Pdfcrowd HTTP header in Pdfcrowd HTTP requests.
|
2755
|
+
#
|
2756
|
+
# * +value+ - Set to true to disable sending X-Pdfcrowd HTTP header.
|
2757
|
+
# * *Returns* - The converter object.
|
2758
|
+
def setNoXpdfcrowdHeader(value)
|
2759
|
+
@fields['no_xpdfcrowd_header'] = value
|
2760
|
+
self
|
2761
|
+
end
|
2762
|
+
|
2344
2763
|
# Run a custom JavaScript after the document is loaded and ready to print. The script is intended for post-load DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
|
2345
2764
|
#
|
2346
|
-
# * +
|
2765
|
+
# * +javascript+ - A string containing a JavaScript code. The string must not be empty.
|
2347
2766
|
# * *Returns* - The converter object.
|
2348
|
-
def setCustomJavascript(
|
2349
|
-
if (!(!
|
2350
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2767
|
+
def setCustomJavascript(javascript)
|
2768
|
+
if (!(!javascript.nil? && !javascript.empty?))
|
2769
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setCustomJavascript", "html-to-image", "The string must not be empty.", "set_custom_javascript"), 470);
|
2351
2770
|
end
|
2352
2771
|
|
2353
|
-
@fields['custom_javascript'] =
|
2772
|
+
@fields['custom_javascript'] = javascript
|
2354
2773
|
self
|
2355
2774
|
end
|
2356
2775
|
|
2357
2776
|
# Run a custom JavaScript right after the document is loaded. The script is intended for early DOM manipulation (add/remove elements, update CSS, ...). In addition to the standard browser APIs, the custom JavaScript code can use helper functions from our JavaScript library.
|
2358
2777
|
#
|
2359
|
-
# * +
|
2778
|
+
# * +javascript+ - A string containing a JavaScript code. The string must not be empty.
|
2360
2779
|
# * *Returns* - The converter object.
|
2361
|
-
def setOnLoadJavascript(
|
2362
|
-
if (!(!
|
2363
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2780
|
+
def setOnLoadJavascript(javascript)
|
2781
|
+
if (!(!javascript.nil? && !javascript.empty?))
|
2782
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(javascript, "setOnLoadJavascript", "html-to-image", "The string must not be empty.", "set_on_load_javascript"), 470);
|
2364
2783
|
end
|
2365
2784
|
|
2366
|
-
@fields['on_load_javascript'] =
|
2785
|
+
@fields['on_load_javascript'] = javascript
|
2367
2786
|
self
|
2368
2787
|
end
|
2369
2788
|
|
2370
2789
|
# Set a custom HTTP header that is sent in Pdfcrowd HTTP requests.
|
2371
2790
|
#
|
2372
|
-
# * +
|
2791
|
+
# * +header+ - A string containing the header name and value separated by a colon.
|
2373
2792
|
# * *Returns* - The converter object.
|
2374
|
-
def setCustomHttpHeader(
|
2375
|
-
unless /^.+:.+$/.match(
|
2376
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2793
|
+
def setCustomHttpHeader(header)
|
2794
|
+
unless /^.+:.+$/.match(header)
|
2795
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(header, "setCustomHttpHeader", "html-to-image", "A string containing the header name and value separated by a colon.", "set_custom_http_header"), 470);
|
2377
2796
|
end
|
2378
2797
|
|
2379
|
-
@fields['custom_http_header'] =
|
2798
|
+
@fields['custom_http_header'] = header
|
2380
2799
|
self
|
2381
2800
|
end
|
2382
2801
|
|
2383
|
-
# Wait the specified number of milliseconds to finish all JavaScript after the document is loaded.
|
2802
|
+
# Wait the specified number of milliseconds to finish all JavaScript after the document is loaded. Your API license defines the maximum wait time by "Max Delay" parameter.
|
2384
2803
|
#
|
2385
|
-
# * +
|
2804
|
+
# * +delay+ - The number of milliseconds to wait. Must be a positive integer number or 0.
|
2386
2805
|
# * *Returns* - The converter object.
|
2387
|
-
def setJavascriptDelay(
|
2388
|
-
if (!(Integer(
|
2389
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2806
|
+
def setJavascriptDelay(delay)
|
2807
|
+
if (!(Integer(delay) >= 0))
|
2808
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(delay, "setJavascriptDelay", "html-to-image", "Must be a positive integer number or 0.", "set_javascript_delay"), 470);
|
2390
2809
|
end
|
2391
2810
|
|
2392
|
-
@fields['javascript_delay'] =
|
2811
|
+
@fields['javascript_delay'] = delay
|
2393
2812
|
self
|
2394
2813
|
end
|
2395
2814
|
|
@@ -2399,7 +2818,7 @@ module Pdfcrowd
|
|
2399
2818
|
# * *Returns* - The converter object.
|
2400
2819
|
def setElementToConvert(selectors)
|
2401
2820
|
if (!(!selectors.nil? && !selectors.empty?))
|
2402
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "
|
2821
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setElementToConvert", "html-to-image", "The string must not be empty.", "set_element_to_convert"), 470);
|
2403
2822
|
end
|
2404
2823
|
|
2405
2824
|
@fields['element_to_convert'] = selectors
|
@@ -2412,7 +2831,7 @@ module Pdfcrowd
|
|
2412
2831
|
# * *Returns* - The converter object.
|
2413
2832
|
def setElementToConvertMode(mode)
|
2414
2833
|
unless /(?i)^(cut-out|remove-siblings|hide-siblings)$/.match(mode)
|
2415
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "
|
2834
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setElementToConvertMode", "html-to-image", "Allowed values are cut-out, remove-siblings, hide-siblings.", "set_element_to_convert_mode"), 470);
|
2416
2835
|
end
|
2417
2836
|
|
2418
2837
|
@fields['element_to_convert_mode'] = mode
|
@@ -2425,7 +2844,7 @@ module Pdfcrowd
|
|
2425
2844
|
# * *Returns* - The converter object.
|
2426
2845
|
def setWaitForElement(selectors)
|
2427
2846
|
if (!(!selectors.nil? && !selectors.empty?))
|
2428
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "
|
2847
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(selectors, "setWaitForElement", "html-to-image", "The string must not be empty.", "set_wait_for_element"), 470);
|
2429
2848
|
end
|
2430
2849
|
|
2431
2850
|
@fields['wait_for_element'] = selectors
|
@@ -2434,49 +2853,62 @@ module Pdfcrowd
|
|
2434
2853
|
|
2435
2854
|
# Set the output image width in pixels.
|
2436
2855
|
#
|
2437
|
-
# * +
|
2856
|
+
# * +width+ - The value must be in the range 96-65000.
|
2438
2857
|
# * *Returns* - The converter object.
|
2439
|
-
def setScreenshotWidth(
|
2440
|
-
if (!(Integer(
|
2441
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2858
|
+
def setScreenshotWidth(width)
|
2859
|
+
if (!(Integer(width) >= 96 && Integer(width) <= 65000))
|
2860
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(width, "setScreenshotWidth", "html-to-image", "The value must be in the range 96-65000.", "set_screenshot_width"), 470);
|
2442
2861
|
end
|
2443
2862
|
|
2444
|
-
@fields['screenshot_width'] =
|
2863
|
+
@fields['screenshot_width'] = width
|
2445
2864
|
self
|
2446
2865
|
end
|
2447
2866
|
|
2448
|
-
# Set the output image height in pixels. If it
|
2867
|
+
# Set the output image height in pixels. If it is not specified, actual document height is used.
|
2449
2868
|
#
|
2450
|
-
# * +
|
2869
|
+
# * +height+ - Must be a positive integer number.
|
2451
2870
|
# * *Returns* - The converter object.
|
2452
|
-
def setScreenshotHeight(
|
2453
|
-
if (!(Integer(
|
2454
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2871
|
+
def setScreenshotHeight(height)
|
2872
|
+
if (!(Integer(height) > 0))
|
2873
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(height, "setScreenshotHeight", "html-to-image", "Must be a positive integer number.", "set_screenshot_height"), 470);
|
2455
2874
|
end
|
2456
2875
|
|
2457
|
-
@fields['screenshot_height'] =
|
2876
|
+
@fields['screenshot_height'] = height
|
2458
2877
|
self
|
2459
2878
|
end
|
2460
2879
|
|
2461
2880
|
# Set the scaling factor (zoom) for the output image.
|
2462
2881
|
#
|
2463
|
-
# * +
|
2882
|
+
# * +factor+ - The percentage value. Must be a positive integer number.
|
2883
|
+
# * *Returns* - The converter object.
|
2884
|
+
def setScaleFactor(factor)
|
2885
|
+
if (!(Integer(factor) > 0))
|
2886
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(factor, "setScaleFactor", "html-to-image", "Must be a positive integer number.", "set_scale_factor"), 470);
|
2887
|
+
end
|
2888
|
+
|
2889
|
+
@fields['scale_factor'] = factor
|
2890
|
+
self
|
2891
|
+
end
|
2892
|
+
|
2893
|
+
# The output image background color.
|
2894
|
+
#
|
2895
|
+
# * +color+ - The value must be in RRGGBB or RRGGBBAA hexadecimal format.
|
2464
2896
|
# * *Returns* - The converter object.
|
2465
|
-
def
|
2466
|
-
|
2467
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2897
|
+
def setBackgroundColor(color)
|
2898
|
+
unless /^[0-9a-fA-F]{6,8}$/.match(color)
|
2899
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(color, "setBackgroundColor", "html-to-image", "The value must be in RRGGBB or RRGGBBAA hexadecimal format.", "set_background_color"), 470);
|
2468
2900
|
end
|
2469
2901
|
|
2470
|
-
@fields['
|
2902
|
+
@fields['background_color'] = color
|
2471
2903
|
self
|
2472
2904
|
end
|
2473
2905
|
|
2474
2906
|
# 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.
|
2475
2907
|
#
|
2476
|
-
# * +
|
2908
|
+
# * +value+ - Set to true to enable the debug logging.
|
2477
2909
|
# * *Returns* - The converter object.
|
2478
|
-
def setDebugLog(
|
2479
|
-
@fields['debug_log'] =
|
2910
|
+
def setDebugLog(value)
|
2911
|
+
@fields['debug_log'] = value
|
2480
2912
|
self
|
2481
2913
|
end
|
2482
2914
|
|
@@ -2513,6 +2945,12 @@ module Pdfcrowd
|
|
2513
2945
|
return @helper.getOutputSize()
|
2514
2946
|
end
|
2515
2947
|
|
2948
|
+
# Get the version details.
|
2949
|
+
# * *Returns* - API version, converter version, and client version.
|
2950
|
+
def getVersion()
|
2951
|
+
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
2952
|
+
end
|
2953
|
+
|
2516
2954
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
2517
2955
|
#
|
2518
2956
|
# * +tag+ - A string with the custom tag.
|
@@ -2524,67 +2962,81 @@ module Pdfcrowd
|
|
2524
2962
|
|
2525
2963
|
# 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.
|
2526
2964
|
#
|
2527
|
-
# * +
|
2965
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
2528
2966
|
# * *Returns* - The converter object.
|
2529
|
-
def setHttpProxy(
|
2530
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
2531
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2967
|
+
def setHttpProxy(proxy)
|
2968
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
2969
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "html-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
|
2532
2970
|
end
|
2533
2971
|
|
2534
|
-
@fields['http_proxy'] =
|
2972
|
+
@fields['http_proxy'] = proxy
|
2535
2973
|
self
|
2536
2974
|
end
|
2537
2975
|
|
2538
2976
|
# 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.
|
2539
2977
|
#
|
2540
|
-
# * +
|
2978
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
2541
2979
|
# * *Returns* - The converter object.
|
2542
|
-
def setHttpsProxy(
|
2543
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
2544
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2980
|
+
def setHttpsProxy(proxy)
|
2981
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
2982
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "html-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
|
2545
2983
|
end
|
2546
2984
|
|
2547
|
-
@fields['https_proxy'] =
|
2985
|
+
@fields['https_proxy'] = proxy
|
2548
2986
|
self
|
2549
2987
|
end
|
2550
2988
|
|
2551
2989
|
# A client certificate to authenticate Pdfcrowd converter on your web server. The certificate is used for two-way SSL/TLS authentication and adds extra security.
|
2552
2990
|
#
|
2553
|
-
# * +
|
2991
|
+
# * +certificate+ - The file must be in PKCS12 format. The file must exist and not be empty.
|
2554
2992
|
# * *Returns* - The converter object.
|
2555
|
-
def setClientCertificate(
|
2556
|
-
if (!(File.file?(
|
2557
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
2993
|
+
def setClientCertificate(certificate)
|
2994
|
+
if (!(File.file?(certificate) && !File.zero?(certificate)))
|
2995
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(certificate, "setClientCertificate", "html-to-image", "The file must exist and not be empty.", "set_client_certificate"), 470);
|
2558
2996
|
end
|
2559
2997
|
|
2560
|
-
@files['client_certificate'] =
|
2998
|
+
@files['client_certificate'] = certificate
|
2561
2999
|
self
|
2562
3000
|
end
|
2563
3001
|
|
2564
|
-
# A password for PKCS12 file with a client certificate if it
|
3002
|
+
# A password for PKCS12 file with a client certificate if it is needed.
|
2565
3003
|
#
|
2566
|
-
# * +
|
3004
|
+
# * +password+ -
|
2567
3005
|
# * *Returns* - The converter object.
|
2568
|
-
def setClientCertificatePassword(
|
2569
|
-
@fields['client_certificate_password'] =
|
3006
|
+
def setClientCertificatePassword(password)
|
3007
|
+
@fields['client_certificate_password'] = password
|
3008
|
+
self
|
3009
|
+
end
|
3010
|
+
|
3011
|
+
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
3012
|
+
#
|
3013
|
+
# * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
|
3014
|
+
# * *Returns* - The converter object.
|
3015
|
+
def setConverterVersion(version)
|
3016
|
+
unless /(?i)^(latest|20.10|18.10)$/.match(version)
|
3017
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "html-to-image", "Allowed values are latest, 20.10, 18.10.", "set_converter_version"), 470);
|
3018
|
+
end
|
3019
|
+
|
3020
|
+
@helper.setConverterVersion(version)
|
2570
3021
|
self
|
2571
3022
|
end
|
2572
3023
|
|
2573
3024
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
3025
|
+
# Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
|
2574
3026
|
#
|
2575
|
-
# * +
|
3027
|
+
# * +value+ - Set to true to use HTTP.
|
2576
3028
|
# * *Returns* - The converter object.
|
2577
|
-
def setUseHttp(
|
2578
|
-
@helper.setUseHttp(
|
3029
|
+
def setUseHttp(value)
|
3030
|
+
@helper.setUseHttp(value)
|
2579
3031
|
self
|
2580
3032
|
end
|
2581
3033
|
|
2582
|
-
# Set a custom user agent HTTP header. It can be
|
3034
|
+
# Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
|
2583
3035
|
#
|
2584
|
-
# * +
|
3036
|
+
# * +agent+ - The user agent string.
|
2585
3037
|
# * *Returns* - The converter object.
|
2586
|
-
def setUserAgent(
|
2587
|
-
@helper.setUserAgent(
|
3038
|
+
def setUserAgent(agent)
|
3039
|
+
@helper.setUserAgent(agent)
|
2588
3040
|
self
|
2589
3041
|
end
|
2590
3042
|
|
@@ -2602,10 +3054,10 @@ module Pdfcrowd
|
|
2602
3054
|
|
2603
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.
|
2604
3056
|
#
|
2605
|
-
# * +
|
3057
|
+
# * +count+ - Number of retries wanted.
|
2606
3058
|
# * *Returns* - The converter object.
|
2607
|
-
def setRetryCount(
|
2608
|
-
@helper.setRetryCount(
|
3059
|
+
def setRetryCount(count)
|
3060
|
+
@helper.setRetryCount(count)
|
2609
3061
|
self
|
2610
3062
|
end
|
2611
3063
|
|
@@ -2634,7 +3086,7 @@ module Pdfcrowd
|
|
2634
3086
|
# * *Returns* - Byte array containing the conversion output.
|
2635
3087
|
def convertUrl(url)
|
2636
3088
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
2637
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "
|
3089
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-image", "The supported protocols are http:// and https://.", "convert_url"), 470);
|
2638
3090
|
end
|
2639
3091
|
|
2640
3092
|
@fields['url'] = url
|
@@ -2647,7 +3099,7 @@ module Pdfcrowd
|
|
2647
3099
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2648
3100
|
def convertUrlToStream(url, out_stream)
|
2649
3101
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
2650
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "image-to-image", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
3102
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "image-to-image", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
2651
3103
|
end
|
2652
3104
|
|
2653
3105
|
@fields['url'] = url
|
@@ -2660,7 +3112,7 @@ module Pdfcrowd
|
|
2660
3112
|
# * +file_path+ - The output file path. The string must not be empty.
|
2661
3113
|
def convertUrlToFile(url, file_path)
|
2662
3114
|
if (!(!file_path.nil? && !file_path.empty?))
|
2663
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "image-to-image", "The string must not be empty.", "convert_url_to_file"), 470);
|
3115
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "image-to-image", "The string must not be empty.", "convert_url_to_file"), 470);
|
2664
3116
|
end
|
2665
3117
|
|
2666
3118
|
output_file = open(file_path, "wb")
|
@@ -2676,11 +3128,11 @@ module Pdfcrowd
|
|
2676
3128
|
|
2677
3129
|
# Convert a local file.
|
2678
3130
|
#
|
2679
|
-
# * +file+ - The path to a local file to convert. The file
|
3131
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
2680
3132
|
# * *Returns* - Byte array containing the conversion output.
|
2681
3133
|
def convertFile(file)
|
2682
3134
|
if (!(File.file?(file) && !File.zero?(file)))
|
2683
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "
|
3135
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "image-to-image", "The file must exist and not be empty.", "convert_file"), 470);
|
2684
3136
|
end
|
2685
3137
|
|
2686
3138
|
@files['file'] = file
|
@@ -2689,11 +3141,11 @@ module Pdfcrowd
|
|
2689
3141
|
|
2690
3142
|
# Convert a local file and write the result to an output stream.
|
2691
3143
|
#
|
2692
|
-
# * +file+ - The path to a local file to convert. The file
|
3144
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
2693
3145
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
2694
3146
|
def convertFileToStream(file, out_stream)
|
2695
3147
|
if (!(File.file?(file) && !File.zero?(file)))
|
2696
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "image-to-image", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
|
3148
|
+
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);
|
2697
3149
|
end
|
2698
3150
|
|
2699
3151
|
@files['file'] = file
|
@@ -2702,11 +3154,11 @@ module Pdfcrowd
|
|
2702
3154
|
|
2703
3155
|
# Convert a local file and write the result to a local file.
|
2704
3156
|
#
|
2705
|
-
# * +file+ - The path to a local file to convert. The file
|
3157
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
2706
3158
|
# * +file_path+ - The output file path. The string must not be empty.
|
2707
3159
|
def convertFileToFile(file, file_path)
|
2708
3160
|
if (!(!file_path.nil? && !file_path.empty?))
|
2709
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "image-to-image", "The string must not be empty.", "convert_file_to_file"), 470);
|
3161
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "image-to-image", "The string must not be empty.", "convert_file_to_file"), 470);
|
2710
3162
|
end
|
2711
3163
|
|
2712
3164
|
output_file = open(file_path, "wb")
|
@@ -2744,7 +3196,7 @@ module Pdfcrowd
|
|
2744
3196
|
# * +file_path+ - The output file path. The string must not be empty.
|
2745
3197
|
def convertRawDataToFile(data, file_path)
|
2746
3198
|
if (!(!file_path.nil? && !file_path.empty?))
|
2747
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "image-to-image", "The string must not be empty.", "convert_raw_data_to_file"), 470);
|
3199
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertRawDataToFile::file_path", "image-to-image", "The string must not be empty.", "convert_raw_data_to_file"), 470);
|
2748
3200
|
end
|
2749
3201
|
|
2750
3202
|
output_file = open(file_path, "wb")
|
@@ -2758,13 +3210,51 @@ module Pdfcrowd
|
|
2758
3210
|
end
|
2759
3211
|
end
|
2760
3212
|
|
3213
|
+
# Convert an input stream.
|
3214
|
+
#
|
3215
|
+
# * +in_stream+ - The input stream with the source data.
|
3216
|
+
# * *Returns* - Byte array containing the conversion output.
|
3217
|
+
def convertStream(in_stream)
|
3218
|
+
@raw_data['stream'] = in_stream.read
|
3219
|
+
@helper.post(@fields, @files, @raw_data)
|
3220
|
+
end
|
3221
|
+
|
3222
|
+
# Convert an input stream and write the result to an output stream.
|
3223
|
+
#
|
3224
|
+
# * +in_stream+ - The input stream with the source data.
|
3225
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
3226
|
+
def convertStreamToStream(in_stream, out_stream)
|
3227
|
+
@raw_data['stream'] = in_stream.read
|
3228
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
3229
|
+
end
|
3230
|
+
|
3231
|
+
# Convert an input stream and write the result to a local file.
|
3232
|
+
#
|
3233
|
+
# * +in_stream+ - The input stream with the source data.
|
3234
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
3235
|
+
def convertStreamToFile(in_stream, file_path)
|
3236
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
3237
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "image-to-image", "The string must not be empty.", "convert_stream_to_file"), 470);
|
3238
|
+
end
|
3239
|
+
|
3240
|
+
output_file = open(file_path, "wb")
|
3241
|
+
begin
|
3242
|
+
convertStreamToStream(in_stream, output_file)
|
3243
|
+
output_file.close()
|
3244
|
+
rescue Error => why
|
3245
|
+
output_file.close()
|
3246
|
+
FileUtils.rm(file_path)
|
3247
|
+
raise
|
3248
|
+
end
|
3249
|
+
end
|
3250
|
+
|
2761
3251
|
# The format of the output file.
|
2762
3252
|
#
|
2763
3253
|
# * +output_format+ - Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.
|
2764
3254
|
# * *Returns* - The converter object.
|
2765
3255
|
def setOutputFormat(output_format)
|
2766
3256
|
unless /(?i)^(png|jpg|gif|tiff|bmp|ico|ppm|pgm|pbm|pnm|psb|pct|ras|tga|sgi|sun|webp)$/.match(output_format)
|
2767
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(output_format, "
|
3257
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(output_format, "setOutputFormat", "image-to-image", "Allowed values are png, jpg, gif, tiff, bmp, ico, ppm, pgm, pbm, pnm, psb, pct, ras, tga, sgi, sun, webp.", "set_output_format"), 470);
|
2768
3258
|
end
|
2769
3259
|
|
2770
3260
|
@fields['output_format'] = output_format
|
@@ -2791,10 +3281,10 @@ module Pdfcrowd
|
|
2791
3281
|
|
2792
3282
|
# 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.
|
2793
3283
|
#
|
2794
|
-
# * +
|
3284
|
+
# * +value+ - Set to true to enable the debug logging.
|
2795
3285
|
# * *Returns* - The converter object.
|
2796
|
-
def setDebugLog(
|
2797
|
-
@fields['debug_log'] =
|
3286
|
+
def setDebugLog(value)
|
3287
|
+
@fields['debug_log'] = value
|
2798
3288
|
self
|
2799
3289
|
end
|
2800
3290
|
|
@@ -2831,6 +3321,12 @@ module Pdfcrowd
|
|
2831
3321
|
return @helper.getOutputSize()
|
2832
3322
|
end
|
2833
3323
|
|
3324
|
+
# Get the version details.
|
3325
|
+
# * *Returns* - API version, converter version, and client version.
|
3326
|
+
def getVersion()
|
3327
|
+
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
3328
|
+
end
|
3329
|
+
|
2834
3330
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
2835
3331
|
#
|
2836
3332
|
# * +tag+ - A string with the custom tag.
|
@@ -2842,45 +3338,59 @@ module Pdfcrowd
|
|
2842
3338
|
|
2843
3339
|
# 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.
|
2844
3340
|
#
|
2845
|
-
# * +
|
3341
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
2846
3342
|
# * *Returns* - The converter object.
|
2847
|
-
def setHttpProxy(
|
2848
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
2849
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3343
|
+
def setHttpProxy(proxy)
|
3344
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
3345
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "image-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
|
2850
3346
|
end
|
2851
3347
|
|
2852
|
-
@fields['http_proxy'] =
|
3348
|
+
@fields['http_proxy'] = proxy
|
2853
3349
|
self
|
2854
3350
|
end
|
2855
3351
|
|
2856
3352
|
# 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.
|
2857
3353
|
#
|
2858
|
-
# * +
|
3354
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
2859
3355
|
# * *Returns* - The converter object.
|
2860
|
-
def setHttpsProxy(
|
2861
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
2862
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3356
|
+
def setHttpsProxy(proxy)
|
3357
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
3358
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "image-to-image", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
|
2863
3359
|
end
|
2864
3360
|
|
2865
|
-
@fields['https_proxy'] =
|
3361
|
+
@fields['https_proxy'] = proxy
|
3362
|
+
self
|
3363
|
+
end
|
3364
|
+
|
3365
|
+
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
3366
|
+
#
|
3367
|
+
# * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
|
3368
|
+
# * *Returns* - The converter object.
|
3369
|
+
def setConverterVersion(version)
|
3370
|
+
unless /(?i)^(latest|20.10|18.10)$/.match(version)
|
3371
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "image-to-image", "Allowed values are latest, 20.10, 18.10.", "set_converter_version"), 470);
|
3372
|
+
end
|
3373
|
+
|
3374
|
+
@helper.setConverterVersion(version)
|
2866
3375
|
self
|
2867
3376
|
end
|
2868
3377
|
|
2869
3378
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
3379
|
+
# Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
|
2870
3380
|
#
|
2871
|
-
# * +
|
3381
|
+
# * +value+ - Set to true to use HTTP.
|
2872
3382
|
# * *Returns* - The converter object.
|
2873
|
-
def setUseHttp(
|
2874
|
-
@helper.setUseHttp(
|
3383
|
+
def setUseHttp(value)
|
3384
|
+
@helper.setUseHttp(value)
|
2875
3385
|
self
|
2876
3386
|
end
|
2877
3387
|
|
2878
|
-
# Set a custom user agent HTTP header. It can be
|
3388
|
+
# Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
|
2879
3389
|
#
|
2880
|
-
# * +
|
3390
|
+
# * +agent+ - The user agent string.
|
2881
3391
|
# * *Returns* - The converter object.
|
2882
|
-
def setUserAgent(
|
2883
|
-
@helper.setUserAgent(
|
3392
|
+
def setUserAgent(agent)
|
3393
|
+
@helper.setUserAgent(agent)
|
2884
3394
|
self
|
2885
3395
|
end
|
2886
3396
|
|
@@ -2898,10 +3408,10 @@ module Pdfcrowd
|
|
2898
3408
|
|
2899
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.
|
2900
3410
|
#
|
2901
|
-
# * +
|
3411
|
+
# * +count+ - Number of retries wanted.
|
2902
3412
|
# * *Returns* - The converter object.
|
2903
|
-
def setRetryCount(
|
2904
|
-
@helper.setRetryCount(
|
3413
|
+
def setRetryCount(count)
|
3414
|
+
@helper.setRetryCount(count)
|
2905
3415
|
self
|
2906
3416
|
end
|
2907
3417
|
|
@@ -2930,7 +3440,7 @@ module Pdfcrowd
|
|
2930
3440
|
# * *Returns* - The converter object.
|
2931
3441
|
def setAction(action)
|
2932
3442
|
unless /(?i)^(join|shuffle)$/.match(action)
|
2933
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(action, "
|
3443
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(action, "setAction", "pdf-to-pdf", "Allowed values are join, shuffle.", "set_action"), 470);
|
2934
3444
|
end
|
2935
3445
|
|
2936
3446
|
@fields['action'] = action
|
@@ -2955,7 +3465,7 @@ module Pdfcrowd
|
|
2955
3465
|
# * +file_path+ - The output file path. The string must not be empty.
|
2956
3466
|
def convertToFile(file_path)
|
2957
3467
|
if (!(!file_path.nil? && !file_path.empty?))
|
2958
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "
|
3468
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertToFile", "pdf-to-pdf", "The string must not be empty.", "convert_to_file"), 470);
|
2959
3469
|
end
|
2960
3470
|
|
2961
3471
|
output_file = open(file_path, "wb")
|
@@ -2969,7 +3479,7 @@ module Pdfcrowd
|
|
2969
3479
|
# * *Returns* - The converter object.
|
2970
3480
|
def addPdfFile(file_path)
|
2971
3481
|
if (!(File.file?(file_path) && !File.zero?(file_path)))
|
2972
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "
|
3482
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "addPdfFile", "pdf-to-pdf", "The file must exist and not be empty.", "add_pdf_file"), 470);
|
2973
3483
|
end
|
2974
3484
|
|
2975
3485
|
@files['f_%s' % @file_id] = file_path
|
@@ -2979,267 +3489,319 @@ module Pdfcrowd
|
|
2979
3489
|
|
2980
3490
|
# Add in-memory raw PDF data to the list of the input PDFs.Typical usage is for adding PDF created by another Pdfcrowd converter. Example in PHP: $clientPdf2Pdf->addPdfRawData($clientHtml2Pdf->convertUrl('http://www.example.com'));
|
2981
3491
|
#
|
2982
|
-
# * +
|
3492
|
+
# * +data+ - The raw PDF data. The input data must be PDF content.
|
2983
3493
|
# * *Returns* - The converter object.
|
2984
|
-
def addPdfRawData(
|
2985
|
-
if (!(!
|
2986
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message("raw PDF data", "
|
3494
|
+
def addPdfRawData(data)
|
3495
|
+
if (!(!data.nil? && data.length > 300 and data[0...4] == '%PDF'))
|
3496
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message("raw PDF data", "addPdfRawData", "pdf-to-pdf", "The input data must be PDF content.", "add_pdf_raw_data"), 470);
|
2987
3497
|
end
|
2988
3498
|
|
2989
|
-
@raw_data['f_%s' % @file_id] =
|
3499
|
+
@raw_data['f_%s' % @file_id] = data
|
2990
3500
|
@file_id += 1
|
2991
3501
|
self
|
2992
3502
|
end
|
2993
3503
|
|
2994
3504
|
# Apply the first page of the watermark PDF to every page of the output PDF.
|
2995
3505
|
#
|
2996
|
-
# * +
|
3506
|
+
# * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
|
3507
|
+
# * *Returns* - The converter object.
|
3508
|
+
def setPageWatermark(watermark)
|
3509
|
+
if (!(File.file?(watermark) && !File.zero?(watermark)))
|
3510
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(watermark, "setPageWatermark", "pdf-to-pdf", "The file must exist and not be empty.", "set_page_watermark"), 470);
|
3511
|
+
end
|
3512
|
+
|
3513
|
+
@files['page_watermark'] = watermark
|
3514
|
+
self
|
3515
|
+
end
|
3516
|
+
|
3517
|
+
# Load a watermark PDF from the specified URL and apply the first page of the watermark PDF to every page of the output PDF.
|
3518
|
+
#
|
3519
|
+
# * +url+ - The supported protocols are http:// and https://.
|
2997
3520
|
# * *Returns* - The converter object.
|
2998
|
-
def
|
2999
|
-
|
3000
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3521
|
+
def setPageWatermarkUrl(url)
|
3522
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
3523
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageWatermarkUrl", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_page_watermark_url"), 470);
|
3001
3524
|
end
|
3002
3525
|
|
3003
|
-
@
|
3526
|
+
@fields['page_watermark_url'] = url
|
3004
3527
|
self
|
3005
3528
|
end
|
3006
3529
|
|
3007
3530
|
# Apply each page of the specified watermark PDF to the corresponding page of the output PDF.
|
3008
3531
|
#
|
3009
|
-
# * +
|
3532
|
+
# * +watermark+ - The file path to a local watermark PDF file. The file must exist and not be empty.
|
3533
|
+
# * *Returns* - The converter object.
|
3534
|
+
def setMultipageWatermark(watermark)
|
3535
|
+
if (!(File.file?(watermark) && !File.zero?(watermark)))
|
3536
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(watermark, "setMultipageWatermark", "pdf-to-pdf", "The file must exist and not be empty.", "set_multipage_watermark"), 470);
|
3537
|
+
end
|
3538
|
+
|
3539
|
+
@files['multipage_watermark'] = watermark
|
3540
|
+
self
|
3541
|
+
end
|
3542
|
+
|
3543
|
+
# Load a watermark PDF from the specified URL and apply each page of the specified watermark PDF to the corresponding page of the output PDF.
|
3544
|
+
#
|
3545
|
+
# * +url+ - The supported protocols are http:// and https://.
|
3010
3546
|
# * *Returns* - The converter object.
|
3011
|
-
def
|
3012
|
-
|
3013
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3547
|
+
def setMultipageWatermarkUrl(url)
|
3548
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
3549
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageWatermarkUrl", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_watermark_url"), 470);
|
3014
3550
|
end
|
3015
3551
|
|
3016
|
-
@
|
3552
|
+
@fields['multipage_watermark_url'] = url
|
3017
3553
|
self
|
3018
3554
|
end
|
3019
3555
|
|
3020
3556
|
# Apply the first page of the specified PDF to the background of every page of the output PDF.
|
3021
3557
|
#
|
3022
|
-
# * +
|
3558
|
+
# * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
|
3559
|
+
# * *Returns* - The converter object.
|
3560
|
+
def setPageBackground(background)
|
3561
|
+
if (!(File.file?(background) && !File.zero?(background)))
|
3562
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(background, "setPageBackground", "pdf-to-pdf", "The file must exist and not be empty.", "set_page_background"), 470);
|
3563
|
+
end
|
3564
|
+
|
3565
|
+
@files['page_background'] = background
|
3566
|
+
self
|
3567
|
+
end
|
3568
|
+
|
3569
|
+
# Load a background PDF from the specified URL and apply the first page of the background PDF to every page of the output PDF.
|
3570
|
+
#
|
3571
|
+
# * +url+ - The supported protocols are http:// and https://.
|
3023
3572
|
# * *Returns* - The converter object.
|
3024
|
-
def
|
3025
|
-
|
3026
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3573
|
+
def setPageBackgroundUrl(url)
|
3574
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
3575
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setPageBackgroundUrl", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_page_background_url"), 470);
|
3027
3576
|
end
|
3028
3577
|
|
3029
|
-
@
|
3578
|
+
@fields['page_background_url'] = url
|
3030
3579
|
self
|
3031
3580
|
end
|
3032
3581
|
|
3033
3582
|
# Apply each page of the specified PDF to the background of the corresponding page of the output PDF.
|
3034
3583
|
#
|
3035
|
-
# * +
|
3584
|
+
# * +background+ - The file path to a local background PDF file. The file must exist and not be empty.
|
3036
3585
|
# * *Returns* - The converter object.
|
3037
|
-
def setMultipageBackground(
|
3038
|
-
if (!(File.file?(
|
3039
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3586
|
+
def setMultipageBackground(background)
|
3587
|
+
if (!(File.file?(background) && !File.zero?(background)))
|
3588
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(background, "setMultipageBackground", "pdf-to-pdf", "The file must exist and not be empty.", "set_multipage_background"), 470);
|
3040
3589
|
end
|
3041
3590
|
|
3042
|
-
@files['multipage_background'] =
|
3591
|
+
@files['multipage_background'] = background
|
3592
|
+
self
|
3593
|
+
end
|
3594
|
+
|
3595
|
+
# Load a background PDF from the specified URL and apply each page of the specified background PDF to the corresponding page of the output PDF.
|
3596
|
+
#
|
3597
|
+
# * +url+ - The supported protocols are http:// and https://.
|
3598
|
+
# * *Returns* - The converter object.
|
3599
|
+
def setMultipageBackgroundUrl(url)
|
3600
|
+
unless /(?i)^https?:\/\/.*$/.match(url)
|
3601
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "setMultipageBackgroundUrl", "pdf-to-pdf", "The supported protocols are http:// and https://.", "set_multipage_background_url"), 470);
|
3602
|
+
end
|
3603
|
+
|
3604
|
+
@fields['multipage_background_url'] = url
|
3043
3605
|
self
|
3044
3606
|
end
|
3045
3607
|
|
3046
3608
|
# Create linearized PDF. This is also known as Fast Web View.
|
3047
3609
|
#
|
3048
|
-
# * +
|
3610
|
+
# * +value+ - Set to true to create linearized PDF.
|
3049
3611
|
# * *Returns* - The converter object.
|
3050
|
-
def setLinearize(
|
3051
|
-
@fields['linearize'] =
|
3612
|
+
def setLinearize(value)
|
3613
|
+
@fields['linearize'] = value
|
3052
3614
|
self
|
3053
3615
|
end
|
3054
3616
|
|
3055
3617
|
# Encrypt the PDF. This prevents search engines from indexing the contents.
|
3056
3618
|
#
|
3057
|
-
# * +
|
3619
|
+
# * +value+ - Set to true to enable PDF encryption.
|
3058
3620
|
# * *Returns* - The converter object.
|
3059
|
-
def setEncrypt(
|
3060
|
-
@fields['encrypt'] =
|
3621
|
+
def setEncrypt(value)
|
3622
|
+
@fields['encrypt'] = value
|
3061
3623
|
self
|
3062
3624
|
end
|
3063
3625
|
|
3064
3626
|
# Protect the PDF with a user password. When a PDF has a user password, it must be supplied in order to view the document and to perform operations allowed by the access permissions.
|
3065
3627
|
#
|
3066
|
-
# * +
|
3628
|
+
# * +password+ - The user password.
|
3067
3629
|
# * *Returns* - The converter object.
|
3068
|
-
def setUserPassword(
|
3069
|
-
@fields['user_password'] =
|
3630
|
+
def setUserPassword(password)
|
3631
|
+
@fields['user_password'] = password
|
3070
3632
|
self
|
3071
3633
|
end
|
3072
3634
|
|
3073
3635
|
# Protect the PDF with an owner password. Supplying an owner password grants unlimited access to the PDF including changing the passwords and access permissions.
|
3074
3636
|
#
|
3075
|
-
# * +
|
3637
|
+
# * +password+ - The owner password.
|
3076
3638
|
# * *Returns* - The converter object.
|
3077
|
-
def setOwnerPassword(
|
3078
|
-
@fields['owner_password'] =
|
3639
|
+
def setOwnerPassword(password)
|
3640
|
+
@fields['owner_password'] = password
|
3079
3641
|
self
|
3080
3642
|
end
|
3081
3643
|
|
3082
3644
|
# Disallow printing of the output PDF.
|
3083
3645
|
#
|
3084
|
-
# * +
|
3646
|
+
# * +value+ - Set to true to set the no-print flag in the output PDF.
|
3085
3647
|
# * *Returns* - The converter object.
|
3086
|
-
def setNoPrint(
|
3087
|
-
@fields['no_print'] =
|
3648
|
+
def setNoPrint(value)
|
3649
|
+
@fields['no_print'] = value
|
3088
3650
|
self
|
3089
3651
|
end
|
3090
3652
|
|
3091
|
-
# Disallow modification of the
|
3653
|
+
# Disallow modification of the output PDF.
|
3092
3654
|
#
|
3093
|
-
# * +
|
3655
|
+
# * +value+ - Set to true to set the read-only only flag in the output PDF.
|
3094
3656
|
# * *Returns* - The converter object.
|
3095
|
-
def setNoModify(
|
3096
|
-
@fields['no_modify'] =
|
3657
|
+
def setNoModify(value)
|
3658
|
+
@fields['no_modify'] = value
|
3097
3659
|
self
|
3098
3660
|
end
|
3099
3661
|
|
3100
3662
|
# Disallow text and graphics extraction from the output PDF.
|
3101
3663
|
#
|
3102
|
-
# * +
|
3664
|
+
# * +value+ - Set to true to set the no-copy flag in the output PDF.
|
3103
3665
|
# * *Returns* - The converter object.
|
3104
|
-
def setNoCopy(
|
3105
|
-
@fields['no_copy'] =
|
3666
|
+
def setNoCopy(value)
|
3667
|
+
@fields['no_copy'] = value
|
3106
3668
|
self
|
3107
3669
|
end
|
3108
3670
|
|
3109
3671
|
# Specify the page layout to be used when the document is opened.
|
3110
3672
|
#
|
3111
|
-
# * +
|
3673
|
+
# * +layout+ - Allowed values are single-page, one-column, two-column-left, two-column-right.
|
3112
3674
|
# * *Returns* - The converter object.
|
3113
|
-
def setPageLayout(
|
3114
|
-
unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(
|
3115
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3675
|
+
def setPageLayout(layout)
|
3676
|
+
unless /(?i)^(single-page|one-column|two-column-left|two-column-right)$/.match(layout)
|
3677
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(layout, "setPageLayout", "pdf-to-pdf", "Allowed values are single-page, one-column, two-column-left, two-column-right.", "set_page_layout"), 470);
|
3116
3678
|
end
|
3117
3679
|
|
3118
|
-
@fields['page_layout'] =
|
3680
|
+
@fields['page_layout'] = layout
|
3119
3681
|
self
|
3120
3682
|
end
|
3121
3683
|
|
3122
3684
|
# Specify how the document should be displayed when opened.
|
3123
3685
|
#
|
3124
|
-
# * +
|
3686
|
+
# * +mode+ - Allowed values are full-screen, thumbnails, outlines.
|
3125
3687
|
# * *Returns* - The converter object.
|
3126
|
-
def setPageMode(
|
3127
|
-
unless /(?i)^(full-screen|thumbnails|outlines)$/.match(
|
3128
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3688
|
+
def setPageMode(mode)
|
3689
|
+
unless /(?i)^(full-screen|thumbnails|outlines)$/.match(mode)
|
3690
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(mode, "setPageMode", "pdf-to-pdf", "Allowed values are full-screen, thumbnails, outlines.", "set_page_mode"), 470);
|
3129
3691
|
end
|
3130
3692
|
|
3131
|
-
@fields['page_mode'] =
|
3693
|
+
@fields['page_mode'] = mode
|
3132
3694
|
self
|
3133
3695
|
end
|
3134
3696
|
|
3135
3697
|
# Specify how the page should be displayed when opened.
|
3136
3698
|
#
|
3137
|
-
# * +
|
3699
|
+
# * +zoom_type+ - Allowed values are fit-width, fit-height, fit-page.
|
3138
3700
|
# * *Returns* - The converter object.
|
3139
|
-
def setInitialZoomType(
|
3140
|
-
unless /(?i)^(fit-width|fit-height|fit-page)$/.match(
|
3141
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3701
|
+
def setInitialZoomType(zoom_type)
|
3702
|
+
unless /(?i)^(fit-width|fit-height|fit-page)$/.match(zoom_type)
|
3703
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom_type, "setInitialZoomType", "pdf-to-pdf", "Allowed values are fit-width, fit-height, fit-page.", "set_initial_zoom_type"), 470);
|
3142
3704
|
end
|
3143
3705
|
|
3144
|
-
@fields['initial_zoom_type'] =
|
3706
|
+
@fields['initial_zoom_type'] = zoom_type
|
3145
3707
|
self
|
3146
3708
|
end
|
3147
3709
|
|
3148
3710
|
# Display the specified page when the document is opened.
|
3149
3711
|
#
|
3150
|
-
# * +
|
3712
|
+
# * +page+ - Must be a positive integer number.
|
3151
3713
|
# * *Returns* - The converter object.
|
3152
|
-
def setInitialPage(
|
3153
|
-
if (!(Integer(
|
3154
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3714
|
+
def setInitialPage(page)
|
3715
|
+
if (!(Integer(page) > 0))
|
3716
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(page, "setInitialPage", "pdf-to-pdf", "Must be a positive integer number.", "set_initial_page"), 470);
|
3155
3717
|
end
|
3156
3718
|
|
3157
|
-
@fields['initial_page'] =
|
3719
|
+
@fields['initial_page'] = page
|
3158
3720
|
self
|
3159
3721
|
end
|
3160
3722
|
|
3161
3723
|
# Specify the initial page zoom in percents when the document is opened.
|
3162
3724
|
#
|
3163
|
-
# * +
|
3725
|
+
# * +zoom+ - Must be a positive integer number.
|
3164
3726
|
# * *Returns* - The converter object.
|
3165
|
-
def setInitialZoom(
|
3166
|
-
if (!(Integer(
|
3167
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
3727
|
+
def setInitialZoom(zoom)
|
3728
|
+
if (!(Integer(zoom) > 0))
|
3729
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(zoom, "setInitialZoom", "pdf-to-pdf", "Must be a positive integer number.", "set_initial_zoom"), 470);
|
3168
3730
|
end
|
3169
3731
|
|
3170
|
-
@fields['initial_zoom'] =
|
3732
|
+
@fields['initial_zoom'] = zoom
|
3171
3733
|
self
|
3172
3734
|
end
|
3173
3735
|
|
3174
3736
|
# Specify whether to hide the viewer application's tool bars when the document is active.
|
3175
3737
|
#
|
3176
|
-
# * +
|
3738
|
+
# * +value+ - Set to true to hide tool bars.
|
3177
3739
|
# * *Returns* - The converter object.
|
3178
|
-
def setHideToolbar(
|
3179
|
-
@fields['hide_toolbar'] =
|
3740
|
+
def setHideToolbar(value)
|
3741
|
+
@fields['hide_toolbar'] = value
|
3180
3742
|
self
|
3181
3743
|
end
|
3182
3744
|
|
3183
3745
|
# Specify whether to hide the viewer application's menu bar when the document is active.
|
3184
3746
|
#
|
3185
|
-
# * +
|
3747
|
+
# * +value+ - Set to true to hide the menu bar.
|
3186
3748
|
# * *Returns* - The converter object.
|
3187
|
-
def setHideMenubar(
|
3188
|
-
@fields['hide_menubar'] =
|
3749
|
+
def setHideMenubar(value)
|
3750
|
+
@fields['hide_menubar'] = value
|
3189
3751
|
self
|
3190
3752
|
end
|
3191
3753
|
|
3192
3754
|
# Specify whether to hide user interface elements in the document's window (such as scroll bars and navigation controls), leaving only the document's contents displayed.
|
3193
3755
|
#
|
3194
|
-
# * +
|
3756
|
+
# * +value+ - Set to true to hide ui elements.
|
3195
3757
|
# * *Returns* - The converter object.
|
3196
|
-
def setHideWindowUi(
|
3197
|
-
@fields['hide_window_ui'] =
|
3758
|
+
def setHideWindowUi(value)
|
3759
|
+
@fields['hide_window_ui'] = value
|
3198
3760
|
self
|
3199
3761
|
end
|
3200
3762
|
|
3201
3763
|
# Specify whether to resize the document's window to fit the size of the first displayed page.
|
3202
3764
|
#
|
3203
|
-
# * +
|
3765
|
+
# * +value+ - Set to true to resize the window.
|
3204
3766
|
# * *Returns* - The converter object.
|
3205
|
-
def setFitWindow(
|
3206
|
-
@fields['fit_window'] =
|
3767
|
+
def setFitWindow(value)
|
3768
|
+
@fields['fit_window'] = value
|
3207
3769
|
self
|
3208
3770
|
end
|
3209
3771
|
|
3210
3772
|
# Specify whether to position the document's window in the center of the screen.
|
3211
3773
|
#
|
3212
|
-
# * +
|
3774
|
+
# * +value+ - Set to true to center the window.
|
3213
3775
|
# * *Returns* - The converter object.
|
3214
|
-
def setCenterWindow(
|
3215
|
-
@fields['center_window'] =
|
3776
|
+
def setCenterWindow(value)
|
3777
|
+
@fields['center_window'] = value
|
3216
3778
|
self
|
3217
3779
|
end
|
3218
3780
|
|
3219
3781
|
# Specify whether the window's title bar should display the document title. If false , the title bar should instead display the name of the PDF file containing the document.
|
3220
3782
|
#
|
3221
|
-
# * +
|
3783
|
+
# * +value+ - Set to true to display the title.
|
3222
3784
|
# * *Returns* - The converter object.
|
3223
|
-
def setDisplayTitle(
|
3224
|
-
@fields['display_title'] =
|
3785
|
+
def setDisplayTitle(value)
|
3786
|
+
@fields['display_title'] = value
|
3225
3787
|
self
|
3226
3788
|
end
|
3227
3789
|
|
3228
3790
|
# Set the predominant reading order for text to right-to-left. This option has no direct effect on the document's contents or page numbering but can be used to determine the relative positioning of pages when displayed side by side or printed n-up
|
3229
3791
|
#
|
3230
|
-
# * +
|
3792
|
+
# * +value+ - Set to true to set right-to-left reading order.
|
3231
3793
|
# * *Returns* - The converter object.
|
3232
|
-
def setRightToLeft(
|
3233
|
-
@fields['right_to_left'] =
|
3794
|
+
def setRightToLeft(value)
|
3795
|
+
@fields['right_to_left'] = value
|
3234
3796
|
self
|
3235
3797
|
end
|
3236
3798
|
|
3237
3799
|
# 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.
|
3238
3800
|
#
|
3239
|
-
# * +
|
3801
|
+
# * +value+ - Set to true to enable the debug logging.
|
3240
3802
|
# * *Returns* - The converter object.
|
3241
|
-
def setDebugLog(
|
3242
|
-
@fields['debug_log'] =
|
3803
|
+
def setDebugLog(value)
|
3804
|
+
@fields['debug_log'] = value
|
3243
3805
|
self
|
3244
3806
|
end
|
3245
3807
|
|
@@ -3282,6 +3844,12 @@ module Pdfcrowd
|
|
3282
3844
|
return @helper.getOutputSize()
|
3283
3845
|
end
|
3284
3846
|
|
3847
|
+
# Get the version details.
|
3848
|
+
# * *Returns* - API version, converter version, and client version.
|
3849
|
+
def getVersion()
|
3850
|
+
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
3851
|
+
end
|
3852
|
+
|
3285
3853
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
3286
3854
|
#
|
3287
3855
|
# * +tag+ - A string with the custom tag.
|
@@ -3291,21 +3859,35 @@ module Pdfcrowd
|
|
3291
3859
|
self
|
3292
3860
|
end
|
3293
3861
|
|
3862
|
+
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
3863
|
+
#
|
3864
|
+
# * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
|
3865
|
+
# * *Returns* - The converter object.
|
3866
|
+
def setConverterVersion(version)
|
3867
|
+
unless /(?i)^(latest|20.10|18.10)$/.match(version)
|
3868
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "pdf-to-pdf", "Allowed values are latest, 20.10, 18.10.", "set_converter_version"), 470);
|
3869
|
+
end
|
3870
|
+
|
3871
|
+
@helper.setConverterVersion(version)
|
3872
|
+
self
|
3873
|
+
end
|
3874
|
+
|
3294
3875
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
3876
|
+
# Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
|
3295
3877
|
#
|
3296
|
-
# * +
|
3878
|
+
# * +value+ - Set to true to use HTTP.
|
3297
3879
|
# * *Returns* - The converter object.
|
3298
|
-
def setUseHttp(
|
3299
|
-
@helper.setUseHttp(
|
3880
|
+
def setUseHttp(value)
|
3881
|
+
@helper.setUseHttp(value)
|
3300
3882
|
self
|
3301
3883
|
end
|
3302
3884
|
|
3303
|
-
# Set a custom user agent HTTP header. It can be
|
3885
|
+
# Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
|
3304
3886
|
#
|
3305
|
-
# * +
|
3887
|
+
# * +agent+ - The user agent string.
|
3306
3888
|
# * *Returns* - The converter object.
|
3307
|
-
def setUserAgent(
|
3308
|
-
@helper.setUserAgent(
|
3889
|
+
def setUserAgent(agent)
|
3890
|
+
@helper.setUserAgent(agent)
|
3309
3891
|
self
|
3310
3892
|
end
|
3311
3893
|
|
@@ -3323,10 +3905,10 @@ module Pdfcrowd
|
|
3323
3905
|
|
3324
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.
|
3325
3907
|
#
|
3326
|
-
# * +
|
3908
|
+
# * +count+ - Number of retries wanted.
|
3327
3909
|
# * *Returns* - The converter object.
|
3328
|
-
def setRetryCount(
|
3329
|
-
@helper.setRetryCount(
|
3910
|
+
def setRetryCount(count)
|
3911
|
+
@helper.setRetryCount(count)
|
3330
3912
|
self
|
3331
3913
|
end
|
3332
3914
|
|
@@ -3355,7 +3937,7 @@ module Pdfcrowd
|
|
3355
3937
|
# * *Returns* - Byte array containing the conversion output.
|
3356
3938
|
def convertUrl(url)
|
3357
3939
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
3358
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "
|
3940
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrl", "image-to-pdf", "The supported protocols are http:// and https://.", "convert_url"), 470);
|
3359
3941
|
end
|
3360
3942
|
|
3361
3943
|
@fields['url'] = url
|
@@ -3368,7 +3950,7 @@ module Pdfcrowd
|
|
3368
3950
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
3369
3951
|
def convertUrlToStream(url, out_stream)
|
3370
3952
|
unless /(?i)^https?:\/\/.*$/.match(url)
|
3371
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "url", "image-to-pdf", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
3953
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(url, "convertUrlToStream::url", "image-to-pdf", "The supported protocols are http:// and https://.", "convert_url_to_stream"), 470);
|
3372
3954
|
end
|
3373
3955
|
|
3374
3956
|
@fields['url'] = url
|
@@ -3381,7 +3963,7 @@ module Pdfcrowd
|
|
3381
3963
|
# * +file_path+ - The output file path. The string must not be empty.
|
3382
3964
|
def convertUrlToFile(url, file_path)
|
3383
3965
|
if (!(!file_path.nil? && !file_path.empty?))
|
3384
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "image-to-pdf", "The string must not be empty.", "convert_url_to_file"), 470);
|
3966
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertUrlToFile::file_path", "image-to-pdf", "The string must not be empty.", "convert_url_to_file"), 470);
|
3385
3967
|
end
|
3386
3968
|
|
3387
3969
|
output_file = open(file_path, "wb")
|
@@ -3397,11 +3979,11 @@ module Pdfcrowd
|
|
3397
3979
|
|
3398
3980
|
# Convert a local file.
|
3399
3981
|
#
|
3400
|
-
# * +file+ - The path to a local file to convert. The file
|
3982
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
3401
3983
|
# * *Returns* - Byte array containing the conversion output.
|
3402
3984
|
def convertFile(file)
|
3403
3985
|
if (!(File.file?(file) && !File.zero?(file)))
|
3404
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "
|
3986
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "convertFile", "image-to-pdf", "The file must exist and not be empty.", "convert_file"), 470);
|
3405
3987
|
end
|
3406
3988
|
|
3407
3989
|
@files['file'] = file
|
@@ -3410,11 +3992,11 @@ module Pdfcrowd
|
|
3410
3992
|
|
3411
3993
|
# Convert a local file and write the result to an output stream.
|
3412
3994
|
#
|
3413
|
-
# * +file+ - The path to a local file to convert. The file
|
3995
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
3414
3996
|
# * +out_stream+ - The output stream that will contain the conversion output.
|
3415
3997
|
def convertFileToStream(file, out_stream)
|
3416
3998
|
if (!(File.file?(file) && !File.zero?(file)))
|
3417
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file, "file", "image-to-pdf", "The file must exist and not be empty.", "convert_file_to_stream"), 470);
|
3999
|
+
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);
|
3418
4000
|
end
|
3419
4001
|
|
3420
4002
|
@files['file'] = file
|
@@ -3423,11 +4005,11 @@ module Pdfcrowd
|
|
3423
4005
|
|
3424
4006
|
# Convert a local file and write the result to a local file.
|
3425
4007
|
#
|
3426
|
-
# * +file+ - The path to a local file to convert. The file
|
4008
|
+
# * +file+ - The path to a local file to convert. The file must exist and not be empty.
|
3427
4009
|
# * +file_path+ - The output file path. The string must not be empty.
|
3428
4010
|
def convertFileToFile(file, file_path)
|
3429
4011
|
if (!(!file_path.nil? && !file_path.empty?))
|
3430
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "image-to-pdf", "The string must not be empty.", "convert_file_to_file"), 470);
|
4012
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertFileToFile::file_path", "image-to-pdf", "The string must not be empty.", "convert_file_to_file"), 470);
|
3431
4013
|
end
|
3432
4014
|
|
3433
4015
|
output_file = open(file_path, "wb")
|
@@ -3465,7 +4047,7 @@ module Pdfcrowd
|
|
3465
4047
|
# * +file_path+ - The output file path. The string must not be empty.
|
3466
4048
|
def convertRawDataToFile(data, file_path)
|
3467
4049
|
if (!(!file_path.nil? && !file_path.empty?))
|
3468
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "file_path", "image-to-pdf", "The string must not be empty.", "convert_raw_data_to_file"), 470);
|
4050
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertRawDataToFile::file_path", "image-to-pdf", "The string must not be empty.", "convert_raw_data_to_file"), 470);
|
3469
4051
|
end
|
3470
4052
|
|
3471
4053
|
output_file = open(file_path, "wb")
|
@@ -3479,6 +4061,44 @@ module Pdfcrowd
|
|
3479
4061
|
end
|
3480
4062
|
end
|
3481
4063
|
|
4064
|
+
# Convert an input stream.
|
4065
|
+
#
|
4066
|
+
# * +in_stream+ - The input stream with the source data.
|
4067
|
+
# * *Returns* - Byte array containing the conversion output.
|
4068
|
+
def convertStream(in_stream)
|
4069
|
+
@raw_data['stream'] = in_stream.read
|
4070
|
+
@helper.post(@fields, @files, @raw_data)
|
4071
|
+
end
|
4072
|
+
|
4073
|
+
# Convert an input stream and write the result to an output stream.
|
4074
|
+
#
|
4075
|
+
# * +in_stream+ - The input stream with the source data.
|
4076
|
+
# * +out_stream+ - The output stream that will contain the conversion output.
|
4077
|
+
def convertStreamToStream(in_stream, out_stream)
|
4078
|
+
@raw_data['stream'] = in_stream.read
|
4079
|
+
@helper.post(@fields, @files, @raw_data, out_stream)
|
4080
|
+
end
|
4081
|
+
|
4082
|
+
# Convert an input stream and write the result to a local file.
|
4083
|
+
#
|
4084
|
+
# * +in_stream+ - The input stream with the source data.
|
4085
|
+
# * +file_path+ - The output file path. The string must not be empty.
|
4086
|
+
def convertStreamToFile(in_stream, file_path)
|
4087
|
+
if (!(!file_path.nil? && !file_path.empty?))
|
4088
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(file_path, "convertStreamToFile::file_path", "image-to-pdf", "The string must not be empty.", "convert_stream_to_file"), 470);
|
4089
|
+
end
|
4090
|
+
|
4091
|
+
output_file = open(file_path, "wb")
|
4092
|
+
begin
|
4093
|
+
convertStreamToStream(in_stream, output_file)
|
4094
|
+
output_file.close()
|
4095
|
+
rescue Error => why
|
4096
|
+
output_file.close()
|
4097
|
+
FileUtils.rm(file_path)
|
4098
|
+
raise
|
4099
|
+
end
|
4100
|
+
end
|
4101
|
+
|
3482
4102
|
# Resize the image.
|
3483
4103
|
#
|
3484
4104
|
# * +resize+ - The resize percentage or new image dimensions.
|
@@ -3499,10 +4119,10 @@ module Pdfcrowd
|
|
3499
4119
|
|
3500
4120
|
# 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.
|
3501
4121
|
#
|
3502
|
-
# * +
|
4122
|
+
# * +value+ - Set to true to enable the debug logging.
|
3503
4123
|
# * *Returns* - The converter object.
|
3504
|
-
def setDebugLog(
|
3505
|
-
@fields['debug_log'] =
|
4124
|
+
def setDebugLog(value)
|
4125
|
+
@fields['debug_log'] = value
|
3506
4126
|
self
|
3507
4127
|
end
|
3508
4128
|
|
@@ -3539,6 +4159,12 @@ module Pdfcrowd
|
|
3539
4159
|
return @helper.getOutputSize()
|
3540
4160
|
end
|
3541
4161
|
|
4162
|
+
# Get the version details.
|
4163
|
+
# * *Returns* - API version, converter version, and client version.
|
4164
|
+
def getVersion()
|
4165
|
+
return "client " + CLIENT_VERSION + ", API v2, converter " + @helper.getConverterVersion()
|
4166
|
+
end
|
4167
|
+
|
3542
4168
|
# Tag the conversion with a custom value. The tag is used in conversion statistics. A value longer than 32 characters is cut off.
|
3543
4169
|
#
|
3544
4170
|
# * +tag+ - A string with the custom tag.
|
@@ -3550,45 +4176,59 @@ module Pdfcrowd
|
|
3550
4176
|
|
3551
4177
|
# 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.
|
3552
4178
|
#
|
3553
|
-
# * +
|
4179
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
3554
4180
|
# * *Returns* - The converter object.
|
3555
|
-
def setHttpProxy(
|
3556
|
-
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(
|
3557
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
4181
|
+
def setHttpProxy(proxy)
|
4182
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
4183
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpProxy", "image-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_http_proxy"), 470);
|
3558
4184
|
end
|
3559
4185
|
|
3560
|
-
@fields['http_proxy'] =
|
4186
|
+
@fields['http_proxy'] = proxy
|
3561
4187
|
self
|
3562
4188
|
end
|
3563
4189
|
|
3564
4190
|
# 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.
|
3565
4191
|
#
|
3566
|
-
# * +
|
4192
|
+
# * +proxy+ - The value must have format DOMAIN_OR_IP_ADDRESS:PORT.
|
4193
|
+
# * *Returns* - The converter object.
|
4194
|
+
def setHttpsProxy(proxy)
|
4195
|
+
unless /(?i)^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z0-9]{1,}:\d+$/.match(proxy)
|
4196
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(proxy, "setHttpsProxy", "image-to-pdf", "The value must have format DOMAIN_OR_IP_ADDRESS:PORT.", "set_https_proxy"), 470);
|
4197
|
+
end
|
4198
|
+
|
4199
|
+
@fields['https_proxy'] = proxy
|
4200
|
+
self
|
4201
|
+
end
|
4202
|
+
|
4203
|
+
# Set the converter version. Different versions may produce different output. Choose which one provides the best output for your case.
|
4204
|
+
#
|
4205
|
+
# * +version+ - The version identifier. Allowed values are latest, 20.10, 18.10.
|
3567
4206
|
# * *Returns* - The converter object.
|
3568
|
-
def
|
3569
|
-
unless /(?i)^(
|
3570
|
-
raise Error.new(Pdfcrowd.create_invalid_value_message(
|
4207
|
+
def setConverterVersion(version)
|
4208
|
+
unless /(?i)^(latest|20.10|18.10)$/.match(version)
|
4209
|
+
raise Error.new(Pdfcrowd.create_invalid_value_message(version, "setConverterVersion", "image-to-pdf", "Allowed values are latest, 20.10, 18.10.", "set_converter_version"), 470);
|
3571
4210
|
end
|
3572
4211
|
|
3573
|
-
@
|
4212
|
+
@helper.setConverterVersion(version)
|
3574
4213
|
self
|
3575
4214
|
end
|
3576
4215
|
|
3577
4216
|
# Specifies if the client communicates over HTTP or HTTPS with Pdfcrowd API.
|
4217
|
+
# Warning: Using HTTP is insecure as data sent over HTTP is not encrypted. Enable this option only if you know what you are doing.
|
3578
4218
|
#
|
3579
|
-
# * +
|
4219
|
+
# * +value+ - Set to true to use HTTP.
|
3580
4220
|
# * *Returns* - The converter object.
|
3581
|
-
def setUseHttp(
|
3582
|
-
@helper.setUseHttp(
|
4221
|
+
def setUseHttp(value)
|
4222
|
+
@helper.setUseHttp(value)
|
3583
4223
|
self
|
3584
4224
|
end
|
3585
4225
|
|
3586
|
-
# Set a custom user agent HTTP header. It can be
|
4226
|
+
# Set a custom user agent HTTP header. It can be useful if you are behind some proxy or firewall.
|
3587
4227
|
#
|
3588
|
-
# * +
|
4228
|
+
# * +agent+ - The user agent string.
|
3589
4229
|
# * *Returns* - The converter object.
|
3590
|
-
def setUserAgent(
|
3591
|
-
@helper.setUserAgent(
|
4230
|
+
def setUserAgent(agent)
|
4231
|
+
@helper.setUserAgent(agent)
|
3592
4232
|
self
|
3593
4233
|
end
|
3594
4234
|
|
@@ -3606,10 +4246,10 @@ module Pdfcrowd
|
|
3606
4246
|
|
3607
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.
|
3608
4248
|
#
|
3609
|
-
# * +
|
4249
|
+
# * +count+ - Number of retries wanted.
|
3610
4250
|
# * *Returns* - The converter object.
|
3611
|
-
def setRetryCount(
|
3612
|
-
@helper.setRetryCount(
|
4251
|
+
def setRetryCount(count)
|
4252
|
+
@helper.setRetryCount(count)
|
3613
4253
|
self
|
3614
4254
|
end
|
3615
4255
|
|