Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Jan 15, 2014 6:36 pm

I scanned 5 sheets and generated 5 PNG files. The size of each one is between 35KB and 37KB. Then, I modified the following code to build a PDF file. Such code was given to me by you as an example about how to create such PDF file, I only changed it a bit to include the correct files. The problem I see is that the size of the generated PDF file is about 4MB and it seems very large to me. Is there a way to decrease it?

Code: Select all
PdfDocument doc = new PdfDocument();

PdfPageBase page;
PdfImage image;

//add png files here
String[] str = new String[] { "pic-1.png", "pic-2.png", "pic-3.png" };

for (int i = 0; i < str.Length; i++)
{
    page = doc.Pages.Add();
    image = PdfImage.FromFile(str[i]);
    float width = image.Width * 1f;
    float height = image.Height * 1f;
    float x = (page.Canvas.ClientSize.Width - width) / 2;

    page.Canvas.DrawImage(image, x, 60, width, height);
}

doc.SaveToFile("Image.pdf");
doc.Close();

JORGEMAL
 
Posts: 9
Joined: Fri Jan 10, 2014 5:18 pm

Thu Jan 16, 2014 1:56 am

Hello,

Thanks for your inquiry.

Would you please provide us your image files if convenience?
Kindly note that please zip before uploading.

Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu Jan 16, 2014 3:15 pm

I am sending the png files and also a new version of the C# code that I found in your program guide section.

Best regards,
Jorge Maldonado

JORGEMAL
 
Posts: 9
Joined: Fri Jan 10, 2014 5:18 pm

Fri Jan 17, 2014 3:21 am

Hello,

Thanks for your information.
We have transferred it to our Dev team, once there are any progress from them, we will inform you at the first time. Sorry for inconvenience.
If there are any questions, welcome to get it back to us.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Wed Feb 05, 2014 5:13 pm

I will very much appreciate if you let me know the status of this issue.

With respect,
Jorge Maldonado

JORGEMAL
 
Posts: 9
Joined: Fri Jan 10, 2014 5:18 pm

Thu Feb 06, 2014 2:44 am

Hello Jorge,

Our Dev team is still fixing, once it is resolved, we will inform you immediately, so sorry for inconvenience.

If there are any questions, welcome to get it back to us.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Wed Apr 09, 2014 9:34 am

I have the same problem, pdf of 3 pages with a png image of 178k on each page and some text that blows up to 6mb.

I'm evaluating the lirabry for purchase but I can't seem to find a way to reduce the size of the document.

Any hint ?

Luca Lusetti

llusetti
 
Posts: 3
Joined: Wed Feb 19, 2014 3:39 pm

Thu Apr 10, 2014 3:13 am

Hello,

Sorry for inconvenience. Our Dev team always improves the performance.If convenient, could you please provide us your document for testing further?
Thanks,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Thu Apr 10, 2014 6:45 am

Here is a zip containing the image used and the pdf output. The code is as follow

Code: Select all
 
        public static void CreatePDF(string imgExt)
        {
            Console.WriteLine("Creating with SPIRE - {0}", imgExt);
            var fileName = string.Format("spire-test-{0}.pdf", imgExt);

            var doc = new PdfDocument(PdfConformanceLevel.Pdf_A1B);
            doc.CompressionLevel = PdfCompressionLevel.Best;

            var margins = new PdfMargins(0);

            var page = doc.Pages.Add(PdfPageSize.A4, margins);

            var pWidth = page.Canvas.ClientSize.Width;
            var pHeight = page.Canvas.ClientSize.Height;


            var img = PdfImage.FromFile(string.Format("01.{0}", imgExt));

            page.Canvas.DrawImage(img, 0, 0, pWidth, pHeight);


            if (File.Exists(fileName))
                File.Delete(fileName);

            doc.SaveToFile(fileName);           
        }

llusetti
 
Posts: 3
Joined: Wed Feb 19, 2014 3:39 pm

Thu Apr 10, 2014 7:54 am

Thanks, once there are any update, we will let you know immediately.

Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Mon Apr 14, 2014 12:27 pm

Hello,
I just wanted to let you know that we went with a different library becasue the size of the PDF really matters and 3 months to solve this problems (first report is of 15 jan from jorgemal) are really too much for us.

Thanks anyway
Luca Lusetti

llusetti
 
Posts: 3
Joined: Wed Feb 19, 2014 3:39 pm

Tue Apr 15, 2014 9:07 am

Hello,

Thanks for the reply.

Sincerely,
Gary
E-iceblue support team
User avatar

Gary.zhang
 
Posts: 1380
Joined: Thu Apr 04, 2013 1:30 am

Tue Sep 01, 2015 6:10 pm

Was there any resolution to this? I am having the same issue. The PdfCompressionLevel does not seam to do anything.

Thank you.

jshade@solsticebenefits.com
 
Posts: 1
Joined: Mon Aug 31, 2015 9:46 pm

Wed Sep 02, 2015 2:45 am

Hello,

Thanks for your inquiry.
Our Dev team is looking into the issue, once it is resolved, we will inform you immediately. So sorry for inconvenience.

Best Regards,
Sweety
E-iceblue support team
User avatar

sweety1
 
Posts: 539
Joined: Wed Mar 11, 2015 1:14 am

Fri Oct 09, 2015 9:12 pm

Was there ever a fix for this? It seems to be related to the question I posted earlier here:

http://www.e-iceblue.com/forum/massive-filesize-increase-problem-t5603.html

This is going to be a huge issue for two of my current projects that I'm planning on using Spire for. If you could address this sooner rather than later it would be greatly appreciated.

Thank you.

MatthewPierce
 
Posts: 22
Joined: Thu Jul 16, 2015 4:45 pm

Return to Spire.PDF