From marck@woozle.rinet.ru  Thu Mar 28 12:36:29 2002
Return-Path: <marck@woozle.rinet.ru>
Received: from woozle.rinet.ru (woozle.rinet.ru [195.54.192.68])
	by hub.freebsd.org (Postfix) with ESMTP id A993537B42F
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 28 Mar 2002 12:36:20 -0800 (PST)
Received: (from marck@localhost)
	by woozle.rinet.ru (8.11.6/8.11.6) id g2SKaIM44289;
	Thu, 28 Mar 2002 23:36:18 +0300 (MSK)
	(envelope-from marck)
Message-Id: <200203282036.g2SKaIM44289@woozle.rinet.ru>
Date: Thu, 28 Mar 2002 23:36:18 +0300 (MSK)
From: Dmitry Morozovsky <marck@rinet.ru>
Reply-To: Dmitry Morozovsky <marck@rinet.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: Proposal for doc/share/mk: make folded books using psutils
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         36432
>Category:       docs
>Synopsis:       Proposal for doc/share/mk: make folded books using psutils
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    gabor
>State:          closed
>Quarter:        
>Keywords:       all
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 28 12:40:01 PST 2002
>Closed-Date:    Wed Jul 04 21:49:49 UTC 2012
>Last-Modified:  Wed Jul 04 21:50:43 UTC 2012
>Originator:     Dmitry Morozovsky
>Release:        FreeBSD 4-STABLE i386
>Organization:
Cronyx Plus LLC (RiNet ISP)
>Environment:
System: FreeBSD 4-STABLE. Docs tree as of today.


>Description:

I suppose it would be useful to have ability to make folded printable books
by docproj (psbook and psnup binaries from print/psutils* port are required).

Personally, I have made handbook and many articles from docproj in folded
format, print them and have very good time reading well-formed books (or
brochures) ;-)

Patches for share/mk files are here. Proposed formats are folded.ps 
and folded.pdf respectively.

>How-To-Repeat:

- empty -

>Fix:


Index: doc.docbook.mk
===================================================================
RCS file: /home/ncvs/doc/share/mk/doc.docbook.mk,v
retrieving revision 1.62
diff -u -r1.62 doc.docbook.mk
--- doc.docbook.mk	2002/02/25 14:24:51	1.62
+++ doc.docbook.mk	2002/03/28 20:30:21
@@ -135,7 +135,7 @@
 JADEOPTS=	${JADEFLAGS} ${SGMLFLAGS} ${CATALOGS}
 
 KNOWN_FORMATS=	html html.tar html-split html-split.tar \
-		txt rtf ps pdf tex dvi tar pdb
+		txt rtf ps folded.ps pdf folded.pdf tex dvi tar pdb
 
 CSS_SHEET?=	${DOC_PREFIX}/share/misc/docbook.css
 PDFTEX_DEF?=	${DOC_PREFIX}/share/web2c/pdftex.def
@@ -191,6 +191,13 @@
 .if defined(PAPERSIZE)
 DVIPSOPTS?=	-t ${PAPERSIZE:L} ${DVIPSFLAGS}
 .endif
+PSBOOK?=	${PREFIX}/bin/psbook
+PSBOOKSIGSZ?=	16
+PSBMAXSIGPG?=	24
+PSBOOKOPTS?=	-s${PSBOOKSIGSZ}
+PSNUP?=		${PREFIX}/bin/psnup
+PSNUPOPTS?=	-2
+PS2PDF?=	${PREFIX}/bin/ps2pdf
 
 GZIP?=	-9
 GZIP_CMD?=	gzip -qf ${GZIP}
@@ -278,11 +285,19 @@
 CLEANFILES+= ${DOC}.aux ${DOC}.log
 
 .elif ${_cf} == "ps"
-CLEANFILES+= ${DOC}.aux ${DOC}.dvi ${DOC}.log ${DOC}.tex-ps
+CLEANFILES+= ${DOC}.aux ${DOC}.dvi ${DOC}.log ${DOC}.tex-ps ${DOC}.tex
 
+.elif ${_cf} == "folded.ps"
+CLEANFILES+= ${DOC}.aux ${DOC}.dvi ${DOC}.log ${DOC}.tex-ps ${DOC}.tex \
+	${DOC}.ps ${DOC}.ps.gz
+
 .elif ${_cf} == "pdf"
 CLEANFILES+= ${DOC}.aux ${DOC}.dvi ${DOC}.log ${DOC}.out ${DOC}.tex-pdf
 
+.elif ${_cf} == "folded.pdf"
+CLEANFILES+= ${DOC}.aux ${DOC}.dvi ${DOC}.log ${DOC}.tex-ps ${DOC}.tex \
+	${DOC}.ps ${DOC}.folded.ps
+
 .elif ${_cf} == "pdb"
 _docs+= ${.CURDIR:T}.pdb
 CLEANFILES+= ${.CURDIR:T}.pdb
@@ -436,6 +451,23 @@
 ${DOC}.ps: ${DOC}.dvi
 	${DVIPS} ${DVIPSOPTS} -o ${.TARGET} ${.ALLSRC}
 
+${DOC}.folded.ps: ${DOC}.ps
+	@TOTALPAGES=`grep '^%%Pages: ' ${.ALLSRC} | 	\
+		head -1 | sed 's/%%Pages://'`;		\
+	echo Total pages: $$TOTALPAGES;			\
+	if test $$TOTALPAGES -gt ${PSBMAXSIGPG}; then	\
+		echo Splitting by ${PSBOOKOPTS};	\
+		${PSBOOK} ${PSBOOKOPTS} ${.ALLSRC} |	\
+		${PSNUP} ${PSNUPOPTS} > ${.TARGET};	\
+	else						\
+		echo Splitting as on sig;		\
+		${PSBOOK} ${.ALLSRC} |			\
+		${PSNUP} ${PSNUPOPTS} > ${.TARGET};	\
+	fi; true
+
+${DOC}.folded.pdf: ${DOC}.folded.ps
+	${PS2PDF} ${.ALLSRC} ${.TARGET}
+	
 ${DOC}.tar: ${SRCS} ${LOCAL_IMAGES} ${LOCAL_CSS_SHEET}
 	${TAR} cf ${.TARGET} -C ${.CURDIR} ${SRCS} \
 		-C ${.OBJDIR} ${IMAGES} ${CSS_SHEET:T}
Index: doc.project.mk
===================================================================
RCS file: /home/ncvs/doc/share/mk/doc.project.mk,v
retrieving revision 1.12
diff -u -r1.12 doc.project.mk
--- doc.project.mk	2002/02/25 14:24:51	1.12
+++ doc.project.mk	2002/03/28 20:30:21
@@ -61,7 +61,7 @@
 # Master list of known target formats.  The doc.<format>.mk files implement 
 # the code to convert from their source format to one or more of these target
 # formats
-ALL_FORMATS=	html html.tar html-split html-split.tar txt rtf ps pdf tex dvi tar pdb
+ALL_FORMATS=	html html.tar html-split html-split.tar txt rtf ps folded.ps pdf folded.pdf tex dvi tar pdb
 
 # User-modifiable
 LOCALBASE?=	/usr/local
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: gabor 
State-Changed-When: Wed May 28 00:07:01 UTC 2008 
State-Changed-Why:  
Hello Dmitry, 

I think it's a good idea, but it seem it needs further work. I've installed 
print/psutils-a4 and generated a folded pdf: 
http://kovesdan.org/files/article.folded.pdf 

As you can see, it does not fit on the page. Could you take a look at this 
issue? If so, I'd be happy to take care of this great piece of work. 

Regards, 
Gabor 


Responsible-Changed-From-To: freebsd-doc->gabor 
Responsible-Changed-By: gabor 
Responsible-Changed-When: Wed May 28 00:07:01 UTC 2008 
Responsible-Changed-Why:  
Track. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=36432 
State-Changed-From-To: feedback->closed 
State-Changed-By: gabor 
State-Changed-When: Wed Jul 4 21:47:59 UTC 2012 
State-Changed-Why:  
Close this PR in lack of feedback.  Anyway, PDF readers are usually
able to print multiple pages on a single sheet.

http://www.freebsd.org/cgi/query-pr.cgi?pr=36432 
>Unformatted:
