From edi at agharta.de Fri Apr 8 11:28:37 2005 From: edi at agharta.de (Edi Weitz) Date: Fri, 08 Apr 2005 13:28:37 +0200 Subject: [cl-typesetting-devel] Tables with variable column widths Message-ID: Hi! I admit I haven't done much with CL-PDF and CL-TYPESETTING yet so if this is a particularly dumb question or has been discussed before feel free to be rude. I'm trying to create a table where I don't know the width of the columns in advance, i.e. I want the table to be "just big enough" like in HTML or LaTeX. I've looked at the table example in tables.lisp which uses fixed column sizes. Am I supposed to calculate the sizes myself? And if so, what are the functions one would use to do that? Thanks in advance, Edi. From edi at agharta.de Fri Apr 8 12:04:29 2005 From: edi at agharta.de (Edi Weitz) Date: Fri, 08 Apr 2005 14:04:29 +0200 Subject: [cl-typesetting-devel] Tables with variable column widths In-Reply-To: (Edi Weitz's message of "Fri, 08 Apr 2005 13:28:37 +0200") References: Message-ID: On Fri, 08 Apr 2005 13:28:37 +0200, Edi Weitz wrote: > I admit I haven't done much with CL-PDF and CL-TYPESETTING yet so if > this is a particularly dumb question or has been discussed before > feel free to be rude. > > I'm trying to create a table where I don't know the width of the > columns in advance, i.e. I want the table to be "just big enough" > like in HTML or LaTeX. I've looked at the table example in > tables.lisp which uses fixed column sizes. Am I supposed to > calculate the sizes myself? And if so, what are the functions one > would use to do that? I've searched the list archives a bit and found a discussion from about a year ago where the general agreement obviously was that fully automatic tables are hard to do. Is that the last word? Anyway - let's suppose I just want a very simple table: each row as exactly n columns and I /know/ that the whole table will fit on the page. I just want to compute the maximum width for each column in order to feed it into the table description - how do I do that? Thanks, Edi. From marc.battyani at fractalconcept.com Fri Apr 8 14:01:55 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Fri, 8 Apr 2005 16:01:55 +0200 Subject: [cl-typesetting-devel] Tables with variable column widths References: Message-ID: <075b01c53c43$86d68bd0$0a02a8c0@marcxp> "Edi Weitz" wrote: > On Fri, 08 Apr 2005 13:28:37 +0200, Edi Weitz wrote: > > > I admit I haven't done much with CL-PDF and CL-TYPESETTING yet so if > > this is a particularly dumb question or has been discussed before > > feel free to be rude. > > > > I'm trying to create a table where I don't know the width of the > > columns in advance, i.e. I want the table to be "just big enough" > > like in HTML or LaTeX. I've looked at the table example in > > tables.lisp which uses fixed column sizes. Am I supposed to > > calculate the sizes myself? And if so, what are the functions one > > would use to do that? > > I've searched the list archives a bit and found a discussion from > about a year ago where the general agreement obviously was that fully > automatic tables are hard to do. Is that the last word? > > Anyway - let's suppose I just want a very simple table: each row as > exactly n columns and I /know/ that the whole table will fit on the > page. I just want to compute the maximum width for each column in > order to feed it into the table description - how do I do that? The general case is very difficult to do well but simple cases are... simple ;-) I just did not found the time to work on it. Basically what is needed is a first pass to compute the natural width of the cells. Then the maximum one for each row and finally the table width. So far so good. The problems start when the table width is too big. Then it's some kind of NP optimization problem. I wanted to use screamer or something like that to do this just for the fun ;-) I can do that simple case if you want. Cheers, Marc From edi at agharta.de Fri Apr 8 16:19:40 2005 From: edi at agharta.de (Edi Weitz) Date: Fri, 08 Apr 2005 18:19:40 +0200 Subject: [cl-typesetting-devel] Tables with variable column widths In-Reply-To: <075b01c53c43$86d68bd0$0a02a8c0@marcxp> (Marc Battyani's message of "Fri, 8 Apr 2005 16:01:55 +0200") References: <075b01c53c43$86d68bd0$0a02a8c0@marcxp> Message-ID: On Fri, 8 Apr 2005 16:01:55 +0200, "Marc Battyani" wrote: > I can do that simple case if you want. Hey, you don't have to do my work... :) Just tell me how I can find out the width of the table cells so I can compute the stuff myself. OK, I'll be offline until monday. Thanks, Edi. From marc.battyani at fractalconcept.com Fri Apr 8 16:55:47 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Fri, 8 Apr 2005 18:55:47 +0200 Subject: [cl-typesetting-devel] Tables with variable column widths References: <075b01c53c43$86d68bd0$0a02a8c0@marcxp> Message-ID: <082c01c53c5b$d08cdc30$0a02a8c0@marcxp> "Edi Weitz" wrote: > On Fri, 8 Apr 2005 16:01:55 +0200, "Marc Battyani" wrote: > > > I can do that simple case if you want. > > Hey, you don't have to do my work... :) Thanks! ;-) > Just tell me how I can find out the width of the table cells so I can > compute the stuff myself. Something like this will give you the width: (compute-boxes-natural-size (content cell) #'dx) This will give you the maximal height (and base-line) (compute-boxes-natural-size (content cell) #'dy) You probably don't need the second one as the table will compute the needed height. > OK, I'll be offline until monday. OK have a nice week-end. :) Marc From edi at agharta.de Sat Apr 9 21:46:31 2005 From: edi at agharta.de (Edi Weitz) Date: Sat, 09 Apr 2005 23:46:31 +0200 Subject: [cl-typesetting-devel] Tables with variable column widths In-Reply-To: <082c01c53c5b$d08cdc30$0a02a8c0@marcxp> (Marc Battyani's message of "Fri, 8 Apr 2005 18:55:47 +0200") References: <075b01c53c43$86d68bd0$0a02a8c0@marcxp> <082c01c53c5b$d08cdc30$0a02a8c0@marcxp> Message-ID: [Trying to post via my cell phone - hope it works.] On Fri, 8 Apr 2005 18:55:47 +0200, "Marc Battyani" wrote: > Something like this will give you the width: > (compute-boxes-natural-size (content cell) #'dx) Thanks, this works fine if I use the default font. However, the two following forms (compute-boxes-natural-size (boxes (compile-text (:font "Times-Bold") "foo")) #'dx) (compute-boxes-natural-size (boxes (compile-text (:font "Times-Roman") "foo")) #'dx) evaluate to the same result. I would have expected the first one to return a larger width. How can I compute the width if I want to take the font into account? Thanks, Edi. From marc.battyani at fractalconcept.com Sun Apr 10 07:58:57 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Sun, 10 Apr 2005 09:58:57 +0200 Subject: [cl-typesetting-devel] Tables with variable column widths References: <075b01c53c43$86d68bd0$0a02a8c0@marcxp> <082c01c53c5b$d08cdc30$0a02a8c0@marcxp> Message-ID: <00c301c53da3$3aae4430$0a02a8c0@marcxp> > [Trying to post via my cell phone - hope it works.] Yes :) > On Fri, 8 Apr 2005 18:55:47 +0200, "Marc Battyani" wrote: > > > Something like this will give you the width: > > (compute-boxes-natural-size (content cell) #'dx) > > Thanks, this works fine if I use the default font. However, the two > following forms > > (compute-boxes-natural-size > (boxes (compile-text (:font "Times-Bold") "foo")) #'dx) > > (compute-boxes-natural-size > (boxes (compile-text (:font "Times-Roman") "foo")) #'dx) > > evaluate to the same result. I would have expected the first one to > return a larger width. How can I compute the width if I want to take > the font into account? It's because you forgot a () and a with-style: (compute-boxes-natural-size (boxes (compile-text () (with-style (:font "Times-Bold") "foo"))) #'dx) 15.696000000000002 (compute-boxes-natural-size (boxes (compile-text () (with-style (:font "Times-Roman") "foo"))) #'dx) 15.996 (compute-boxes-natural-size (boxes (compile-text () (with-style (:font "Times-Roman" :font-size 16) "foo"))) #'dx) 21.328 Cheers, Marc From edi at agharta.de Sun Apr 10 20:32:35 2005 From: edi at agharta.de (Edi Weitz) Date: Sun, 10 Apr 2005 22:32:35 +0200 Subject: [cl-typesetting-devel] Tables with variable column widths In-Reply-To: <00c301c53da3$3aae4430$0a02a8c0@marcxp> (Marc Battyani's message of "Sun, 10 Apr 2005 09:58:57 +0200") References: <075b01c53c43$86d68bd0$0a02a8c0@marcxp> <082c01c53c5b$d08cdc30$0a02a8c0@marcxp> <00c301c53da3$3aae4430$0a02a8c0@marcxp> Message-ID: On Sun, 10 Apr 2005 09:58:57 +0200, "Marc Battyani" wrote: > It's because you forgot a () and a with-style: No, I couldn't forget it because I didn't know about it. Or did I miss the documentation? :) > (compute-boxes-natural-size > (boxes (compile-text () > (with-style (:font "Times-Bold") "foo"))) #'dx) > 15.696000000000002 > > (compute-boxes-natural-size > (boxes (compile-text () > (with-style (:font "Times-Roman") "foo"))) #'dx) > 15.996 > > (compute-boxes-natural-size > (boxes (compile-text () > (with-style (:font "Times-Roman" :font-size 16) "foo"))) #'dx) > 21.328 Thanks, that works fine. Cheers, Edi. From marc.battyani at fractalconcept.com Sun Apr 10 20:57:32 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Sun, 10 Apr 2005 22:57:32 +0200 Subject: [cl-typesetting-devel] Tables with variable column widths References: <075b01c53c43$86d68bd0$0a02a8c0@marcxp> <082c01c53c5b$d08cdc30$0a02a8c0@marcxp> <00c301c53da3$3aae4430$0a02a8c0@marcxp> Message-ID: <020b01c53e0f$ec0eed80$0a02a8c0@marcxp> "Edi Weitz" wrote: > No, I couldn't forget it because I didn't know about it. Or did I > miss the documentation? > > :) Hehe... right! IIRC Brian Sorg has started something like that some time ago... Marc From kw at w-m-p.com Fri Apr 15 03:17:22 2005 From: kw at w-m-p.com (Klaus Weidner) Date: Thu, 14 Apr 2005 22:17:22 -0500 Subject: [cl-typesetting-devel] Update to XML renderer Message-ID: <20050415031722.GC24636@w-m-p.com> Hello, I've upgraded to Marc's latest versions and verified that the XML renderer still works in clisp :-) The attached patch is for contrib/examples/xml-renderer/: - removed the external PDF compressor code in the "html2pdf" script that isn't needed anymore thanks to salza. - a one-line change reduces memory consumption by an order of magnitude, wrapping the entire document in a single macro wasn't a good idea. - added basic support for some of the most common HTML entities so that more documents can be rendered. This is a hack, but I'm too lazy to do a proper Unicode solution at this time... - fixed the change bars which were being drawn in the wrong place occasionally, now uses the (with-contextual-style) macro in kw-extensions.pdf - various minor cleanups I'd appreciate feedback if someone tries this, both positive and negative ;-) -Klaus -------------- next part -------------- diff -urb ./html2pdf /home/kw/lisp/source/xml-render/html2pdf --- ./html2pdf 2005-04-14 21:25:35.000000000 -0500 +++ /home/kw/lisp/source/xml-render/html2pdf 2005-04-14 22:05:20.000000000 -0500 @@ -35,6 +35,10 @@ #CLISP=/usr/lib/clisp/full/lisp.run CLISP=clisp +# avoid non-standard charsets... +LC_CTYPE=en_US +export LC_CTYPE + # WARNING: creates fixed-name temp files in current working directory. # Don't use it if current dir is writable for untrusted users. @@ -45,13 +49,6 @@ # line if you don't want to use it. [ -z "$TIDY" ] && TIDY=$(which tidy) -# Optional: clisp generates uncompressed PDF. Use the "PDF Toolkit" -# (pdftk) to compress it. See http://www.accesspdf.com/pdftk/ -# -# Comment out the next line if you don't want to use it. -# FIXME: pdftk fails on output generated by v66 cl-pdf ?! -#[ -z "$PDFTK" ] && PDFTK=$(which pdftk) - ### End of user configurable section Usage () { @@ -77,7 +74,3 @@ $CLISP -q -q -M $IMAGE -- "$XML" "$OUT" [ -x "$TIDY" ] && rm -f "$XML" - -[ -x "$PDFTK" ] && { - "$PDFTK" "$OUT" output "$OUT.new" compress && mv "$OUT.new" "$OUT" -} diff -urb ./xml-xform.lisp /home/kw/lisp/source/xml-render/xml-xform.lisp --- ./xml-xform.lisp 2005-04-14 21:25:50.000000000 -0500 +++ /home/kw/lisp/source/xml-render/xml-xform.lisp 2005-01-30 14:30:34.000000000 -0600 @@ -159,6 +159,18 @@ ;;(adjoin '("sect;" #\#) xmls::*entities* :test #'equal)) ;;setq xmls::*entities* ;;(adjoin '("nbsp;" #\Space) xmls::*entities* :test #'equal)) + (setq xmls::*entities* + (concatenate 'vector + '(("AElig;" #\?) + ("sect;" #\#) + ("nbsp;" #\Space) + ("#8211;" #\-) + ("#8217;" #\') + ("#8219;" #\`) + ("#8220;" #\") + ("#8221;" #\") + ("#8230;" #\?)) + xmls::*entities*)) (with-open-file (s file) (let ((xml (xmls:parse s :compress-whitespace nil))) (xml-xform #'attr-list-to-assoc xml)))) @@ -255,12 +267,6 @@ ;; The XHTML style sheet -(defvar *font-normal* "Times-Roman") -(defvar *font-bold* "Times-Bold") -(defvar *font-italic* "Times-Italic") -(defvar *font-bold-italic* "Times-BoldItalic") -(defvar *font-monospace* "Courier") - (defun typeset-elem-xform (node parents) (let ((elem (xml-elem node)) (attr (xml-attr node)) @@ -268,10 +274,10 @@ ;; Deal with each element recursively. (case elem - ((:html) `(with-style () , at clst)) + ((:html) (apply #'append (remove-if #'stringp clst))) - ((:head) `(set-contextual-variable :title - ,(xml-extract-text (xml-subtree '(:title) node)))) + ((:head) `((set-contextual-variable :title + ,(xml-extract-text (xml-subtree '(:title) node))))) ;; need to preserve :title for :head to work on, due to ;; depth-first search @@ -282,18 +288,14 @@ ((:body) (if (> *toc-depth* 0) (let ((toc (remove-if #'null (make-toc)))) - (setf *chapter-nums* nil) - (setq *chapters* nil) - `(with-style (:font *font-normal* :font-size 10) - (set-contextual-variable :header-enabled t) + `((set-contextual-variable :header-enabled t) (set-contextual-variable :footer-enabled t) (mark-ref-point '(:chapter 0) :data "Table of Contents") , at toc :fresh-page , at clst (mark-ref-point "DocumentEnd"))) - `(with-style (:font *font-normal* :font-size 10) - , at clst + `(, at clst (mark-ref-point "DocumentEnd")))) ((:a) @@ -307,7 +309,8 @@ (append1 out (if (eql #\# (aref href 0)) `(put-string (format nil " (page ~D)" - (find-ref-point-page-number ,(subseq href 1)))) + (find-ref-point-page-number + ,(subseq href 1)))) `(with-style () " (" (with-style (:color :blue) @@ -315,43 +318,12 @@ ")")))) `(with-style () , at out))) - ((:h1) - `(with-style () - :fresh-page - (paragraph (:font "Helvetica-Bold" :font-size 20 - :top-margin 14 :bottom-margin 10) - (apply #'mark-ref-point ',(chp-ref 0 (xml-extract-text node))) - , at clst))) - - ((:h2) - `(paragraph (:font "Helvetica-BoldOblique" - :font-size 18 :top-margin 10 :bottom-margin 8) - (apply #'mark-ref-point ',(chp-ref 1 (xml-extract-text node))) - , at clst)) - - ((:h3) - `(paragraph (:font "Helvetica-Bold" :font-size 16 - :top-margin 10 :bottom-margin 8) - (apply #'mark-ref-point ',(chp-ref 2 (xml-extract-text node))) - , at clst)) - - ((:h4) - `(paragraph (:font "Helvetica-BoldOblique" :font-size 14 - :top-margin 10 :bottom-margin 8) - (apply #'mark-ref-point ',(chp-ref 3 (xml-extract-text node))) - , at clst)) - - ((:h5) - `(paragraph (:font "Helvetica-Bold" :font-size 12 - :top-margin 10 :bottom-margin 8) - (apply #'mark-ref-point ',(chp-ref 4 (xml-extract-text node))) - , at clst)) - - ((:h6) - `(paragraph (:font "Helvetica-BoldOblique" :font-size 12 - :top-margin 10 :bottom-margin 8) - (apply #'mark-ref-point ',(chp-ref 5 (xml-extract-text node))) - , at clst)) + ((:h1) (chapter-markup 0 (xml-extract-text node) clst)) + ((:h2) (chapter-markup 1 (xml-extract-text node) clst)) + ((:h3) (chapter-markup 2 (xml-extract-text node) clst)) + ((:h4) (chapter-markup 3 (xml-extract-text node) clst)) + ((:h5) (chapter-markup 4 (xml-extract-text node) clst)) + ((:h6) (chapter-markup 5 (xml-extract-text node) clst)) ((:p) `(paragraph (:font *font-normal* :font-size 10 @@ -508,18 +480,21 @@ ;; This is some bold text ((:ins-start) - `(set-style (:pre-decoration - #'decoration-green-background) + `(with-style () + (set-contextual-style (:pre-decoration + #'decoration-green-background)) (change-start-insert))) ((:del-start) - `(set-style (:post-decoration - #'decoration-strikethrough) + `(with-style () + (set-contextual-style (:post-decoration + #'decoration-strikethrough)) (change-start-delete))) ((:ins-end :del-end) - `(set-style (:pre-decoration :none - :post-decoration :none) + `(with-style () + (set-contextual-style (:pre-decoration :none + :post-decoration :none)) (change-end))) ;; Unknown item: insert bright and ugly complaint @@ -530,12 +505,15 @@ ;;; high-level functions +(defun load-xml-file-xform (input) + (xml-xform #'xml-collapse-whitespace + (xml-xform #'xml-collapse-sxml-namespace + (load-xml-file input)))) + (defun xhtml-to-typeset (input) "Read XML input file and transform to typesetting instructions" ;; First some cleanup on the input XML file - (let ((tree (xml-xform #'xml-collapse-whitespace - (xml-xform #'xml-collapse-sxml-namespace - (load-xml-file input))))) + (let ((tree (load-xml-file-xform input))) ;; Generate table of contents #-(and) (setq *chapters* (mapcar (lambda (h) (xml-extract-text h)) From marc.battyani at fractalconcept.com Fri Apr 15 13:59:05 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Fri, 15 Apr 2005 15:59:05 +0200 Subject: [cl-typesetting-devel] Update to XML renderer References: <20050415031722.GC24636@w-m-p.com> Message-ID: <01ea01c541c3$4a849c00$0a02a8c0@marcxp> "Klaus Weidner" wrote: > I've upgraded to Marc's latest versions and verified that the XML > renderer still works in clisp :-) You even have the compression now (with salza)! > The attached patch is for contrib/examples/xml-renderer/: > > - removed the external PDF compressor code in the "html2pdf" script that > isn't needed anymore thanks to salza. > > - a one-line change reduces memory consumption by an order of magnitude, > wrapping the entire document in a single macro wasn't a good idea. > > - added basic support for some of the most common HTML entities so that > more documents can be rendered. This is a hack, but I'm too lazy to do a > proper Unicode solution at this time... > > - fixed the change bars which were being drawn in the wrong place > occasionally, now uses the (with-contextual-style) macro in > kw-extensions.pdf > > - various minor cleanups > > I'd appreciate feedback if someone tries this, both positive and negative ;-) I failed to apply the patch. Can you send me an unified diff format generated by subversion or just the modified files ? Thanks, Marc From marc.battyani at fractalconcept.com Fri Apr 15 21:12:41 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Fri, 15 Apr 2005 23:12:41 +0200 Subject: [cl-typesetting-devel] Re: Problems with cl-typesetting References: <001001c541f9$4f3ff1a0$bf50e4d5@alcinoos> Message-ID: <034d01c541ff$ddeb2bd0$0a02a8c0@marcxp> lisptracker wrote: >Sorry my bothering you. I am heavy puzzled by using russian fonts in >cl-typesetting. These questions should be sent to the cl-typesetting or cl-pdf mailing lists rather than to lisp-hug. (I've put this email in copy to the cl-typesetting list) The mailing lists are here: http://common-lisp.net/mailman/listinfo/cl-pdf-devel http://common-lisp.net/mailman/listinfo/cl-pdf-devel >I've just typed russian letters to one of strings in test.lisp's HELLO >function, but GET-CHAR-SIZE function in cl-pdf's font.lisp called from >MAKE-CHAR-BOX function in typo.lisp says that it cannot violate array bounds >(character code is > 255): >;; (let* ((char (aref (characters font) (force-char-code char-or-code))) >So I write function that convert unicode string to cp-1251 code page and >wrap string in it. So hello.pdf generated fine, but russian text was >invisible. I tried to use all encodings from encodings.lisp in cl-pdf with >no effect. I converted Arial.ttf to Arial.afm by ttf2afm.exe utility from >Cygnus. The hello.pdf generated silently but Acrobat Reader said that Arial >had bad \bbox or so. I've already spent many hours trying to solve this >puzzle, looks like I need good advice from somebody more experienced >(lucky). To use cl-typesetting with Russian fonts, you should have a look at Dmitri Ivanov's page here: http://lisp.ystok.ru/cl-pdf.html The cl-typesetting example with a paragraph in Arial Cyrillic font is here: http://lisp.ystok.ru/code/ex-1251.pdf I plan to integrate Dmitri's modifications but some portability issues need to be addressed (Dmitri's code is for LW only so far). Unicode support should be added too. Marc From marc.battyani at fractalconcept.com Wed Apr 20 20:11:49 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Wed, 20 Apr 2005 22:11:49 +0200 Subject: [cl-typesetting-devel] cl-pdf and cl-typesetting release candidates References: <074c01c503f3$13b432c0$0a02a8c0@marcxp> <019701c53a24$46defe20$0a02a8c0@marcxp> Message-ID: <2fb101c545e5$31557a80$0a02a8c0@marcxp> The last "official" versions for cl-pdf and cl-typesetting are very old (1 year ?). It seems that some people don't like to use the latest versions and prefer official releases. So I plan to do one tomorrow. Please send me remarks, fixes and patches you may have from the current repository version. Rev 93: cl-pdf: Updated iterate to the latest version (1.4?) Rev 92: cl-typesetting: Perform early compression of the content-streams (as soon as they are closed) to reduce memory use. Updated Klaus Weidner's (X)HTML to pdf converter in the contrib directory. Added Spanish hyphenation file [Andrew Philpot] Rev 91: cl-pdf: Some file encoding modifications More salza optimizations [Dmitri Ivanov] The full repository is here: http://www.fractalconcept.com:8000/public/open-source/ (It's a subversion 1.1 repository.) The projects repositories are: http://www.fractalconcept.com:8000/public/open-source/cl-pdf/ http://www.fractalconcept.com:8000/public/open-source/cl-typesetting/ http://www.fractalconcept.com:8000/public/open-source/mod_lisp/ There are also tarballs available http://www.fractalconcept.com/download/cl-pdf-current.tgz http://www.fractalconcept.com/download/cl-typesetting-current.tgz BTW the (rather outdated) home pages for these projects are here: http://www.fractalconcept.com/asp/html/cl-pdf.html http://www.fractalconcept.com/asp/html/cl-typesetting.html http://www.fractalconcept.com/asp/html/mod_lisp.html Marc From edi at agharta.de Thu Apr 21 22:39:28 2005 From: edi at agharta.de (Edi Weitz) Date: Fri, 22 Apr 2005 00:39:28 +0200 Subject: [cl-typesetting-devel] Empty pages, again Message-ID: Hi! I have again problems with PDFs that come out as empty pages on Acrobat 7. Here's a simplified version of the code: (use-package :typeset) (defun write-table (n) (let* ((tt::*default-font* (pdf:get-font "Helvetica")) (tt::*default-font-size* 24) content (margins (list 10 10 10 10))) (with-open-file (out "/shared/foo.pdf" :direction :output :if-exists :supersede) (with-document () (setq content (compile-text (:font tt::*default-font* :font-size tt::*default-font-size*) (dotimes (i n) (insert-table "foo")))) (draw-pages content :margins margins :break :after) (pdf:write-document out))))) (defun insert-table (text) (table (:col-widths (list 155) :padding 0 :border 1) (row (:height 44) (tt::add-table-cell (make-instance 'tt::table-cell :v-align :center :content (compile-text (:h-align :center) text)))))) If I call (WRITE-TABLE 1) I get a page with one table that looks fine. If I call (WRITE-TABLE 2) instead I get an empty page. What am I doing wrong? Thanks, Edi. From jdcal at yahoo.com Fri Apr 22 07:13:48 2005 From: jdcal at yahoo.com (Jeff Caldwell) Date: Fri, 22 Apr 2005 00:13:48 -0700 (PDT) Subject: [cl-typesetting-devel] Empty pages, again In-Reply-To: 6667 Message-ID: <20050422071348.74064.qmail@web50603.mail.yahoo.com> --- Edi Weitz wrote: > Hi! > > I have again problems with PDFs that come out as empty pages on > Acrobat 7. Here's a simplified version of the code: It's the padding and border parameters causing the problem, I think. The following code works OK for me. ;;;; cl-typesetting-devel 20050421 Edi Weitz ;;;; changes by JDC investigating the problem Edi reported ;;;; Acrobat 6.0 LWW 4.3 ;;;; Acrobat 6.0 showed the same problems reported by Edi in Acrobat 7.0 (defpackage ts (:use :cl :cl-user :typeset)) (in-package :ts) (defun write-table (n) (let* ((tt::*default-font* (pdf:get-font "Helvetica")) (tt::*default-font-size* 24) content (margins (list 10 10 10 10))) (with-open-file (out "c:/tmp/foo.pdf" :direction :output :if-exists :supersede) (with-document () (pdf:with-page () (setq content (compile-text (:font tt::*default-font* :font-size tt::*default-font-size*) (dotimes (i n) (insert-table "foo"))))) (draw-pages content :margins margins :break :after) (pdf:write-document out))))) (defun insert-table (text) (table (:col-widths (list 155)) ; :padding and :border are removed (row (:height 44) (tt::add-table-cell (make-instance 'tt::table-cell :v-align :center :content (compile-text (:h-align :center) text)))))) __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From jdcal at yahoo.com Fri Apr 22 07:26:01 2005 From: jdcal at yahoo.com (Jeff Caldwell) Date: Fri, 22 Apr 2005 00:26:01 -0700 (PDT) Subject: [cl-typesetting-devel] Empty pages, again In-Reply-To: 6667 Message-ID: <20050422072602.31373.qmail@web50608.mail.yahoo.com> --- Edi Weitz wrote: >> Hi! >> >> I have again problems with PDFs that come out as empty pages on >> Acrobat 7. Here's a simplified version of the code: >It's the padding and border parameters causing the problem, I think. >The following code works OK for me. I forgot to mention I also added with-page. (See the code in my prior post.) For what it is worth, the code seemed fragile. As I varied the code I had the following problems: . The pdf file contained only one very small page, showing at 800% magnification and still very small in the center of the Acrobat page. . The pdf file contained one entirely blank page. . Acrobat reported an "unrecognized token" error the text of which seemed unrelated to text in the source code. . I think there were times when the code would work if the table code was inline with the dotimes but not work when the table code was in a function. . and possibly other problems ... Of course, now that I have reached a working version, the nature of those problems may be eliminated or changed ... Jeff Caldwell __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com From marc.battyani at fractalconcept.com Fri Apr 22 09:36:14 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Fri, 22 Apr 2005 11:36:14 +0200 Subject: [cl-typesetting-devel] Empty pages, again References: <20050422072602.31373.qmail@web50608.mail.yahoo.com> Message-ID: <082701c5471e$bb4995c0$0a02a8c0@marcxp> "Jeff Caldwell" wrote: > --- Edi Weitz wrote: > >> Hi! > >> > >> I have again problems with PDFs that come out as empty pages on > >> Acrobat 7. Here's a simplified version of the code: > > >It's the padding and border parameters causing the problem, I think. > >The following code works OK for me. > > I forgot to mention I also added with-page. > (See the code in my prior post.) > > For what it is worth, the code seemed fragile. As I varied > the code I had the following problems: > > . The pdf file contained only one very small page, showing > at 800% magnification and still very small in the center > of the Acrobat page. > . The pdf file contained one entirely blank page. > . Acrobat reported an "unrecognized token" error the text of > which seemed unrelated to text in the source code. > . I think there were times when the code would work if the > table code was inline with the dotimes but not work when > the table code was in a function. > . and possibly other problems ... > > Of course, now that I have reached a working version, the > nature of those problems may be eliminated or changed ... I will have a look at that but now I'm going to Amsterdam. :) Marc From divanov at aha.ru Fri Apr 22 10:08:55 2005 From: divanov at aha.ru (Dmitriy Ivanov) Date: Fri, 22 Apr 2005 14:08:55 +0400 Subject: [cl-typesetting-devel] Empty pages, again References: Message-ID: <001701c54723$923f0c00$9f5802c3@digo> Hello Edi, | I have again problems with PDFs that come out as empty pages on | Acrobat 7. Here's a simplified version of the code: | ...snip...| | | If I call (WRITE-TABLE 1) I get a page with one table that looks fine. | If I call (WRITE-TABLE 2) instead I get an empty page. | | What am I doing wrong? Nothing at the first sight. My version (LWW with opening the output stream in binary mode) lookes as follows: (defun write-table (n) (let* ((tt::*default-font* (pdf:get-font "Helvetica")) (tt::*default-font-size* 24) content (margins (list 10 10 10 10))) (tt:with-document () (setq content (tt:compile-text (:font tt::*default-font* :font-size tt::*default-font-size*) (dotimes (i n) (insert-table "foo")))) (tt:draw-pages content :margins margins :break :after) (pdf:write-document "e:/lisp/projects/cl-typesetting/examples/edi-foo.pdf")))) (defun insert-table (text) (tt:table (:col-widths (list 155) :padding 0 :border 1) (tt:row (:height 44) (tt::add-table-cell (make-instance 'tt::table-cell :v-align :center :content (tt:compile-text (:h-align :center) text)))))) It looks fine on AcrobatReader 5.1. The resulting pdf-file is attached. -- Sincerely, Dmitriy Ivanov lisp.ystok.ru -------------- next part -------------- A non-text attachment was scrubbed... Name: edi-foo.pdf Type: application/pdf Size: 1002 bytes Desc: not available URL: From edi at agharta.de Fri Apr 22 11:14:34 2005 From: edi at agharta.de (Edi Weitz) Date: Fri, 22 Apr 2005 13:14:34 +0200 Subject: [cl-typesetting-devel] Empty pages, again In-Reply-To: <001701c54723$923f0c00$9f5802c3@digo> (Dmitriy Ivanov's message of "Fri, 22 Apr 2005 14:08:55 +0400") References: <001701c54723$923f0c00$9f5802c3@digo> Message-ID: Hi Dmitriy! On Fri, 22 Apr 2005 14:08:55 +0400, "Dmitriy Ivanov" wrote: > Nothing at the first sight. My version (LWW with opening the output > stream in binary mode) lookes as follows: That was the cause! I didn't open the stream in binary mode - now it works. Thanks! However, I'm still kind of confused because I ran my original tests with CMUCL and there the element type of the stream shouldn't matter because in CMUCL characters are octets. Hmmm... Cheers, Edi. From edi at agharta.de Fri Apr 22 11:16:28 2005 From: edi at agharta.de (Edi Weitz) Date: Fri, 22 Apr 2005 13:16:28 +0200 Subject: [cl-typesetting-devel] Empty pages, again In-Reply-To: <20050422071348.74064.qmail@web50603.mail.yahoo.com> (Jeff Caldwell's message of "Fri, 22 Apr 2005 00:13:48 -0700 (PDT)") References: <20050422071348.74064.qmail@web50603.mail.yahoo.com> Message-ID: On Fri, 22 Apr 2005 00:13:48 -0700 (PDT), Jeff Caldwell wrote: > It's the padding and border parameters causing the problem, I think. Hi Jeff! Thanks for your help but (see my other reply) it was due to my using a wrong element type for the stream. Cheers, Edi. From edi at agharta.de Fri Apr 22 11:25:55 2005 From: edi at agharta.de (Edi Weitz) Date: Fri, 22 Apr 2005 13:25:55 +0200 Subject: [cl-typesetting-devel] Re: [cl-pdf-announce] cl-pdf and cl-typesetting release candidates In-Reply-To: <2fb101c545e5$31557a80$0a02a8c0@marcxp> (Marc Battyani's message of "Wed, 20 Apr 2005 22:11:49 +0200") References: <074c01c503f3$13b432c0$0a02a8c0@marcxp> <019701c53a24$46defe20$0a02a8c0@marcxp> <2fb101c545e5$31557a80$0a02a8c0@marcxp> Message-ID: On Wed, 20 Apr 2005 22:11:49 +0200, "Marc Battyani" wrote: > Please send me remarks, fixes and patches you may have from the > current repository version. It didn't even compile on CMUCL due to the following lines at the end of huffman.lisp (note the missing parenthesis): ;;; Stub called from make-deflate-stream if di-huffman is not used. (defun initialize-huffman (&optional force) (declare (ignore force)) Using stock Salza 0.7.1 everything worked fine. As I probably said before - I'm questioning the usefulness of forking other libraries (as long as they're still maintained) and including them into cl-pdf or cl-typesetting. If there are improvements (like the ones from Dmitriy) they should be merged into the upstream code. See you in Amsterdam, Edi.