PDFsharp & MigraDoc Foundation
https://forum.pdfsharp.net/

PDF File Size
https://forum.pdfsharp.net/viewtopic.php?f=2&t=737
Page 1 of 1

Author:  sarabjs [ Thu May 21, 2009 4:06 am ]
Post subject:  PDF File Size

Hi,

First - Thank You to the authors for putting this library together. Great work!

I'm trying to build a C# application to convert JPEG images into PDF files. It works well. The only issue is that the output PDF file size is around 4-5 times larger than that of the original JPEG.

I searched through this forum, and realized that the default setting in PDF Writer is Verbose, and I need to get a 'Release' build.

So to pick up a copy from the 'Release' build (which should use the Compact setting instead), I opened the PdfSharp project in VS C# Express, and built the solution. This created a Release folder in the bin directory, and a PdfSharp.dll file inside.

Using this new dll however does not change the PDF file sizes. They are exactly the same as they were before:

Original JPEG size - Output PDF size
129KB - 582KB
123KB - 484KB

Any ideas?

Thanks.

Sarab

Author:  Thomas Hoevel [ Mon May 25, 2009 7:44 am ]
Post subject: 

Hi!

I can't explain this because JPEG files are (or at least should be) copied into the PDF file. The PDF file size should be only few kB larger than the JPEG file size.

Author:  sarabjs [ Fri May 29, 2009 11:07 am ]
Post subject: 

Hmm. Could it be that I'm still not using the 'Release' dll ?
Anything else I can do to make sure that's not the case ?

Thanks...

Author:  Thomas Hoevel [ Tue Jun 02, 2009 10:18 am ]
Post subject: 

Are you using the GDI+ build (PDFsharp-VS2008.sln) or the WPF build (PdfSharp-WPF.sln)?

I just noticed that the WPF build treats JPEG images incorrectly. This could explain the increase in size.

Author:  Siva [ Fri Jun 05, 2009 3:27 am ]
Post subject: 

I am hitting the exact same problem. I am using WPF version of it. PdfSharp-WPF.sln.

I spent sometime debugging the problem, looks like the logic of handling Jpeg images in WPF is not working.

In file ximage.cs
string pixelFormat = this.wpfImage.Format.ToString();
switch (pixelFormat)
{
case "Bgr32":
case "Bgra32":
case "Pbgra32":
case "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}": // bmp
case "{B96B3CAF-0728-11D3-9D7B-0000F81EF32E}": // png
this.format = XImageFormat.Png;
break;

Even for jpeg it is getting png.


Can I get a fix for this?

Author:  Siva [ Fri Jun 05, 2009 4:27 pm ]
Post subject: 

I changed to use the non WPF version and it is working great. I will switch to WPF version once it is fixed. Also I noticed that WPF version does not load multi page tiff files. I did not do much research though.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/