From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/115768 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jethro Djan via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: Clipping multiple PDFs Date: Mon, 22 Aug 2022 15:44:56 +0000 Message-ID: Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 (1.0) Content-Type: multipart/mixed; boundary="===============2948630766901347805==" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29873"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Jethro Djan To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Mon Aug 22 19:20:22 2022 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 1oQB66-0007aU-FK for gctc-ntg-context-518@m.gmane-mx.org; Mon, 22 Aug 2022 19:20:22 +0200 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 6D2BD2A403A; Mon, 22 Aug 2022 19:19:37 +0200 (CEST) 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 imJ8falbxGqq; Mon, 22 Aug 2022 19:19:35 +0200 (CEST) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 353B72A4006; Mon, 22 Aug 2022 19:19:34 +0200 (CEST) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 8C4D82A3F6D for ; Mon, 22 Aug 2022 19:19:32 +0200 (CEST) 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 hzWKMVB5SGzg for ; Mon, 22 Aug 2022 19:19:30 +0200 (CEST) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=209.85.128.47; helo=mail-wm1-f47.google.com; envelope-from=jthryeboah@gmail.com; receiver= Original-Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 8B08B259 for ; Mon, 22 Aug 2022 19:19:30 +0200 (CEST) Original-Received: by mail-wm1-f47.google.com with SMTP id r83-20020a1c4456000000b003a5cb389944so8168534wma.4 for ; Mon, 22 Aug 2022 10:19:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:date:message-id:subject:mime-version:from :content-transfer-encoding:from:to:cc; bh=t2umNGObRlJyULW3TOBCKtRCjiLeO4L+5/Jmvms07No=; b=LwrK2GDd2pdaQOHC5fhkLKRQGmtAz/WoT1AsDsVSowZAxNtBLgWA9N4DebjoM4aWnW FzxFXIUaSnM9H8Ogn4xHGW0gTvTjhm25xu83utz8WOryyk0ieXREWmgcDfho58xCY45f D0JuKatI5zuzl52NYBzXrWHqIcY/mhAX2RHxGgH4AIBV4TbEU5NDFlCFgtgMh4vW6RYc 7AHYkeGYhGeL9jC8BCKJUDPDAuKZpS5szJcrTVns4nxKs9rNEVeJix9FrmoBmW5dDBbc u8T3rR1fDkXVoUWLdfpe2JLiR7SiqcZSBLuvKVU7nUwO/7fcDvdYT060gaVWzzGY4Rya b4SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:date:message-id:subject:mime-version:from :content-transfer-encoding:x-gm-message-state:from:to:cc; bh=t2umNGObRlJyULW3TOBCKtRCjiLeO4L+5/Jmvms07No=; b=bLtI7YtZGCJC9XPClADYPmLO/p870edDghsHuX680gN3BNaEAjZU5zgFmdu0P+ic+3 i719BaqexNRIUwU8u3ovfJGep66F7Qa+6j4XMfmyMjvOIzgeRsurelXD1pVnOMewvwP5 yfGvB7w4S07PNNGFbmIDGB+8/DE/WgJ8EsqM3xl2qB+FPlEadQlVP2LQruxpwhgwUyu6 U0w0MAd86oUYntbl8nzF9rUFbKinZlqwQdMNyZo4YA2FZyBLPPN8mxJP8YrtsLyBYgNh 9o8ilNgFm0ArAskiHMx7gKWIcluTceQgPec4dhpZksDe3JH36bIYI4fuAlt8EsJkt7ue 7u/Q== X-Gm-Message-State: ACgBeo3R6GBf+yfcpKsKs3WOTx0sQd1aD4tx7jYhppGdxVgnszroH6yy 6W3tN7hpW7SfbvBnIAXe5K0hqMMsD4k= X-Google-Smtp-Source: AA6agR5stnrLtOdVyIENyFOOJifrcfdfm9T1DNKWhVknokbMG+TddebVM/rpt+zm/3w7xoY6jVIGiA== X-Received: by 2002:a05:600c:4047:b0:3a5:452e:9117 with SMTP id j7-20020a05600c404700b003a5452e9117mr13123163wmm.117.1661188769646; Mon, 22 Aug 2022 10:19:29 -0700 (PDT) Original-Received: from smtpclient.apple ([102.176.94.135]) by smtp.gmail.com with ESMTPSA id k6-20020a5d6d46000000b00225221fd286sm12069813wri.114.2022.08.22.10.19.27 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 22 Aug 2022 10:19:28 -0700 (PDT) X-Mailer: iPhone Mail (19G71) 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:115768 Archived-At: --===============2948630766901347805== Content-Type: multipart/alternative; boundary=Apple-Mail-ED2D227B-B1AB-42E7-9808-E4B72CB68BED Content-Transfer-Encoding: 7bit --Apple-Mail-ED2D227B-B1AB-42E7-9808-E4B72CB68BED Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable =EF=BB=BF Thanks for the solution Pablo. It works well. I wanted to add more pdfs (which also has many pages) and found it was easie= r for me to reason in the lua side of things. This is what I have at the mom= ent: \starttext \startluacode local function doc(fil) return fil..[[.pdf]] end local function disppdf(fname) n =3D 1=20 repeat=20 context.externalfigure({fname},{ page =3D n, width =3D "200mm", scale =3D "950" }) n =3D n + 1 until n =3D=3D context(context.noffigurepages) end local pdffiles =3D {"ass1", "ass2", "ass3", "ass4", "ass5", "ass6", "ass7"= , "ass8"} for index=3D1,#pdffiles do=20 local f =3D doc(pdffiles[index]) context.getfiguredimensions({f}) disppdf(pdffiles[index]) end \stopluacode \stoptext I didn=E2=80=99t know how to get an array (or indexed table or whatever you c= all it) in ConTeXt/Tex. My problem is now with context(context.noffigurepage= s). Am I calling it wrong? All I want to do is call \noffigurepages from the= lua side. Is there something I am missing? Jethro > On 21 Aug 2022, at 4:41 PM, Pablo Rodriguez via ntg-context wrote: >=20 > On 8/18/22 02:13, jethro Reuel via ntg-context wrote: >> Hello, >>=20 >> I am trying to put multiple PDF=E2=80=99s that were typeset differently i= nto >> one document without modifying the individual files themselves. >> [...] >> The problem is the original page numbers show and I=E2=80=99d prefer that= it >> did not. So I thought maybe I could clip all the page numbers from >> every page (since they are all in the same position across all the >> pages) but I don=E2=80=99t know how to do this with the \clip command. An= y >> ideas? I already tried using \input but it gives some weird output in >> some places. It doesn=E2=80=99t have to use this method as long as it doe= s >> what I need it to do. >=20 > Hi Jethro, >=20 > it works using \clip with \externalfigure inside a loop (\dorecurse). >=20 > With \getfiguredimensions you get the number of pages of each PDF > document (\noffigurepages). >=20 > The following source both generates the source PDF document and the > imposed result with clipped pages (just to see a sample of the commands > mentioned above): >=20 > \startbuffer[newbuff] > \setuppapersize[A3] > \setupbodyfont[sans, 1200pt] > \starttext > \dorecurse{8} > {\startmakeup[page][pagestate=3Dstart, align=3Dcenter, style=3D\bf] > \recurselevel > \stopmakeup} > \stoptext > \stopbuffer > \startmode[*first] > \savebuffer[newbuff][source_page.tex, prefix=3Dno] > \executesystemcommand{context --purgeall source_page.tex} > \stopmode > \setuplayout[page] > \setuppapersize[A6][A4] > \setuppaper[nx=3D2, ny=3D2] > \setuparranging [XY] > \starttext > \startnotmode[*first] > \def\Doc{source_page.pdf} > \getfiguredimensions[\Doc] > \dorecurse{\noffigurepages} > {\clip[hoffset=3D96mm, voffset=3D136mm, width=3D105mm, height=3D148mm] > {\externalfigure[\Doc][page=3D\recurselevel]}} > \stopnotmode > \stoptext >=20 > Just in case it might help, >=20 > Pablo > __________________________________________________________________________= _________ > If your question is of interest to others as well, please add an entry to t= he Wiki! >=20 > maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-co= ntext > webpage : https://www.pragma-ade.nl / http://context.aanhet.net > archive : https://bitbucket.org/phg/context-mirror/commits/ > wiki : https://contextgarden.net > __________________________________________________________________________= _________ --Apple-Mail-ED2D227B-B1AB-42E7-9808-E4B72CB68BED Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
=EF=BB=BF
Thanks for the solution Pablo. It work= s well.

I wanted to add more pdfs (which also h= as many pages) and found it was easier for me to reason in the lua side of t= hings. This is what I have at the moment:

= \starttext
\startluacode
  local function d= oc(fil)
    return fil..[[.pdf]]
 = ; end

  local function disppdf(fname)
    n =3D 1 
    repeat&nbs= p;
      context.externalfigure({fname},{
        page =3D n,
   =     width =3D "200mm",
        s= cale =3D "950"
      })
  &n= bsp;   n =3D n + 1
    until n =3D=3D context(c= ontext.noffigurepages)
  end

  local pdffiles =3D {"ass1", "ass2", "ass3", "ass4", "ass5", "ass6", "= ass7", "ass8"}
  for index=3D1,#pdffiles do 
    local f =3D doc(pdffiles[index])
  &= nbsp; context.getfiguredimensions({f})
    disppdf(p= dffiles[index])
  end
\stopluacode
\stoptext

I didn=E2= =80=99t know how to get an array (or indexed table or whatever you call it) i= n ConTeXt/Tex. My problem is now with context(context.noffigurepages). A= m I calling it wrong? All I want to do is call \noffigurepages from the lua s= ide. Is there something I am missing?

Jethro
On 21 Aug 2022, at 4:41 PM, Pablo Rodriguez via ntg-context <ntg-context@ntg.nl> wrote:

On 8/18/22 02:13, jethro Reuel via ntg-context wrot= e:
Hello,
<= br class=3D"">I am trying to put multiple PDF=E2=80=99s that were typeset di= fferently into
one document without modifying the individual f= iles themselves.
[...]
The problem is the origin= al page numbers show and I=E2=80=99d prefer that it
did not. S= o I thought maybe I could clip all the page numbers from
every= page (since they are all in the same position across all the
= pages) but I don=E2=80=99t know how to do this with the \clip command. Anyideas? I already tried using \input but it gives some weird out= put in
some places. It doesn=E2=80=99t have to use this method= as long as it does
what I need it to do.

Hi Jethro,

it works using= \clip with \externalfigure inside a loop (\dorecurse).

With \getfiguredimensions you get the number of pages of each PDFdocument (\noffigurepages).

The fo= llowing source both generates the source PDF document and the
= imposed result with clipped pages (just to see a sample of the commands
mentioned above):

 \startbuffer[= newbuff]
 \setuppapersize[A3]
 \setupb= odyfont[sans, 1200pt]
 \starttext
 \do= recurse{8}
 {\startmakeup[page][pagestate=3Dstart, align=3D= center, style=3D\bf]
   \recurselevel
=   \stopmakeup}
 \stoptext
 \stopb= uffer
 \startmode[*first]
 \savebuffer= [newbuff][source_page.tex, prefix=3Dno]
 \executesystemco= mmand{context --purgeall source_page.tex}
 \stopmode
 \setuplayout[page]
 \setuppapersize[A6][A= 4]
 \setuppaper[nx=3D2, ny=3D2]
 \setu= parranging [XY]
 \starttext
 \startnot= mode[*first]
 \def\Doc{source_page.pdf}
&nb= sp;\getfiguredimensions[\Doc]
 \dorecurse{\noffigurepages= }
   {\clip[hoffset=3D96mm, voffset=3D136mm, width=3D= 105mm, height=3D148mm]
       {\externalfi= gure[\Doc][page=3D\recurselevel]}}
 \stopnotmode
 \stoptext

Just in case it might hel= p,

Pablo
________________________= ___________________________________________________________
If= your question is of interest to others as well, please add an entry to the W= iki!

maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/nt= g-context
webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
archive &= nbsp;: https://bitbucket.org/phg/context-mirror/commits/
wiki &= nbsp;   : https://con= textgarden.net
___________________________________________= ________________________________________

= --Apple-Mail-ED2D227B-B1AB-42E7-9808-E4B72CB68BED-- --===============2948630766901347805== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cHM6Ly93d3cubnRnLm5sL21haWxtYW4v bGlzdGluZm8vbnRnLWNvbnRleHQKd2VicGFnZSAgOiBodHRwczovL3d3dy5wcmFnbWEtYWRlLm5s IC8gaHR0cDovL2NvbnRleHQuYWFuaGV0Lm5ldAphcmNoaXZlICA6IGh0dHBzOi8vYml0YnVja2V0 Lm9yZy9waGcvY29udGV4dC1taXJyb3IvY29tbWl0cy8Kd2lraSAgICAgOiBodHRwczovL2NvbnRl eHRnYXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --===============2948630766901347805==--