Skip to content

Commit c99068f

Browse files
committed
Updated PDFSharp version to 1.5beta3 (partial library set from self-compiled version). Update was required to resolve the issue with transparency blocking PDF/X-1a conversion in Acrobat. Also added logic to remove the alpha channel from images as they are loaded.
1 parent b19e31e commit c99068f

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed
-13 KB
Binary file not shown.
-48.5 KB
Binary file not shown.
0 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

PdfConstruct/PdfConstructForm.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,16 @@
2626
using System.Collections.Generic;
2727
using System.Drawing;
2828
using System.Drawing.Imaging;
29+
using System.IO;
30+
using System.Linq;
2931
using System.Text;
3032
using System.Threading;
3133
using System.Windows.Forms;
3234
using PdfConstruct.DataObjects;
35+
using PdfConstruct.Properties;
3336
using PdfSharp.Pdf;
3437
using PdfSharp.Drawing;
38+
using PdfSharp.Pdf.Advanced;
3539
using Support.IO;
3640
using Support.UI;
3741

@@ -237,8 +241,10 @@ private void listViewCards_KeyDown(object sender, KeyEventArgs e)
237241
private void ExportThread(object zParam)
238242
{
239243
var zDocument = new PdfDocument();
244+
zDocument.Options.ColorMode = PdfColorMode.Undefined;
245+
//zDocument.Options.NoCompression = true;
240246

241-
List<string> listFiles = (List<string>)zParam;
247+
var listFiles = (List<string>)zParam;
242248
Func<decimal> funcGetDpi = () => numericDPI.Value;
243249
Func<string> funcGetOutputPath = () => txtOutputPath.Text;
244250

@@ -249,26 +255,28 @@ private void ExportThread(object zParam)
249255
{
250256
var zImgSrc = Image.FromFile(sFile);
251257

252-
#if false
258+
// wipe out any transparency on the images
253259
var zImgDestination = new Bitmap(zImgSrc.Width, zImgSrc.Height, PixelFormat.Format24bppRgb);
254260
var zImageGfx = Graphics.FromImage(zImgDestination);
255261
zImageGfx.Clear(Color.White);
256262
zImageGfx.DrawImage(zImgSrc, 0, 0);
257-
zImgSrc.Dispose();
258-
zImgDestination.Save("C:\\tmp.bmp", ImageFormat.Bmp);
259-
zImgDestination.Dispose();
260-
zImgSrc = Image.FromFile("C:\\tmp.bmp");
261-
#endif
263+
262264
var zPage = zDocument.AddPage(new PdfPage()
263265
{
264266
Width = XUnit.FromInch((double)zImgSrc.Width / dDPI),
265267
Height = XUnit.FromInch((double)zImgSrc.Height / dDPI)
266268
});
267269
var zGfx = XGraphics.FromPdfPage(zPage);
268-
var zXImage = XImage.FromGdiPlusImage(zImgSrc);
269-
zGfx.DrawImage(zXImage, Point.Empty);
270-
progressBar.InvokeAction(() => progressBar.Value++);
270+
using (var zMem = new MemoryStream())
271+
{
272+
zImgDestination.Save(zMem, ImageFormat.Bmp);
273+
var zXImage = XImage.FromStream(zMem);
274+
zGfx.DrawImage(zXImage, new XPoint());
275+
zXImage.Dispose();
276+
}
277+
zImgDestination.Dispose();
271278
zImgSrc.Dispose();
279+
progressBar.InvokeAction(() => progressBar.Value++);
272280
});
273281
zDocument.Save(sOutputPth);
274282
ConfigureControlState(false);

0 commit comments

Comments
 (0)