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

Free Support Forum - aspose.com

Issue with Upgrade of ASPOSE word for JAVA

Hi
we are going to upgrade aspose as per version mentioned in the bottom of this post
However , i am seeing there has been considerable changes in the upgraded version
those change are creating in our code

till now i have identified couple of runtime issue

for e.g
i) Issue using Run Object : i believe this is due to the introduction of DocuementBase class

code :

Document doc = new Document();
Run run = new Run(doc,“test”);
String runTxt = run.toTxt();
System.out.println(“runTxt:” + runTxt);


result :

java.util.EmptyStackException
at java.util.Stack.peek(Stack.java:85)
at com.aspose.words.avg.visitRun(TxtWriter.java:109)
at com.aspose.words.Run.accept(Run.java:89)
at com.aspose.words.avg.w(TxtWriter.java:68)
at com.aspose.words.Document.a(Document.java:1371)
at com.aspose.words.Node.toTxt(Node.java:565)
at com.test.TestUpHeaderFooter.main(TestUpHeaderFooter.java:28)


expected result :

runTxt:test




ii) Issue using Header and footer : Attaching the used word doc


code :

Document clauseDoc = new Document(“C:\DocEd\Express Header.doc”);
if (clauseDoc.getSections().get(0) != null)
{ int cnt = clauseDoc.getSections().get(0).getHeadersFooters().getCount();
System.out.println(“HeadersFooters count:”+cnt);


for (HeaderFooter hf : clauseDoc.getSections().get(0).getHeadersFooters())
{
System.out.println("Remove Header Footer: " + hf.getHeaderFooterType());
hf.remove();

}
}


result :

HeadersFooters count:6
Remove Header Footer: 0

doc header and footer is not getting removed


expected result :

HeadersFooters count:6
Remove Header Footer: 0
Remove Header Footer: 1
Remove Header Footer: 2
Remove Header Footer: 3
Remove Header Footer: 4
Remove Header Footer: 5

and the doc with removed header and footer



iii) I see there is a new class DocumentBase introduced as a parent to Document class , which
we were using in our Existing version.Is there any documentation availble telling the classes impacted by addition of
DocumentBase class as parent of Document class ?


iv) In general ,Is there any documentation which will help us to identify and suggest all the changes to upgrade our code version





Exisiting Product Info:

Specification-Title: Aspose.Words for Java
Implementation-Title: Aspose.Words for Java
Specification-Version: 3.3.0.0
Implementation-Version: 3.3.0.0
Specification-Vendor: Aspose Pty Ltd
Implementation-Vendor: Aspose Pty Ltd
Copyright: Copyright 2003-2009 Aspose Pty Ltd

New/Upgraded Product Info :

Specification-Title: Aspose.Words for Java
Specification-Version: 10.5.0.0
Specification-Vendor: Aspose Pty Ltd
Implementation-Title: Aspose.Words for Java
Implementation-Version: 10.5.0.0
Implementation-Vendor: Aspose Pty Ltd
Release-Date: 2011.09.30

Hi,


Thanks for your inquiry.

1) While using the latest version of Aspose.Words for Java i.e. 10.6.0 and your code, I managed to reproduce this issue on my side. I have logged this issue in our bug tracking system. Your request has also been linked to this issue and you will be notified as soon as it is resolved. However, as a work around, please try using getText method instead of toTxt(). For more details, please visit the following link:
http://www.aspose.com/documentation/java-components/aspose.words-for-java/com/aspose/words/run.html

2) Please note that HeaderFooter is a section-level node and can only be a child of Section. There can only be one HeaderFooter of each HeaderFooterType in a Section. If the HeaderFooter has no child nodes, this header/footer is considered linked to the header/footer of the same type of the previous section. So calling hf.remove() actually removes the main header itself from the parent. You can get the expected result by not calling this hf.remove() method. For more information, please visit the following link:
http://www.aspose.com/documentation/java-components/aspose.words-for-java/com/aspose/words/headerfooter.html

3) Please visit the following API link for details about DocumentBase class:
http://www.aspose.com/documentation/java-components/aspose.words-for-java/com/aspose/words/documentbase.html

4) You can find the release notes for Aspose.Words for Java 10.5 by visiting the following link:
http://www.aspose.com/community/files/72/java-components/aspose.words-for-java/entry332937.aspx

Please let us know if you need more information, We are always glad to help you.

Best Regards,

Thanks for the response, i have below things now

5. Do you have an ETA for the recognized bug mentioned as per #1

6. Can i have the list of known bugs as of now for the latest version , so that i can straight away see the impacts and look for alternate solution till those are fixed rather than reporting a known bug

7. For concern #2 am not sure if i have made you understand the problem , i am attaching the test code TestHF.java and used doc

a) Express Header.doc
b) Express Pricing Schedule signature.doc

Try running this code with both the version , you will see what i mean , with the new version it gives an exception
however with the older version it works fine.
I believe there is problem with the method remove() of the HeaderFooter class

8. I am planning to use this as a single thread to seek help and/or report any issues with my upgrade activity.Let me know if this
is fine

Hi,


Thanks for the additional information.

1) This issue is pending for analysis and is in the queue. Unfortunately, at the moment I cannot provide you any reliable estimate regarding this issue. However, you will surely be notified as soon as it is resolved. Sorry for inconvenience.

2) We have an internal issue tracking system and I think, we don’t have any such list of known bugs i.e. publicly available. You may consult the release notes as I mentioned in my previous post. Moreover, please visit the following link for a list of few known issues:
http://www.aspose.com/documentation/java-components/aspose.words-for-java/known-issues-in-aspose-words-for-java.html

3) Calling hf.remove() in your code will remove the header/footer from the parent section. Please see the following link for more details about remove method:
http://www.aspose.com/documentation/java-components/aspose.words-for-java/com/aspose/words/node.html#remove()

Yes, while using the latest version of Aspose.Words, I managed to reproduce this exception on my side. As in your source document (i.e. Express+Header.doc) the type of Header is HEADER_PRIMARY, so please see the following work around:

public static
Document replaceHeaderFooter(Document ipdoc1, Document
ipdoc2) throws Exception {<o:p></o:p>

HeaderFooter header1Dst, header2Dst, footer1Dst, footer2Dst, header3Dst, header1Src;

double headDist = 0;

for (HeaderFooter hf : ipdoc2.getSections().get(0).getHeadersFooters()) {

System.out.println("Remove Header Footer: " + hf.getHeaderFooterType());

hf.remove();

}

for (HeaderFooter hf : ipdoc1.getFirstSection().getHeadersFooters()) {

header1Src = hf;

if (hf.isHeader()) {

header1Dst = (HeaderFooter) ipdoc2.importNode(header1Src, true, ImportFormatMode.KEEP_SOURCE_FORMATTING);

System.out.println("Is Header :-" + header1Dst.isHeader());

if (ipdoc2.getFirstSection() != null) {

System.out.println("HF is having Header");

HeaderFooterCollection HFC = ipdoc2.getFirstSection().getHeadersFooters();

if (header1Src.getHeaderFooterType() == HeaderFooterType.HEADER_PRIMARY)

HFC.add(header1Dst);

}

headDist = ipdoc1.getFirstSection().getPageSetup().getHeaderDistance();

ipdoc2.getFirstSection().getPageSetup().setHeaderDistance(headDist);

}

}

//addFooter(ipdoc2 ,ipdoc1);

return ipdoc2;

}


4) You are welcome to use Aspose.Words forum for your future inquiries; however, I would suggest you to please create separate logical threads so that we can keep related posts under specific subject/topic.

Please let us know if we can be of any further assistance.

Best Regards,

Thanks for your response

so for #3 ( related to removal of header and footer ) :
It is also a bug in the latest version of ASPOSE right ?

Hi

Thanks for your request. It is not a bug. The problem occurs because you are removing items from the live collection in the loop. That is why the loop is interrupted. You can easily resolve this by looping through Node array instead of live NodeCollection. Please see the following code:

Document clauseDoc = new Document("C:\\Temp\\Express+Header.doc");

if (clauseDoc.getSections().get(0) != null)

{

int cnt = clauseDoc.getSections().get(0).getHeadersFooters().getCount();

System.out.println("HeadersFooters count:"+cnt);

Node[] headersFooters = clauseDoc.getSections().get(0).getHeadersFooters().toArray();

for (Node hf : headersFooters)

{

System.out.println("Remove Header Footer: " + ((HeaderFooter)hf).getHeaderFooterType());

hf.remove();

}

}

Best regards,

Also, if you would like to remove all headers/footers, there is much simpler way:

Document clauseDoc = new Document("C:\\Temp\\Express+Header.doc");

if (clauseDoc.getSections().get(0) != null)

{

System.out.println("HeadersFooters count:"+clauseDoc.getSections().get(0).getHeadersFooters().getCount());

clauseDoc.getSections().get(0).getHeadersFooters().clear();

System.out.println("HeadersFooters count:"+clauseDoc.getSections().get(0).getHeadersFooters().getCount());

}

Best regards,

well ,seeing at the difference of behavior of the remove() method in the two version ( earlier version it works and the latest it does not) made me comment it as having bug or something in latest version.

Anways , i am going to pursue the alternate solution for this.

Thanks for your response

The issues you have found earlier (filed as WORDSJAVA-455) have been fixed in this .NET update and this Java update.


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