Problem on saving chart as a pdf by programming.

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

Liu
Posts: 90
Joined: Tue Jun 08, 2010 6:22 am

Problem on saving chart as a pdf by programming.

Postby Liu » Mon Jul 30, 2012 7:11 am

Hi all,

I understand that eviews might not let users save a chart in a PDF format as an option of graph.save. However, I installed a software to enable my
computer to do so.

My problem is: how can I do it by programming. Right now, whenever I want to save a chart, I have to open a chart, click" Print" , and select printer (which is the software I use to save as PDF file). Can I use commands to do all these? This is because I have roughly a hundred charts created by a program. To save them by clicking is really painful. It would save much time if I could do them by commands.

Thanks in advance.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Problem on saving chart as a pdf by programming.

Postby EViews Gareth » Mon Jul 30, 2012 7:58 am

Since EViews doesn't offer printing to a PDF document, there is no way to print to a PDF document via the command line / in a program.

Liu
Posts: 90
Joined: Tue Jun 08, 2010 6:22 am

Re: Problem on saving chart as a pdf by programming.

Postby Liu » Mon Jul 30, 2012 8:33 am

Hi Gareth,

I understand what you mean, but what I mean is: is there a way I can convert the manual work into command:
theoratically, all the actions (such as clicking, manual inputting etc.) have commands behind the shell.
If I can do something via clicking, I should be able to also do it via commanding. Just my quick thought though.

The key of the problem is: how to assign a printer as eviews' printing device by command.
I tried the print command options, but didn't find what argument I should change to set my external
software (which I used to save a chart as PDF) as default printer. If I can do the printer setting by command, I think
the problem is solved.

startz
Non-normality and collinearity are NOT problems!
Posts: 3798
Joined: Wed Sep 17, 2008 2:25 pm

Re: Problem on saving chart as a pdf by programming.

Postby startz » Mon Jul 30, 2012 8:44 am

Two things:

Gareth: Would it be possible to use Print Setup and set the printer to a pdf driver? At least only one manual intervention would be required?

Liu: Perhaps surprisingly, EViews isn't a shell on top of commands. A lot of the GUI is hardwired to the code, with the commands being the add-on.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Problem on saving chart as a pdf by programming.

Postby EViews Gareth » Mon Jul 30, 2012 9:16 am

I think the issue you're both missing is that EViews isn't offering the GUI that does the PDF printing. That is offered by whatever software you downloaded that offers PDF printing.

Liu when you say that:
If I can do something via clicking, I should be able to also do it via commanding. Just my quick thought though.
This is only true for things that EViews does. EViews does not do PDF printing, therefore there is no command to do it.


All you can do in EViews is select a printer. Anything that happens after EViews has sent a document to print is not controllable by EViews.

startz
Non-normality and collinearity are NOT problems!
Posts: 3798
Joined: Wed Sep 17, 2008 2:25 pm

Re: Problem on saving chart as a pdf by programming.

Postby startz » Mon Jul 30, 2012 9:20 am

Uh, if the default print driver happens to be a pdf driver (nothing to do with EViews) won't printing send out pdfs? Or is the problem that the pdf print driver needs interaction that can't be automated inside EViews?

Alternatively, send files to a spool and then print the spool to pdf manually???

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Problem on saving chart as a pdf by programming.

Postby EViews Glenn » Mon Jul 30, 2012 9:49 am

In principle, yes to the first question, but as you have speculated, the problem is that most drivers that print to a file prompt you for the output file name.

Liu
Posts: 90
Joined: Tue Jun 08, 2010 6:22 am

Re: Problem on saving chart as a pdf by programming.

Postby Liu » Mon Jul 30, 2012 11:42 am

I think the issue you're both missing is that EViews isn't offering the GUI that does the PDF printing. That is offered by whatever software you downloaded that offers PDF printing.

Liu when you say that:
If I can do something via clicking, I should be able to also do it via commanding. Just my quick thought though.
This is only true for things that EViews does. EViews does not do PDF printing, therefore there is no command to do it.


All you can do in EViews is select a printer. Anything that happens after EViews has sent a document to print is not controllable by EViews.

Hi Gareth,
That's exactly what I want. It would be great if I could use commands to select a printer, which will bypass the limitation that eviews can't save pdf.
I guess it might be a command like: print (printer=PDFwriter) chart1 . This way I don't have to open each chart and click print then click printer everytime.

Hi Startz and Glenn:
you are right that the external software does require a file name when I intend to "print" to the PDF printer. However, that is not a big problem since the chartname is the default file name (or at least I can solve that problem later.)
It would be great if I can assign a printer as default printer by defaut. Right now the default printing device for eviews is the last device used for printing.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Problem on saving chart as a pdf by programming.

Postby EViews Glenn » Mon Jul 30, 2012 11:50 am

Should be the default printer for your system. If you change your system printer EViews should pick that up.

Liu
Posts: 90
Joined: Tue Jun 08, 2010 6:22 am

Re: Problem on saving chart as a pdf by programming.

Postby Liu » Tue Jul 31, 2012 1:14 pm

The default printer is always the last printing device being used by eviews. The system printer unfortunately is not recognized as default for eviews.
Can I use a command to verbally assign a printer as default printer in the printing command?

Right now, I used print chart1 to save chart1 in a pdf format, and it took me to the PDF-writer interface. The question is:
can I ask eviews to hit enter for me? I know eviews can do it to certain programs but I'm not sure how I can achieve it in this case.

Many thanks.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: Problem on saving chart as a pdf by programming.

Postby EViews Glenn » Tue Jul 31, 2012 2:09 pm

I never change printers so I wasn't sure about that one. Thanks. Unfortunately, you'll have to change the driver by hand.

Unfortunately, EViews is not going to be able to communicate with the print driver for you. Drivers sometimes have settings that allow you to skip the prompt step, but that's really driver specific.

startz
Non-normality and collinearity are NOT problems!
Posts: 3798
Joined: Wed Sep 17, 2008 2:25 pm

Re: Problem on saving chart as a pdf by programming.

Postby startz » Tue Jul 31, 2012 2:13 pm

Liu,

Gareth is a little distracted at the moment :D

To solve your practical problem, send all your graphs to one spool. Then manually print that one spool to a pdf.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Problem on saving chart as a pdf by programming.

Postby EViews Gareth » Tue Jul 31, 2012 3:35 pm

Or, find a PDF printing program that has full command prompt support, then save your graphs to disk within EViews and then use the Shell or Spawn commands to trigger the PDF printer.

startz
Non-normality and collinearity are NOT problems!
Posts: 3798
Joined: Wed Sep 17, 2008 2:25 pm

Re: Problem on saving chart as a pdf by programming.

Postby startz » Tue Jul 31, 2012 3:56 pm

Or, find a PDF printing program that has full command prompt support, then save your graphs to disk within EViews and then use the Shell or Spawn commands to trigger the PDF printer.
Try irfanView http://www.irfanview.com/

Liu
Posts: 90
Joined: Tue Jun 08, 2010 6:22 am

Re: Problem on saving chart as a pdf by programming.

Postby Liu » Wed Aug 01, 2012 9:10 am

I never change printers so I wasn't sure about that one. Thanks. Unfortunately, you'll have to change the driver by hand.

Unfortunately, EViews is not going to be able to communicate with the print driver for you. Drivers sometimes have settings that allow you to skip the prompt step, but that's really driver specific.
From what I understand, this limitation is basically solved by using spool and shell commands, as long as the software has command-line interfaces? So the idea is: spawn a command to a
cli based pdf writer? (I guess Irfanview meets both requirements since Startz recommended it.)

just a quick question here, can I use spawn/shell to push multiple commands to external software?
such as

Code: Select all

spawn "c:\program\irfanview.exe" save /path/ chart1 exit irfanview.exe


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests