Exclude a style from exporting


I’m working on a document that should exist in two versions - one normal version, and one version with extra informations here and there aswell as additional paragraphs.

I currently marked the extra paragraphs with a different paragraph style and color, but exporting two PDF from a single office file is still a hassle - i have to remove everything by hand, then export, then put them back, which is prone to error too.

Is there a way to export a ODT to PDF but “excluding” an entire style, that is, acting like if it wasn’t here at all (even if that changes layout) ? This way I could export my master with the comments and export the commentless version with the same file.

Kind regards,

As I understand, you want both remove a style and remove any paragraphs formatted with that style, right? I doubt that it is possible in any other way than writing a macro.

I do not want to remove a style, I want to export a PDF document that omits every paragraph with style X. without having to remove said style or said paragraphs from my document before.

You can assign a style (or a group of heir styles) to the extra informations, and modify the (parent) style Hidden font effect before exporting the second file.

Tested with LibreOffice (x86); OS: Windows 6.1.

Add Answer is reserved for solutions. If you think the answer is not satisfactory, add a comment below, or click edit (below your question) to add more information. Thanks.

Check the mark (Answer markCorrect answer mark) to the left of the answer that solves your question.

If the answer helped you, you can mark the up arrow (Upvote mark) that is on the left (to vote, you need to have karma of at least 5).

This is very cool! Is there a way to make this automatic upon export, to generate to files?
Via script or something maybe?

Take a look at the answer for /question/136558/.

What you are looking for is usually called conditional text, i.e. part of the document is displayed depending on a condition. This requires to mark up your text.

First, at the beginning of your document, define a variable which will tell when the controlled text is hidden.

  • Insert>Field>More Fields
  • go to the Variables tab
  • in Type click on Set variable, type public in Name and 0 in Value
  • push Insert

With public set to 0, all the document is visible. When it is set to 1, only non-confidential content is shown.

Now, you’re ready to mark up your document.

At the beginning of restricted paragraphs:

  • Insert>Field>More Fields
  • go to the Functions tab
  • in Type click on Hidden Paragraph, in Condition enter public
  • push Insert

This keeps all styling possibilities unchanged for the paragraph and does not require a specific style.

Hiding individual words is also possible but not very flexible (all words in a “sequence” must have the same character style). Proceed as above but select Hidden text and enter the word in Hidden text instead of inside the paragraph.

I highly recommend you enable View>Formatting Marks and View>Field Shading so that you have visual cues about the existence and location of the various fields.

To change the display condition, double-click on the public definition and change its value.

To show the community your question has been answered, click the ✓ next to the correct answer, and “upvote” by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

In case you need clarification, edit your question (not an answer which is reserved for solutions) or comment the relevant answer.

Don’t works for me (LibreOffice (x86); OS: Windows 6.1). What could be the problem?

The condition tells when text is hidden (not when it is shown, what users usually expect). Otherwise you must write a full “equation” like public == 0. What is not user-friendly is you must define a variable. It would have been better to work with a File>Properties, Custom Property.

If it still doesn’t work, attach a sample file to a comment (I assume you know the trick as you’re now a power user of this site).

Got it. Choose menu Tools - Options… - LibreOffice Writer - View, and uncheck Hidden paragraphs.


There is a way to hide the 1 or 0? OK. I answer me. Check the Invisible field in the Edit Fields dialog. :slight_smile:

When editing, as an author, you should always keep hidden text visible. When the condition is in effect, hidden paragraphs have a dotted underline, just like text styled Hidden. I prefer this so that I always know if there is real conditional text or not. I admit it is more difficult to get the look of the final document but it avoids many mistakes.