Saving as .pdf seems to remove parts

Post questions on how to use or achieve an effect in Inkscape.
brasem
Posts: 3
Joined: Wed Nov 26, 2014 1:46 am

Saving as .pdf seems to remove parts

Postby brasem » Wed Nov 26, 2014 2:27 am

Hello,

I've been experiencing a really strange bug, and I was hoping a more experienced user could help me out. I have produced a .pdf figure using Matplotlib for those of you who know it. It is basically a 2D plot just like m@tlab (for some reason tis word activates spamfilter) makes them. I want to load this .pdf in Inkscape and then do some things to it and save it to a new .pdf image. The .pdf image that inkscape saves looks good when I open it with evince or acroread, but some people only see the 2D plot borders without any plot contents. When I open the .pdf in inkscape, the plot contents are also empty. So it seems like inkscape does something strange when exporting the plot to .pdf.

Some easy steps to reproduce what is going wrong

1: Use the .pdf image that I produced using matplotlib (was larger than 256kb so couldnt attach to forum post). http://web.mit.edu/lawillem/www/inkscape_problem/truncated_model_pluto_grid.pdf
2: Open the figure using Inkscape (I have version 0.48.5). Untick 'replace pdf fonts', but this does not seem to have an influence on the results.
3: For the easiest problem reproduce, just save the figure directly to another .pdf filename. I use 600dpi, and the results are similar for when I use pdf1.4 or pdf1.5
4: Now open the .pdf file you just output, using inkscape again. The content of the boxes is now empty, as can be seen in this Inkscape screenshot here : http://web.mit.edu/lawillem/www/inkscape_problem/bugged_output.png.
The funny thing is that if you open this .pdf in acroread or evince, it can show the plot contents correctly. Some pdfreaders also just show empty white boxes.

Could anyone please reproduce this ? If someone has ideas about how to fix this problem I'd be very grateful, because the problem is presenting some problems when sharing the draft of my paper with collaborators.
sincerely
Bram

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Saving as .pdf seems to remove parts

Postby Lazur » Wed Nov 26, 2014 2:56 am

Hi.

The problem is related how pdf- are organized. Matplotlib produces raster plots, that are embedded in the example pdf with masking.
Which masking cannot be re-saved right.
Like in this topic.
What can be done about it? ungrouping the opened pdf and removing the masking.
For that matter, the "gradients" are made up of 250+ objects -250 groups nested into eachother, each with a clipping involved. Replacing it with a simple gradient would produce a bit "cleaner" svg.

The fastest workaround yet is to share drafts would be to use raster images instead.

brasem
Posts: 3
Joined: Wed Nov 26, 2014 1:46 am

Re: Saving as .pdf seems to remove parts

Postby brasem » Wed Nov 26, 2014 4:19 am

Thanks Lazur, your instructions were very helpful. I will just leave some notes here about how the fix works for this specific problem. This will help someone else who tries to format matplotlib generated pdf figures, and it will help myself as well when I will undoubtedly run into this problem again at some point in the future :-)

1: Press control A to select everything, then do control U a few times to ungroup everything.
2: Press control A to select everything again, and then go to object -> mask -> release . The plots now all look white.
3: Select the white squares inside the plots and select 'lower selection to bottom (end)'. The plot will now pop up again.
4: When you save as .pdf and then load again in inkscape, the figure is correct!

These steps are probably stating the obvious, but it may help someone.
thanks Lazur URH! It would have taken me a very long time to figure this out by myself.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Saving as .pdf seems to remove parts

Postby Lazur » Wed Nov 26, 2014 4:25 am

Cheers!


Also mentioned the problem here, so maybe it will get to the attention of the developers as well.

brasem
Posts: 3
Joined: Wed Nov 26, 2014 1:46 am

Re: Saving as .pdf seems to remove parts

Postby brasem » Wed Nov 26, 2014 4:30 am

great, thanks!


Return to “Help with using Inkscape”