Changed multiline text support to deal properly with double backslashes, for example '\\\\n' on command line gives '\\n' which should print '\n' not act as a newline
This commit is contained in:
parent
97928bc5a0
commit
c02f47cf4f
9
cpdf.ml
9
cpdf.ml
|
@ -1707,6 +1707,7 @@ let addtext
|
||||||
let split_at_newline t =
|
let split_at_newline t =
|
||||||
let rec split_at_newline_inner prev = function
|
let rec split_at_newline_inner prev = function
|
||||||
| [] -> rev (map implode (map rev prev))
|
| [] -> rev (map implode (map rev prev))
|
||||||
|
| '\\'::'\\'::'n'::t -> split_at_newline_inner (('n'::'\\'::'\\'::hd prev)::tl prev) t
|
||||||
| '\\'::'n'::t -> split_at_newline_inner ([]::prev) t
|
| '\\'::'n'::t -> split_at_newline_inner ([]::prev) t
|
||||||
| h::t -> split_at_newline_inner ((h::hd prev)::tl prev) t
|
| h::t -> split_at_newline_inner ((h::hd prev)::tl prev) t
|
||||||
in
|
in
|
||||||
|
@ -1716,7 +1717,8 @@ let rec unescape_chars prev = function
|
||||||
| [] -> rev prev
|
| [] -> rev prev
|
||||||
| '\\'::('0'..'9' as a)::('0'..'9' as b)::('0'..'9' as c)::t ->
|
| '\\'::('0'..'9' as a)::('0'..'9' as b)::('0'..'9' as c)::t ->
|
||||||
let chr = char_of_int (int_of_string ("0o" ^ implode [a;b;c])) in
|
let chr = char_of_int (int_of_string ("0o" ^ implode [a;b;c])) in
|
||||||
unescape_chars (chr::prev) t
|
unescape_chars (chr::prev) t
|
||||||
|
| '\\'::'\\'::t -> unescape_chars ('\\'::prev) t
|
||||||
| '\\'::c::t when c <> 'n' -> unescape_chars (c::prev) t
|
| '\\'::c::t when c <> 'n' -> unescape_chars (c::prev) t
|
||||||
| h::t -> unescape_chars (h::prev) t
|
| h::t -> unescape_chars (h::prev) t
|
||||||
|
|
||||||
|
@ -1753,9 +1755,8 @@ let
|
||||||
flprint "\n";*)
|
flprint "\n";*)
|
||||||
ops_metrics := [];
|
ops_metrics := [];
|
||||||
let text = winansi_of_utf8 text in
|
let text = winansi_of_utf8 text in
|
||||||
let text = unescape_string text in
|
let lines = map unescape_string (split_at_newline text) in
|
||||||
let lines = split_at_newline text
|
let pdf = ref pdf in
|
||||||
and pdf = ref pdf in
|
|
||||||
let voffset =
|
let voffset =
|
||||||
match position with
|
match position with
|
||||||
| Bottom _ | BottomLeft _ | BottomRight _ ->
|
| Bottom _ | BottomLeft _ | BottomRight _ ->
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
(* cpdf command line tools *)
|
(* cpdf command line tools *)
|
||||||
let demo = false
|
let demo = false
|
||||||
and noncomp = true
|
let noncomp = false
|
||||||
and major_version = 1
|
let major_version = 1
|
||||||
and minor_version = 8
|
let minor_version = 8
|
||||||
and version_date = "(unreleased)"
|
let version_date = "(unreleased)"
|
||||||
|
|
||||||
open Pdfutil
|
open Pdfutil
|
||||||
open Pdfio
|
open Pdfio
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
%PDF-1.1
|
||||||
|
%€<>‚ƒ
|
||||||
|
1 0 obj
|
||||||
|
<</Type/Page/Parent 3 0 R/Resources<</Font<</F0<</Type/Font/Subtype/Type1/BaseFont/Times-Italic>>>>>>/MediaBox[0 0 595.275590551 841.88976378]/Rotate 0/Contents[4 0 R]>>
|
||||||
|
endobj
|
||||||
|
2 0 obj
|
||||||
|
<</Type/Catalog/Pages 3 0 R>>
|
||||||
|
endobj
|
||||||
|
3 0 obj
|
||||||
|
<</Type/Pages/Kids[1 0 R]/Count 1>>
|
||||||
|
endobj
|
||||||
|
4 0 obj
|
||||||
|
<</Length 53>>
|
||||||
|
stream
|
||||||
|
1 0 0 1 50 770 cm BT /F0 36 Tf (Hello, World!) Tj ET
|
||||||
|
endstream
|
||||||
|
endobj
|
||||||
|
xref
|
||||||
|
0 5
|
||||||
|
0000000000 65535 f
|
||||||
|
0000000015 00000 n
|
||||||
|
0000000200 00000 n
|
||||||
|
0000000245 00000 n
|
||||||
|
0000000296 00000 n
|
||||||
|
trailer
|
||||||
|
<</Size 5/Root 2 0 R/ID[(Š´DUCâ~b™ÀŒ<C380>X&)(Š´DUCâ~b™ÀŒ<C380>X&)]>>
|
||||||
|
startxref
|
||||||
|
397
|
||||||
|
%%EOF
|
Loading…
Reference in New Issue