Free Support Forum - aspose.com

.NET Aspose.PDF.GetBuffer() Execution time

Hi,

I would like to know if there is any faster way to retrieve the data buffer than to use the .GetBuffer() method (Or some option that can speed up the GetBuffer() execution time).

It is taking roughly 8 seconds for an output buffer of 80500 bytes.

Having to deal with a large amount of data, being able to reduce the execution time of this method would greatly improve the response time of my application.

Thanks.

Hello pierre,

Thanks for considering Aspose.

I'm afraid there is no such method that can improve/speed-up the data retrieving time when using Pdf.GetBuffer() method. Can you please share the code/project so that we can test the scenario at our end.

We apologize for your inconvenience.

Hi,

Well, the code is basically retrieving several word, RTF, PDF document from a database and compiles them into one big PDF File.

I use Aspose.Word to convert Word and RTF files into xml. I then use the Aspose.PDF.BindXML() method to retrieve the content and insert it in the final PDF file.

The code below is not exactly what I am doing (as the doc files do not come from a folder but from a database) but it’s pretty close.


public void test()
{
DirectoryInfo di = new DirectoryInfo(@“c:\Temp\CV”);
FileInfo[] rgFiles = di.GetFiles("*.doc");
iDoc theDoc = new iDoc();

foreach (FileInfo fi in rgFiles)
{
iDoc newDoc = new iDoc();
Aspose.Words.Document doc = new Aspose.Words.Document(fi.FullName);
//…You can merge data/manipulate document content here.
//Save the document in Aspose.Pdf.Xml format.
doc.Save(fi.FullName + “.xml”, Aspose.Words.SaveFormat.AsposePdf);
//Read the document in Aspose.Pdf.Xml format into Aspose.Pdf.
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.BindXML(fi.FullName + “.xml”, null);



byte[] buf = pdf.GetBuffer();

newDoc.Read(buf);
theDoc.Append(newDoc);
}

theDoc.Save(@“c:\Temp\pdffile.pdf”);
}


The iDoc type allows us to merge several type of files in one PDF file, so the code above will probably not work as it is.

It is however quite similar to your Aspose.PDF.Kit.PdfFileEditor.Append() Method except that it has several input format options.

http://www.aspose.com/documentation/.net-components/aspose.pdf.kit-for-.net/aspose.pdf.kit.pdffileeditor.append_overload_1.html



Thank you for your help.

Hello pierre,

Thanks for sharing the details.

Besides using conventional method of using Aspose.Pdf for .NET along with Aspose.Words for .NET to convert RTF file into PDF format, you can try using the Direct-To-PDF save method of Aspose.Words which is introduced in recent versions. As this method does not involve Aspose.Pdf to accomplish the requirement, I think the execution time will be quite much less than the legacy method.

For more information on Direct-To-PDF save method, please visit How-to: Convert a Document to PDF

Once you've converted the RTF, Word files into PDF format, you can convert all the files into a single PDF document. Please visit the following links and I hope they would be helpful.

In case still it does not resolve your problem or you've any further query, please feel free to contact.