#11 Export eps and pdf?

open
nobody
None
5
2013-03-02
2007-02-02
Anonymous
No

Hi,

Sometimes it could be useful to export either eps or pdf from the PSTricks-file with the same name. I.e. not with some temporary name to some temporary directory but for example in default to the same directory where the pst file is located. Could be either command or script? Or is this possible today with some feature?

-Petri

Discussion

  • Mikael Öhman

    Mikael Öhman - 2008-07-20

    Logged In: YES
    user_id=1797910
    Originator: NO

    It's a workaround, in Linux or equivalent; but make a shellscript (make_eps.sh) add this custom action;

    #!/bin/sh

    cd $1
    # There are numerous ways to do this, with the common goal to connvert
    # latex to a small eps with a trimmed down bounding box.
    NAME=$2

    # Begin conversions
    latex $NAME.tex
    dvips $NAME.dvi -o $NAME.ps
    gs -q -sDEVICE=epswrite -dNOPAUSE -dBATCH -sOutputFile=$NAME.eps $NAME.ps
    # Now, this should be enough, but there seems to be a bug in version 8.62 of GS.
    # If you don't have the bounding box bug (GS always write 0 for bounding box for me)
    # Then you can skip these next few lines.
    CORRECT_BBOX=$(gs -q -sDEVICE=bbox -dBATCH -dNOPAUSE $NAME.ps 2>&1)
    # Split them up
    BOX=$(echo $CORRECT_BBOX | sed -e "s/%%HiRes.*//")
    HIRES=$(echo $CORRECT_BBOX | sed -e "s/%%Bound.*%%/%%/")
    sed $NAME.eps -e "s/%%Bounding.*/$BOX/" -e "s/%%HiRes.*/$HIRES/" > $NAME.eps_
    mv $NAME.eps_ $NAME.eps
    # END OF GS BUG-FIX

    # This tool could also do the trick if you wanted EPSF3.0 with preview (large files)
    #ps2epsi $NAME.ps $NAME.eps
    gv $NAME.eps
    #EOF

    Place the file wherever you want (i'm using {i}/unix/tetex/)
    Call this shellscript like this;
    {i}/unix/tetex/make_eps.sh {p} {f}
    Now, the file is a nicely cropped eps displayed in GV and GV has an option to save the file you are viewing. A bit bothersome, but you don't have to dig around the temporary files yourself.

    HOWEVER: It would seem this script would take care of everything, but when i have tested it the *.tex files are empty, so in order for this to work you need to run the TeX-command first, then this custom program. I consider this a bug in jpicedt.
    Add
    convert $NAME.eps $NAME.png
    display $NAME.png
    instead of gv $NAME.eps in the end, and you have yourself a PNG-preview tool (which can also be saved :)

    I would also vote for an export tool for eps/ps (and maybe png, easily done with imagemagick)
    In fact, i might even take some time to add this myself and send a patch.

     
  • Vincent Belaïche

    Please note that since some time now jPicEdt has one more key `{d}' that is expanded to the directory where the source file is placed.

    So if you want to create some script that do this kinds of conversion you do not need to work in the temporary directory, that could be in the same directory.

    What is missing is a key that provides the file name corresponding to the current drawing board --- I can add this with some error message if ever the command name cannot be expanded, which would be the case when the drawing board is not saved to any file, and possibly some dialog like "save the board now ?"

     
  • Vincent Belaïche

    Hello,

    There is a new function with User preamble and postamble that can be directly edited into the file.

    This is still kind of experimental --- because one must be careful not to damage the file --- but that is now working after [bug #62][1] has been corrected.

    [1] http://sourceforge.net/p/jpicedt/bugs/62/

     

Log in to post a comment.