View Issue Details

IDProjectCategoryView StatusLast Update
0013241ScribusPDFpublic2015-11-22 13:56
Reporterwilliam Assigned Tojghali  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformx86_64OSFedora LinuxOS Version20
Product Version1.5.0 
Fixed in Version1.5.1svn 
Summary0013241: Scribus 1.5.1 writes invalid PDF hex strings
DescriptionPDF hex strings should contain only hex (0-9, A-F, a-f).
When Scribus writes long hex strings, it wraps them with a backslash and newline.

When poppler-based utilities read the PDF, they report warnings like the one below. Hex 5C = decimal 92 = the ascii code for a backslash.
Syntax Error (483): Illegal character <5c> in hex string

When ghostscript pdf2ps reads the PDF, it aborts with
**** Error reading a content stream. The page may be incomplete.
Steps To ReproduceTo reproduce the error, open a document in Scribus 1.5.1 and use
  File -> Document Setup -> Document Information
change the Title to something long (over 80 characters), then use
  File -> Export -> Save as PDF
Additional InformationHere is what happens:

scribus/pdflib_core.cpp
PDFLibCore::PDF_Begin_MetadataAndEncrypt() runs
if ((PDF_IsPDFX()) && (docTitle.isEmpty()))
  PutDoc("/Title " + EncStringUTF16(doc.DocName, writer.InfoObj) + "\n");
else
  PutDoc("/Title " + EncStringUTF16(doc.documentInfo().title(), writer.InfoObj) + "\n");

scribus/pdflib_core.cpp
PDFLibCore::EncStringUTF16() runs
  Pdf::toHexString(writer.encryptBytes(us, ObjNum));
  (Scribus 1.4 uses "<"+String2Hex(&uk, false)+">" which writes straight hex with no \ or nl)

scribus/pdfwriter.cpp
toHexString(QByteArray s) runs
  if (i % linelength == linelength-1)
    result.append("\\\n");
TagsNo tags attached.
PatchYes

Activities

william

2015-07-18 05:05

updater  

scribus15-hex-20150718-004651.patch (537 bytes)   
--- scribus15/scribus/pdfwriter.cpp-	2015-06-17 14:44:43.948020830 -0400
+++ scribus15/scribus/pdfwriter.cpp	2015-07-17 21:42:49.212222391 -0400
@@ -339,15 +339,12 @@
 	
 	QByteArray toHexString(QByteArray s)
 	{
-		int linelength = 80;
 		QByteArray result("<");
 		for (int i = 0; i < s.length(); ++i)
 		{
 			uchar v = s[i];
 			result.append("0123456789ABCDEF"[v / 16]);
 			result.append("0123456789ABCDEF"[v % 16]);
-			if (i % linelength == linelength-1)
-				result.append("\\\n");
 		}
 		result.append(">");
 		return result;

william

2015-07-18 05:05

updater  

titletest.sla (13,666 bytes)

william

2015-07-18 05:06

updater   ~0035825

The attached titletest.sla is a Scribus 1.5.1 document with a long title that shows the problem when you export it to PDF.

william

2015-07-18 05:26

updater  

scribus15-hex-20150718-012506.patch (399 bytes)   
--- scribus15/scribus/pdfwriter.cpp-	2015-06-17 14:44:43.948020830 -0400
+++ scribus15/scribus/pdfwriter.cpp	2015-07-18 01:21:52.532662287 -0400
@@ -347,7 +347,7 @@
 			result.append("0123456789ABCDEF"[v / 16]);
 			result.append("0123456789ABCDEF"[v % 16]);
 			if (i % linelength == linelength-1)
-				result.append("\\\n");
+				result.append("\n");
 		}
 		result.append(">");
 		return result;

william

2015-07-18 05:28

updater   ~0035826

The second patch scribus15-hex-20150718-012506.patch only changes the backslash+nl to a nl.

Kunda

2015-07-18 13:45

updater   ~0035828

Great report. Thanks for submitting! :)

jghali

2015-07-18 18:47

administrator   ~0035839

Patch applied, thanks!

Kunda

2015-07-22 15:24

updater   ~0035860

Patch applied in r20262. Thanks William and Jghali!

Issue History

Date Modified Username Field Change
2015-07-18 05:05 william New Issue
2015-07-18 05:05 william File Added: scribus15-hex-20150718-004651.patch
2015-07-18 05:05 william File Added: titletest.sla
2015-07-18 05:06 william Note Added: 0035825
2015-07-18 05:26 william File Added: scribus15-hex-20150718-012506.patch
2015-07-18 05:28 william Note Added: 0035826
2015-07-18 13:45 Kunda Note Added: 0035828
2015-07-18 18:47 jghali Note Added: 0035839
2015-07-18 18:47 jghali Status new => resolved
2015-07-18 18:47 jghali Fixed in Version => 1.5.1svn
2015-07-18 18:47 jghali Resolution open => fixed
2015-07-18 18:47 jghali Assigned To => jghali
2015-07-22 15:24 Kunda Note Added: 0035860
2015-07-22 15:24 Kunda Status resolved => closed
2015-11-22 13:56 jghali Summary [patch] Scribus 1.5.1 writes invalid PDF hex strings => Scribus 1.5.1 writes invalid PDF hex strings