From Marc.Battyani at fractalconcept.com Mon May 2 20:53:07 2005 From: Marc.Battyani at fractalconcept.com (Marc Battyani) Date: Mon, 2 May 2005 22:53:07 +0200 Subject: [cl-pdf-devel] [ANNOUNCE] cl-pdf-parser Message-ID: <05b701c54f58$f49ec790$0a02a8c0@marcxp> This is the first public release of cl-pdf-parser. cl-pdf-parser enables cl-pdf to draw on existing pages and add new pages to an existing PDF document. I have been using this for a long time but it was based on Lispworks parser generator and I was too lazy to write a recursive descent parser. Now that cl-yacc is available, I used it to generate the parser. Here is an example of an existing commercial pdf document opened by cl-pdf-parser and modified with cl-pdf. (The first page have been reduced and drawn a second time rotated+some cl-pdf texts, the second page have been written on and a third page have been added to the document.) http://fractalconcept.com/fcweb/download/cl-pdf-parser-example.pdf cl-pdf-parser is in the cl-pdf repository. 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 (really 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 marc.battyani at fractalconcept.com Wed May 4 17:13:39 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Wed, 4 May 2005 19:13:39 +0200 Subject: [cl-pdf-devel] Re: [ANNOUNCE] cl-pdf-parser References: <05b701c54f58$f49ec790$0a02a8c0@marcxp> Message-ID: <0b9e01c550cc$9ea8cbe0$0a02a8c0@marcxp> cl-pdf-parser: Replacement of the LALR parser by a recursive descent one from Arthur Lemmens. Removed cl-yacc directory. Marc From peter at gigamonkeys.com Fri May 27 16:21:28 2005 From: peter at gigamonkeys.com (Peter Seibel) Date: Fri, 27 May 2005 09:21:28 -0700 Subject: [cl-pdf-devel] Fonts? Message-ID: So can someone point me to or provide a brief summary of how to use new fonts with CL-PDF. I'm deeply ignorant of almost everything to do with fonts so please start at the beginning. For instance: - In what format do I need to obtain the fonts I want to use? - Where do I save them relative to the cl-pdf/cl-typesetting software? - What else do I have to do to let cl-pdf/cl-typesetting know about them? - How do I know how refer to them in a call to pdf:get-font? -Peter -- Peter Seibel peter at gigamonkeys.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From ungil at mac.com Fri May 27 22:40:09 2005 From: ungil at mac.com (Carlos Ungil) Date: Sat, 28 May 2005 00:40:09 +0200 Subject: [cl-pdf-devel] Fonts? In-Reply-To: References: Message-ID: <3b66cd94c87cdd84569c8b416dd38966@mac.com> Hello, I'm not an expert, but I'll tell you what I did to have GillSans in cl-typesetting. I use MacOS X and I had the following in my system: /Library/Fonts/GillSans.dfont cl-pdf needs afm and pfb files (see cl-pdf/t1-font.lisp). The second file is optional but I don't know what's the difference it makes, so I included it as well just in case. I used http://fontforge.sourceforge.net to convert the font definition: open the dfont file (and select one of the styles available) execute File/Generate Fonts... this generates the pfb and afm files (the option "output afm" was enabled by default) To use the :font "GillSans" just load it before: (pdf:load-t1-font #P"/tmp/GillSans.afm" #P"/tmp/GillSans.pfb") I hope this helps, Carlos On May 27, 2005, at 6:21 PM, Peter Seibel wrote: > So can someone point me to or provide a brief summary of how to use > new fonts with CL-PDF. I'm deeply ignorant of almost everything to do > with fonts so please start at the beginning. For instance: > > - In what format do I need to obtain the fonts I want to use? > > - Where do I save them relative to the cl-pdf/cl-typesetting software? > > - What else do I have to do to let cl-pdf/cl-typesetting know about > them? > > - How do I know how refer to them in a call to pdf:get-font? > > -Peter > > -- > Peter Seibel peter at gigamonkeys.com > > Lisp is the red pill. -- John Fraser, comp.lang.lisp > _______________________________________________ > cl-pdf-devel site list > cl-pdf-devel at common-lisp.net > http://common-lisp.net/mailman/listinfo/cl-pdf-devel From marc.battyani at fractalconcept.com Fri May 27 22:52:49 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Sat, 28 May 2005 00:52:49 +0200 Subject: [cl-pdf-devel] Fonts? References: Message-ID: <073001c5630e$cf364720$0a02a8c0@marcxp> "Peter Seibel" wrote: > So can someone point me to or provide a brief summary of how to use > new fonts with CL-PDF. I'm deeply ignorant of almost everything to do > with fonts so please start at the beginning. For instance: > > - In what format do I need to obtain the fonts I want to use? You need type 1 fonts (a .afm and a .pfb files). There is a true-type to type 1 converter somewhere. > - Where do I save them relative to the cl-pdf/cl-typesetting software? Where you want. ;-) > - What else do I have to do to let cl-pdf/cl-typesetting know about them? Load the font with #'pdf:load-t1-font > - How do I know how refer to them in a call to pdf:get-font? You give the font name as a string: "Helvetica" Then you use pdf:set-font with the font you got from pdf:get-font You can look at the test examples in cl-typesetting. I load and use TeX fonts for the math layout demo. Marc From marc.battyani at fractalconcept.com Fri May 27 22:56:42 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Sat, 28 May 2005 00:56:42 +0200 Subject: [cl-pdf-devel] Fonts? References: <3b66cd94c87cdd84569c8b416dd38966@mac.com> Message-ID: <073c01c5630f$5a3ca3f0$0a02a8c0@marcxp> "Carlos Ungil" wrote: > I'm not an expert, but I'll tell you what I did to have GillSans in > cl-typesetting. > > I use MacOS X and I had the following in my system: > /Library/Fonts/GillSans.dfont > > cl-pdf needs afm and pfb files (see cl-pdf/t1-font.lisp). The second > file is optional The AFM is the font metrics and the PFB is the actual font content. > but I don't know what's the difference it makes, so I included it as > well just in case. > > I used http://fontforge.sourceforge.net to convert the font definition: Very interesting link! > open the dfont file (and select one of the styles available) > execute File/Generate Fonts... > this generates the pfb and afm files > (the option "output afm" was enabled by default) > To use the :font "GillSans" just load it before: > (pdf:load-t1-font #P"/tmp/GillSans.afm" #P"/tmp/GillSans.pfb") Marc From peter at gigamonkeys.com Sat May 28 01:17:02 2005 From: peter at gigamonkeys.com (Peter Seibel) Date: Fri, 27 May 2005 18:17:02 -0700 Subject: [cl-pdf-devel] Fonts? In-Reply-To: <073001c5630e$cf364720$0a02a8c0@marcxp> (Marc Battyani's message of "Sat, 28 May 2005 00:52:49 +0200") References: <073001c5630e$cf364720$0a02a8c0@marcxp> Message-ID: "Marc Battyani" writes: > "Peter Seibel" wrote: > >> So can someone point me to or provide a brief summary of how to use >> new fonts with CL-PDF. I'm deeply ignorant of almost everything to do >> with fonts so please start at the beginning. For instance: >> >> - In what format do I need to obtain the fonts I want to use? > > You need type 1 fonts (a .afm and a .pfb files). There is a true-type to > type 1 converter somewhere. So does cl-pdf support only Type 1 because of something intrinsic in PDF or is it just a matter of programming to teach it to grok Truetype fonts as well. And what about this new thing, OpenType? -Peter -- Peter Seibel peter at gigamonkeys.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From marc.battyani at fractalconcept.com Sun May 29 09:41:49 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Sun, 29 May 2005 11:41:49 +0200 Subject: [cl-pdf-devel] Fonts? References: <073001c5630e$cf364720$0a02a8c0@marcxp> Message-ID: <09ee01c56432$a4209bb0$0a02a8c0@marcxp> "Peter Seibel" writes: > > So does cl-pdf support only Type 1 because of something intrinsic in > PDF or is it just a matter of programming to teach it to grok Truetype > fonts as well. And what about this new thing, OpenType? PDF can use Truetype fonts but it's not in cl-pdf as the font metrics is needed to be able to use the font anyway. It's possible to extract this information from a truetype file but it's not done yet. I think I've seen a cl-truetype somewhere which could be used for that. [Real time google check...] Looks like Zach Beane has something like that: www.xach.com/lisp/cl-truetype/ So maybe it's relatively simple. I don't know if OpenType fonts are supported yet in pdf (It's not in the PDF reference 1.5). Marc From adia at hellug.gr Sun May 29 15:01:01 2005 From: adia at hellug.gr (Alexandros Diamantidis) Date: Sun, 29 May 2005 18:01:01 +0300 Subject: [cl-pdf-devel] Fonts? In-Reply-To: <09ee01c56432$a4209bb0$0a02a8c0@marcxp> References: <09ee01c56432$a4209bb0$0a02a8c0@marcxp> Message-ID: <20050529150101.GD8788@hellug.gr> * Marc Battyani [2005-05-29 11:41]: > I don't know if OpenType fonts are supported yet in pdf (It's not in > the PDF reference 1.5). I think PDF can only use OpenType fonts as a source of glyphs, which can be embedded in the PDF as Type 1 (PostScript) or or Type 42 (TrueType) outlines. The "interesting" parts of OpenType (the various advanced layout tables) have to be parsed and used by the typesetter. For an introduction to what these tables are used for, see for example here: http://partners.adobe.com/public/developer/opentype/index_layout.html -- Alexandros Diamantidis * adia at hellug.gr From adia at hellug.gr Sun May 29 15:22:47 2005 From: adia at hellug.gr (Alexandros Diamantidis) Date: Sun, 29 May 2005 18:22:47 +0300 Subject: [cl-pdf-devel] Fonts? In-Reply-To: <20050529150101.GD8788@hellug.gr> References: <09ee01c56432$a4209bb0$0a02a8c0@marcxp> <20050529150101.GD8788@hellug.gr> Message-ID: <20050529152247.GE8788@hellug.gr> I wrote: > I think PDF can only use OpenType fonts as a source of glyphs, which > can be embedded in the PDF as Type 1 (PostScript) or or Type 42 > (TrueType) outlines. The "interesting" parts of OpenType (the > various advanced layout tables) have to be parsed and used by the > typesetter. After some quick reading, I see I've mixed up the terminology a little... "Type 42" is a PostScript concept - a way to wrap up a TrueType font in a PS dictionary so that it looks like a PS font. PDF supports TrueType fonts directly. PDF 1.6 also supports embedding of OpenType fonts, but the advanced layout tables still have to be understood by the typesetter in order to be used. -- Alexandros Diamantidis * adia at hellug.gr From peter at gigamonkeys.com Sun May 29 18:56:39 2005 From: peter at gigamonkeys.com (Peter Seibel) Date: Sun, 29 May 2005 11:56:39 -0700 Subject: [cl-pdf-devel] Fonts? In-Reply-To: <09ee01c56432$a4209bb0$0a02a8c0@marcxp> (Marc Battyani's message of "Sun, 29 May 2005 11:41:49 +0200") References: <073001c5630e$cf364720$0a02a8c0@marcxp> <09ee01c56432$a4209bb0$0a02a8c0@marcxp> Message-ID: "Marc Battyani" writes: > "Peter Seibel" writes: >> >> So does cl-pdf support only Type 1 because of something intrinsic in >> PDF or is it just a matter of programming to teach it to grok Truetype >> fonts as well. And what about this new thing, OpenType? > > PDF can use Truetype fonts but it's not in cl-pdf as the font metrics is > needed to be able to use the font anyway. It's possible to extract this > information from a truetype file but it's not done yet. I think I've seen a > cl-truetype somewhere which could be used for that. [Real time google > check...] Looks like Zach Beane has something like that: > www.xach.com/lisp/cl-truetype/ > So maybe it's relatively simple. > > I don't know if OpenType fonts are supported yet in pdf (It's not in > the PDF reference 1.5). Hmmm, just a wacky thought. Is there any easy way to extract fonts from existing PDF docs? For instance, if I make a document in Word using all sorts of fancy fonts and then print it to PDF (easy on the Mac) cl-pdf-parse or something, extract the font info it needs to use those fonts? -Peter -- Peter Seibel peter at gigamonkeys.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From marc.battyani at fractalconcept.com Sun May 29 19:13:11 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Sun, 29 May 2005 21:13:11 +0200 Subject: [cl-pdf-devel] Fonts? References: <073001c5630e$cf364720$0a02a8c0@marcxp><09ee01c56432$a4209bb0$0a02a8c0@marcxp> Message-ID: <006601c56482$75f7d730$0a02a8c0@marcxp> "Peter Seibel" writes: > Hmmm, just a wacky thought. Is there any easy way to extract fonts > from existing PDF docs? For instance, if I make a document in Word > using all sorts of fancy fonts and then print it to PDF (easy on the > Mac) cl-pdf-parse or something, extract the font info it needs to use > those fonts? Generally no, as only the needed characters glyphs are embedded in the pdf file. But if you write all the possibles characters in the pdf it should be OK. Marc From peter at gigamonkeys.com Tue May 31 04:11:10 2005 From: peter at gigamonkeys.com (Peter Seibel) Date: Mon, 30 May 2005 21:11:10 -0700 Subject: [cl-pdf-devel] Fonts? In-Reply-To: <006601c56482$75f7d730$0a02a8c0@marcxp> (Marc Battyani's message of "Sun, 29 May 2005 21:13:11 +0200") References: <073001c5630e$cf364720$0a02a8c0@marcxp> <09ee01c56432$a4209bb0$0a02a8c0@marcxp> <006601c56482$75f7d730$0a02a8c0@marcxp> Message-ID: "Marc Battyani" writes: > "Peter Seibel" writes: > >> Hmmm, just a wacky thought. Is there any easy way to extract fonts >> from existing PDF docs? For instance, if I make a document in Word >> using all sorts of fancy fonts and then print it to PDF (easy on the >> Mac) cl-pdf-parse or something, extract the font info it needs to use >> those fonts? > > Generally no, as only the needed characters glyphs are embedded in > the pdf file. But if you write all the possibles characters in the > pdf it should be OK. Anyway, I got the fontforge software that Carlos mentioned, figured out how to get it running on OS X and converted a few .dfont files to afm/pfb combos and have now used CL-PDF to design some business cards for my new Lisp consulting business. Samples at: I'll probably go with either the one in the 2nd column, 2nd from the bottom or the first column, bottom row. But if anyone has any suggestions or comments about how to improve them, please let me know. And thanks again to Marc for producing this fine piece of software. -Peter -- Peter Seibel peter at gigamonkeys.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From marc.battyani at fractalconcept.com Tue May 31 07:37:04 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Tue, 31 May 2005 09:37:04 +0200 Subject: [cl-pdf-devel] Fonts? References: <073001c5630e$cf364720$0a02a8c0@marcxp><09ee01c56432$a4209bb0$0a02a8c0@marcxp><006601c56482$75f7d730$0a02a8c0@marcxp> Message-ID: <013a01c565b3$8b3f73f0$0a02a8c0@marcxp> "Peter Seibel" writes: > > Anyway, I got the fontforge software that Carlos mentioned, figured > out how to get it running on OS X and converted a few .dfont files to > afm/pfb combos and have now used CL-PDF to design some business cards > for my new Lisp consulting business. Samples at: > > Cool. > I'll probably go with either the one in the 2nd column, 2nd from the > bottom or the first column, bottom row. But if anyone has any > suggestions or comments about how to improve them, please let me know. I prefer the bottom right one too. Did you use cl-typesetting or only cl-pdf ? (the kerning seems not totally accurate) > And thanks again to Marc for producing this fine piece of software. Thanks, :-) Marc From edi at agharta.de Tue May 31 07:49:23 2005 From: edi at agharta.de (Edi Weitz) Date: Tue, 31 May 2005 09:49:23 +0200 Subject: [cl-pdf-devel] Fonts? In-Reply-To: (Peter Seibel's message of "Mon, 30 May 2005 21:11:10 -0700") References: <073001c5630e$cf364720$0a02a8c0@marcxp> <09ee01c56432$a4209bb0$0a02a8c0@marcxp> <006601c56482$75f7d730$0a02a8c0@marcxp> Message-ID: On Mon, 30 May 2005 21:11:10 -0700, Peter Seibel wrote: > Anyway, I got the fontforge software that Carlos mentioned, figured > out how to get it running on OS X and converted a few .dfont files > to afm/pfb combos and have now used CL-PDF to design some business > cards for my new Lisp consulting business. Samples at: > > I see frames with grey borders instead of spaces. I suppose that's not on purpose. Or is it? [Acrobat Reader 7.0.1 on Windows.] Cheers, Edi. From marc.battyani at fractalconcept.com Tue May 31 08:48:51 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Tue, 31 May 2005 10:48:51 +0200 Subject: [cl-pdf-devel] Fonts? References: <073001c5630e$cf364720$0a02a8c0@marcxp><09ee01c56432$a4209bb0$0a02a8c0@marcxp><006601c56482$75f7d730$0a02a8c0@marcxp> Message-ID: <017301c565bd$926c1bb0$0a02a8c0@marcxp> "Edi Weitz" writes: > On Mon, 30 May 2005 21:11:10 -0700, Peter Seibel wrote: > > > Anyway, I got the fontforge software that Carlos mentioned, figured > > out how to get it running on OS X and converted a few .dfont files > > to afm/pfb combos and have now used CL-PDF to design some business > > cards for my new Lisp consulting business. Samples at: > > > > > > I see frames with grey borders instead of spaces. I suppose that's > not on purpose. Or is it? I've seen this too. I assumed it was on purpose but maybe not. Marc From peter at gigamonkeys.com Tue May 31 15:19:52 2005 From: peter at gigamonkeys.com (Peter Seibel) Date: Tue, 31 May 2005 08:19:52 -0700 Subject: [cl-pdf-devel] Fonts? In-Reply-To: <017301c565bd$926c1bb0$0a02a8c0@marcxp> (Marc Battyani's message of "Tue, 31 May 2005 10:48:51 +0200") References: <073001c5630e$cf364720$0a02a8c0@marcxp> <09ee01c56432$a4209bb0$0a02a8c0@marcxp> <006601c56482$75f7d730$0a02a8c0@marcxp> <017301c565bd$926c1bb0$0a02a8c0@marcxp> Message-ID: "Marc Battyani" writes: > "Edi Weitz" writes: > >> On Mon, 30 May 2005 21:11:10 -0700, Peter Seibel > wrote: >> >> > Anyway, I got the fontforge software that Carlos mentioned, figured >> > out how to get it running on OS X and converted a few .dfont files >> > to afm/pfb combos and have now used CL-PDF to design some business >> > cards for my new Lisp consulting business. Samples at: >> > >> > >> >> I see frames with grey borders instead of spaces. I suppose that's >> not on purpose. Or is it? > > I've seen this too. I assumed it was on purpose but maybe not. No. That's not what I see either when I print it or in Preview on OS X or xpdf on GNU/Linux. That's strange. -Peter -- Peter Seibel peter at gigamonkeys.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From peter at gigamonkeys.com Tue May 31 15:21:11 2005 From: peter at gigamonkeys.com (Peter Seibel) Date: Tue, 31 May 2005 08:21:11 -0700 Subject: [cl-pdf-devel] Fonts? In-Reply-To: <013a01c565b3$8b3f73f0$0a02a8c0@marcxp> (Marc Battyani's message of "Tue, 31 May 2005 09:37:04 +0200") References: <073001c5630e$cf364720$0a02a8c0@marcxp> <09ee01c56432$a4209bb0$0a02a8c0@marcxp> <006601c56482$75f7d730$0a02a8c0@marcxp> <013a01c565b3$8b3f73f0$0a02a8c0@marcxp> Message-ID: "Marc Battyani" writes: > "Peter Seibel" writes: >> >> Anyway, I got the fontforge software that Carlos mentioned, figured >> out how to get it running on OS X and converted a few .dfont files to >> afm/pfb combos and have now used CL-PDF to design some business cards >> for my new Lisp consulting business. Samples at: >> >> > > Cool. > >> I'll probably go with either the one in the 2nd column, 2nd from the >> bottom or the first column, bottom row. But if anyone has any >> suggestions or comments about how to improve them, please let me know. > > I prefer the bottom right one too. > Did you use cl-typesetting or only cl-pdf ? > (the kerning seems not totally accurate) Just cl-pdf. I didn't realize that cl-typesetting would help with something like this. I'll give it a whirl before I have them printed up. -Peter -- Peter Seibel peter at gigamonkeys.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From peter at gigamonkeys.com Tue May 31 15:44:29 2005 From: peter at gigamonkeys.com (Peter Seibel) Date: Tue, 31 May 2005 08:44:29 -0700 Subject: [cl-pdf-devel] Question about tables Message-ID: [This message got rejected by the cl-typesetting list--maybe I'm not subscribed under this address to that list. Or did that list get decomissioned? Anyway, I'm sure someone here can help too.] I'm trying to make some PDF reports with a bunch of spreadsheet-style tables. Here's some sample code: (defpackage :com.gigamonkeys.table-test (:use :cl :typeset)) (in-package :com.gigamonkeys.table-test) (defun make-test-data (columns rows) (loop for c from 0 below columns collect (list (format nil "COLUMN ~d" c) (coerce (loop repeat rows collect (+ 10000 (random 10000d0))) 'vector)))) (defun compute-column-widths (columns) (let ((cols (length columns))) (loop repeat cols collect (floor (- 792 (* 2 36)) cols)))) (defun test-cell-wrapping (columns &optional (file "/tmp/analysis.pdf")) (with-document () (let ((content (compile-text () (paragraph (:h-align :center :font "Helvetica-Bold" :font-size 18 :color '(0.0 0 0.0)) "Test" :eol) (with-style (:font "Helvetica" :font-size 6) (table (:col-widths (compute-column-widths columns) :splittable-p t) (header-row () (loop for label in (mapcar #'first columns) do (cell () (with-style (:font "Helvetica-Bold") label)))) (loop for i from 0 below (length (second (first columns))) do (row () (loop for col in (mapcar #'second columns) do (cell () (put-string (format nil "~,2f" (aref col i))))))))) (vspace 10) :eol))) (draw-pages content :size :letter :orientation :landscape :margins '(36 36 36 36)) (when pdf:*page* (finalize-page pdf:*page*)) (pdf:write-document file)))) I have three main questions: 1) Why doesn't my compute-column-widths work correctly--it seems that I'm taking the total width of the page, subtracting the width of the left and right margins and then dividing by the number of columns. Yet the table, while starting at what looks like the correct left margin, goes to or even beyond the right edge of the page. To see this try evaluating: (test-cell-wrapping (make-test-data 10 10)) 2) Why does the content of the cells get broken over two lines even when there's seemingly plenty of room left in the cell. To see what I'm talking about try: (test-cell-wrapping (make-test-data 15 10)) 3) How do I adjust the line height to make the height of the rows smaller? -Peter -- Peter Seibel peter at gigamonkeys.com Lisp is the red pill. -- John Fraser, comp.lang.lisp From marc.battyani at fractalconcept.com Tue May 31 15:58:01 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Tue, 31 May 2005 17:58:01 +0200 Subject: [cl-pdf-devel] Fonts? References: <073001c5630e$cf364720$0a02a8c0@marcxp><09ee01c56432$a4209bb0$0a02a8c0@marcxp><006601c56482$75f7d730$0a02a8c0@marcxp><013a01c565b3$8b3f73f0$0a02a8c0@marcxp><02db01c565f7$15c840e0$0a02a8c0@marcxp> Message-ID: <02ea01c565f9$86590450$0a02a8c0@marcxp> "Peter Seibel" writes: > "Marc Battyani" writes: > > > If you look at "Yo" for instance you will see that the Y is too far > > from the o. cl-typesetting uses the kerning tables to correct this. > > Ah. So can I combine typeset:put-string with pdf:move-text, et al. to > get the good kerning while still taking care of positioning things > myself? Also, is there some smarter way to write this function that I > use to measure the length of the text so I can do things like center it? > > (flet ((text-width (text font font-size) > (* font-size (reduce #'+ text :key #'(lambda (c) (pdf:get-char-width c font)))))) text-width is already in text.lisp ;-) As you only need left/center/right text alignement, cl-typesetting will do it naturally. Just use one or several draw-block to put the text on the page. Marc From marc.battyani at fractalconcept.com Tue May 31 16:41:44 2005 From: marc.battyani at fractalconcept.com (Marc Battyani) Date: Tue, 31 May 2005 18:41:44 +0200 Subject: [cl-pdf-devel] Question about tables References: Message-ID: <02f601c565ff$a2562e70$0a02a8c0@marcxp> "Peter Seibel" writes: > [This message got rejected by the cl-typesetting list--maybe I'm not > subscribed under this address to that list. Or did that list get > decomissioned? Anyway, I'm sure someone here can help too.] I've put the cl-typesetting mailing list in copy. > I'm trying to make some PDF reports with a bunch of spreadsheet-style > tables. Here's some sample code: > > (defpackage :com.gigamonkeys.table-test (:use :cl :typeset)) > > (in-package :com.gigamonkeys.table-test) > > (defun make-test-data (columns rows) > (loop for c from 0 below columns > collect > (list > (format nil "COLUMN ~d" c) > (coerce (loop repeat rows collect (+ 10000 (random 10000d0))) 'vector)))) > > (defun compute-column-widths (columns) > (let ((cols (length columns))) > (loop repeat cols collect (floor (- 792 (* 2 36)) cols)))) > > (defun test-cell-wrapping (columns &optional (file "/tmp/analysis.pdf")) > (with-document () > (let ((content > (compile-text () > (paragraph (:h-align :center :font "Helvetica-Bold" :font-size 18 :color '(0.0 0 0.0)) "Test" :eol) > (with-style (:font "Helvetica" :font-size 6) > (table (:col-widths (compute-column-widths columns) :splittable-p t) > (header-row () > (loop for label in (mapcar #'first columns) > do (cell () (with-style (:font "Helvetica-Bold") label)))) > > (loop for i from 0 below (length (second (first columns))) do > (row () > (loop for col in (mapcar #'second columns) > do (cell () (put-string (format nil "~,2f" (aref col i))))))))) > (vspace 10) > :eol))) > (draw-pages content :size :letter :orientation :landscape :margins '(36 36 36 36)) > (when pdf:*page* (finalize-page pdf:*page*)) > (pdf:write-document file)))) > > I have three main questions: > > 1) Why doesn't my compute-column-widths work correctly--it seems that > I'm taking the total width of the page, subtracting the width of > the left and right margins and then dividing by the number of > columns. Yet the table, while starting at what looks like the > correct left margin, goes to or even beyond the right edge of the > page. To see this try evaluating: > > (test-cell-wrapping (make-test-data 10 10)) There is the cell-padding also. Have you counted it ? > 2) Why does the content of the cells get broken over two lines even > when there's seemingly plenty of room left in the cell. To see > what I'm talking about try: > > (test-cell-wrapping (make-test-data 15 10)) > > 3) How do I adjust the line height to make the height of the rows > smaller? For 2 and 3, the problem is probably that each cell is is a cl-typesetting engine and the "parent" style is not passed to the cells (yet...). If you wrap your cell's put-string into a with-style, it looks ok for me. Marc