Thread Subject: Print figures with a patch object into a searchable pdf file

Subject: Print figures with a patch object into a searchable pdf file

From: OKO

Date: 14 Mar, 2008 21:36:00

Message: 1 of 3

I used patch in Matlab to generate transparent object for a figure.
Then the figure need to be exported into a pdf file. The last
requirement is that, in the generated pdf file, the values (axis and
characters) need to be searchable, that means you can use text-cursor
to select those single value or characters.

I tried two methods, but each of them only reach partially my
requirement. So I was wondering if anyone can find a complete solution
to this.

Thanks in advance.

OKO


Matlab Codes:

%_____figure with a transparent object:______

x = [0.8, 1.6, 1.6, 1.2, 0.8];
y = [0.6, 1.2, 1.2, 0.9, 0.6];
z = [1, 1, 2, 1.7, 2];
patch(x, y, z, 'g','EdgeColor','none','FaceAlpha',0.3)
axis equal
box on
view([35, 30])

%______Solution 1:_____________________
print('-painters','-dpdf','-r100','c:\test.pdf')
%this is similar as using 'copy figure' in menu, paste into word, and
print as adobe pdf file
%the drawback of this method is that, the transparent object in the
figure becomes non-transparent!

%______Solution 2:_____________________
print('-dtiff','-noui','-r100','c:\1')
%create a tif file and then convert it into pdf using adobe
professional 8.0
%the figure in pdf is non-searchable

The
advantage and
disadvantage
Solution 1 value in pdf is
searchable lose transparent
object
Solution 2 transparent object kept in
pdf vaues in pdf is not
searchable

Subject: Print figures with a patch object into a searchable pdf file

From: Richard Quist

Date: 28 Mar, 2008 00:02:01

Message: 2 of 3

OKO <yuanjiabei@gmail.com> wrote in message
<d25ee624-f5e5-4564-9560-d3fa5e925835@e6g2000prf.googlegroups.com>...
> I used patch in Matlab to generate transparent object for
a figure.
> Then the figure need to be exported into a pdf file. The last
> requirement is that, in the generated pdf file, the values
(axis and
> characters) need to be searchable, that means you can use
text-cursor
> to select those single value or characters.
>
> I tried two methods, but each of them only reach partially my
> requirement. So I was wondering if anyone can find a
complete solution
> to this.
>
> Thanks in advance.
>
> OKO
>
>
> Matlab Codes:
>
> %_____figure with a transparent object:______
>
> x = [0.8, 1.6, 1.6, 1.2, 0.8];
> y = [0.6, 1.2, 1.2, 0.9, 0.6];
> z = [1, 1, 2, 1.7, 2];
> patch(x, y, z, 'g','EdgeColor','none','FaceAlpha',0.3)
> axis equal
> box on
> view([35, 30])
>
> %______Solution 1:_____________________
> print('-painters','-dpdf','-r100','c:\test.pdf')
> %this is similar as using 'copy figure' in menu, paste
into word, and
> print as adobe pdf file
> %the drawback of this method is that, the transparent
object in the
> figure becomes non-transparent!
>
> %______Solution 2:_____________________
> print('-dtiff','-noui','-r100','c:\1')
> %create a tif file and then convert it into pdf using adobe
> professional 8.0
> %the figure in pdf is non-searchable
>
> The
> advantage and
> disadvantage
> Solution 1 value in pdf is
> searchable lose
transparent
> object
> Solution 2 transparent object kept in
> pdf vaues in pdf is not
> searchable
>

As you've seen, each of the renderers have different
capabilities - painters, which allows you to make a
searchable pdf doesn't support transparency; opengl supports
transparency, but doesn't generate vector output (required
to be searchable).

You **MIGHT** be able to use exportfig from the file
exchange to output the text and graphics into 2 separate
files and then combine them (there's an epscombine also on
the file exchange)... Finally, you could call out to
ghostscript to convert the eps file into a pdf...

It's not pretty, but it might work.

-

Richard Quist
Software Developer
The MathWorks, Inc.

Subject: Print figures with a patch object into a searchable pdf file

From: Christopher Hummersone

Date: 11 Mar, 2010 18:29:21

Message: 3 of 3

OKO <yuanjiabei@gmail.com> wrote in message <d25ee624-f5e5-4564-9560-d3fa5e925835@e6g2000prf.googlegroups.com>...
> I used patch in Matlab to generate transparent object for a figure.
> Then the figure need to be exported into a pdf file. The last
> requirement is that, in the generated pdf file, the values (axis and
> characters) need to be searchable, that means you can use text-cursor
> to select those single value or characters.
>
> I tried two methods, but each of them only reach partially my
> requirement. So I was wondering if anyone can find a complete solution
> to this.
>
> Thanks in advance.

[snip]

I know this reply is a bit random but I googled for this, couldn't find a solution, but now have one so thought I would share it.

So if you want to:
- plot lines
- use patch objects (perhaps to shade regions) that are transparent
- export to PDF

You can overlay the line(s) on the patch object(s) instead of using transparency:
- Use plot3 instead of plot, set the Z-data to be ones the same size as X or Y
- Set Z in patch to be zeros the same size as X or Y
- Export to PDF as usual

Hope this helps someone sometime!

Chris

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
pdf Christopher Hummersone 11 Mar, 2010 13:29:28
patch Christopher Hummersone 11 Mar, 2010 13:29:28
transparent Christopher Hummersone 11 Mar, 2010 13:29:28
epscombine Richard Quist 27 Mar, 2008 20:05:09
exportfig Richard Quist 27 Mar, 2008 20:05:09
pdf Richard Quist 27 Mar, 2008 19:43:25
transparency Richard Quist 27 Mar, 2008 19:43:25
print Richard Quist 27 Mar, 2008 19:43:25
painters Richard Quist 27 Mar, 2008 19:43:25
opengl Richard Quist 27 Mar, 2008 19:43:25
rssFeed for this Thread

Contact us at files@mathworks.com