Write to tuc file
Hi, I want to split a PDF produced by context automatically at certain points. I was thinking I could add information about the desired breakpoints to the tuc file, but I don't know how you do this. Any hints? Best, Denis
On 2/27/2021 5:58 PM, denis.maier@ub.unibe.ch wrote:
I want to split a PDF produced by context automatically at certain points. I was thinking I could add information about the desired breakpoints to the tuc file, but I don’t know how you do this. Any hints? Can you define "split"
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
It's a book that will be published in two volumes, continually paginated. In the end I need two pdf files, but I thought it might be easier to treat them as one volume and just split the files with some external tool afterwards. I could also treat them as two individual books, but then I'd have to get the last page number of volume 1 in volume 2. Denis
-----Ursprüngliche Nachricht----- Von: Hans Hagen
Gesendet: Samstag, 27. Februar 2021 18:23 An: mailing list for ConTeXt users ; Maier, Denis Christian (UB) Betreff: Re: [NTG-context] Write to tuc file On 2/27/2021 5:58 PM, denis.maier@ub.unibe.ch wrote:
I want to split a PDF produced by context automatically at certain points. I was thinking I could add information about the desired breakpoints to the tuc file, but I don't know how you do this. Any hints? Can you define "split"
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 2/27/2021 6:28 PM, denis.maier@ub.unibe.ch wrote:
It's a book that will be published in two volumes, continually paginated. In the end I need two pdf files, but I thought it might be easier to treat them as one volume and just split the files with some external tool afterwards.
I could also treat them as two individual books, but then I'd have to get the last page number of volume 1 in volume 2. On the console you see the pagenumbers right? What you need is the realpage. You could actually do something:
\dorecurse{10}{\samplefile{tufte}\page} \appendetoks \writestatus{!!!!!}{} \writestatus{!!!!!}{SPLIT HERE: \the\realpageno} \writestatus{!!!!!}{} \to \everystoptext \dorecurse{10}{\samplefile{tufte}\page} and then use this number in: context --extra=select --selection=1:4 oeps.pdf --once --autopdf context --extra=select --selection=5:9999 oeps.pdf --once --autopdf (We can actually relate tags to pages so maybe I will make something to pick that up from the tuc file.) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Thanks, that's helpful. So to automate this, I'll just need to get the pagenumbers from the log file. I'll give it a try.
________________________________________
Von: Hans Hagen
It's a book that will be published in two volumes, continually paginated. In the end I need two pdf files, but I thought it might be easier to treat them as one volume and just split the files with some external tool afterwards.
I could also treat them as two individual books, but then I'd have to get the last page number of volume 1 in volume 2. On the console you see the pagenumbers right? What you need is the realpage. You could actually do something:
\dorecurse{10}{\samplefile{tufte}\page} \appendetoks \writestatus{!!!!!}{} \writestatus{!!!!!}{SPLIT HERE: \the\realpageno} \writestatus{!!!!!}{} \to \everystoptext \dorecurse{10}{\samplefile{tufte}\page} and then use this number in: context --extra=select --selection=1:4 oeps.pdf --once --autopdf context --extra=select --selection=5:9999 oeps.pdf --once --autopdf (We can actually relate tags to pages so maybe I will make something to pick that up from the tuc file.) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Oh, another thing I've learned from your example us that \starttext ...\stoptext can be nested...
________________________________________
Von: Hans Hagen
It's a book that will be published in two volumes, continually paginated. In the end I need two pdf files, but I thought it might be easier to treat them as one volume and just split the files with some external tool afterwards.
I could also treat them as two individual books, but then I'd have to get the last page number of volume 1 in volume 2. On the console you see the pagenumbers right? What you need is the realpage. You could actually do something:
\dorecurse{10}{\samplefile{tufte}\page} \appendetoks \writestatus{!!!!!}{} \writestatus{!!!!!}{SPLIT HERE: \the\realpageno} \writestatus{!!!!!}{} \to \everystoptext \dorecurse{10}{\samplefile{tufte}\page} and then use this number in: context --extra=select --selection=1:4 oeps.pdf --once --autopdf context --extra=select --selection=5:9999 oeps.pdf --once --autopdf (We can actually relate tags to pages so maybe I will make something to pick that up from the tuc file.) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 2/27/2021 6:28 PM, denis.maier@ub.unibe.ch wrote:
It's a book that will be published in two volumes, continually paginated. In the end I need two pdf files, but I thought it might be easier to treat them as one volume and just split the files with some external tool afterwards.
I could also treat them as two individual books, but then I'd have to get the last page number of volume 1 in volume 2. In the early days of context (more than 2 decades ago) we had a printer where we could inject from different trays and that is why we have a feature in context to mark pages (so that directives for printers could be inserted). This feature survived / evolved into marked pages.
You can do this (oeps.tex): \starttext \chapter[one]{One} \markpage[first] test \page test \page \markpage[second] test \page \chapter[two]{Two} test \page \markpage[fourth] test \page % \doifelsemarkedpage{second}{YES}{NO} % \doifelsemarkedpage{fourth}{YES}{NO} % \page % \doifelsemarkedpage{second}{YES}{NO} % \doifelsemarkedpage{fourth}{YES}{NO} \stoptext So, I was wondering if we can expose that differently.
context --pages oeps mtx-context | page : 0001 first mtx-context | page : 0003 second mtx-context | page : 0005 fourth
context --pages --page=second oeps mtx-context | page : 0003 second
context --pages --page=second,fourth oeps mtx-context | page : 0003 second mtx-context | page : 0005 fourth
But, as you're talking chapters, a variants (with less overhead) is:
context --pages --list=one,two oeps mtx-context | list : 0001 one mtx-context | list : 0004 two
Which of course assumes that you have a reference for the chapters. This --pages feature is in the latest upload. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Thanks for this as well, Hans. Looks promising. So, this is to select pages or page-ranges for processing?
-----Ursprüngliche Nachricht----- Von: Hans Hagen
Gesendet: Freitag, 5. März 2021 11:29 An: Maier, Denis Christian (UB) ; ntg- context@ntg.nl Betreff: Re: AW: [NTG-context] Write to tuc file It's a book that will be published in two volumes, continually paginated. In the end I need two pdf files, but I thought it might be easier to treat
On 2/27/2021 6:28 PM, denis.maier@ub.unibe.ch wrote: them as one volume and just split the files with some external tool afterwards.
I could also treat them as two individual books, but then I'd have to get the
last page number of volume 1 in volume 2. In the early days of context (more than 2 decades ago) we had a printer where we could inject from different trays and that is why we have a feature in context to mark pages (so that directives for printers could be inserted). This feature survived / evolved into marked pages.
You can do this (oeps.tex):
\starttext
\chapter[one]{One}
\markpage[first] test \page test \page \markpage[second] test \page
\chapter[two]{Two}
test \page \markpage[fourth] test
\page
% \doifelsemarkedpage{second}{YES}{NO} % \doifelsemarkedpage{fourth}{YES}{NO}
% \page
% \doifelsemarkedpage{second}{YES}{NO} % \doifelsemarkedpage{fourth}{YES}{NO}
\stoptext
So, I was wondering if we can expose that differently.
context --pages oeps mtx-context | page : 0001 first mtx-context | page : 0003 second mtx-context | page : 0005 fourth
context --pages --page=second oeps mtx-context | page : 0003 second
context --pages --page=second,fourth oeps mtx-context | page : 0003 second mtx-context | page : 0005 fourth
But, as you're talking chapters, a variants (with less overhead) is:
context --pages --list=one,two oeps mtx-context | list : 0001 one mtx-context | list : 0004 two
Which of course assumes that you have a reference for the chapters.
This --pages feature is in the latest upload.
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 3/5/2021 10:38 PM, denis.maier@ub.unibe.ch wrote:
Thanks for this as well, Hans. Looks promising. So, this is to select pages or page-ranges for processing? assuming that you have either marked pages or proper refs for chapters you can use the reported values and feed them into whatever
i could add something to the select style but i guess then there is no uniformity in how users do this Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 3/5/21 11:13 PM, Hans Hagen wrote:
On 3/5/2021 10:38 PM, denis.maier@ub.unibe.ch wrote:
Thanks for this as well, Hans. Looks promising. So, this is to select pages or page-ranges for processing? assuming that you have either marked pages or proper refs for chapters you can use the reported values and feed them into whatever
i could add something to the select style but i guess then there is no uniformity in how users do this
Many thanks for the new stuff, Hans. This could be an approach: \starttext \completecontent \dorecurse{10} {\startchapter\markpage[start-\recurselevel] \dorecurse{\randomnumber{0}{1000}} {\input knuth\par} \markpage[stop-\recurselevel]\stopchapter} \stoptext "start-" and "stop-" could define page ranges when the same identifier is used. The select style could generate from start-identifier and stop-identifier, the result "identifier.pdf". I think this is a simple approach. Many thanks for your help, Pablo -- http://www.ousia.tk
On 3/6/2021 1:56 PM, Pablo Rodriguez wrote:
On 3/5/21 11:13 PM, Hans Hagen wrote:
On 3/5/2021 10:38 PM, denis.maier@ub.unibe.ch wrote:
Thanks for this as well, Hans. Looks promising. So, this is to select pages or page-ranges for processing? assuming that you have either marked pages or proper refs for chapters you can use the reported values and feed them into whatever
i could add something to the select style but i guess then there is no uniformity in how users do this
Many thanks for the new stuff, Hans.
This could be an approach:
\starttext \completecontent \dorecurse{10} {\startchapter\markpage[start-\recurselevel] \dorecurse{\randomnumber{0}{1000}} {\input knuth\par} \markpage[stop-\recurselevel]\stopchapter} \stoptext
"start-" and "stop-" could define page ranges when the same identifier is used.
The select style could generate from start-identifier and stop-identifier, the result "identifier.pdf". \startchapter[reference=whatever,title=foo] \stopchapter \startchapter[reference=moreover,title=oof] \stopchapter
and --pages=whatever,moreover will give you the info you need to call context --extra=copy or whatever with the right arguments ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On 3/6/21 2:35 PM, Hans Hagen wrote:
On 3/6/2021 1:56 PM, Pablo Rodriguez wrote:
[...] The select style could generate from start-identifier and stop-identifier, the result "identifier.pdf". \startchapter[reference=whatever,title=foo] \stopchapter \startchapter[reference=moreover,title=oof] \stopchapter
and --pages=whatever,moreover will give you the info you need to call context --extra=copy or whatever with the right arguments
Hans, real-world needs may be complex, such as in the following sample: \starttext \completecontent \dorecurse{3} {\startpart \edef\pn{\recurselevel} \dorecurse{30} {\startchapter\markpage[start-\pn.\recurselevel] \dorecurse{\randomnumber{0}{30}} {\input knuth\par} \markpage[stop-\pn.\recurselevel]\stopchapter} \stoppart} \stoptext This generates a document to be split in 90 individual documents. I cannot even think in specifying them manually. It would be very useful to have something similar to: context --extra=select --selection=pages oeps --once --autopdf I hope my explanation is clearer now. Many thanks for your help, Pablo -- http://www.ousia.tk
participants (3)
-
denis.maier@ub.unibe.ch
-
Hans Hagen
-
Pablo Rodriguez