diff --git a/itext.tests/itext.kernel.tests/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest.cs b/itext.tests/itext.kernel.tests/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest.cs index 464d0daa7..cf938b485 100644 --- a/itext.tests/itext.kernel.tests/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest.cs +++ b/itext.tests/itext.kernel.tests/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest.cs @@ -145,7 +145,6 @@ public virtual void InlineImagesTest03() { [NUnit.Framework.Test] public virtual void InlineImagesPngTest() { - //TODO update cmp-files after DEVSIX-3564 will be fixed String filename = "inlineImagePng.pdf"; PdfDocument document = new PdfDocument(CompareTool.CreateTestPdfWriter(destinationFolder + filename)); PdfPage page = document.AddNewPage(); @@ -159,7 +158,6 @@ public virtual void InlineImagesPngTest() { [NUnit.Framework.Test] public virtual void InlineImagesPngErrorWhileOpenTest() { - //TODO update cmp-files after DEVSIX-3564 will be fixed String filename = "inlineImagePngErrorWhileOpen.pdf"; PdfDocument document = new PdfDocument(CompareTool.CreateTestPdfWriter(destinationFolder + filename)); PdfPage page = document.AddNewPage(); diff --git a/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePng.pdf b/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePng.pdf index 402b81c91..650e266b1 100644 Binary files a/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePng.pdf and b/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePng.pdf differ diff --git a/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePngErrorWhileOpen.pdf b/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePngErrorWhileOpen.pdf index 42e92c46a..e61658af1 100644 Binary files a/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePngErrorWhileOpen.pdf and b/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImagePngErrorWhileOpen.pdf differ diff --git a/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages01.pdf b/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages01.pdf index 81f42a914..f7c5bf489 100644 Binary files a/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages01.pdf and b/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages01.pdf differ diff --git a/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages02.pdf b/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages02.pdf index 896fe09ec..ef51a0117 100644 Binary files a/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages02.pdf and b/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages02.pdf differ diff --git a/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages03.pdf b/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages03.pdf index 5d88b57d0..b00d23948 100644 Binary files a/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages03.pdf and b/itext.tests/itext.kernel.tests/resources/itext/kernel/pdf/canvas/PdfCanvasInlineImagesTest/cmp_inlineImages03.pdf differ diff --git a/itext/itext.kernel/itext/kernel/pdf/canvas/PdfCanvas.cs b/itext/itext.kernel/itext/kernel/pdf/canvas/PdfCanvas.cs index c0e19162c..aacc14a43 100644 --- a/itext/itext.kernel/itext/kernel/pdf/canvas/PdfCanvas.cs +++ b/itext/itext.kernel/itext/kernel/pdf/canvas/PdfCanvas.cs @@ -2125,6 +2125,7 @@ protected internal virtual void AddInlineImage(PdfImageXObject imageXObject, flo PdfOutputStream os = contentStream.GetOutputStream(); os.WriteBytes(BI); byte[] imageBytes = imageXObject.GetPdfObject().GetBytes(false); + SaveColorSpaceToPageResourcesIfNeeded(imageXObject.GetPdfObject()); foreach (KeyValuePair entry in imageXObject.GetPdfObject().EntrySet()) { PdfName key = entry.Key; if (!PdfName.Type.Equals(key) && !PdfName.Subtype.Equals(key) && !PdfName.Length.Equals(key)) { @@ -2141,6 +2142,22 @@ protected internal virtual void AddInlineImage(PdfImageXObject imageXObject, flo RestoreState(); } + private void SaveColorSpaceToPageResourcesIfNeeded(PdfStream image) { + PdfObject colorSpace = image.Get(PdfName.ColorSpace); + //The colour space specified by the ColorSpace (or CS) entry shall be one of the standard device colour spaces + //(DeviceGray, DeviceRGB, or DeviceCMYK). + if (colorSpace == null || colorSpace.Equals(PdfName.DeviceGray) || colorSpace.Equals(PdfName.DeviceRGB) || + colorSpace.Equals(PdfName.DeviceCMYK)) { + return; + } + //PDF 1.2: the value of the ColorSpace entry may also be the name of a colour space in the ColorSpace + //subdictionary of the current resource dictionary. In this case, the name may designate any colour space + //that can be used with an image XObject. + PdfName name = resources.AddColorSpace(colorSpace); + image.Remove(PdfName.ColorSpace); + image.Put(PdfName.ColorSpace, name); + } + /// /// Adds /// diff --git a/port-hash b/port-hash index 5b8c1411d..5d4971883 100644 --- a/port-hash +++ b/port-hash @@ -1 +1 @@ -fdf0981cf57bd8f4e1b26df8abe030126ca2a0ac +e441c12a214f5ed043403b9377dc71061e7a0d78