Page 1 of 1

Join files macro - headers and footers

Posted: 2020-01-31 04:14:56
by bmscmoreira
Hi. I am using NWP' macro join files to join several NWP rtf files, each one with its own header and footer specific content.
However, when joining them, NWP deletes header and footer content. Is there any way to preserve this during join? Thanks.

Re: Join files macro - headers and footers

Posted: 2020-01-31 08:45:45
by martin
I'm sorry but I think that isn't currently possible.

The desired macro would need to join your files using section breaks, so that each section can have distinct headers/footers. That is currently possible. What isn't possible is for the macro to copy the header/footer content from your source files to the joined file. Currently macros don't have the ability to manipulate section headers/footers. I'll file an enhancement request that we consider adding such a feature in the future. Thanks for bringing it to our attention.

Re: Join files macro - headers and footers

Posted: 2020-01-31 08:57:02
by bmscmoreira
Thanks. Guess I will have to do it manually for now!

Re: Join files macro - headers and footers

Posted: 2020-01-31 18:41:00
by phspaelti
While I sincerely hope that Nisus adds a "Section" object (and maybe a "Header/Footer" object, and/or a ".allHeaders/Footers" property to the Document object), I have to say it is possible to copy headers from one document to the other. Ideally the Section Object would allow for control of margins, header/footer sections, number of columns.

Martin is of course correct that there is no current way to insert a section break and then adjust its heading settings. BUT, if you already have a section break with the correct settings you can copy it from one document to the other. The macro language can also change the content of any given header within a document. So if you really want a macro to do this it could be done in the following manner.
  • Keep a document (perhaps the macro itself? or a glossary?) with the desired type of section breaks
  • insert section breaks from this storage document
  • adjust the header content as needed
UPDATE: I have just confirmed for myself, that creating a glossary with entries like "section_break_with_different_header" works to insert such section breaks. The contents of the headers can be manipulated, for example, with code like this:

Code: Select all

$doc =
$i = 1
foreach $text in $doc.allTexts
   if $text.documentContentType == "header"
      $text.insertAtIndex 0, "Howdy #$i"
      $i += 1

Re: Join files macro - headers and footers

Posted: 2020-01-31 19:07:20
by phspaelti
Having suggested the above "hack", it must be said that this approach is likely to be brittle. As far as I can make out, there is no way to know which header text object belongs to which section break, especially if some of the section breaks do not have the "different headers" on. A setting for "different first page" or "odd & even" would also add uncertainty. Assuming that the text objects of the document are sensibly ordered one could probably rely on the last header text object belonging to a section break entered at the end of the document, which might be good enough for a join document macro.