[Ipe-discuss] Request for feature: iperender by page title
Sherif Ghali
shghali at gmail.com
Tue Sep 13 04:41:01 CEST 2022
Nice! Thanks, Zhengdao.
On Mon, Sep 12, 2022 at 9:21 PM Zhengdao Wang <zhengdao at iastate.edu> wrote:
>
> You could put a label on each page, by pressing Ctrl-P and enter, e.g., \label{mylabel}, and then extract these labels as part of the filename, using e.g., a script like the following:
>
> #!/bin/bash
>
> input="$1"
>
> pages=$(
> gawk '
> /^<page/{
> i++
> match($0, /\\label{[^}]+}/)
> if(RSTART>0)
> label=substr($0, RSTART+7, RLENGTH-8)
> else
> label=sprintf("page%02d", i)
> print label
> }' "$input"
> )
>
> let num=1
> echo "$pages"|while read label; do
> iperender -pdf -page $num "$input" pdf/$label.pdf
> let num=num+1
> done
>
> which will use the label if present, and default to pagexx.pdf otherwise. It also has the added benefit that the total number of pages is adaptive.
>
> Hope this works for you.
>
> Zhengdao Wang
>
> -----Original Message-----
> >From: Sherif Ghali via Ipe-discuss <ipe-discuss at lists.science.uu.nl>
> >Date: Mon, 12 Sep 2022 18:11:08 -0400
> >To: ipe-discuss <ipe-discuss at lists.science.uu.nl>
> >Subject: [Ipe-discuss] Request for feature: iperender by page title
> >
> >When a document contains n figures, (1+n) source files are needed. One
> >file for the text, and one ipe file for each figure.
> >
> >This can be greatly simplified by using just one file for the text and
> >one file for the drawings, and running a script such as:
> >
> > #!/bin/bash
> >
> > IPERENDER="/Applications/Ipe.app/Contents/MacOS/iperender"
> > IPESOURCE="drawings.ipe"
> > OPTSPREFIX="-pdf"
> > FILEEXT=".pdf"
> >
> > for num in $(seq 1 7)
> > do
> > set -x
> > zero_leading_num=$(printf "%02d" $num)
> > ${IPERENDER} ${OPTSPREFIX} -page ${num} ${IPESOURCE}
> >"pdf/d"${zero_leading_num}${FILEEXT}
> > set +x
> > done
> >
> >The files "d01.pdf", "d02.pdf", ... can then be used in the text file.
> >(If you want, you can count the number of <page> nodes in the XML file
> >and use that in the script.)
> >
> >All is good, except that as you edit the source and figures documents,
> >the numbers go out of sync.
> >
> >Feature request: could you add a feature to enable saving by a unique
> >page tag? It would work like this. Each page already has a title
> >("Pages" \ "Edit title & sections"). Iperender would have an
> >additional option ("-savebytitle", say) that would take the directory
> >name, rather than the filename, where the output would go.
> >Alternatively, and to continue reading existing documents that have
> >multiple pages with the same title (without issuing a warning), add a
> >"page tag" box to the UI.
> >
> >Thank you,
> >Sherif Ghali
> >_______________________________________________
> >Ipe-discuss mailing list
> >Ipe-discuss at lists.science.uu.nl
> >https://mailman.science.uu.nl/mailman/listinfo/ipe-discuss
More information about the Ipe-discuss
mailing list