From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/110743 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.comp.tex.context Subject: Re: outputting components in their own PDFs Date: Mon, 1 Mar 2021 22:07:39 +0000 Message-ID: References: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2359370040335285185==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23300"; mail-complaints-to="usenet@ciao.gmane.io" To: Original-X-From: ntg-context-bounces@ntg.nl Mon Mar 01 23:08:15 2021 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lGqi6-0005wj-Mo for gctc-ntg-context-518@m.gmane-mx.org; Mon, 01 Mar 2021 23:08:14 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 7E5BD281162; Mon, 1 Mar 2021 23:07:45 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Bxkghj-Tn3NU; Mon, 1 Mar 2021 23:07:43 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 62A2928116A; Mon, 1 Mar 2021 23:07:43 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 00203281150 for ; Mon, 1 Mar 2021 23:07:42 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PZV-TsOxIm6a for ; Mon, 1 Mar 2021 23:07:41 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=130.92.0.83; helo=mailhub-lb2.unibe.ch; envelope-from=denis.maier@ub.unibe.ch; receiver= Original-Received: from mailhub-lb2.unibe.ch (mailhub-lb2.unibe.ch [130.92.0.83]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 85881280E98 for ; Mon, 1 Mar 2021 23:07:41 +0100 (CET) X-Virus-Scanned: By University of Bern - MGW Original-Received: from mail.campus.unibe.ch (aai-edge-03.campus.unibe.ch [130.92.13.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailhub-lb2.unibe.ch (Postfix) with ESMTPS id E39B650008D for ; Mon, 1 Mar 2021 23:07:39 +0100 (CET) Thread-Topic: [NTG-context] outputting components in their own PDFs Thread-Index: AQHXDuPad60SP1PMX0qFUJyXQwGK7KpvrKnQ In-Reply-To: Accept-Language: de-CH, en-US Content-Language: de-DE x-originating-ip: [130.92.13.161] X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:110743 Archived-At: --===============2359370040335285185== Content-Language: de-DE Content-Type: multipart/alternative; boundary="_000_cbd20e8c0b6f4fbba10438ddabed142bubunibech_" --_000_cbd20e8c0b6f4fbba10438ddabed142bubunibech_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable What exactly do you need? You can just process each component on its own. W= ith a makefile or shell script, batch file, that should be easy enough. Or, do you need to have correct cross references, page numbers, etc.? I was= asking a similar question two days ago, and Hans showed me how to add inf= ormation to the log file: \writestatus{!!!!!}{SPLIT HERE: \the\realpageno} You should be then able to extract the split points from the log file and e= xtract the components from the complete PDF. Or, if you know that you will need to split your document at certain struct= ure elements (chapters, sections or so), it's even simpler. The lua script below will split your PDF at each chapter. It uses pdftk for= splitting, but it should be easy to adapt this to context's own mechanism = mentioned by Hans in the other thread. Denis =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -- mit welchen Dateien arbeiten wir? local base =3D assert(arg[1], "Keine Datei angegeben") local pdf =3D base .. ".pdf" local tuc =3D base .. ".tuc" -- import .tuc-file /extension lua local utilitydata =3D dofile(tuc) local breakpoints =3D {} local last_page =3D utilitydata.structures.counters.collected["realpage"][1= ][1] print ("Letzte Seite: " .. last_page) -- iterate over .tuc =3D> get breakpoints for index, content in pairs(utilitydata.structures.lists.collected) do if (content["titledata"]["label"] =3D=3D "chapter") then table.insert(breakpoints,content["references"]["realpage"]) end end -- welches sind die Breakpoints? print("Wir haben folgende Breakpoints:") for index, content in pairs(breakpoints) do print (content) end -- wie viele Breakpoint haben wir? function tablelength(T) local count =3D 0 for _ in pairs(T) do count =3D count + 1 end return count end local breakpoints_length =3D tablelength(breakpoints) print ("Wir haben " .. breakpoints_length .. " Breakpoints.") -- Extraktionsbereiche festlegen local extractions =3D {} for index, breakpoint in pairs(breakpoints) do region =3D {} local startregion =3D breakpoint local nextstartregion =3D breakpoints[index + 1] local stopregion; if (nextstartregion =3D=3D nil) then stopregion =3D last_page else stopregion =3D nextstartregion - 1 end region["start"] =3D startregion region["stop"] =3D stopregion table.insert(extractions,region) end print ("Wir extrahieren ...") for index, region in pairs(extractions) do print("von " .. region["start"] .. " bis " .. region["stop"]) local outputfile =3D "article" .. index .. ".pdf" local extract_command =3D "pdftk " .. pdf .. " cat " .. region["start"] .= . "-" .. region["stop"] .. " output " .. outputfile os.execute(extract_command) end =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Von: ntg-context Im Auftrag von Alan Bowen Gesendet: Montag, 1. M=E4rz 2021 22:38 An: mailing list for ConTeXt users Betreff: [NTG-context] outputting components in their own PDFs I have a project-component setup and need to produce a single PDF file cont= aining all the components as well as a PDF file for each component. The sin= gle file is easy. Is there a way to automate the generation of the PDF file= s for the individual components? Alan --_000_cbd20e8c0b6f4fbba10438ddabed142bubunibech_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable

What exactly do you need? You can just process each component on its = own. With a makefile or shell script, batch file, that should be easy enoug= h.

Or, do you need to have correct cross references, page numbers, etc.?= I was asking a similar question two days ago, and  Hans showed me how= to add information to the log file:

 

\writestatus{!!!!!}{SPLIT HE= RE: \the\realpageno}

 

You should be then able to extract the split points from the log file= and extract the components from the complete PDF.

 

Or, if you know that you will need to split your document at certain = structure elements (chapters, sections or so), it’s even simpler.

 

The lua script below will split your PDF at each chapter. It uses pdf= tk for splitting, but it should be easy to adapt this to context’s ow= n mechanism mentioned by Hans in the other thread.

 

Denis

 

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

-- mit we= lchen Dateien arbeiten wir?

&nbs= p;

local bas= e =3D assert(arg[1], "Keine Datei angegeben")

local pdf =3D base .. ".pdf"

local tuc =3D base .. ".tuc= "

 

 

-- import .tuc-file /extension lua

local utilitydata =3D dofile(tuc)

local breakpoints =3D {}

 

local last_page =3D utilitydata.structures.counters.collected["r= ealpage"][1][1]

print ("Letzte Seite: " .. last_page)

 

-- iterate over .tuc =3D> get breakpoints

for index, content in pairs(utilitydata.structures.lists.collected) d= o

    if (content["titledata"]["label&quo= t;] =3D=3D "chapter")

    then

        table.insert(breakpoints,c= ontent["references"]["realpage"])

    end 

end<= /o:p>

&nbs= p;

-- welche= s sind die Breakpoints?

print(&qu= ot;Wir haben folgende Breakpoints:")

for index, content in pairs(breakpoints) do

    print (content)

end<= /o:p>

&nbs= p;

-- wie vi= ele Breakpoint haben wir?

function tablelength(T)

  local count =3D 0

  for _ in pairs(T) do count =3D count + 1 end

  return count

end

 

local breakpoints_length =3D tablelength(breakpoints)

print ("Wir haben " .. breakpoints_length .. " Breakpo= ints.")

 

-- Extraktionsbereiche festlegen

local extractions =3D {}

 

for index, breakpoint in pairs(breakpoints) do

    region =3D {}

    local startregion =3D breakpoint=

           &nb= sp;    local nextstartregion =3D breakpoints[index + 1]<= o:p>

           &nb= sp;    local stopregion;

           &nb= sp;    if (nextstartregion =3D=3D nil)

           &nb= sp;    then

           &nb= sp;      stopregion =3D last_page

           &nb= sp;    else

           &nb= sp;      stopregion =3D nextstartregion - 1

           &nb= sp;    end

           &nb= sp;    region["start"] =3D startregion<= /span>

           &nb= sp;    region["stop"] =3D stopregion

    table.insert(extractions,region)=

end

 

 

print ("Wir extrahieren ...")

for index, region in pairs(extractions) do

  print("von " .. region["start"] .. " = bis " .. region["stop"])

  local outputfile =3D "article" .. index .. ".pd= f"

  local extract_command =3D "pdftk " .. pdf .. " = cat " .. region["start"] .. "-" .. region["st= op"] .. " output " .. outputfile

  os.execute(extract_command)

end

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

 

 

Von: ntg-context <ntg-context-bounces@ntg.nl> Im Auftrag von Alan Bowen
Gesendet: Montag, 1.
M=E4rz 2021 22:38 An: mailing list for ConTeXt users <ntg-context@ntg.nl>
Betreff: [NTG-context] outputting components in their own PDFs<= /o:p>

 

I have a project-component setup and need to pro= duce a single PDF file containing all the components as well as a PDF file = for each component. The single file is easy. Is there a way to automate the generation of the PDF files for the individual=  components?

 

Alan

--_000_cbd20e8c0b6f4fbba10438ddabed142bubunibech_-- --===============2359370040335285185== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============2359370040335285185==--