From e42f4ae38eb915bcad21bd6a15bc7dadb5dfb6c1 Mon Sep 17 00:00:00 2001 From: Qingping Hou Date: Fri, 2 Mar 2012 13:27:44 +0800 Subject: [PATCH] mod: bug fix in reading TOC change misplaced carriage ret characters (0x0d) in toc entry to white space (0x20) to avoid displaying empty boxes. --- pdf.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pdf.c b/pdf.c index 15c6d3f8a..c375f93e1 100644 --- a/pdf.c +++ b/pdf.c @@ -104,6 +104,17 @@ static int walkTableOfContent(lua_State *L, fz_outline* ol, int *count, int dept lua_pushnumber(L, depth); lua_settable(L, -3); lua_pushstring(L, "title"); + + /* workaround for misplaced carriage ret in toc entry */ + int i = 0; + while (ol->title[i]) { + if (ol->title[i] == 0x0d) { + ol->title[i] = ' '; + } + /*printf("%x|", ol->title[i]);*/ + i++; + } + lua_pushstring(L, ol->title); lua_settable(L, -3);