9

I already have set a document with text and image. On the whole document:

Is it possible to make the white background go set to black?

That is: text in white color & background in black color.

I know this is very anti-economical print-wise, but it's for artistic purposes. In this approach I would only be printing the black sections in a regular printer.

There's also a black and white image, and gray too (cc symbol). If I can keep that in original colors it'd be best. (Or not! ..oh my! I have to check how it looks)

This has been done before but not on such a big scale of page:

Perhaps an option to invert colors in full document?

This would change the image. But since it's only one maybe that can be inverted too.


Another chance could be to just take the .tex file and format the color of text (and leaving background unchanged): change black (standar) color of letters to white and get a proper printer and use black paper as background. It'd be great to hear ideas on this option too. Although printing with white ink on black-tainted pages may be even more expensive than the 1st option...


SeRe's answer is just great. I'm just going to add a mwe of my own because I had some frames that went back to default and I wanted to post how I managed to customize them to be as the rest of the document. Any other ideas on how to do this are more than welcome.

\documentclass[12pt]{report}
\usepackage{xcolor}
\usepackage{pagecolor}
\usepackage{lipsum}  
\usepackage{mdframed}

\pagecolor{black}
\color{white}

\begin{document}
\lipsum[2]

\begin{mdframed}[backgroundcolor=black,linecolor=white,fontcolor=white]
\texttt{\textbf{Yes! Customized.}} \\
In any right triangle, the area of the square whose side is the hypotenuse
is equal to the sum of the areas of the squares whose sides are the two
legs.\end{mdframed}

\mdfapptodefinestyle{example1}{backgroundcolor=brown!20,linecolor=red!40!black,linewidth=4pt}
\begin{mdframed}[style=mdfexample1]\textit{No: Default mdframed.} \\Not desirable white backgroundcolor and text in black.\end{mdframed}
\lipsum[3]
\end{document}
12
 \documentclass[a4, 12pt]{report}
\usepackage{xcolor}
\usepackage{pagecolor}
\usepackage{lipsum}  

\pagecolor{black}
\color{white}

\begin{document}

\lipsum
\lipsum
\lipsum


\end{document}

This gives you as global pagecolor black and as global textcolor white. I think that this is what you're looking for. For further information, you can also have a look on the pagecolor package

5

Let's assume you have the following 259 page document, littered with text and images:

enter image description here

\documentclass{article}

\usepackage{graphicx,lipsum}
\newcounter{lipsumcntr}

\begin{document}

\loop\unless\ifnum\value{lipsumcntr}=50
  \stepcounter{lipsumcntr}
  \lipsum[1-\thelipsumcntr] {\centering \includegraphics[width=.8\linewidth]{example-image}\par}
\repeat

\end{document}

It is not possible to retro-actively change a PDF from within (La)TeX. It is a processed, binary format. (La)TeX can only display it as-is without much change. As such, you might be encouraged to follow a conversion process that I list below. Everything can be done in bulk.

Here are the steps you can follow:

  1. Burst the PDF into single-page PDFs using The PDF Toolkit:

    pdftk myfile.pdf burst
    

    This creates a bunch of pg_XXXX.pdf files, one for each page where XXXX has a leading 0. The above document therefore produces the files pg_0001.pdf through pg_0259.pdf.

  2. Use ImageMagick to bulk-convert and -negate each page:

    mogrify -format png -negate -sharpen 0x0.1 -density 300 -quality 100 pg_0*.pdf
    

    I've tried to keep a high-quality output. Depending on the image quality chosen to convert the burst pages to PNG, this may take quite a while.

  3. Create a new PDF containing the -negated images:

    enter image description here

    \documentclass{article}
    
    \usepackage{graphicx,eso-pic,pagecolor}
    \newcounter{pgcntr}
    \pagecolor{black}% Black page background
    
    \begin{document}
    
    \pagestyle{empty}% No page header/footer
    
    \loop\unless\ifnum\value{pgcntr}=259
      \clearpage
      \mbox{}% Just put something on the page
      \stepcounter{pgcntr}
      \AddToShipoutPictureFG*{
        \AtPageLowerLeft{
          \edef\pgnum{\ifnum\value{pgcntr}<100 0\fi\ifnum\value{pgcntr}<10 0\fi\thepgcntr}% Prepend with 0s
          \includegraphics[width=\pdfpagewidth]{pg_0\pgnum.png}% Insert image
        }
      }
    \repeat
    
    \end{document}
    

    The above loop inserts an \mbox{} on every blank page (no header/footer) and places a subsequent page - a PNG file - in the ForeGround so that it fits exactly within the page geometry (with the aid of eso-pic).

    We create a \pgnum macro to hold the page number about to be included. This macros prepends the actual page number with sufficient 0s in order to retrieve the required filename.

    Depending on the image quality chosen to convert the burst pages to PNG, this may take quite a while.

  4. Clean-up:

    del pg_0*.pdf
    del pg_0*.png
    
  5. Print

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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