We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

File Manipulation Increases Size and slows performance.

Thread ID:





51212 Oct 31,2006 03:34 PM UTC Nov 2,2006 01:16 PM UTC WinForms 4
Tags: PDF
Jody Kelsch
Asked On October 31, 2006 03:34 PM UTC

I have an App that Scans documents in as Jpg Files.
I use the DrawImage to draw the image to a pdf.

It Also has a feature to rotate the image in the pdf in case it was scanned upside down.

The steps taken to rotate the image are:

Open the Original PDf File.
Create a new Pdf Object.
Write Each Page of the Original PDF to the New Pdf until I Encounter the page I want to rotate using the DrawPDFTemplate

Use the IPDFGraphicState.Rotate to Rotate the drawing plane.
Draw the Page as rotated.
Rotate the Plane Back to normal.
Continue the write the Pages to the New PDF using the DrawPDFTemplate
Save the New PDf.

The Problem is the rotate takes about 2 seconds and the file size is increased by 3KB

Each time the rotate button is clicked it adds 3KB to the file and takes longer each time 2 sec, then 3 sec, then 4 sec, then 6 seconds.

Is there a memory problem with the DrawPDFTemplate?

I know it is not in the rotate portion because I get the same behavior from when I try to reorder the pages using the same technique only writing page 1 then 2 then 4 then 3 then 5 to the new pdf.

Thank You

Dhivya K [Syncfusion]
Replied On November 1, 2006 09:43 AM UTC

Hi Jody,

Thanks for explaining the issue in detail.
I was able to reproduce the issue. The problem is,when you click the button each time,the page is overlaid on the existing page. DrawPDFTemplate will draw the page on the existing page.Hence each time it increases the size of the document.
However, you can use compress the document after creating it using following statement.

//compress the document
pdfDoc.Compression = CompressionLevel.Best;

However, I was not able to reproduce the second case. I tried creating sample with your specification.

1.Added 1st page then 3rd,then 2nd,then 4th page.
2.Saved the document.
3.Compared the size of the original document with the newly created document.

There seem to be no change in the size.

Here is a sample for your reference:

Please take a look into it and let me know if I am missing something. I guess you have tried this issue with template.I have used Add() method in my sample.
Will it be possible to use this method of importing for other pages other than the page that has to be rotated?This will reduce the size of the document.

Please let me know if you need further assit regarding this issue.


Jody Kelsch
Replied On November 1, 2006 09:23 PM UTC

I tried your sample and it takes your PDF File from 4812 KB to 4816 KB.

I changed my code to use the Add() instead of DrawPDfTemplate, but it seems to have the same problem.

Any suggestions?

Thank You
Jody Kelsch

Administrator [Syncfusion]
Replied On November 1, 2006 09:24 PM UTC

The compression did not seem to do anything either.

Dhivya K [Syncfusion]
Replied On November 2, 2006 01:16 PM UTC

Hi Jody,

Here are some suggestions to reduce the size of the file.

1. As I told you in my previous post, the performance can be improved by using Add() method rather than using templates.

2. To rotate the page that has the image, you can do the following and add them as page itself rather than as template.

//Rotate the page
IPDFPage page = doc.Pages[ 0 ];
page.Rotation = PageRotation.Degree90;
page.Graphics.DrawImage(new PointF(100,400),@path+"Sunset.jpg",new Size(350,300));

3. Also, you can rotate the image and then render that image into PDF document as follows.

//Rotate the image
System.Drawing.Image img= System.Drawing.Image.FromFile(@"../../data/Sunset.jpg");

//Draw the image into the document.
doc.LastPage.Graphics.DrawImage(new PointF(100,400),img,new Size(350,300));

Here is a sample for your reference

These will reduce the size and time when compared to usage of templates.Please take a look into it and let me know if you have anyother queries.

Regarding the compression, the compression type supported by Essential PDF is Zlib Compression.
You can find the change in size of the file based on the content of the PDF document.
ZIP works well on images with large areas of single colors or repeating patterns, such as screen shots and simple images created with paint programs, and for black-and-white images that contain repeating patterns.

Hence in other type of contents, Zlib is lossless and you can not find difference in size.

Please let me know if you have any queries.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon