r13843 by jghali - #8326 : corrupted pdf caused by overwrite of already existing resource

scribus-commit scribus-commit at lists.scribus.net
Wed Aug 26 05:34:14 CEST 2009


Revision: 13843
Author: jghali
Date: 2009-08-11T17:47:59.697726Z
Commit message: #8326 : corrupted pdf caused by overwrite of already existing resource

Changeset: 
M  /branches/Version135/Scribus/scribus/pdflib_core.cpp

Diffs:
Index: scribus/pdflib_core.cpp
===================================================================
--- scribus/pdflib_core.cpp	(revision 13842)
+++ scribus/pdflib_core.cpp	(revision 13843)
@@ -5245,8 +5245,8 @@
 			QMap<QString,SpotC>::Iterator it3sc;
 			if (spotMap.count() != 0)
 			{
-			for (it3sc = spotMap.begin(); it3sc != spotMap.end(); ++it3sc)
-				PutDoc("/"+it3sc.value().ResName+" "+QString::number(it3sc.value().ResNum)+" 0 R\n");
+				for (it3sc = spotMap.begin(); it3sc != spotMap.end(); ++it3sc)
+					PutDoc("/"+it3sc.value().ResName+" "+QString::number(it3sc.value().ResNum)+" 0 R\n");
 			}
 			PutDoc(">>\n");
 		}
@@ -6919,31 +6919,34 @@
 							components = 3;
 						}
 					}
-					PutDoc("<<\n");
-					if ((Options.CompressMethod != PDFOptions::Compression_None) && Options.Compress)
+					if (!ICCProfiles.contains(profInUse))
 					{
-						QByteArray compData = CompressArray(dataP);
-						if (compData.size() > 0)
+						PutDoc("<<\n");
+						if ((Options.CompressMethod != PDFOptions::Compression_None) && Options.Compress)
 						{
-							PutDoc("/Filter /FlateDecode\n");
-							dataP = compData;
+							QByteArray compData = CompressArray(dataP);
+							if (compData.size() > 0)
+							{
+								PutDoc("/Filter /FlateDecode\n");
+								dataP = compData;
+							}
 						}
+						PutDoc("/Length "+QString::number(dataP.size()+1)+"\n");
+						PutDoc("/N "+QString::number(components)+"\n");
+						PutDoc(">>\nstream\n");
+						EncodeArrayToStream(dataP, embeddedProfile);
+						PutDoc("\nendstream\nendobj\n");
+						uint profileResource = newObject();
+						StartObj(profileResource);
+						dataD.ResName = ResNam+QString::number(ResCount);
+						dataD.ICCArray = "[ /ICCBased "+QString::number(embeddedProfile)+" 0 R ]";
+						dataD.ResNum = profileResource;
+						dataD.components = components;
+						ICCProfiles[profInUse] = dataD;
+						PutDoc("[ /ICCBased "+QString::number(embeddedProfile)+" 0 R ]\n");
+						PutDoc("endobj\n");
+						ResCount++;
 					}
-					PutDoc("/Length "+QString::number(dataP.size()+1)+"\n");
-					PutDoc("/N "+QString::number(components)+"\n");
-					PutDoc(">>\nstream\n");
-					EncodeArrayToStream(dataP, embeddedProfile);
-					PutDoc("\nendstream\nendobj\n");
-					uint profileResource = newObject();
-					StartObj(profileResource);
-					dataD.ResName = ResNam+QString::number(ResCount);
-					dataD.ICCArray = "[ /ICCBased "+QString::number(embeddedProfile)+" 0 R ]";
-					dataD.ResNum = profileResource;
-					dataD.components = components;
-					ICCProfiles[profInUse] = dataD;
-					PutDoc("[ /ICCBased "+QString::number(embeddedProfile)+" 0 R ]\n");
-					PutDoc("endobj\n");
-					ResCount++;
 					if (components == 1)
 						hasGrayProfile = true;
 				}




More information about the scribus-commit mailing list