Re: [NTG-context] How to display the pages of a particular section in another PDF?
On 12/6/2022 6:33 PM, Pablo Rodriguez via ntg-context wrote: On 12/6/22 09:05, Hans Hagen via ntg-context wrote: On 12/6/2022 1:39 AM, Joel wrote: Thanks so much! It took some work for me to figure out how to make it work, but it now works great! i added \firstsectionpage and \lastsectionpage that (i guess) Pablo will document at the wiki Many thanks for the implementation, Hans. https://wiki.contextgarden.net/Including_pages_from_PDF_documents contains the new information (please, Joel, could you check whether the explanation is clear?). But I’m afraid I’m seeing a potential problem here, if the source PDF is doublesided, \lastsectionpage from a reference may be an empty page. There is not much we do about that. Oen can then do {\numexpr\lastsectionpage... -1\relax} 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 - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] How to display the pages of a particular section in another PDF?
On 12/6/22 09:05, Hans Hagen via ntg-context wrote: > On 12/6/2022 1:39 AM, Joel wrote: >> Thanks so much! It took some work for me to figure out how to make it >> work, but it now works great! > i added \firstsectionpage and \lastsectionpage that (i guess) Pablo will > document at the wiki Many thanks for the implementation, Hans. https://wiki.contextgarden.net/Including_pages_from_PDF_documents contains the new information (please, Joel, could you check whether the explanation is clear?). But I’m afraid I’m seeing a potential problem here, if the source PDF is doublesided, \lastsectionpage from a reference may be an empty page. Many thanks for your help, Pablo ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] How to display the pages of a particular section in another PDF?
On 12/6/2022 1:39 AM, Joel wrote: Thanks so much! It took some work for me to figure out how to make it work, but it now works great! i added \firstsectionpage and \lastsectionpage that (i guess) Pablo will document at the wiki 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 - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] How to display the pages of a particular section in another PDF?
Thanks so much! It took some work for me to figure out how to make it work, but it now works great! --Joel On Monday, December 5, 2022 at 05:15:49 AM MST, Hans Hagen via ntg-context wrote: On 12/4/2022 11:30 PM, Joel via ntg-context wrote: > I can use this code to display page 5 from a PDF: > > \externalfigure[filename.pdf][page=5] > > I am making a teacher's guide for a workbook (workbook.pdf). I need to > be able to display on the page all pages of a particular section. > > The teacher's guide uses the same section titles as the workbook, e.g.: > > 17-A: Title > 17-B: Title > > In other words, there is 1:1 pairing of section titles in the teacher's > guide and the workbook. > > Is there any way to tell ConTeXt to display all of the pages for a > particular section? > > \externalfigure[filename.pdf][section=17A] prototype attached (first process crap, then load) 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 - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___ ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] How to display the pages of a particular section in another PDF?
On 12/5/2022 7:23 PM, Pablo Rodriguez via ntg-context wrote: On 12/5/22 18:30, Hans Hagen via ntg-context wrote: On 12/5/2022 5:39 PM, Pablo Rodriguez via ntg-context wrote: [...] it would be great to have something like: \loadsection[1] [2] [3] [...] that is not flexible ... we're talking about a rather special application, so what I can add is a simple helper that returns the first and last page of a section That would be great for me. keep in mind that it is also a biut fragile as one never know where the last one ends I wondered whether \doifreference{\lastsectionpage[file][reference]} would make sense here, but this would probably be a way of unnecesarily complicating things... for sure complicating, as i have no cleu what that would mean 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 - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] How to display the pages of a particular section in another PDF?
On 12/5/22 18:30, Hans Hagen via ntg-context wrote: > On 12/5/2022 5:39 PM, Pablo Rodriguez via ntg-context wrote: >> [...] >> it would be great to have something like: >> >>\loadsection [1] [2] [3] >> [...] > that is not flexible ... we're talking about a rather special > application, so what I can add is a simple helper that returns the first > and last page of a section That would be great for me. > keep in mind that it is also a biut fragile as one never know where the > last one ends I wondered whether \doifreference{\lastsectionpage[file][reference]} would make sense here, but this would probably be a way of unnecesarily complicating things... Many thanks for your help, Pablo ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] How to display the pages of a particular section in another PDF?
On 12/5/2022 5:39 PM, Pablo Rodriguez via ntg-context wrote: On 12/5/22 13:13, Hans Hagen via ntg-context wrote: On 12/4/2022 11:30 PM, Joel via ntg-context wrote: I can use this code to display page 5 from a PDF: [...] \externalfigure[filename.pdf][section=17A] prototype attached (first process crap, then load) Hi Hans, it would be great to have something like: \loadsection [1] [2] [3] 1FILE 2REFERENCE 3inherits from \setupexternalfigure Just in case it may be relevant to the discussion. that is not flexible ... we're talking about a rather special application, so what I can add is a simple helper that returns the first and last page of a section \dostepwiserecurse {\firstsectionpage[crap][chapter:3]} {\lastsectionpage[crap][chapter:3]} {1} { \startpagemakeup \externalfigure[crap.pdf][page=#1] \stoppagemakeup } \dostepwiserecurse {\firstsectionpage[crap][chapter:5]} {\lastsectionpage[crap][chapter:5]} {1} { \dontleavehmode \externalfigure[crap.pdf][page=#1,width=3cm,frame=on]% \space\allowbreak } keep in mind that it is also a biut fragile as one never know where the last one ends 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 - ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] How to display the pages of a particular section in another PDF?
On 12/5/22 13:13, Hans Hagen via ntg-context wrote: > On 12/4/2022 11:30 PM, Joel via ntg-context wrote: >> I can use this code to display page 5 from a PDF: >> [...] >> \externalfigure[filename.pdf][section=17A] > > prototype attached (first process crap, then load) Hi Hans, it would be great to have something like: \loadsection [1] [2] [3] 1 FILE 2 REFERENCE 3 inherits from \setupexternalfigure Just in case it may be relevant to the discussion. Many thanks for your help, Pablo ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] How to display the pages of a particular section in another PDF?
On 12/4/2022 11:30 PM, Joel via ntg-context wrote: I can use this code to display page 5 from a PDF: \externalfigure[filename.pdf][page=5] I am making a teacher's guide for a workbook (workbook.pdf). I need to be able to display on the page all pages of a particular section. The teacher's guide uses the same section titles as the workbook, e.g.: 17-A: Title 17-B: Title In other words, there is 1:1 pairing of section titles in the teacher's guide and the workbook. Is there any way to tell ConTeXt to display all of the pages for a particular section? \externalfigure[filename.pdf][section=17A] prototype attached (first process crap, then load) 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 - \startluacode document.foundsection = { first = 0, last = 0 } function document.loadsection(filename,reference) local data = job.loadother(file.addsuffix(filename,"tuc")) if data then local lists = data.structures.lists.collected local pages = data.structures.pages.collected if lists and pages then for i=1,#lists do local li = lists[i] if li.references.reference == reference then local first = 1 local last = pages[#pages].number local level = li.metadata.level first = li.references.realpage for j=i+1,#lists do local lj = lists[j] if lj.metadata.level == level then last = lj.references.realpage - 1 break end end document.foundsection.first = first document.foundsection.last = last end end end end end \stopluacode % it depends what interface one wants ... we could have % % \externalfigure[crap.pdf][section=] % takes from crap % % but we need more inpiut and discussion for that \starttexdefinition DoWithSection #1#2 \startpagemakeup \externalfigure[#1.pdf][page=#2] \stoppagemakeup \stoptexdefinition \starttexdefinition LoadSectionsA #1#2 \ctxlua{document.loadsection("#1","#2")} \doifnot{\cldcontext{document.foundsection.first}} {0} { \dostepwiserecurse {\cldcontext{document.foundsection.first}} {\cldcontext{document.foundsection.last}} {1} { \DoWithSection{#1}{\recurselevel} } } \stoptexdefinition \starttexdefinition spaces LoadSectionsB #1#2 \ctxlua{ document.loadsection("#1","#2") if document.foundsection.first > 0 then for i=document.foundsection.first,document.foundsection.last do context.DoWithSection("#1",i) end end } \stoptexdefinition \starttext \LoadSectionsA{crap}{chapter:3} \LoadSectionsB{crap}{chapter:2} \stoptext \starttext \dorecurse{10}{ \startchapter[title=Chapter #1,reference=chapter:#1] \dorecurse{10}{ \startsubject[title=Subject #1] \dorecurse{2}{\samplefile{tufte}\par} \stopsubject \startsection[title=Section #1.##1,reference=#1.##1] \dorecurse{10}{\samplefile{tufte}\par} \stopsection } \stopchapter } \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] How to display the pages of a particular section in another PDF?
Am 04.12.22 um 23:30 schrieb Joel via ntg-context: I can use this code to display page 5 from a PDF: \externalfigure[filename.pdf][page=5] I am making a teacher's guide for a workbook (workbook.pdf). I need to be able to display on the page all pages of a particular section. The teacher's guide uses the same section titles as the workbook, e.g.: 17-A: Title 17-B: Title In other words, there is 1:1 pairing of section titles in the teacher's guide and the workbook. Is there any way to tell ConTeXt to display all of the pages for a particular section? \externalfigure[filename.pdf][section=17A] Use a loop in Lua or TeX: https://wiki.contextgarden.net/System_Macros/Loops_and_Recursion \dostepwiserecurse {5} {17} {1} {\externalfigure[filename.pdf][page=\recurselevel]} or \startluacode for s=5, 17 do context.externalfigure({"filename.pdf"},{page=s}) end \stopluacode (untested) Hraban ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] How to display the pages of a particular section in another PDF?
Don’t know about ConTeXt. But maybe you might want to have a look at pdftk. You could try to produce per-section pdfs and include those. Best, Denis Von: ntg-context Im Auftrag von Joel via ntg-context Gesendet: Sonntag, 4. Dezember 2022 23:31 An: Mailing List for ConTeXt Users Cc: Joel Betreff: [NTG-context] How to display the pages of a particular section in another PDF? I can use this code to display page 5 from a PDF: \externalfigure[filename.pdf][page=5] I am making a teacher's guide for a workbook (workbook.pdf). I need to be able to display on the page all pages of a particular section. The teacher's guide uses the same section titles as the workbook, e.g.: 17-A: Title 17-B: Title In other words, there is 1:1 pairing of section titles in the teacher's guide and the workbook. Is there any way to tell ConTeXt to display all of the pages for a particular section? \externalfigure[filename.pdf][section=17A] --Joel ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] How to display the pages of a particular section in another PDF?
I can use this code to display page 5 from a PDF:\externalfigure[filename.pdf][page=5]I am making a teacher's guide for a workbook (workbook.pdf). I need to be able to display on the page all pages of a particular section. The teacher's guide uses the same section titles as the workbook, e.g.: 17-A: Title 17-B: Title In other words, there is 1:1 pairing of section titles in the teacher's guide and the workbook. Is there any way to tell ConTeXt to display all of the pages for a particular section? \externalfigure[filename.pdf][section=17A] --Joel ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___