How to make elements visible in PDF but invisible at printing?

Hello all,

I have created a letter template where headers and footers have been inserted. These are also displayed during the PDF export.

My question: is there any way to hide the headers and footers when I print the document without having to delete them manually?

I have pre-printed letterheads. That’s why I want it to be hidden when printing, but visible when exporting to PDF - without changing the letter template.

Do you guys have a solution for this?

Greetings from Germany

If I understand right, you have stationery with printed header and footer and you want to avoid double printing them (with a high risk of misalignment). However, you want to keep the header/footer for archival purpose.

I see three possibilities:

  • you archive without header or footer (but this seems to be excluded)
    In case of need you can print on your stationery.

  • you slightly change your styles before printing
    This assumes your template and your letter are styled according to good practice instead of direct-formatting your text.
    Before printing, you set Hidden attribute in Header and Footer paragraph styles (Font Effects tab). Don’t save the modified document after printing.

  • you change the template before printing
    In this solution, I assume that you use word “template” in its Writer technical meaning, i.e. an .ott document which turns into a .odt file as soon as it is opened. You then prepare two templates:

    • the “normal” one with all styles definitions and initial contents, including header and footer
    • the “printing” one containing only the styles definitions, among which Header and Footer are made hidden as explained above
      You also need to install the TemplateChanger extension.

    The procedure is as follows:

    • you create your letter based on the “normal” template with header and footer
    • you save this “fully decorated” letter
    • when you want to print the letter on plain paper, do it as usual
    • when you want to print on your stationery:
      • rebase the letter on the “printing” template with TemplateChanger
      • print
      • don’t save the modified file
1 Like

Thank you for the prompt answer, @ajlittoz. You did understand my problem. The solution sounds more complex, especially for casual users.

The LibreOffice team should consider this as a nice feature making elements hidden in print, but visible in PDF.

I am not sure that your special requirement fits in the intended use of any office suite. Adding elements in a document to “hide” them immediately (and those “elements” have no side effect on others) looks a bit weird.
Your problem is not a document-creation problem, it is an archival issue. What you want in fact is some sort of scanning the outbound mail without going through the pain of a real scanning step.
A finally user-friendly solution goes by answering “What do you do with archived letters?”. Do you need to print them again in case of problems? Do they serve as legal proof? But usually, courts request written evidence, not electronic files (though things are evolving in this domain); so you have to print them again (plain paper or stationery)?
The only reason I see for header archival is the event your office is relocated somewhere else and your archived copy will keep track of the various locations, phone numbers, tax id number, bank account, …
I think it is up to you to introspect your workflow and find the best trade-off.

1 Like

I just want to make it very easy for my client. He is not really tech affine. He oftens print the document on pre-printed letterheads. In some case, he needs to send the documents / bills via email as PDF.

I want to make it as easy as possible without need to change the template. There are already options that make elements not printable, but pity, that make it also hidden on PDF export.

So, I can also call this as a feature request?

Anyway, thank you for the answers so far, @ajlittoz :slight_smile:

You may call it whatever you like but to cite this site
Feature requests should go directly to Bugzilla as Enhancements .

Comes from here:

You could work the other way round.
Create the document without header-footer. The client may print as usual on his stationary.
.
Create a macro to generate also the pdf without header, but add some code to add a pdf-stationary to archive or mail.
.
Some time ago I created a solution for this using PDFtk/STAMPtk using SHELL() from a macro

.
Can find/post the macro, if you are interested…

1 Like

Hi,
my simple proposal is to have “connected” sections in a single document (for doubling the content). Within the Writer-document you have two varieties of page styles: with and without headers and footer.
If you print out on paper you have to select the “without” pages, for PDF export you have to select the “with” pages.
See attached screenshot and sample file.

Problems:

  • Updating after inserting more content (menu Tools | Update | Update all)
  • Erasing page 2 - you probably have to apply the page style of the duplicatet text area anew.




PagesWithWithoutHeaderFooter_SectionDoubling.odt (63.4 KB)

Cheers

2 Likes

Thanks @Grantler, but that is not a good solution.

I really want to avoid copy pasting content. Just one content and if printing, then header & footer invisible and if PDF, then header / footer visible. I really want to make it easy for my client, who is not very tech affine.

But I am really grateful that you all are trying to help me!

OMG. So check my second attempt which is a bit simpler than the first one. It is a little bit strange combination of frames and sections… Sometimes the header was not shown despite inserting the right field value…
Hopefully your assistant can manage to insert number 0 or 1 (or 2… :blush:).



HeaderFooter_ShowHideWhenPrinted.odt (75.8 KB)

2 Likes

Preprint_Dummy_Template.ott (99.2 KB)

This is the mockup of a German letter template with preprinted contents. It has a push button in the top-right corner with property Print=Off.
Frame1 shows the current path and name of the stored document with option Print=Off
Frame2 has the receipient’s address with option Print=On
One OLE Object (LibreOffice Draw) named “PDF_Print_Letterhead_1”.
The left border has 3 fold marks which are invisible by default.
“PDF_Print_Fold_Mark1_1”
“PDF_Print_Fold_Mark2_1”
“PDF_Print_Fold_Mark3_1”

The push button calls a macro embedded in the template. It could be stored in the global scope as well.
The macro breaks if the document is a template .ott or if the document is not yet saved.
If the document is saved as a text document (
.odt), every element having a name starting with “PDF_Print_” and ending with “1” becomes visible or printable. Every element having a name starting with “PDF_Print_” and ending with “0” becomes hidden or unprintable. Then the document is exported to PDF under the same path-name as the document. Existing PDFs won’t be overwritten. They get a 2-digit version number as in “MyDocument_01.pdf”.
After the PDF has been saved, the macro resets all “PDF_Print_” elements to the opposite state for paper print. What you see in the print preview is the paper print.
For testing or if something went wrong, there are 2 separate macros Prepare_PDF and Prepare_Print to reset the document to either state.

This is the PDF output I get:
Document_03.pdf (56.5 KB)

1 Like

Wow, thank you very much for your help! This seems the “easiest” way to make headers / footers invisible, when printing, but visible on PDF. But to be honestly: I am not a friend of using macros.

I will try to learn how this macro works and how to make a template for the client in the easiest possible way.

Thank you and all other users again for the help!

Short instruction manual:

  1. Design your template for paper print with PDF stuff hidden/unprintable. You find these options in the properties dialog of the respective element (picture, frame, OLE object, form control).
  2. Copy my template’s Basic module to your template or put it anywhere under “My Macros” (current users’s user profile).
  3. Turn on design view in the Forms menu, attach a form control of type “push button”, turn off control property “Printable” and assign the module’s “Main” routine to the button’s execute event. Instead of an attached button, you may prefer some custom menu entry or toolbar button. Custom menues and toolbars can be attached to templates.
  4. Rename all the elements that you want to be visible on PDF only with prefix “PDF_Print_” and suffix “1”.
  5. Rename all the elements that you want to be visible on paper print only with prefix “PDF_Print_” and suffix “0”.
  6. Create a new test document from your template and store it in a “trusted directory” according to Tools>Options>Security… [Macro Seurity…]. After saving for the first time, call menu:File>Reload. This will reload the document from the trusted directory without any macro warning.
  7. Start testing your test document with the help of the print preview and macros “Prepare_PDF” and “Prepare_PDF”.

To avoid any macro warning right from the start, it might be best practice to store this template in a trusted directory or declare the user profile’s template directory as trusted. Do not lower the security level. Do not add the user’s downloads directory to the trusted sources.