Hi,
We have a problem which manifests itself when converting a Word document saved as a DOCX to PDF using the Aspose Word library. However this is not the case if the same document is first saved as a Word 97-2003 compatible (DOC) and then converted to a PDF. The Aspose library version we are currently using (11.11.0.0) and the latest version (16.1.0.0) seem to be affected by the same problem.
Attached is the DOCX and the converted PDF. The difference is that the table heading text colour in the DOCX is white and in the PDF it is black.
What are the limitations of using DOCX compared to DOC file formats for PDF conversion and is this issue likely to be addressed in future versions?
Hi Ben,
Thanks for your inquiry. We have tested the scenario using latest version of Aspose.Words for .NET 16.1.0 and have not found the shared issue. Please use Aspose.Words for .NET 16.1.0. We have attached the output Pdf with this post for your kind reference.
Hi Tahir,
I’ve done some tests and found that the code we were using to create the PDF seems to create the problem although I’m not sure why.
The following code highlights the problem
’ Use a blank document as the destination document.
Dim dstDoc As New Aspose.Words.Document()
Dim srcDoc As New Aspose.Words.Document("Simple Bookmark Test 1.docx")
dstDoc.RemoveAllChildren()
dstDoc.AppendDocument(srcDoc, ImportFormatMode.KeepSourceFormatting)
dstDoc.Save("Simple Bookmark Test 1.pdf")
Whereas the following code doesn’t.
Dim doc As New Aspose.Words.Document("Simple Bookmark Test 1.docx")
doc.Save("Simple Bookmark Test 1.pdf")
Why does appending the document fail in this respect?
Hi Ben,
Thanks for your inquiry. Please note that Aspose.Words mimics the same behavior as MS Word does. If you copy the contents of input document into empty document with ‘Keep Source Formatting’ using MS Word, you will get the same output.
Please use ImportFormatMode as UseDestinationStyles to get the desired output. We suggest you please read about ImportFormat modes from following link.
Differences between ImportFormat Modes
Hi Tahir,
Using AppendDocument with the following mode corrected the problem in 16.1
ImportFormatMode.KeepDifferentStyles
However that mode is not available in 11.11. Is there a workaround that can be achieved using this version?
TIA
Hi Ben,
Thanks for your inquiry. If you want to use ImportFormatMode.KeepDifferentStyles, please upgrade to latest version of Aspose.Words for .NET 16.1.0. However, you can get the desired output using ImportFormatMode.UseDestinationStyles as shown below.
Dim dstDoc As New Document()
dstDoc.RemoveAllChildren()
Dim srcDoc As New Document(MyDir + "Simple Bookmark Test 1.docx")
dstDoc.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles)
dstDoc.Save(MyDir + "Out.pdf")
Hi Tahir,
I’m sorry to say I tried your code with 11.11 and it still produces a PDF with table heading text colour in black.
This is quite easy to replicate so I’m not sure why you get a different result. Is there something else I need to do to get this to work?
Hi Ben,
Thanks for your inquiry. Please note that we don’t provide support for older released versions of Aspose.Words. Moreover, we do not provide any fixes or patches for old versions of Aspose products either. All fixes and new features are always added into new versions of our products.
We have tested the scenario using latest version of Aspose.Words for .NET 16.1.0 and have not found the shared issue. Please use Aspose.Words for .NET 16.1.0. We have attached the output Pdf with this post for your kind reference.
Dim dstDoc As New Document()
dstDoc.RemoveAllChildren()
Dim srcDoc As New Document(MyDir + "Simple Bookmark Test 1.docx")
dstDoc.AppendDocument(srcDoc, ImportFormatMode.UseDestinationStyles)
dstDoc.Save(MyDir + "Out.pdf")
Hi Tahir,
I can confirm this works with 16.1 but not 11.11.
Thanks anyway.