pdf.Save(stream) needs several minutes

I’m trying to convert the content of an xml file (with 1MB size) to a simple pdf.

I’m only reading the string content of the xml file an add the content as Text to to a pdf.

But when executing pdf.Save(stream) it need for about 15minutes.

Why does this take so long, is there a option to speed up this???



Hi,

Can you please provide us with the source code as well so that we can more accurately figure out the cause of the problem.

Thanks.



byte [] bFile = File.ReadAllBytes(“xml_unsigned.1MB.xml”);
Aspose.Pdf.Pdf pdf = new Pdf();
Aspose.Pdf.Section txtSection = pdf.Sections.Add();

string fileContent = String.Empty;
fileContent = Encoding.ASCII.GetString(bFile);

Aspose.Pdf.Text txt = new Text(fileContent);

txtSection.Paragraphs.Add(txt);
using (Stream str = new MemoryStream())
{

pdf.Save(str);

}

Hi,

I have tested your file and was able to reproduce the problem. I have logged this as PDFNET-4395 in our issue tracking system. We will try our best to resolve this as soon as possible.

Thanks.

Hi,

The performance is low in this case. As a work around, please alter to use the following codes:
Aspose.Pdf.Pdf pdf = new Pdf();
Aspose.Pdf.Section txtSection = pdf.Sections.Add();

string fileContent = String.Empty;
string line;
Aspose.Pdf.Text txt = null;
// Read the file and display it line by line.
System.IO.StreamReader file =
new System.IO.StreamReader(“c:/xml_unsigned.1MB.xml”);
while ((line = file.ReadLine()) != null)
{
txt = new Text(line);
txtSection.Paragraphs.Add(txt);
}

file.Close();
using (Stream str = new MemoryStream())
{
pdf.Save(str);
}


It takes about 30s on my computer. We will improve the performance on this case in our future version. Please try it and be free to ask questions if you have any other problems. Thanks.

Best regards.

Hi,

The new hot fix Aspose.Pdf 3.6.2.0 has been published and the fix of PDFNET-4395 is included. Please download it follow this link: http://www.aspose.com/Community/Files/
Thanks.

Best regards.

Thanks, It’s working fine now.

I’ve got the same problem as mentioned above, but now I’ve got an 20MB xml file.

Is there any chance to fasten this convertion?

Thanks.

Hi,

It is a known issue that the performance of large xml convertion is low especially processing very large tables. We have done some job to improve it. But I am afraid we can’t resolve it in short time. As a workaround, please read the xml file line by line and construct each line as a text object if you want convert the xml file’s content into pdf.

Best regards.