3
$\begingroup$

Why is the pdf output for the following flags not rendering properly? I am using v12.2.0 on Win7-x64.

threeflags = 
 CountryData[#, "Flag"] & /@ {"China", "Portugal", "Samoa"}

Export["C:/threeflags.pdf", threeflags]

To show the part with artifacts only (on the pdf):

enter image description here


I am trying to put together a poster of flags of all nations. These artifacts won't be so visible on a smaller sized poster but I would like to know if there are workarounds in case a larger sized poster has to be printed.

There are plenty of flags with stars and other detailed features that render correctly on the pdf, so it cannot be the pdf conversion process (or so I think).

Thanks for your help.

$\endgroup$
3
  • 1
    $\begingroup$ Are you talking about the black spots on the flag of Portugal? (I don't see any other artifacts in "13.3.0 for Microsoft Windows (64-bit) (June 3, 2023)"). To me it seems that these artifacts are due to "mistakes" in the graphics of the flag (which should be reported to the WRI), specifically the presence of Thickness[0.]. If you do Export["threeflags.pdf", threeflags /. Thickness[0.] -> Thickness[0.000831]], the output looks fine. $\endgroup$
    – Domen
    Jan 25 at 14:14
  • $\begingroup$ This workaround fixes the black spots from the flag of Portugal. I will manually edit the stars on the pdf, if nothing else works. @Domen Thanks $\endgroup$
    – Syed
    Jan 25 at 14:32
  • $\begingroup$ The flag of "Bosnia and Herzegovina" has a similar problem with stars after pdf conversion. $\endgroup$
    – Syed
    Jan 26 at 9:01

1 Answer 1

3
$\begingroup$

In V13.3, the only problematic flag (out of the three you provided) is the Portuguese one. I believe this is a bug in the graphics of the flag, specifically the Thickness[0.] of the bottom-right castle and part of the bottom-left castle, which can be seen already if you make the image smaller in the notebook (or observe the InputForm). I think this should be reported to the WRI.

As a workaround, you can significantly increase ImageSize.

portugal = CountryData["Portugal", "Flag"];
Export["portugal.pdf", portugal]

enter image description here

Export["portugal.pdf", portugal, ImageSize -> 3000]

enter image description here

Note that the same solution will help for the other two flags in V12, where the problem looks like a wrong calculation of the clipping mask.

$\endgroup$
3
  • $\begingroup$ You could also replace the Thickness directives in the Graphics, e.g. ReplaceAll[image, Thickness[_] -> Thickness[Scaled[0.0008]] ]. That seems to give a better image at all sizes, but I have not tried to export it. $\endgroup$
    – MarcoB
    Jan 25 at 14:53
  • $\begingroup$ @MarcoB, true, but you have to manually determine what thickness to use so that the flag looks correct. Also, for flags having lines with different thicknesses, this will mess them up ... Anyways, I think WRI should fix the thickness in their database :) $\endgroup$
    – Domen
    Jan 25 at 14:57
  • $\begingroup$ Yes, absolutely! It's not even the only problem with this flag. Some of the details may use a tune up too. $\endgroup$
    – MarcoB
    Jan 25 at 16:56

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.