Thread Subject: Report Generator - Export Figures to PDF in Vector format

Subject: Report Generator - Export Figures to PDF in Vector format

From: Richard

Date: 3 Oct, 2008 15:17:02

Message: 1 of 17

Hi there,

I'm trying to export figures to PDF files using Report Generator but am just getting a blank PDF with no figure inside.

I need the final figure to be in vector format so that it can be scaled in PDF viewer.

To do this I am specifying the 'Image File Format'of my 'Figure Snapshot' to be 'Color Encapsulated Postscript2'.

However this just outputs a PDF file, with no figure included.

Is this a bug, or are there some other options that need to be set in order to export vector graphics to PFD using Report Generator?

Many thanks for any help, Rich

Subject: Report Generator - Export Figures to PDF in Vector format

From: Richard

Date: 13 Oct, 2008 11:42:02

Message: 2 of 17

UPDATE

Mathworks have confirmed that the Report Generator uses third-party software that cannot retain vector properties when exporting to PDF via Report Generator, despite apparently offering this functionality in the Report Generator GUI.

This is now a known issue and the developers are working to resolve it for a future as yet unspecified release.

The work around is to not use Report Generator and use the print command with -dpdf option. This retains the vector format, but at the cost of the rest of the Report Generator functionality. In particular there is no append option with -dpdf so multi-page PDFs present more of a challenge.

I am looking into a solution for creating multi-page PDF documents via the -dpdf command.

I was initially thinking of resorting to a system command in conjunction with a third party PDF tool - however this presents it's own set of problems for deploying the compiled Matlab executable because of the dependancy on the third party .exe.

If anyone has any thoughts on whether it is technically possible to create a compiled Matlab GUI that creates multi-page vector PDFs, using pure Matlab code I would be very grateful.

Cheers, Rich


"Richard " <richard.germuska@nhs.net> wrote in message <gc5d1d$bn$1@fred.mathworks.com>...
> Hi there,
>
> I'm trying to export figures to PDF files using Report Generator but am just getting a blank PDF with no figure inside.
>
> I need the final figure to be in vector format so that it can be scaled in PDF viewer.
>
> To do this I am specifying the 'Image File Format'of my 'Figure Snapshot' to be 'Color Encapsulated Postscript2'.
>
> However this just outputs a PDF file, with no figure included.
>
> Is this a bug, or are there some other options that need to be set in order to export vector graphics to PFD using Report Generator?
>
> Many thanks for any help, Rich

Subject: Report Generator - Export Figures to PDF in Vector format

From: tristram.scott@ntlworld.com (Tristram Scott)

Date: 13 Oct, 2008 14:12:04

Message: 3 of 17

Richard <richard.germuska@nhs.net> wrote:
> UPDATE
>
> Mathworks have confirmed that the Report Generator uses third-party
> software that cannot retain vector properties when exporting to PDF via
> Report Generator, despite apparently offering this functionality in the
> Report Generator GUI.
[snip]

>
> If anyone has any thoughts on whether it is technically possible to
> create a compiled Matlab GUI that creates multi-page vector PDFs, using
> pure Matlab code I would be very grateful.

What about creating a LaTeX report instead, with the images going in as
eps? You can then run PDFLaTeX over it, or LateX, dvips and psp2df.

Not quite a pure MATLAB solution, but then, technically, neither is the
report generator.

Personally, I am still awaiting a command line version of the report
generator, allowing creation of documents paragraph by paragraph through
function calls. It doesn't seem to be the toolbox that gets the most
attention from the developers.

--
Dr Tristram J. Scott
Energy Consultant

Subject: Report Generator - Export Figures to PDF in Vector format

From: Richard

Date: 13 Oct, 2008 14:51:02

Message: 4 of 17

Thanks Tristram,

This should work for most people, but I am creating a reporting application that needs to be deployed as a compiled standalone.

I tried bringing in the various eps2pdf m-files and ghostscript files to the Matlab compiler but it fell over.

If anyone has any more ideas on exporting multi-page PDFs directly from Matlab without resorting to eps shenanigans that'd be great.

Cheers, Rich

PS I thought all of the Report Generator toolbox functions etc were already available on the command line as function calls? That said I've not used it much, but I think there's a way to expose the m-code that the report generator automatically creates.


> What about creating a LaTeX report instead, with the images going in as
> eps? You can then run PDFLaTeX over it, or LateX, dvips and psp2df.
>
> Not quite a pure MATLAB solution, but then, technically, neither is the
> report generator.
>
> Personally, I am still awaiting a command line version of the report
> generator, allowing creation of documents paragraph by paragraph through
> function calls. It doesn't seem to be the toolbox that gets the most
> attention from the developers.
>
> --
> Dr Tristram J. Scott
> Energy Consultant

Subject: Report Generator - Export Figures to PDF in Vector format

From: Richard Quist

Date: 14 Oct, 2008 13:28:32

Message: 5 of 17

Richard wrote:
> UPDATE
>
> Mathworks have confirmed that the Report Generator uses third-party software that cannot retain vector properties when exporting to PDF via Report Generator, despite apparently offering this functionality in the Report Generator GUI.
>
> This is now a known issue and the developers are working to resolve it for a future as yet unspecified release.
>
> The work around is to not use Report Generator and use the print command with -dpdf option. This retains the vector format, but at the cost of the rest of the Report Generator functionality. In particular there is no append option with -dpdf so multi-page PDFs present more of a challenge.
>
> I am looking into a solution for creating multi-page PDF documents via the -dpdf command.
>
> I was initially thinking of resorting to a system command in conjunction with a third party PDF tool - however this presents it's own set of problems for deploying the compiled Matlab executable because of the dependancy on the third party .exe.
>
> If anyone has any thoughts on whether it is technically possible to create a compiled Matlab GUI that creates multi-page vector PDFs, using pure Matlab code I would be very grateful.
>
> Cheers, Rich
>
The ps2pdf function I submitted to the File Exchange (available from here:
http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectId=1097474&objectType=author)
will create a pdf file from a specified postscript file. Since MATLAB supports
creating multi-page postscript files (using the -append option of the print
command) you can create multi-page pdf files with this utility.

Hope that helps.
--

Richard Quist
Software Developer
The MathWorks, Inc.

Subject: Report Generator - Export Figures to PDF in Vector format

From: Richard

Date: 14 Oct, 2008 16:24:01

Message: 6 of 17

But can ps2pdf be compiled and distributed to platforms with only the MCR (Matlab Compiler Runtime) installed? i.e

1) Does the MCR R2008a install a version of Ghostscript?

2) If it does will ps2pdf detect the MCR's version of Ghostscript to generate an A4 pdf using ps2pdf('psfile', 'input.ps', 'pdffile', 'output.pdf', 'gspapersize', 'a4')?

Cheers, Rich

> The ps2pdf function I submitted to the File Exchange (available from here:
> http://www.mathworks.com/matlabcentral/fileexchange/loadAuthor.do?objectId=1097474&objectType=author)
> will create a pdf file from a specified postscript file. Since MATLAB supports
> creating multi-page postscript files (using the -append option of the print
> command) you can create multi-page pdf files with this utility.
>
> Hope that helps.
> --
>
> Richard Quist
> Software Developer
> The MathWorks, Inc.

Subject: Report Generator - Export Figures to PDF in Vector format

From: Richard

Date: 14 Oct, 2008 17:14:02

Message: 7 of 17

Here's the error message I get in the DOS box when I try and run a compiled GUI that uses ps2pdf:

?? Undefined function or method 'gscript' for input arguments of type 'char'.

error in ==> ps2pdf at 123

The GUI was previously working as an uncompiled M-file.

Richard is this a straightforward update for ps2pdf?


Subject: Report Generator - Export Figures to PDF in Vector format

From: Richard

Date: 14 Oct, 2008 17:39:02

Message: 8 of 17

It seems that some form of ghostscript might be included in the MCR and the default install path in the MCR is:

C:\Program Files\MATLAB\R2008a\toolbox\compiler\mcr\matlab\graphics\private

This folder does not include gswin32c.exe but it does include the following possibly relevant files:

ghostscript.m
gscript.mexw32

However manually passing these as the path to ps2pdf does not work either e.g.

gs_MCR_path = 'C:\Program Files\MATLAB\R2008a\toolbox\compiler\mcr\matlab\graphics\private\gscript.mexw32';

ps2pdf('psfile', [output_string,'.ps'], 'pdffile', [output_string, '_converted.pdf'], 'gspapersize', 'a4',...
'gscommand', gs_MCR_path);

Any ideas?

Subject: Report Generator - Export Figures to PDF in Vector format

From: Richard

Date: 24 Oct, 2008 11:17:02

Message: 9 of 17

Sorry to do this but reposting as no response in last 7 days and this issue is becoming project critical. Originally posted on 3rd October.

Any ideas on how to get ps2pdf working in a compiled standalone app?

Thanks, Rich

Subject: Report Generator - Export Figures to PDF in Vector format

From: tristram.scott@ntlworld.com (Tristram Scott)

Date: 24 Oct, 2008 13:21:44

Message: 10 of 17

Richard <richard.germuska@nhs.net> wrote:
> Sorry to do this but reposting as no response in last 7 days and this
> issue is becoming project critical. Originally posted on 3rd October.
>
> Any ideas on how to get ps2pdf working in a compiled standalone app?
>
> Thanks, Rich

Install a copy of Ghostscript, and make sure it is on your PATH. Then you
should be able to use !ps2pdf myfile or dos('ps2pdf myfile').

ps2pdf is part of the standard Ghostscript distribution.

--
Dr Tristram J. Scott
Energy Consultant

Subject: Report Generator - Export Figures to PDF in Vector format

From: Walter Roberson

Date: 24 Oct, 2008 14:20:38

Message: 11 of 17

Richard wrote:
> Sorry to do this but reposting as no response in last 7 days and this issue is
> becoming project critical. Originally posted on 3rd October.

> Any ideas on how to get ps2pdf working in a compiled standalone app?

Sorry, the response from this quarter is "I am -completely- unfamiliar with
the Report Generator, so my existing experience does not help; and I have
not licensed the Report Generator -or- the compiler, so I cannot experiment."

Subject: Report Generator - Export Figures to PDF in Vector format

From: Richard

Date: 24 Oct, 2008 15:27:02

Message: 12 of 17

Thanks Tristram,

I am hoping NOT to have to install Ghostscript on every client I deploy the application to...

Since I think Ghostscript already comes with the MCR (Matlab Compiler Runtime) the question really is how to make ps2pdf.m that Richard Quist wrote find the right file in the MCR installation - does anyone know what it is? See postings above for more details on what I've already tried...

Walter, this has now turned into a conversation about the compiler only. The report generator solution was ditched early on in the thread (despite the title!).

Any other ideas?

Subject: Report Generator - Export Figures to PDF in Vector format

From: Richard Quist

Date: 27 Oct, 2008 14:38:06

Message: 13 of 17

Richard wrote:
> Sorry to do this but reposting as no response in last 7 days and this issue is becoming project critical. Originally posted on 3rd October.
>
> Any ideas on how to get ps2pdf working in a compiled standalone app?
>
> Thanks, Rich

It appears to be a problem with accessing the mex file in a private directory.
I've asked internally about the issue and will post again when I know more. As
an interim workaround, it should be possible to copy the gscript.mexw32 file
into the same directory as the ps2pdf.m file
--

Richard Quist
Software Developer
The MathWorks, Inc.

Subject: Report Generator - Export Figures to PDF in Vector format

From: Micha?l

Date: 7 Nov, 2008 18:19:02

Message: 14 of 17

Richard Quist <rquist_nospam@mathworks.com> wrote in message <ge4joe$3m1$1@fred.mathworks.com>...
> Richard wrote:
>
> It appears to be a problem with accessing the mex file in a private directory.
> I've asked internally about the issue and will post again when I know more. As
> an interim workaround, it should be possible to copy the gscript.mexw32 file
> into the same directory as the ps2pdf.m file
> --

I've tried this workaround (to include the gscript.mexw32 file with the "others files" of the deploy tool). It works well in an executable runned on a Matlab equiped computer but fails on a computer equiped only with the MCR (v78).
Any thought?

Michael Fournier

Subject: Report Generator - Export Figures to PDF in Vector format

From: tristram.scott@ntlworld.com (Tristram Scott)

Date: 7 Nov, 2008 19:30:52

Message: 15 of 17

Micha?l <orthal@hotmail.com> wrote:
> Richard Quist <rquist_nospam@mathworks.com> wrote in message
> <ge4joe$3m1$1@fred.mathworks.com>...
>> Richard wrote:
>>
>> It appears to be a problem with accessing the mex file in a private
>> directory.
>> I've asked internally about the issue and will post again when I know
>> more. As
>> an interim workaround, it should be possible to copy the gscript.mexw32
>> file
>> into the same directory as the ps2pdf.m file
>> --
>
> I've tried this workaround (to include the gscript.mexw32 file with the
> "others files" of the deploy tool). It works well in an executable runned
> on a Matlab equiped computer but fails on a computer equiped only with the
> MCR (v78).
>
> Any thought?
>

Do you have a copy of ghostscript properly installed and on the search path
of the machine with only the MCR?

--
Dr Tristram J. Scott
Energy Consultant

Subject: Report Generator - Export Figures to PDF in Vector format

From: Micha?l

Date: 13 Nov, 2008 15:45:05

Message: 16 of 17

tristram.scott@ntlworld.com (Tristram Scott) wrote in message <MH0Rk.2556$QF4.959@newsfe13.ams2>...
> Micha?l <orthal@hotmail.com> wrote:
> > Richard Quist <rquist_nospam@mathworks.com> wrote in message
> > <ge4joe$3m1$1@fred.mathworks.com>...
> >> Richard wrote:
> >>
> >> It appears to be a problem with accessing the mex file in a private
> >> directory.
> >> I've asked internally about the issue and will post again when I know
> >> more. As
> >> an interim workaround, it should be possible to copy the gscript.mexw32
> >> file
> >> into the same directory as the ps2pdf.m file
> >> --
> >
> > I've tried this workaround (to include the gscript.mexw32 file with the
> > "others files" of the deploy tool). It works well in an executable runned
> > on a Matlab equiped computer but fails on a computer equiped only with the
> > MCR (v78).
> >
> > Any thought?
> >
>
> Do you have a copy of ghostscript properly installed and on the search path
> of the machine with only the MCR?
>
> --
> Dr Tristram J. Scott
> Energy Consultant

My application is going to be distributed to computers on which I'll have no control. That's the reason why I'd like to use internal Matlab (MCR) libraries only.

Thanks,
Micha?l

Subject: Report Generator - Export Figures to PDF in Vector format

From: tristram.scott@ntlworld.com (Tristram Scott)

Date: 14 Nov, 2008 10:14:16

Message: 17 of 17

Micha?l <orthal@hotmail.com> wrote:
> tristram.scott@ntlworld.com (Tristram Scott) wrote in message <MH0Rk.2556$QF4.959@newsfe13.ams2>...
>>
>> Do you have a copy of ghostscript properly installed and on the search path
>> of the machine with only the MCR?
>>
>
> My application is going to be distributed to computers on which I'll have
> no control. That's the reason why I'd like to use internal Matlab (MCR)
> libraries only.
>

Then, assuming you are going down this ghostscript route, you probably have
two choices. The first would be to tell the end users that when they
install your application they must also install ghostscript and add it to
the search path.

The second would be to link to the ghostscript libraries as part of your
build, calling them directly to create the pdf. You can probably put a
reasonably simple mex wrapper around ghostscript.

I have no experience with the MATLAB compiler, but I did think it was
possible to have it bundle up an arbitrary list of files together with all
the things it wants for itself. If that is the case, perhaps you can ask
it to distribute all of ghostscript too?

Really, though, I think that you seem to be going to an awful lot of effort
to work around something which is essentially a problem with the Report
Generator. Tell the MathWorks exactly what the problem is, and how much
grief it causes you, and see if they can provide a suitable workaround for
you.

--
Dr Tristram J. Scott
Energy Consultant

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
multipage Richard 13 Oct, 2008 07:45:09
dpdf Richard 13 Oct, 2008 07:45:09
compiled Richard 13 Oct, 2008 07:45:09
vector Richard 3 Oct, 2008 11:20:06
pdf Richard 3 Oct, 2008 11:20:06
report generator Richard 3 Oct, 2008 11:20:06
rssFeed for this Thread
 

MATLAB Central Terms of Use

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Terms prior to use.

Contact us at files@mathworks.com