The attached one-page document (generated with TexLive 2011 by an Okular user) 
labels its only page with the unicode string "1" <FEFF0031>.
In qt4, Page::label() returns a QString containing "1\0" (i.e. 2 character 
long with a NUL character at the end). I haven't tested, but I think the same 
goes for the other frontends.

I think that the issue is in PageLabelInfo::indexToLabel, because it's here 
where the extra NUL is appended.
This extra NUL seems to be wrong, because GooStrings are not NUL terminated in 
the non-unicode case.
It also confuses Okular, making it assume that page labels differ from page 
indices.

I'm attaching a patch that removes the NUL at the end.

Attachment: example.pdf
Description: Adobe PDF document

From 43ef31b147d9a2315ae86ab9ad7fd5370b428d5a Mon Sep 17 00:00:00 2001
From: Fabio D'Urso <[email protected]>
Date: Sun, 8 Apr 2012 23:15:15 +0200
Subject: [PATCH] FIX: Do not append a NUL character to Unicode page labels

---
 poppler/PageLabelInfo.cc |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/poppler/PageLabelInfo.cc b/poppler/PageLabelInfo.cc
index 1330988..456db05 100644
--- a/poppler/PageLabelInfo.cc
+++ b/poppler/PageLabelInfo.cc
@@ -352,8 +352,6 @@ GBool PageLabelInfo::indexToLabel(int index, GooString *label)
 	  ucs2_char[1] = number_string.getChar(i);
 	  label->append(ucs2_char, 2);
       }
-      ucs2_char[1] = 0;
-      label->append(ucs2_char, 2);
   } else {
       label->append(&number_string);
   }
-- 
1.7.6.5

_______________________________________________
poppler mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/poppler

Reply via email to