From ff5c5da9c6680c1bfc9a91e7359b171bee735fab Mon Sep 17 00:00:00 2001 From: John Whitington Date: Thu, 19 May 2022 17:15:08 +0100 Subject: [PATCH] Allows \n in custom fonts, by reordering in add-text --- cpdfaddtext.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpdfaddtext.ml b/cpdfaddtext.ml index 0601b60..09bc1cd 100644 --- a/cpdfaddtext.ml +++ b/cpdfaddtext.ml @@ -491,8 +491,9 @@ let end | _ -> failwith "addtext: font dictionary not present" in - let text = if raw then text else charcodes_of_utf8 (Pdftext.read_font pdf fontpdfobj) text in + (* 19th May 2022. Reversed the phase order (split first, then get charcodes. This allows \n in custom fonts. *) let lines = map unescape_string (split_at_newline text) in + let lines = map (fun text -> if raw then text else charcodes_of_utf8 (Pdftext.read_font pdf fontpdfobj) text) lines in let pdf = ref pdf in let voffset = let open Cpdfposition in