We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Page Extract Performance

I have a class that extracts a page from a PDF file, rotates the page, and hands a memorystream back to the caller. I am finding that the initial call to perform the extract/rotate takes about 1.2 seconds, and subsequent attempts to the same calls take between .07 seconds and .1 seconds. I know I am talking about fractions of a second, but the fractions are noticable in my environment. I have been trying to figure out if there is any way for me to initialize and bring the time delay into the init of my class rather than when a user is trying to actually use the function, but have not had much luck. I have attached the relavent portions of the class. It is more complicated than it needs to be at this point simply becuase I have been trying to pinpoint where I am seeing the performance hit.

Any ideas on how to get this delay to happen on init rather than on the first call to the methods in question? PDF.Kit version is 3.2.0.0.

public class PageManager
{
PdfFileEditor fEdit;
MemoryStream input;
PdfPageEditor pEdit;

///


/// Rotate a pdf page.
///

/// Path and file name to the PDF image.
/// Page number to rotate (1 based).
/// Numeric value for rotation (90, 180, 270).
/// MemoryStream
public MemoryStream RotatePage(String FilePath, Int32 Page, Int32 Rotation)
{
if (input == null)
{
Byte[] inputBytes = File.ReadAllBytes(@FilePath);
input.Write(inputBytes, 0, inputBytes.Length);

input.Seek(0, 0);
}

MemoryStream output = new MemoryStream();
fEdit.Extract(input, new int[] { Page }, output);

pEdit.BindPdf(output);
pEdit.Pages = new Int32[] { 1 };
pEdit.Rotation = Rotation;
pEdit.Save(output);

return output;
}

public PageManager()
{
fEdit = new PdfFileEditor();
input = new MemoryStream();
pEdit = new PdfPageEditor();
}

public PageManager(String FilePath)
{
if (File.Exists(FilePath))
{
fEdit = new PdfFileEditor();
input = new MemoryStream();
pEdit = new PdfPageEditor();

inputBytes = File.ReadAllBytes(@FilePath);
input.Write(inputBytes, 0, inputBytes.Length);


input.Seek(0, 0);
}
}

private Byte[] inputBytes { get; set; }
}

Hi,

We're looking into the matter and will update you the earliest possible.

We are sorry for the inconvenience.

Regards,

Hi,

I have investigated the issue at my end in detail and below are my findings.

First I tested the rotation method using a pdf fild containing only five pages. After initializing the pdf file in the constructor, I made multiple calls to rotate different pages. Each call took 0.01 second. Then, I used a pdf file containing 50 pages and repeated the same process. This time every call took 0.04 seconds. I also tested with other types of files and the time was somewhere between this interval. So, this processing time will depend upon the file size, the number of pages in a pdf file, and the file complexity.

As far moving this processing time to the initialization process is concerned ,I'm afraid, this wouldn't be possible. Because, this time is the core processing overhead which can't be moved somewhere else.

We're sorry for the inconvenience. If you have any further questions or concerns please do let us know.

Regards,