We will be migrating from Ask to Discourse on the first week of August, read the details here

# Exclude a style from exporting [closed]

Hello,

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,

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by Alex Kemp close date 2021-06-01 22:05:43.008558

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.

( 2020-12-29 10:52:46 +0200 )edit

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.

( 2020-12-29 11:08:40 +0200 )edit

Sort by » oldest newest most voted

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 6.4.7.2 (x86); OS: Windows 6.1.

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

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

more

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

( 2020-12-29 17:34:28 +0200 )edit

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

( 2020-12-29 17:39:10 +0200 )edit

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.

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.

more

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

( 2020-12-30 15:45:06 +0200 )edit

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).

( 2020-12-30 16:50:06 +0200 )edit

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

Thanks.

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

( 2020-12-30 17:03:03 +0200 )edit
1

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.

( 2020-12-30 17:11:30 +0200 )edit