I want a faithful PDF file of the exported graphs from Mathematica 13 & 14. The MWE is based upon plotting multiple functions with one control parameter as:
legend2[ls__] = LineLegend[Dashing /@ {None, {0.02, 0.01}}, {ls}, "LegendItem" -> {sparkline}];
testPlot = Plot[Evaluate[Table[Style[{Sin[a r], 3 + Cos[a r]}, ColorData["Rainbow"][(a - 1)/(8 - 1)]], {a, 1, 8, 1}]], {r, -Pi, Pi},
PlotRange -> {All, All},
PlotStyle -> {Automatic, Dashing[{0.02, 0.01}]},
PlotLegends -> legend2["A", "B"]]
Export[SetDirectory[NotebookDirectory[]] <> "//testFile.pdf", testPlot, "PDF", "AllowRasterization" -> False]
Export[SetDirectory[NotebookDirectory[]] <> "//testFile.png", testPlot, "PNG", "AllowRasterization" -> False]
Export[SetDirectory[NotebookDirectory[]] <> "//testFile.svg", testPlot, "SVG", "AllowRasterization" -> False]
Any workaround this problem/bug or any other way to get PDF file without such issues?


"LegendItem" -> {sparkline}does not work on "14.1.0 for Mac OS X ARM (64-bit) (July 16, 2024)". $\endgroup$