valerybokov commented on pull request #107: URL: https://github.com/apache/pdfbox/pull/107#issuecomment-855732380
> Re PDPageLabels: my understanding of the code is that it removes the 0 bytes at the end, and only these, see https://issues.apache.org/jira/browse/PDFBOX-1047 . The problem string there is <33000000> so there are three 0 bytes. public static void main(String[]args) { //row with null bytes in the center cutNullBytes(new byte[]{ 1,2,3,0,0,0,0,0,5,4,5,4,6,0,0,0}, false);//todo check and change false to true //row without null bytes in the center cutNullBytes(new byte[]{ 1,2,3,5,4,5,4,6,0,0,0}, false);//todo check and change false to true } private static void cutNullBytes(byte[]bytes, boolean useLastIndexOf) { String label = new String(bytes); System.out.println("label length: " + label.length() + " label value: " + label); if (useLastIndexOf) { //slow code while (label.lastIndexOf(0) != -1) { label = label.substring(0, label.length() - 1); } } else { //fast code int index = label.indexOf(0); if (index > -1) label = label.substring(0, index); } System.out.println("label length: " + label.length() + " label value: " + label); } -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
