RTF file Meging and Document Saving

Hi,

When I am working on RTF files, I am getting the ““Object reference not set to an instance of an object.” Error.

My regular work follows like this

  1. Read the RTF file from the server
  2. create a document by using “Aspose.Words”
  3. if there are more than one RTF file involved in process, then merge the document and save the document back to server.

Document doc = new Document(Path);

doc.SaveToPdf(Folder + “\” + SourceFile.Name);

Enviorment I am using

  1. VS 2005

  2. ASPOSE.Words version number “6.6.0.0”

  3. The Nornal size of the RTF file will be around 3.5MB

plase help me by explaining how to process a RTF file with an example.

Hello

Thanks for your inquiry. Could you please attach your document for testing? I will check the problem on my side and provide you more information.

Best regards,

Hi,

i am here attatching test document which i am using for proces. when ever i try to create a object using

Document doc = new Document(@"c:\Test.doc");

is taking around 8sec(for 1.5MB file size) in development enviornment.

and it is throwing error when i am try to save the document in a different location by using

doc.Save(@"c:\Test1.doc");

please help me ASAP.

thank you.

Hi

Thank you for additional information. I can successfully save your document in DOC format and other formats. I used the following code for testing:

// Open document.
Document doc = new Document(@"Test001\Test.rtf");

// Save output document in different formats.
doc.Save(@"Test001\out.doc", SaveFormat.Doc);
doc.Save(@"Test001\out.docx", SaveFormat.Docx);
doc.Save(@"Test001\out.xml", SaveFormat.WordML);
doc.Save(@"Test001\out.rtf", SaveFormat.Rtf);
doc.Save(@"Test001\out.txt", SaveFormat.Text);
doc.Save(@"Test001\out.html", SaveFormat.Html);

However, an exception occurs, when I try to save this document to ODT format and during rendering (converting to PDF/XPS/Image). You will be notified as soon as it is resolved.

Best regards.

Hi,

Thanks for prompt reply.

As I am getting the RTF files with DOC extension, it’s better if you test the same document with DOC extension, instead of RTF.

To create an object ASPOSE.WORD taking bit higher time (8sec for 1.5mb file), is there any way to reduce the time? because it is hitting the performance issue.

Thank you

Hi

Thank you for additional information. It takes 3 seconds on m y side to open and save this document. Here is code I used for testing:

DateTime start = DateTime.Now;
Document doc = new Document(@"Test001\Test.doc");
doc.Save(@"Test001\out.doc");
Console.WriteLine("Time: {0} sec", (DateTime.Now - start).TotalSeconds);

Actually, RTF format is slower than other formats, because it is text format. For example, if you convert your RTF document to binary DOC format, it takes less than 1 second to open and save it.

Best regards

Hi,

By using the above fix, I am facing below issues

When I am working on RTF files and try to save or merge files, I am getting the ““Object reference not set to an instance of an object.” Error.

below is the sample code

Document doc = new Document(Path);
doc.Save(Folder + "\\" + SourceFile.Name);

Whenever I try to create a object using

Document doc = new Document (@"c:\Test.doc");

is taking around 8sec(for 1.5MB file size) in development environment is there any way to reduce the time? because it is hitting the performance issue, and it is throwing error when I am try to save the document in a different location by using

doc.Save (@"c:\Test1.doc"); method.

Thank you.

Hi

Thanks for your request. As I can see this post describes the same as you already described above.

  1. As I told you earlier, I managed to reproduce the problem during saving document to PDF and ODT format and you will be notified as soon as the problems are resolved.

  2. Exception does not occur when I save your document in DOC format. Which exception do you get when save your document to DOC? This code works just fine with your document on my side:

// Open document.
Document doc = new Document(@"Test001\Test.doc");
// Save output document.
doc.Save(@"Test001\out.doc");
  1. On my side it takes 3 seconds to open/save your document, this is normal time for large RTF, if you would like to improve performance, use DOC format instead of RTF.

Best regards.

Hi,

Thanks for your reply,
I tested the application with 8mb document; it is taking around 19sec to create a object. Here I am attaching the code with time screen shot and document.

Why is it taking such a huge time?

Help me with a way to reduce the time for creating an object.

Thank you.

Hi

Thanks for your request. As I wrote you earlier, RTF format is slower than other formats, because it is text format and that is why it takes more time to parse RTF files. You can observe the same behavior, when try opening large RTF documents in MS Word. IF you would like to improve performance, you can try using binary DOC format instead of RTF.

Also, I tested your document on 2 PCs on my side.

Code is the same as I used previously:

DateTime start = DateTime.Now;
Document doc = new Document(@"Test001\Test.doc");
doc.Save(@"Test001\out.doc");
Console.WriteLine("Time: {0} sec", (DateTime.Now - start).TotalSeconds);

The first PC:

CPU: Celeron 2.8GHz

RAM: 2GB

OS: Windows XP SP3

Result: 8,578125 sec

The second PC:

CPU: Intel Core 2 Duo 1.5GHz

RAM: 1GB

OS: Windows XP SP3

Result: 4,609375 sec

Best regards.

Hi,

Thanks for update.

We had an issue with some of the RTF files, and you gave a fix, after this fix, we started getting performance issues. Earlier before the latest release it used to work fine, just want to understand is there some thing in the current ASPOSE version causing this performance issue.

Thanks.

Hi

Thank you for additional information. I do not think, that this fix can affect the performance of the document loading. Which version of Aspose.Words did you use before?

Best regards

Thank you for your reply. Earlier version of Aspose.Words we worked is 6.3.0.0

Hi

Thank you for additional information. I tested with Aspose.Words 6.3.0 nad result is the same. Time to load and save your document is the same using 6.3.0 and 6.6.0 versions of Aspose.Words.

Best regards.

Thanks’ for your reply.

I found this issue will be with my documents. I am here placing my stack trace. As a security issue I cont send you the documents.

If you have information on what type of content in a RTF file Aspose.word will not process, please share with us, it will help us in understanding the our own documents.

i checked the one more thing it is throwing the same error when i use the method

Document doc = new Document(@"c:\Test\Test.doc");
doc.ExpandTableStylesToDirectFormatting();

I noticed one more thing in my RTF files is, if i add or remove a even single space from the file, the size of the document is reduced from 2mb to 300kb. If you have any information on this please share with us, it will help us a lot.

Stack trace:-
Check here, it is trying to create a table, which it can’t understand and throwing error.

at Aspose.Words.Tables.Table.ᯨ()
at ㏌.㏋.VisitTableStart(Table table)
at Aspose.Words.Tables.Table.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.ဢ(DocumentVisitor ྍ)
at Aspose.Words.Body.Accept(DocumentVisitor visitor)
at ㏌.㏋.Ἧ(Section ᲼)
at ㏌.㏋.㏢()
at ㏌.㏋.ἧ(Ὑ Ἠ)
at Aspose.Words.Document.࿠(Stream ܭ, String ܬ, SaveFormat ࿡)
at Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)
at FilesHelper.DirectoryHelper.DownloadFile(String FileName, String Folder, Int32 ExecutionType) in C:\GCFHDWordServiceNew\FileHelper\DirectoryHelper.cs:line 150

please do the needful.

Thank you.

Please attach sample document and code, which will allow me to reproduce the problem on my side. I will check the issue and provide you more information.

Best regards.

Thanks’ for your reply.

I found this issue will be with my documents. I am here placing my stack trace. As a security issue I cont send you the documents.

If you have information on what type of content in a RTF file Aspose.word will not process, please share with us, it will help us in understanding the our own documents.

i checked the one more thing it is throwing the same error when i use the method

Document doc = new Document(@"c:\Test\Test.doc");
doc.ExpandTableStylesToDirectFormatting();

I noticed one more thing in my RTF files is, if i add or remove a even single space from the file, the size of the document is reduced from 2mb to 300kb. If you have any information on this please share with us, it will help us a lot.

Stack trace:-
Check here, it is trying to create a table, which it can’t understand and throwing error.

at Aspose.Words.Tables.Table.ᯨ()
at ㏌.㏋.VisitTableStart(Table table)
at Aspose.Words.Tables.Table.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.ဢ(DocumentVisitor ྍ)
at Aspose.Words.Body.Accept(DocumentVisitor visitor)
at ㏌.㏋.Ἧ(Section ᲼)
at ㏌.㏋.㏢()
at ㏌.㏋.ἧ(Ὑ Ἠ)
at Aspose.Words.Document.࿠(Stream ܭ, String ܬ, SaveFormat ࿡)
at Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)
at FilesHelper.DirectoryHelper.DownloadFile(String FileName, String Folder, Int32 ExecutionType) in C:\GCFHDWordServiceNew\FileHelper\DirectoryHelper.cs:line 150

please do the needful.

Thank you.

All content in the RTF documents should be processed.

Each document format allows some fluctuation, some parts of the document are not required, and some parts can be written differently. That is why size of the documents can be different after processing or resaving documents.

Unfortunately, I cannot provide you any information regarding the issue you have reported without your document. I need to reproduce the problem to analyze it. You can try removing sensitive content from your document and attach it here or send it to my e-mail.

Best regards.

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


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

Thanks for your reply.

We installed the latest ASPOSE.WORD from the update you gave in the post.

Here are the details of Aspose.Words.dll

Assembly Version: 7.0.0.0

Product Version: 2009.09.14

But still we are getting the same error while saving the RTF document. We tested with the same document we attached to this post earlier. But still for your reference I’m attaching another document that is causing this issue.

Exception Message:
Object reference not set to an instance of an object.
Exception StackTrace:

at Aspose.Words.Tables.Table.ᛷ()
at ㋟.㋞.VisitTableStart(Table table)
at Aspose.Words.Tables.Table.Accept(DocumentVisitor visitor)
at Aspose.Words.CompositeNode.Ս(DocumentVisitor Վ)
at Aspose.Words.Body.Accept(DocumentVisitor visitor)
at ㋟.㋞.⌱(Section )
at ㋟.㋞.㋵()
at ㋟.㋞.〈(⍝ 〉)
at Aspose.Words.Document.ԅ(Stream Ӿ, String Ӽ, SaveFormat Ԇ)
at Aspose.Words.Document.Save(String fileName, SaveFormat fileFormat)
at Aspose.Words.Document.Save(String fileName)
at TestProject.Form1.button7_Click(Object sender, EventArgs e) in C:\BACS\Projects\GCFHDWordServiceNew\TestProject\UnitTestForm.cs:line 317

Please do the needful

Thanks