Error while generating a document


#1

Hello

When I try to generate a doc with the attached code an exception is thrown

Szymon


#2

Sorry, just got a message I can’t upload files - here’s the source of the app


Aspose.Word.License license = new Aspose.Word.License();
//license.SetLicense(“Aspose.Custom.lic”);
Aspose.Pdf.License pdflicense = new Aspose.Pdf.License();
//pdflicense.SetLicense(“Aspose.Custom.lic”);

Aspose.Word.Document sourceDoc = new Aspose.Word.Document( “test.doc” );

MemoryStream ms = new MemoryStream();
XmlDocument xml = new XmlDocument();
sourceDoc.Save( ms, Aspose.Word.SaveFormat.FormatAsposePdf );

byte[] b = ms.ToArray();
System.Text.UTF8Encoding uni = new System.Text.UTF8Encoding();
string s = uni.GetString( b, 0, b.Length );
s = s.Substring( s.IndexOf( “>”, 0 )+1, s.Length - s.IndexOf( “>”, 0 ) - 1 );
xml.LoadXml( s );

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
pdf.BindXML( xml, null );
ms.Close();

System.IO.MemoryStream pdfMS = new MemoryStream();
pdf.Save( pdfMS );


If you need the doc file also let me know how to upload it

Szymon


#3

Dear Szymon,

Thank you for considering Aspose.

Please try saving the xml into a disk file and then bind that file to Aspose.Pdf. If it works, the error should be caused by the code you used to load the XmlDocument. If it still can’t work, please post the detaild error message here.


#4

Hi

I’ve tried with the following code but the result is the same:

Aspose.Word.License license = new Aspose.Word.License();
//license.SetLicense(“Aspose.Custom.lic”);
Aspose.Pdf.License pdflicense = new Aspose.Pdf.License();
//pdflicense.SetLicense(“Aspose.Custom.lic”);

Aspose.Word.Document sourceDoc = new Aspose.Word.Document( “test.doc” );

MemoryStream ms = new MemoryStream();
XmlDocument xml = new XmlDocument();
sourceDoc.Save( ms, Aspose.Word.SaveFormat.FormatAsposePdf );

byte[] b = ms.ToArray();
System.Text.UTF8Encoding uni = new System.Text.UTF8Encoding();
string s = uni.GetString( b, 0, b.Length );
s = s.Substring( s.IndexOf( “>”, 0 )+1, s.Length - s.IndexOf( “>”, 0 ) - 1 );
xml.LoadXml( s );

StreamWriter sw = File.CreateText( “test.xml” );
sw.Write( s );
sw.Close();
Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();
//pdf.BindXML( xml, null );
pdf.BindXML( “test.xml”, null );
ms.Close();
System.IO.MemoryStream pdfMS = new MemoryStream();
pdf.Save( pdfMS );

Regards
Szymon


#5

Dear Szymon,

Thank you for considering Aspose.Pdf.

Please provide the Word document and let me test it. If you still can’t attach it in the forum, please send it to tommy.wang@aspose.com directly.


#6

Hello

Here’s the doc (I hope It’ll get attachedSmile)

Szymon


#7

You document is very simple. I have tested it and fonud no error. Can you please post your error message here?


#8

Hello

Here’s the exception

See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.ApplicationException: Unknown attribute in TabStops element. The attribute name is AlignmentType.
at Aspose.Pdf.Xml.an.a(TabStops A_0, XmlTextReader A_1)
at Aspose.Pdf.Xml.an.a(Text A_0, XmlTextReader A_1)
at Aspose.Pdf.Xml.b.a(Pdf A_0, Section A_1, HeaderFooter A_2, Cell A_3, aa A_4, XmlTextReader A_5)
at Aspose.Pdf.Xml.x.a(Pdf A_0, XmlTextReader A_1)
at Aspose.Pdf.Xml.n.a(ad A_0, XmlTextReader A_1)
at Aspose.Pdf.Xml.ad.a(XmlTextReader A_0)
at Aspose.Pdf.Xml.ad.a(XmlDocument A_0, XslTransform A_1)
at Aspose.Pdf.Pdf.BindXML(String xmlFile, String xslFile)
at AsposeTest.Form1.button1_Click(Object sender, EventArgs e) in c:\projekty\asposetest\asposetest\form1.cs:line 115
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
AsposeTest
Assembly Version: 1.0.2041.20980
Win32 Version: 1.0.2041.20980
CodeBase: file:///c:/temp/Debug/AsposeTest.exe
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
System.Xml
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
----------------------------------------
Aspose.Word
Assembly Version: 2.5.2.0
Win32 Version: 2.5.2.0
CodeBase: file:///c:/temp/Debug/Aspose.Word.DLL
----------------------------------------
Aspose.Pdf
Assembly Version: 2.1.6.1
Win32 Version: 2.1.6.1
CodeBase: file:///c:/temp/Debug/Aspose.Pdf.DLL
----------------------------------------

************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:


<system.windows.forms jitDebugging=“true” />


When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.


Regards
Szymon


#9

This error message indicates you are using a old version of Aspose.Pdf. Please update to the latest version.