IC SunsetThe developerWorks Connections Platform is now in read-only mode and content is only available for viewing. No new wiki pages, posts, or messages may be added. Please see our FAQ for more information. The developerWorks Connections platform will officially shut down on March 31, 2020 and content will no longer be available. More details available on our FAQ. (Read in Japanese.)
Topic
  • 10 replies
  • Latest Post - ‏2014-02-27T14:33:20Z by ledel1990
PVMW
PVMW
17 Posts

Pinned topic Copying Master Pages

‏2014-02-20T14:34:36Z |

Is there a way of copying master Pages in a template?

 

  • Dragos.Cojocari
    Dragos.Cojocari
    1654 Posts

    Re: Copying Master Pages

    ‏2014-02-20T15:04:23Z  

    Hey Paul,

     

    copying master pages is not possible but depending on what you want to achieve there are other options you could explore. For example if what you want to achieve are 2 version of the same MP which differ only in their orientation, you could code that using JavaScript to make the "orientation" property of the MP to depend on a certain template variable.

     

    Regards,  

        Dragos

  • PVMW
    PVMW
    17 Posts

    Re: Copying Master Pages

    ‏2014-02-20T15:24:58Z  

    Hi Dragos.

    You've guessed my problem in one (it makes me wonder if this is a common question - which means RPE really ought to be able to accommodate it)

    I want to switch between Portrait and Landscape, depending on the status of an Object Attribute. Two of us have spent several days trying to work out a means of doing so, and the only way we can think of is to effectively duplicate the contents of the Container in the Template Content that creates the text, identical except for selection of Master Page being dependant on the Attribute.  This would be a real pain to do, especially as we have several templates.

    Can you explain how we can add code to the Orientation property of the MP.  Page Orientation appears to be a switch True/False in the  "Format Specific" property of the MP, but there is no option to code it.  Actually, I'm not sure that'd be adequate - because the Header/Footer will not expand to fill the width of the page. This must be a common problem, lots of users must need to include landscape pages in documents.

    regards

    Paul

  • ChrisHardy68
    ChrisHardy68
    86 Posts

    Re: Copying Master Pages

    ‏2014-02-20T22:28:34Z  
    • PVMW
    • ‏2014-02-20T15:24:58Z

    Hi Dragos.

    You've guessed my problem in one (it makes me wonder if this is a common question - which means RPE really ought to be able to accommodate it)

    I want to switch between Portrait and Landscape, depending on the status of an Object Attribute. Two of us have spent several days trying to work out a means of doing so, and the only way we can think of is to effectively duplicate the contents of the Container in the Template Content that creates the text, identical except for selection of Master Page being dependant on the Attribute.  This would be a real pain to do, especially as we have several templates.

    Can you explain how we can add code to the Orientation property of the MP.  Page Orientation appears to be a switch True/False in the  "Format Specific" property of the MP, but there is no option to code it.  Actually, I'm not sure that'd be adequate - because the Header/Footer will not expand to fill the width of the page. This must be a common problem, lots of users must need to include landscape pages in documents.

    regards

    Paul

    Hi Paul,

    This may not be the solution that Dragos was talking about but here is how I have achieved this in the past.

    Unfortunately i had to have 2 master pages - Portrait and Landscape

    You are correct you cant directly script the orientation but you can script the master page field.

    So in my case I had a variable called Landscape which was boolean and I wrote a simple java script to check this value and set the master page based on this

     

    Hope that helps

     

  • PVMW
    PVMW
    17 Posts

    Re: Copying Master Pages

    ‏2014-02-21T10:22:45Z  

    Hi Paul,

    This may not be the solution that Dragos was talking about but here is how I have achieved this in the past.

    Unfortunately i had to have 2 master pages - Portrait and Landscape

    You are correct you cant directly script the orientation but you can script the master page field.

    So in my case I had a variable called Landscape which was boolean and I wrote a simple java script to check this value and set the master page based on this

     

    Hope that helps

     

    I sort of understand where you ar coming from.  I also have two master pages, Portrait and landscape, and an Attribute that identifies which style to use.

    The problem I see is that my Template Content has two containers, one that uses portrait and one landscape.  Each of these has a Condition, which tests the attribute and then executes the content of the selected container.  This gives me two problems;

    1.  If there are a number of landscape objects in sequence, after each landscape page is created a blank portait page follows because RPE sequences though each container and even if it doesn't output an object it still changes the orientation.

    2.  Second problem is more awkward, and means the page numbering gets reset every time the orientation changes.  This is because I have an "Index" template that produces the first few pages in Roman numerals. I then change to the Portrait template, and tell it to restart numbering.  If iI then switch to landscape and back again the numbering resets.

    I don't think your solution will solve the second problem.  As for the first, it might - but where do you put the Java that tests the attribute value?

  • Dragos.Cojocari
    Dragos.Cojocari
    1654 Posts

    Re: Copying Master Pages

    ‏2014-02-21T11:57:36Z  
    • PVMW
    • ‏2014-02-21T10:22:45Z

    I sort of understand where you ar coming from.  I also have two master pages, Portrait and landscape, and an Attribute that identifies which style to use.

    The problem I see is that my Template Content has two containers, one that uses portrait and one landscape.  Each of these has a Condition, which tests the attribute and then executes the content of the selected container.  This gives me two problems;

    1.  If there are a number of landscape objects in sequence, after each landscape page is created a blank portait page follows because RPE sequences though each container and even if it doesn't output an object it still changes the orientation.

    2.  Second problem is more awkward, and means the page numbering gets reset every time the orientation changes.  This is because I have an "Index" template that produces the first few pages in Roman numerals. I then change to the Portrait template, and tell it to restart numbering.  If iI then switch to landscape and back again the numbering resets.

    I don't think your solution will solve the second problem.  As for the first, it might - but where do you put the Java that tests the attribute value?

    Hey folks,

     

    the solution provided by Chris is correct and prior to 1.2.1 was the only solution to this problem. With RPE 1.2.1 we now support/allow using variables/scripts to define the Master Page's properties which in turn permits for a simpler solution for this problem, a solution that does not require duplication of master pages.

    @Paul - you are correct in saying this is a rather common request so I have put together an example with additional explanations on how to use this new 1.2.1 feature: http://rpeactual.com/2014/02/21/new-in-1-2-1-dynamic-master-pages/

     

    Regards,

       Dragos

  • ChrisHardy68
    ChrisHardy68
    86 Posts

    Re: Copying Master Pages

    ‏2014-02-27T03:32:39Z  

    Hey folks,

     

    the solution provided by Chris is correct and prior to 1.2.1 was the only solution to this problem. With RPE 1.2.1 we now support/allow using variables/scripts to define the Master Page's properties which in turn permits for a simpler solution for this problem, a solution that does not require duplication of master pages.

    @Paul - you are correct in saying this is a rather common request so I have put together an example with additional explanations on how to use this new 1.2.1 feature: http://rpeactual.com/2014/02/21/new-in-1-2-1-dynamic-master-pages/

     

    Regards,

       Dragos

    Hi Dragos,

    One further point to this. I followed your instructions and they worked fine for the pages numbers but now the total pages numbers is causing an issue as they are reset every time the orientation\section\masterpage changes

    The issue is that if you use Total no of Pages (NumPages) this counts all the pages in the doc whilst Section pages (SectionPages) counts the number of pages in that section. Each time the orientation or masterpage changes its classed as a new section.

    On the face of it it would seem that the correct item to use would be Total no of Pages (NumPages) however, what happens if you have a section(s) before the main body of text that you dont want to to count in the total pages e.g. Title page, contents etc.

    Example. You have a 12 page doc,

    Page 1 is a title page

    page 2 is a contents page

    Page 3 - 12 is the main contents

    On the last page of the doc you would have a footer that reads: "Page 10 of 12" when really I would like it to read "Page 10 of 10"

    Does that makes sense.

    I actually think this is a Word limitation rather than RPE. The only work around i can think of is to put a "dummy" book mark on the last page and use it as a reference in the footer!

    Paul: Have attached an example of where i have got to so far

    Updated on 2014-02-27T04:21:40Z at 2014-02-27T04:21:40Z by ChrisHardy68
  • ledel1990
    ledel1990
    6 Posts

    Re: Copying Master Pages

    ‏2014-02-27T08:43:53Z  

    Chris,

    I have the exact same problem, which can apparently be solved as Dragos says:

    https://www.ibm.com/developerworks/community/forums/html/topic?id=2ba6244a-5075-423d-8afc-995608ad169b#9eb7ad8e-3c71-4463-b981-93779d8c6038

    "I assume you have some variable to determine when the orientatation change should occur. You can also use it in the "restart numbering" property to tell RPE not to restart numbering if just the orientation changes."

     

    Unfortunately I do not know how to do this so we are stuck in the same position! 

  • Dragos.Cojocari
    Dragos.Cojocari
    1654 Posts

    Re: Copying Master Pages

    ‏2014-02-27T09:35:10Z  
    • ledel1990
    • ‏2014-02-27T08:43:53Z

    Chris,

    I have the exact same problem, which can apparently be solved as Dragos says:

    https://www.ibm.com/developerworks/community/forums/html/topic?id=2ba6244a-5075-423d-8afc-995608ad169b#9eb7ad8e-3c71-4463-b981-93779d8c6038

    "I assume you have some variable to determine when the orientatation change should occur. You can also use it in the "restart numbering" property to tell RPE not to restart numbering if just the orientation changes."

     

    Unfortunately I do not know how to do this so we are stuck in the same position! 

    Hey guys,

     

    @Luke - the issue you have is related to page numbers but a bit different from the one Chris has: you need to restart the page number while Chris needs a way to determine when the "total page number" should start being counted. To show how and when to control the page numbering I have modified my example template, see attached. To understand what I've done look at how the "restartPageNumbers_" variable is used in the "restart page numbering" property of the "page number" field in the footer and how it is calculated in the JavaScript code. In my example I reset it only once, at the start, to ensure only the actual page content is numbered and not any title pages that might come from the stylesheet.

     

    @Chris - I think you are right here and there is no straightforward way in Word to do this. Section pages would work if there would  be a way to change the page orientation without introducing a section break. I see others faced this issue and their solutions are quite complex. If we can find a way to do this in Word I'm pretty sure we can get it to work from RPE as well.

     

    Regards,

       Dragos

     

     

  • Dragos.Cojocari
    Dragos.Cojocari
    1654 Posts

    Re: Copying Master Pages

    ‏2014-02-27T10:07:04Z  

    Hey guys,

     

    @Luke - the issue you have is related to page numbers but a bit different from the one Chris has: you need to restart the page number while Chris needs a way to determine when the "total page number" should start being counted. To show how and when to control the page numbering I have modified my example template, see attached. To understand what I've done look at how the "restartPageNumbers_" variable is used in the "restart page numbering" property of the "page number" field in the footer and how it is calculated in the JavaScript code. In my example I reset it only once, at the start, to ensure only the actual page content is numbered and not any title pages that might come from the stylesheet.

     

    @Chris - I think you are right here and there is no straightforward way in Word to do this. Section pages would work if there would  be a way to change the page orientation without introducing a section break. I see others faced this issue and their solutions are quite complex. If we can find a way to do this in Word I'm pretty sure we can get it to work from RPE as well.

     

    Regards,

       Dragos

     

     

    Chris,

     

    good news. There is a rather clean way to do what you need using the formula field. The process is:

    • create a bookmark on the first page of your content ( call it START_PAGE}
    • in you footer instead of using the NUMPAGES field ( which gives the total number of pages) use a formula field that looks like this: { = {NUMPAGES}  - { PAGEREF START_PAGE} }

    If you do this manually make sure you use CTRL+F9 to create the fields ( both the formula one as well as the NUMPAGES and PAGEREF one) otherwise Word will complain about syntax errors. 

     

    The problem is that you cannot create this type of composite field in RPE right now so you'll need to use one of these solutions:

    • add the field manually or through a macro at the end of the docgen
    • define the field in the footer of the title page/style sheet and in the template specify that the footer is "same as previous". See the attached example. The title page that I use as style sheet has the formula field in the footer of the last page. I also attached the output I get to see how it looks.

     

    Regards,

       Dragos

    Attachments

    Updated on 2014-02-27T10:10:14Z at 2014-02-27T10:10:14Z by Dragos.Cojocari
  • ledel1990
    ledel1990
    6 Posts

    Re: Copying Master Pages

    ‏2014-02-27T14:33:20Z  

    Dragos, 

    Thank you very much for your assistance - I have managed to use your suggestion in my template.

    I will mark my other post as answered and refer to this one.

    Many Thanks,

    Luke