Free Support Forum - aspose.com

Settings of header and footer lost after section import

Hello,


it seems that the header and footer settings of section’s page-setup get lost during import into another document. Especially the “OddAndEvenPagesHeaderFooter” can’t be imported automatically.

The following code demonstrates the problem. Please see the attached file for reference.

try
{
Document doc = new Document(“C:/testdok.doc”);
Section sec = doc.getFirstSection();

System.out.println("OddAndEven Source: "
+ sec.getPageSetup().getOddAndEvenPagesHeaderFooter());

Document doc2 = new Document();
doc2.removeAllChildren();
Section importNode = (Section) doc2.importNode(sec, true);

doc2.getSections().add(importNode);
Section sec2 = doc2.getFirstSection();

System.out.println("OddAndEven Target: "
+ sec2.getPageSetup().getOddAndEvenPagesHeaderFooter());
}
catch (Exception e)
{
e.printStackTrace();
}

We are using Aspose Words for Java Version 13.1.0.

Thanks in advance
Klemens Schrage

Hi Klemens,


Thanks for your inquiry. But, if you copy (Ctrl+A and Ctrl+C) the Section from testdok.doc using Microsoft Word and paste it inside another empty word document using Microsoft Word again, you will find ‘Different Odd & Even Pages’ header/footer option unchecked. I think, Aspose.Words in this case mimics the behavior of Microsoft Word. Please let me know if I can be of any further assistance.

Best regards,

Hi,


I would have thought that importing a node really imports the node with all of its settings. Especially when using “keep source formatting”. This way we would never know what fields and parameters might get lost during importing. In my eyes it is not the espected behaviour - regardless of what MS Word does. How do you think about this?

Best regards
Klemens Schrage
Hi Klemens,

Thanks for the additional information.

Sure, I have logged this problem as WORDSNET-7770 in our issue tracking system. Our development team will further look into the details of this problem and will keep you updated on the status of correction. We apologize for your inconvenience.

Best regards,

Hi Klemens,


Please note that although OddAndEvenPagesHeaderFooter property is part of PageSetup class, but, the value of OddAndEvenPagesHeaderFooter is not actually stored in Section properties. It is a global attribute, affects all Sections and stored in DocPr object. That’s why Aspose.Words and Microsoft Word do not import this property during Section import. Please let me know if I can be of any further assistance.

Best regards,

Hi,


that’s a good explanation and solves the issue for me. Do you have a list or reference of properties and settings who might fall into the category aswell?

Beste regards
Klemens Schrage

Hi Klemens,


Thanks for your request.

Unfortunately, I do not have a complete list of such properties at the moment. However, it looks like the PageSetup.MirrorMargins property is a global attribute. I have requested a list of such attributes from our development team. I will update you as soon as I have extra information.

Best regards,

Hi Klemens,


Please find below a list of global attributes that are exposed in PageSetup class:

  • OddAndEvenPagesHeaderFooter
  • MirrorMargins
  • BorderSurroundsHeader
  • BorderSurroundsFooter

If we can help you with anything else, please feel free to ask.

Best regards,
Hi Klemens,

It is to update you that our development team has completed the work on your issue (WORDSNET-7770) and has come to a conclusion that your issue and the behaviour you're observing is actually not a bug in Aspose.Words. So, we've closed this issue as 'Not a Bug'. If we can help you with anything else, please feel free to ask.

Best regards,

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


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