From 454f873b1a388c821e57edf8bfd071057575b56d Mon Sep 17 00:00:00 2001 From: Gerard Gunnewijk Date: Thu, 13 Feb 2025 11:38:01 +0100 Subject: [PATCH] Replace deflate with zlibstream --- src/Synercoding.FileFormats.Pdf/PackageDetails.props | 2 +- src/Synercoding.FileFormats.Pdf/PdfWriter.cs | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Synercoding.FileFormats.Pdf/PackageDetails.props b/src/Synercoding.FileFormats.Pdf/PackageDetails.props index ee3b493..94e8325 100644 --- a/src/Synercoding.FileFormats.Pdf/PackageDetails.props +++ b/src/Synercoding.FileFormats.Pdf/PackageDetails.props @@ -10,7 +10,7 @@ Synercoding.FileFormats.Pdf Synercoding.FileFormats.Pdf Contains classes which makes it easy to quickly create a pdf file. - Added transparent and separation images support. Content streams will be flatedecode encoded. And overprint mode support is added. + Fixed broken zlib stream by removing explicit header and replacing deflate with zlib. diff --git a/src/Synercoding.FileFormats.Pdf/PdfWriter.cs b/src/Synercoding.FileFormats.Pdf/PdfWriter.cs index 4c72d97..40a1163 100644 --- a/src/Synercoding.FileFormats.Pdf/PdfWriter.cs +++ b/src/Synercoding.FileFormats.Pdf/PdfWriter.cs @@ -275,13 +275,10 @@ internal static Stream FlateEncode(Stream inputStream) { var outputStream = new MemoryStream(); - outputStream.WriteByte(0x78); - outputStream.WriteByte(0xDA); - inputStream.Position = 0; - using (var flateStream = new DeflateStream(outputStream, CompressionLevel.SmallestSize, true)) + using (var zlibStream = new ZLibStream(outputStream, CompressionLevel.SmallestSize, true)) { - inputStream.CopyTo(flateStream); + inputStream.CopyTo(zlibStream); } outputStream.Position = 0;