On Thursday, 1 February 2024 16:59:36 GMT Emilia Stoyanova wrote: > Greetings everyone, > > Do any of you have experience with creating ornamented page borders? > I have looked through the mailing list[^1] and through both mom's and > utmac's > documentation but I couldn't find exactly what I have in mind. > > I have attached a pdf document, together with its pic(1) source code, > to illustrate exactly what I am going for. > > I also tried looking through cstr54 and UTP to maybe figure out how I might > do > that myself with pure troff requests, but I gave up after a while, since I'm > still a bit of a neophyte here . . . > > Also, does anyone perhaps have/host a collection of pic decorations one > might > browse and/or add to? I don't even know if using pic for that is standard > o.o > > Kind Regards, > Emilia > --- > [^1]: https://lists.gnu.org/r/groff/2022-09/msg00088.html
Hi Emilia, Everyone has probably got a different way of doing this. Tadziu gave you a pure pic way of doing the edge ornamentation, but the resulting pdf was over 100kb, which is why he would program the pattern in postscript. Peter offered a method using a suitable repeated glyph from a font, which resulted in a 9.5kb file. The big reduction is because the actual stroking of the pattern is stored in the font so the actual pattern is only stored once but used many times. There is a way of pinching that idea of storing the pattern once and using it again and again, but using a single pic instance of your pattern rather than a font glyph. There are 3 stages:- A) First run ornsingle.tr which produces ornsingle.pdf with this command:- groff -Tpdf -p ornsingle.tr -P-p.35i,.35i >orn.pdf Notice the custom paper size (.35 inch square) which is big enough to encompass one instance of your pattern, which, on its own is 2.9kb. B) Now run ornpage.tr which generates an A4 page containing many copies of the pattern in ornpage.pdf, using groff commands. Use:- groff -Tpdf -P-pa4 ornpage.tr > ornpage.pdf Note the 4 lines at the top of the groff script which can affect the pattern generated. Now the whole page of patterns is 4.1kb. C) Is to use ornpage.pdf as a type of watermark to ornament your document. There are several pdf utility programs which could do this job after groff has produced the document you want to ornament. But there is a way to get groff to do this while it is producing your document. The trick is to hook some code into whichever macro deals with starting a new page, for whichever macro language you use, that includes ornpage.pdf on every page. If you include the same pdf multiple times gropdf only stores it once and links to it if you use it again. The file ornmom.tr is a very crude example of this. Since it hooks into the START macro it is really only useful for single page simple documents, something much more sophisticated would be required for multi-page documents, possibly hooking in to NEWPAGE as well. You can run the example like this:- groff -Tpdf -mom -k -P-pa4 ornmom.tr /usr/share/doc/groff-1.23.0/examples/mom/ letter.mom > letter.pdf The document, including the letter, is now 6.3kb. Cheers Deri
.ig groff -Tpdf -p ornsingle.tr -P-p.35i,.35i >orn.pdf .. .po 1p .vs 1p .PS \" Scale width for close fit define orn { [ # Variables sideLength = $1/2; cupRad = $1/10; petalRad = $1/16.6; cornerRad = $1/20; splineLength = sideLength/5; splineTravel = splineLength * 2; rodLength = splineTravel; danglyFstRad = sideLength / 10; danglySndRad = danglyFstRad/2; danglyTrdRad = danglySndRad/2; Diamond: [ NE: line down sideLength right sideLength; SE: line down sideLength left sideLength; SW: line up sideLength left sideLength; NW: line up sideLength right sideLength; ]; # Flower in the middle (Cup & Petals) Cup: circle rad cupRad at Diamond; circle rad petalRad with .s at Cup.n; circle rad petalRad with .sw at Cup.ne; circle rad petalRad with .w at Cup.e; circle rad petalRad with .nw at Cup.se; circle rad petalRad with .n at Cup.s; circle rad petalRad with .ne at Cup.sw; circle rad petalRad with .e at Cup.w; circle rad petalRad with .se at Cup.nw; # Corner Circles N: circle rad cornerRad at Diamond.NE.start; E: circle rad cornerRad at Diamond.SE.start; W: circle rad cornerRad at Diamond.SW.start; S: circle rad cornerRad at Diamond.NW.start; # Side splines move to N down splineTravel left splineTravel; spline left splineLength then down splineLength; move to N down splineTravel right splineTravel; spline right splineLength then down splineLength; move to W up splineTravel right splineTravel; spline right splineLength then up splineLength; move to W up splineTravel left splineTravel; spline left splineLength then up splineLength; # Side dangly bits Lnw: line up rodLength left rodLength at Diamond.NW.center; arc rad danglyFstRad from Lnw.end; arc rad danglySndRad; arc rad danglyTrdRad; arc cw rad danglyFstRad from Lnw.end; arc cw rad danglySndRad; arc cw rad danglyTrdRad; Lsw: line down rodLength left rodLength at Diamond.SW.center; arc cw rad danglyFstRad; arc cw rad danglySndRad; arc cw rad danglyTrdRad; arc rad danglyFstRad from Lsw.end; arc rad danglySndRad; arc rad danglyTrdRad; Lne: line up rodLength right rodLength at Diamond.NE.center; arc cw rad danglyFstRad; arc cw rad danglySndRad; arc cw rad danglyTrdRad; arc rad danglyFstRad from Lne.end; arc rad danglySndRad; arc rad danglyTrdRad; Lse: line down rodLength right rodLength at Diamond.SE.center; arc rad danglyFstRad; arc rad danglySndRad; arc rad danglyTrdRad; arc cw rad danglyFstRad from Lse.end; arc cw rad danglySndRad; arc cw rad danglyTrdRad; ] } size = 0.3 .\" for i = 0 to 23 by 1 do { orn(size); move to last [] down size; } .\" for i = 0 to 16 by 1 do { orn(size); move to last [] right size; } .\" for i = 0 to 23 by 1 do { orn(size); move to last [] up size; } .\" for i = 0 to 16 by 1 do { orn(size); move to last [] left size; } orn(size) .PF \" Fly back to top of page to stop second page eject .po .vs
ornsingle.pdf
Description: Adobe PDF document
.ig groff -Tpdf -P-pa4 ornpage.tr > ornpage.pdf .. .po 0 .vs 0 .nr xct 24 \" Fiddle with :-) .nr yct 34 \" " .nr imgwid 29p \" " .nr imglen 29p \" " .ll 21c \" For A4 paper .pl 29.7c \" " .nr xgap (\n[.l]u-(\n[xct]*\n[imgwid]))/(\n[xct]-1)+\n[imgwid] .nr ygap (\n[.p]u-(\n[yct]*\n[imglen]))/(\n[yct]-1)+\n[imglen] .nr i 0 .nr j 0 .while (\n[i]<\n[yct]) \{\ . sp |(\n[i]u*\n[ygap]u)u . while (\n[j]<\n[xct]) \{\ . if (((\n[i]=0):(\n[i]=(\n[yct]-1))):((\n[j]=0):(\n[j]=(\n[xct]-1)))) \{\ . in (\n[j]u*\n[xgap]u)u . nop \X'pdf: pdfpic ornsingle.pdf L \n[imgwid]z' . \} . nr j +1 . \} . nr j 0 . nr i +1 .\}
ornpage.pdf
Description: Adobe PDF document
letter.pdf
Description: Adobe PDF document
.ig groff -Tpdf -mom -k -P-pa4 ornmom.tr /usr/share/doc/groff-1.23.0/examples/mom/letter.mom > letter.pdf .. .PAPER A4 .am START .mk dj .ev pdfpic .po 0 .vs 0 .sp |0 \X'pdf: pdfpic ornpage.pdf L' .fl .vs .po .ev .sp |\\n[dj]u ..