Join files macro - headers and footers

Get help using and writing Nisus Writer Pro macros.
Post Reply
bmscmoreira
Posts: 9
Joined: 2015-06-01 09:07:27

Join files macro - headers and footers

Post 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.
User avatar
martin
Official Nisus Person
Posts: 5227
Joined: 2002-07-11 17:14:10
Location: San Diego, CA
Contact:

Re: Join files macro - headers and footers

Post 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.
bmscmoreira
Posts: 9
Joined: 2015-06-01 09:07:27

Re: Join files macro - headers and footers

Post by bmscmoreira »

Thanks. Guess I will have to do it manually for now!
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Join files macro - headers and footers

Post 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 = Document.active
$i = 1
foreach $text in $doc.allTexts
   if $text.documentContentType == "header"
      $text.insertAtIndex 0, "Howdy #$i"
      $i += 1
   end
end
philip
User avatar
phspaelti
Posts: 1313
Joined: 2007-02-07 00:58:12
Location: Japan

Re: Join files macro - headers and footers

Post 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.
philip
Post Reply