Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I use OpenOffice to produce a document in PDF format. This document is occasionally revised and reissued. I now need to produce a variant of this document with a small number of paragraphs replaced by other paragraphs. I would prefer to avoid maintaining two separate documents where 95% of the text is the same. In other words, from one ODT file I would like to be able to produce two PDFs with slighly differing content.

Are there some OpenOffice features I could use that would help with this?

share|improve this question
    
Why not have different pages with the changed content, and print the necessary page ranges per PDF? I'm not sure how that would affect your page-numbering scheme though. –  user3463 Nov 29 '11 at 17:02
1  
@RandolphWest: Thanks for the idea. I just found a method that suits me (see my Answer below) –  RedGrittyBrick Nov 30 '11 at 11:06
    
You might be interested in knowing (for Google searches etc.) that this is referred to as 'single-source' authoring/publishing/... –  Rabarberski Feb 6 '12 at 13:18
add comment

1 Answer

up vote 3 down vote accepted

User-variables and the Hidden-Paragraph function.

I positioned the cursor at the start of the document and from the "Insert" menu, chose "Field", "Other". I selected the "Variables" tab then I set Type to "Set Variable", Name to "Product", Value to "Foo" and Format to "Text" (if you don't do this the variable is assigned a value of 0)

I then positioned the cursor within the first of two alternative paragraphs and from the "Insert" menu chose "Field". I selected the "Functions" tab and chose "Hidden Paragraph" and set the Condition to Product != "Foo" (meaning hide this paragraph if the Product isn't Foo)

I then positioned the cursor in the second of the alternative paragraphs and repeated the process but set the condition to Product == "Foo".

I repeated the above for all pairs of alternative paragraphs in the document.

Finally, on the document "View" menu I unticked "Hidden Paragraphs".

By clicking on the field at the start of the document I could edit it's value and thus cause alternative paragraphs to appear (and their counterpart disappear) throughout the document. Using "Export to PDF" had the desired effect of not including currently hidden paragraphs.

OpenOffice Help describes it like this:

Hiding Text

You can use fields and sections to hide or display text in your document if a condition is met. Before you can hide text, you must first create a variable to use in the condition for hiding the text.

To Create a Variable

  1. Click in your document and choose Insert - Fields - Other.
  2. Click the Variables tab and click "Set Variable" in the Type list.
  3. Click "General" in the Format list.
  4. Type a name for the variable in the Name box, for example, Hide.
  5. Enter a value for the variable in the Value box, for example, Hide.
  6. To hide the variable in your document, select Invisible.
  7. Click Insert and Close.

To Hide Text

  1. Click in the document where you want to add the text.
  2. Choose Insert - Fields - Other and click the Functions tab.
  3. Click "Hidden Text" in the Type list.
  4. Enter a statement in the Condition box. For example, using the variable you previously defined, enter Hide==1.
  5. Type the text that you want to hide in the Hidden text box.
  6. Click Insert and Close.

To Hide a Paragraph

  1. Click in the paragraph where you want to add the text.
  2. Choose Insert - Fields - Other and click the Functions tab.
  3. Click "Hidden Paragraph" in the Type list.
  4. Enter a statement in the Condition box. For example, using the variable you previously defined, enter Hide==1.
  5. Click Insert and Close.

    You must enable this feature by removing the tick mark from the View - Hidden Paragraphs menu. When the tick mark is present, you cannot hide any paragraph.

To Hide a Section

  1. Select the text that you want to hide in your document.
  2. Choose Insert - Section.
  3. In the Hide area, select Hide, and then enter an expression in the Condition box. For example, using the variable you previously defined, enter Hide==1.
  4. Click Insert.
share|improve this answer
    
Very nice. +1 for you. –  user3463 Nov 30 '11 at 21:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.