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

Free Support Forum - aspose.com

Using the pdf xml schema in the Aspose.Pdf namespace

Hi,

I saw an older forum post that recommended using the Aspose.Pdf namespace to create documents instead of the Aspose.Pdf.Generator namespace. I’ve been playing around with generating documents in the Aspose.Pdf namespace with the DOM and XML schema. In both cases, I’m generating a 100 rows by 20 column table, and noticed some speed differences. Generating the pdf with a DOM took an average of 420ms while the XML took 1090ms. Here’s a relevant code snippit:

static void generateTableWithDom()
{
var pdfDoc = new Aspose.Pdf.Document();
var page = pdfDoc.Pages.Add();
page.PageInfo.Margin = new MarginInfo(27, 27, 27, 27);
var table = new Aspose.Pdf.Table();
table.ColumnAdjustment = Aspose.Pdf.ColumnAdjustment.AutoFitToContent;
table.DefaultCellPadding = new Aspose.Pdf.MarginInfo(1.44, 1.44, 1.44, 1.44);
table.IsBroken = true;

for (int i = 0; i < 100; ++i)
{
var row = table.Rows.Add();

for (int j = 0; j <= 20; ++j)
{
row.Cells.Add(j.ToString());
}
}

page.Paragraphs.Add(table);
pdfDoc.Save(“dom.pdf”);
}

static void generateTableWithXml()
{
var input = Resources.LargeTable;
var ms = new MemoryStream();
var bytes = Encoding.UTF8.GetBytes(input);
ms.Write(bytes, 0, bytes.Length);
var pdfDoc = new Aspose.Pdf.Document(ms, new Aspose.Pdf.XmlLoadOptions());
pdfDoc.Save(“xml.pdf”);
}

There were a few things I wanted to verify.
1) It looks like the Aspose.Pdf.Document class accepts a stream input that contains valid aspose XML, but is this just using the legacy Aspose.Pdf.Generator code?
2) If this is using the older Aspose.Pdf.Generator code, is there a XML schema based on the Aspose.Pdf namespace?

Thanks,
Ryan

Hi Ryan,


Thanks for contacting support.

I have tested the scenario using Aspose.Pdf namespace and have observed that API is taking 3.4 seconds to render a table of 200 rows with 20 column each in PDF file. Whereas when using XML file to create one row with 20 columns, the output is being generated in 1.4 seconds. The XML file which I have used is attached with this post. However can you please share your input XML, so that we can further look into this matter.

I’ve attached the small console test application I was working with to test this all out. The input XML is inside of the resources.

Hi Ryan,


Thanks for sharing the resource file.

I have tested the scenario and I am able to
notice the same problem. For the sake of correction, I have logged this problem
as PDFNEWNET-39645 in our issue tracking system. We will
further look into the details of this problem and will keep you updated on the
status of correction. Please be patient and spare us little time. We are sorry
for this inconvenience.