Bug introduced in 12 or earlier and persisting through 13.1.0 [CASE:4899765]

The following code generates a plot that has a faint outline around the top, left, and right boundaries of the filling. In Mathematica (, Mac) itself, the outline is not present. It only appears when exporting.

How can I remove this outline?

        {x, 0, 2 Pi},
        Filling -> Top

The outline also appears when exporting Graphics of Polygons and similar shapes.

screenshot of the PDF


2 Answers 2


How about getting rid of the Opacity in the filling?:

Plot[Sin[x], {x, 0, 2 Pi}, Filling -> Top, 
 FillingStyle -> Blend[{White, ColorData[97][1]}, 0.2]]
Export[FileNameJoin[{$TemporaryDirectory, "test.pdf"}], %];
  • $\begingroup$ A solution that respects the Opacity would be nice to have, but this works for my current use case. Thank you! $\endgroup$
    – A.Z.
    Jan 25, 2022 at 18:41

I reproduce the problem with versions 13.0.0 and 12.3.1 on Windows 10 x64, but not with version 8.0.4 on the same machine.

The issue happens when we Export to PDF a Graphics object containing a Rectangle or Polygon primitive with Opacity directive. A minimal example:

gr = Graphics[{Opacity[0.5], Rectangle[]}];
Export["test.pdf", gr] // SystemOpen

In the exported file opened by Adobe Acrobat Reader the rectangle has an unwanted outline:


To explore the problem deeper, I define an auxiliary function that exports supplied expression to PDF, and then immediately imports the results as vector graphics:

vectorExportImportPDF[expr_] :=
  First@ImportString[ExportString[expr, "PDF", "AllowRasterization" -> False],
    If[$VersionNumber >= 12.2, {"PDF", "PageGraphics"}, {"PDF", "Pages"}],
    "TextOutlines" -> False];

Apply it to the above Graphics:

vectorExportImportPDF[gr] // ResourceFunction["ShortInputForm"]


We see that imported graphics contains an explicit outline defined via JoinedCurve. We can see the outline alone if we remove the FilledCurve object:

vectorExportImportPDF[gr] /. _FilledCurve -> {}


Apparently, it is a bug. Reported to the support as [CASE:4899765].

A solution that respects the Opacity would be nice to have

A workaround is to Export a FilledCurve, but not Rectangle or Polygon primitive:

gr2 = vectorExportImportPDF[gr] /. _JoinedCurve -> {};

vectorExportImportPDF[gr2] // ShortInputForm


  • $\begingroup$ I'm curious how did you test with different versions? Did you just install and uninstall them to test? $\endgroup$
    – hana
    Jun 30, 2022 at 9:53
  • 1
    $\begingroup$ @hana Usually I have several versions installed at the same time. $\endgroup$ Jun 30, 2022 at 9:55
  • $\begingroup$ Nice, I didn't know you can do that. $\endgroup$
    – hana
    Jun 30, 2022 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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