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

Free Support Forum - aspose.com

Word to PDF: Word6 SaveToPdf error: "Unknown Attribute"

Hello Aspose.

I tried to to use the new Word 6 doc.SaveToPdf(outputFile), however I get the following error:

"failed to be converted: Unknown attribute in Heading element. The attribute name is Label"

I've zipped up and attached a couple of sample .docs. They convert ok with the old Aspose.Words and Aspose.Pdf.

Thanks, Jacqui

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. I can’t reproduce the problem on my side. Could you please provide me more information? Maybe you have modified your documents before conversion (performed mail merge, edited bookmarks etc). If so please provide me your code.

Best regards.

Hello Alexey.

The files I sent haven't been updated before the conversion. I've also tried using my code that worked with Words 5.2.0.0, but with Words 6.0. and I still get the same error. It fails on the line that binds the XML (which a guess is what it does behind the scenes with the new .SavetoPDF method).

I don't really want to have to go back to Words 5.2.0.0, because we've installed 6.0, which other shared components are now ok using.

thanks, jacqui

Here's the code. The line the error occurs is bold

Protected Function ConvertDocToPdf(ByVal outputFile As String) As Boolean

Dim result As Boolean = False

Dim xmlFile As String = outputFile.ToLower.Replace(".pdf", ".xml")

If File.Exists(outputFile) Then

outputFile = outputFile.Replace(".pdf", Format(Now(), "-yyMMddHHmmss") & ".pdf")

End If

'Convert to aspose pdf xml

Dim doc As Aspose.Words.Document = New Aspose.Words.Document(MyBase.SourceFilename, LoadFormat.Doc, String.Empty)

doc.Save(xmlFile, SaveFormat.AsposePdf)

doc = Nothing

'Read the document in Aspose.Pdf.Xml format into Aspose.Pdf.

_pdf.BindXML(xmlFile, Nothing)

'Delete temporary image files created during the conversion to xml.

_pdf.IsImagesInXmlDeleteNeeded = True

'Enable the caching of True type font map on disk

_pdf.IsTruetypeFontMapCached = True

'Set the path of True type font map file

_pdf.TruetypeFontMapPath = System.IO.Path.GetTempPath()

'Try and save the PDF. Need to do this on a seperate thread and

'throw an exception if it takes too long, because Aspose.PDF doesn't

'throw an exception. If it can't save it just hangs(Aspose defect PDFNET-5394)

Dim d As SavePDFDelegate = New SavePDFDelegate(AddressOf SavePDF)

Dim res As IAsyncResult = d.BeginInvoke(outputFile, Nothing, Nothing)

If res.IsCompleted = False Then

res.AsyncWaitHandle.WaitOne(10000, False)

If res.IsCompleted = False Then

Throw New AsposeWordToPDFTimeoutException()

End If

End If

'Tidy Up

_pdf = Nothing

If File.Exists(xmlFile) Then

File.Delete(xmlFile)

End If

result = True

Return result

End Function

Private Function SavePDF(ByVal outputfile As String) As Boolean

Dim result As Boolean = False

_pdf.Save(outputfile)

result = True

Return result

End Function

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks you for additional information.

Most likely you upgraded Aspose.Words but still use old version of Aspose.Pdf. Please try using Aspose.Words 6.0.0 and Aspose.Pdf 3.9.0.

Note, SaveToPdf method does not use BindXml. This method does not use Aspose.Pdf at all. SaveToPdf is absolutely new method for converting Word document to PDF that uses Aspose.Words only (without using Aspose.Pdf).

In the current version of Aspose.Words (v6.0.0) there is two ways to convert Word document to PDF.

1. Direct conversion to PDF using Aspose.Words (without using Aspose.Pdf). See the following link for more information:

http://www.aspose.com/documentation/file-format-components/aspose.words-for-.net-and-java/aspose.words.document.savetopdf_overload_1.html

here is code:

Document doc = new Document(@"Test012\number_error.doc");

doc.SaveToPdf(@"Test012\aw_out.pdf");

2. Another way is using Aspose.Words and Aspose.Pdf using the following code:

Document doc = new Document(@"Test012\in.doc");

//Save in intermediate AsposePdf format

MemoryStream aPdfStream = new MemoryStream();

doc.Save(aPdfStream, SaveFormat.AsposePdf);

//Create Aspose.Pdf.Pdf document

Aspose.Pdf.Pdf pdf = new Aspose.Pdf.Pdf();

pdf.BindXML(aPdfStream, null);

//Save pdf

pdf.Save(@"Test012\out.pdf");

Best regards.

Hi

I've tried the new way (method 1) but this causes an error, so now I'll try method 2 (Words6 but with PDF3.9.0) and see how it goes.

Thanks, Jacqui

Hi<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Please tell me how I can reproduce this problem on my side. It would be great if you create simple application that will allow me to reproduce the problem.

Best regards.

Hi Alexey

I created a little app and both methods worked once I had the latest Aspose.PDF 3.9.00.

In my main program the new .SaveToPDF method worked okay after removing the reference to Aspose.PDF 3.7.

All seems ok now. Looks like I just had to get the latest version of everything - I'll be certain after our conversion job runs on live tonight.

Many Thanks for your assistance.

Jacqui