Error - Data at the root level is invalid. Line 1- position 1


When I previously generated PDFs using Aspose.Pdf for .NET 6.0.0.0 and Aspose.Pdf.Kit for .NET 5.8.0.0, everything was working perfectly alright.

Recently, i.e. on 11th Oct 2011 we have purchased the Aspose.Pdf for .NET (in which Aspose.Pdf.Kit for .NET is also merged). After adding the Aspose.Pdf.dll 6.3.0.0 and the license file in the project, when I try to create the Pdf file, I get the following error:
System.Xml.XmlException - Data at the root level is invalid. Line 1, position 1.

I have added the sample code below which generates error on the Save method.
I have also attached the Pdf file that is being used.

protected void Button1_Click(object sender, EventArgs e)
{
FileStream fs1 = new FileStream(@“E:\TestPDF.pdf”, FileMode.Open);
FileStream fs2 = new FileStream(@“E:\TestPDF_Flatten.pdf”, FileMode.OpenOrCreate);
try
{
//open document
Aspose.Pdf.Facades.Form pdfForm = new Aspose.Pdf.Facades.Form(fs1, fs2);
//flatten fields
pdfForm.FlattenAllFields();
//save output
pdfForm.Save();

fs1.Close();
fs1.Dispose();
fs2.Close();
fs2.Dispose();

fs1 = new FileStream(@“E:\TestPDF_Flatten.pdf”, FileMode.Open);
fs2 = new FileStream(@“E:\TestPDF_New.pdf”, FileMode.OpenOrCreate);

//create PdfPageEditor object
PdfPageEditor pEdit = new PdfPageEditor();
//bind pdf file
pEdit.BindPdf(fs1);
//and assign it to PageSize property of the PdfPageEditor class
pEdit.PageSize = Aspose.Pdf.Facades.PageSize.A4;
pEdit.Alignment = AlignmentType.Center;
pEdit.VerticalAlignment = VerticalAlignmentType.Center;
//save the file
pEdit.Save(fs2);
pEdit = null;

fs1.Close();
fs1.Dispose();
fs2.Close();
fs2.Dispose();
}
catch (Exception ex)
{
fs1.Close();
fs1.Dispose();
fs2.Close();
fs2.Dispose();
}
}

Please let me know the solution at the earliest as we got to implement the project tomorrow.

Hi Priya,<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>

I
have tested the scenario and have managed to reproduce the same problem. For the
sake of correction, I have logged it in our issue tracking system as <span style=“font-family:“Arial”,“sans-serif””>PDFNEWNET-31306. We
will investigate this issue in details and will keep you updated on the status
of a correction.<span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””><span style=“font-size:10.0pt;font-family:“Arial”,“sans-serif””>

We
apologize for your inconvenience.


Hi,


Is the issue resolved? We have posted two other issues as well.

The new dlls are creating lot of issues. If there are improvements, then they should be for betterment, but instead the merged versions have created many issues. The things that were working fine in previous version arent working.

WE HAVE MISSED OUR DEADLINES BECAUSE OF THIS GOOFUP BY THE TECHNICAL TEAM AND ARE BEING PENALIZED. HOPE THE SITUATION DOESNT COME THAT WE NEED TO ASK FOR REFUND AND STOP USING ASPOSE.

Kindly update us on a priority basis.

Regards,

Hi Priya,

Thanks for your patience.

We have further investigated this issue and have found that XMP metadata in source PDF is corrupted and its causing an exception when accessing the file. However in your code you have handled the exception and tried to save the resultant file. The final output is empty and therefore it seems to be corrupted. The fix will be included in upcoming release version of Aspose.Pdf for .NET which is expected to be released by early next month. Please be patient and spare us little time. Your patience and comprehension is greatly appreciated in this regard. We are really sorry for the delay and inconvenience that you are facing.

PS, If you simply open the source file with Aspose.Pdf.Facades.Form object, call FlattenAllFields(); method and save the document, you will be able to notice this problem.



The issues you have found earlier (filed as 31306) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.