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

Free Support Forum - aspose.com

Converting PDF to PDF performance issues

Hi,

I'm having performance issues when trying to convert PDF to PDF with watermark (PDF with 4 pages takes something like 15 min)
I upgraded the Aspose.PDF .Net from version 5.2.1.0 to version 8.3.0.0

I'm not using a memory stream, I'm using a custom stream, and I noticed that the Read calls thousand times when using BindPDF and something like one hundred thousand times when using "pdfFileSecurity.SetPrivilege" or using "PdfFileInfo" with the stream.

I checked the old Aspose version and I saw that the Read function of the Stream called just a few times.
Can you please help me with this issue?

Here is two examples of how we use it in c#:
(1)
Aspose.Pdf.Facades.PdfConverter converter = new Aspose.Pdf.Facades.PdfConverter();
converter.BindPdf(MyStream);

(2)
PdfFileSecurity pdfFileSecurity = new PdfFileSecurity(myStream, outputMemoryStream);
pdfFileSecurity.SetPrivilege(DocumentPrivilege.AllowAll);



Thanks,
Moshik

Hi Moshik,


Thanks for contacting support.

Can you please share the source PDF file so that we can test the scenario at our end. We apologize for this inconvenience.
Hi,
The issue occurs for all the PDFs.
I'm uploading one of the PDFs I used.

This is my custom stream:

public class MyStream : Stream
{
private Stream inner;

public MyStream(Stream inner)
{
this.inner = inner;
}
public override bool CanRead
{
get { return inner.CanRead; }
}

public override bool CanSeek
{
get { return inner.CanSeek; }
}

public override bool CanWrite
{
get { return inner.CanWrite; }
}

public override void Flush()
{
inner.Flush();
}
public override long Length
{
get { return inner.Length; }
}

public override long Position
{
get
{
return inner.Position;
}
set
{
inner.Position = value;
}
}

public override int Read(byte[] buffer, int offset, int count)
{
logFile.WriteLine("Read: position:{0}, offset:{1}", Position, offset);

return inner.Read(buffer, offset, count);
}

public override long Seek(long offset, SeekOrigin origin)
{
logFile.WriteLine("Seek: position:{0}, offset:{1}", Position, offset);

return inner.Seek(offset, origin);
}
public override void SetLength(long value)
{
inner.SetLength(value);
}

public override void Write(byte[] buffer, int offset, int count)
{
inner.Write(buffer, offset, count);
}
}

Thanks,
Moshik

Hi Moshik,


Thanks for providing additional information. We are looking into your query and will get back to you soon.

Moreover, I’m afraid your above shared PDF document is corrupt as we are unable to open it. Can you please share it again.


Best Regards,

Ok.


thanks

Hi Mohsik,


We are sorry for the inconvenience. I’m afraid, I’m unable to notice performance issue while testing the scenario with Aspose.Pdf for .NET 8.3, Pdf document is being rendered in couple of seconds. We will appreciate if you please share your complete sample code here. So we will replicate the issue at our end and will share information accordingly.

Best Regards,

Hi,

The pdf been converted in a few seconds if you are using MemortStream.

We are using custom Stream - the Read function in my custom stream takes a few milliseconds (something like 30-50 milliseconds) multiply it with 100,000 calls it’s a lot of time.

Thanks,

Hi Mohsik,


Thanks for your feedback. I’ve used your custom MyStream Class to loading PDF document and saved output to disk. But I’m unable to replicate the issue, so requested you for the sample code to replicate the issue. Please share the sample code, it will help us to replicate the issue and further investigation for correction.

We are sorry for the inconvenience caused.

Best Regards,