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 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 information to the log file:

 

\writestatus{!!!!!}{SPLIT HERE: \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 pdftk for splitting, but it should be easy to adapt this to context’s own mechanism mentioned by Hans in the other thread.

 

Denis

 

============

-- mit welchen Dateien arbeiten wir?

 

local base = assert(arg[1], "Keine Datei angegeben")

local pdf = base .. ".pdf"

local tuc = base .. ".tuc"

 

 

-- import .tuc-file /extension lua

local utilitydata = dofile(tuc)

local breakpoints = {}

 

local last_page = utilitydata.structures.counters.collected["realpage"][1][1]

print ("Letzte Seite: " .. last_page)

 

-- iterate over .tuc => get breakpoints

for index, content in pairs(utilitydata.structures.lists.collected) do

    if (content["titledata"]["label"] == "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 = 0

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

  return count

end

 

local breakpoints_length = tablelength(breakpoints)

print ("Wir haben " .. breakpoints_length .. " Breakpoints.")

 

-- Extraktionsbereiche festlegen

local extractions = {}

 

for index, breakpoint in pairs(breakpoints) do

    region = {}

    local startregion = breakpoint

                local nextstartregion = breakpoints[index + 1]

                local stopregion;

                if (nextstartregion == nil)

                then

                  stopregion = last_page

                else

                  stopregion = nextstartregion - 1

                end

                region["start"] = startregion

                region["stop"] = 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 = "article" .. index .. ".pdf"

  local extract_command = "pdftk " .. pdf .. " cat " .. region["start"] .. "-" .. region["stop"] .. " output " .. outputfile

  os.execute(extract_command)

end

============

 

 

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

 

I have a project-component setup and need to produce 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