String to pdf

I have a string value which is pdf data, how can I convert this string into pdf using your product?

Hi,


Thanks for your interest in our products.

As per my understanding, you have the contents of an existing PDF file in String object and now you need to create a new PDF document using this data. Please note that Document class in Aspose.Pdf namespace supports the feature to create as well as manipulate existing PDF files. It also offers the feature to load existing PDF files using Stream objects. So as per your requirement, you can first load the data into Stream object and then instantiate Aspose.Pdf.Document(new MemoryStream()); object.

However if you need to convert a String/Text value to PDF format, please visit the following link for further details on How to Convert a text file to PDF

Our company has very old version(3.9) of Aspose.Pdf so, I can't use this method How to Convert a text file to PDF

What I am working now is

pdf = new Pdf();

buffer = System.Convert.FromBase64String(pdfString);

MemoryStream mStream = new MemoryStream();

mStream.Write(buffer, 0, buffer.Length);

pdf.BindXML(mStream, null); // error

pdf.Save("test.pdf");

But, I got error saying {"Data at the root level is invalid. Line 1, position 1."}

Thanks for help in advance.

Hi,

Thanks for sharing the code snippet.

As per my understanding, you are using XML to PDF conversion feature using BindXML(…) method. Please note that in order to convert an XML file to PDF format, the source/input XML should be in accordance to Document Object Model of Aspose.Pdf.Generator namespace. In case you need to use your existing XML files, you may consider using an XSLT to make it compatible with DOM of Aspose.Pdf.Generator. For further details, please visit

We are sorry for this inconvenience.

PS, we still recommend you to please upgrade to latest release of Aspose.Pdf for .NET 8.8.0 as it includes many new features and fixes related to issues reported in earlier versions.