ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* outputting components in their own PDFs
@ 2021-03-02 15:06 Alan Bowen
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Bowen @ 2021-03-02 15:06 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 429 bytes --]

Denis—

Many thanks for your explanation. It works very well in my separating
components (chapters) and is going to save me a lot of time.

Thanks too to Hans.

And my apologies for missing the earlier discussion: my internet access and
email has been very flakey of late and I know that I have lost messages. In
fact, I found Denis’s reply and the earlier exchange by going to the list
Archive.

All best, Alan

[-- Attachment #1.2: Type: text/html, Size: 1142 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: outputting components in their own PDFs
  2021-03-01 21:38 Alan Bowen
@ 2021-03-01 22:07 ` denis.maier
  0 siblings, 0 replies; 3+ messages in thread
From: denis.maier @ 2021-03-01 22:07 UTC (permalink / raw)
  To: ntg-context


[-- Attachment #1.1: Type: text/plain, Size: 3378 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 15469 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

* outputting components in their own PDFs
@ 2021-03-01 21:38 Alan Bowen
  2021-03-01 22:07 ` denis.maier
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Bowen @ 2021-03-01 21:38 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 264 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 520 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-03-02 15:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-02 15:06 outputting components in their own PDFs Alan Bowen
  -- strict thread matches above, loose matches on Subject: below --
2021-03-01 21:38 Alan Bowen
2021-03-01 22:07 ` denis.maier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).