Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The following MWE contains the offending code. The page that this code is on does not show up when the PDF is seen in Acrobat Reader. I do not use Acrobat myself, but my advisor does, so my thesis has to be compatible with the program. I could write this anew, but not knowing what the error is makes me wary.

It compiles without error, and shows up as should be in SumatraPDF. On Acrobat, though, the faded radial streaks do not show up, and whatever else is on the same page after this figure is not rendered at all.

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{document}
\begin{tikzpicture}
    %I draw the circle.
        \draw[purple!70!black,fill](0,0) circle(1.5);
        \draw[path fading=circle with fuzzy edge 10 percent,fill=purple!80](0,0) circle(1.5);
        \foreach \x in {0,30,...,360}{
    %I generate two random numbers and store them
        \pgfmathparse{rand}\pgfmathsetmacro{\randomnbr}{\pgfmathresult}
        \pgfmathparse{rand}\pgfmathsetmacro{\randomnbrpos}{\pgfmathresult}
    %I now draw the radial streaks.
            \draw[line cap=round,line width=\randomnbrpos*.5mm,purple!80!black,path fading=east,fading transform={rotate=5*\randomnbr+\x},rotate=5*\randomnbr+\x] (rand*.1+.5,0)--(\randomnbrpos*.5+1.0,0)++(0,1pt);
        }
    \end{tikzpicture}
\end{document}

This is how it should look
This is how it should look

share|improve this question
    
Could you reduce the example a bit further, until it only contains the absolute minimum that's necessary to reproduce the problem? All those \pgfmathparse lines and the \foreach distract from finding the root cause of the problem. –  Jake Dec 5 '13 at 13:11
    
I suspect they are part of the problem. If I remove one of the random numbers Adobe Acrobat will render a couple of the streaks, but still fail. –  Mr. V Dec 5 '13 at 13:22

2 Answers 2

up vote 13 down vote accepted

The problem is that you're using rand which generates random numbers between -1 and 1, instead of rnd, which generates random numbers between 0 and 1. This leads to some of the lines having a negative width, which throws Acrobat off.

Replacing the rand with rnd fixes the problem:

\documentclass[tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{fadings}
\begin{document}
\begin{tikzpicture}
    %I draw the circle.
        \draw[purple!70!black,fill](0,0) circle(1.5);
        \draw[path fading=circle with fuzzy edge 10 percent,fill=purple!80](0,0) circle(1.5);
        \foreach \x in {0,30,...,360}{
    %I generate two random numbers and store them
        \pgfmathsetmacro{\randomnbr}{rnd}
        \pgfmathsetmacro{\randomnbrpos}{rnd}
    %I now draw the radial streaks.
            \draw[line cap=round,line width=\randomnbrpos*.5mm,purple!80!black,path fading=east,fading transform={rotate=5*\randomnbr+\x},rotate=5*\randomnbr+\x] (rand*.1+.5,0)--(\randomnbrpos*.5+1.0,0)++(0,1pt);
        }
    \end{tikzpicture}
\end{document}
share|improve this answer

I can confirm this issue on OS X with Adobe Acrobat X. All other, PDFKit-based PDF viewers (Skim, Preview, IDE-integrated viewers) work fine.

A simple, but in my experience always working workaround with problematic PDFs is to sanitize them via conversion to PS and then to PDF1.3 (which basically rasterized some fading and transparency effects):

pdf2ps problematic.pdf tmp.ps
ps2pdf tmp.ps santized.pdf

The resulting PDF displays fine in Acrobat.

share|improve this answer
    
This works really well; +1 for that :-) For my example pdf document of 3 MB, it took ages to produce a 563 MB (!) postscript file and again ages to get the final 122 MB (!) pdf. On the screen, it appears rasterized but the printing gives good quality! –  Thomas F. Sturm Dec 18 '13 at 11:09
    
@ThomasF.Sturm: Yep, there is a price to pay – but if people have to get that thesis out of this #@$#& picky printer tonight, they usually don't mind it :-) However, an effective growth by factor 40 is pretty extreme, I never experienced that. Is your PDF basically a PDF shading test case? –  Daniel Dec 18 '13 at 21:50
    
Not directly; it's the fresh tcolorbox 2.60 manual which contains a lot of opacity effects and shadings. The fancy new cover image kills Adobe Reader X on Windows 7 when printing ... the free SumatraPDF prints without problems but not quite as nice as after the workaround process you described. For a good printout it is really worth to do it :-) –  Thomas F. Sturm Dec 19 '13 at 6:59
    
@ThomasF.Sturm: A beautiful manual, indeed! One thing that caught my eye is the footnote on p. 192: "The reason is that I am to dumb to catch the current color at the split point. If you know the trick, let me know." Well, I don't know it either, but why don't you just ask for it here? –  Daniel Dec 19 '13 at 8:39
    
Right! I just created a MWE for this problem. –  Thomas F. Sturm Dec 20 '13 at 8:39

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.