World: r3wp
[PDF-Maker] discuss Gabriele's pdf-maker
older newer | first last |
Gabriele 23-Aug-2010 [729] | you can have different templates for even and odd pages. |
Graham 23-Aug-2010 [730] | drop-image? |
Gabriele 23-Aug-2010 [731] | flowing text around an image? not implemented yet. it's not trivial unless the image is fixed within the text. (this is a limitation of the TeX algorithm, the width of each row of text must be known in advance) |
Graham 23-Aug-2010 [732] | drop-image load %"Gabriele Fototessera small.jpg" |
Gabriele 23-Aug-2010 [733x2] | ah, i think that is a custom function. you can define your own "functions" or "macros" within the dialect. |
define-func 'drop-image [img font size /local iw ih lh mrgns] [ ( iw: img/size/x / 5.34 ih: img/size/y / 5.34 lh: pdfm/get-font-info font size lh: lh/max-height + lh/max-depth mrgns: copy [0 0] loop round/ceiling ih / lh - 1 [ repend mrgns [iw + 2 0] ] append mrgns [0 0] none ) justify with margins mrgns box iw lh 0 [ image xbl ybl - ih + lh iw ih img ] space 2 font* font size ] | |
Graham 23-Aug-2010 [735] | ahh... ok |
Gabriele 23-Aug-2010 [736] | as you see, it determines the image size, then sets the text margins so that you can make it flow around the image. it's a "trick" but it works if the image is not fixed within the page but moves around with the text, and you know it won't be split across pages. |
Graham 23-Aug-2010 [737] | so if you were doing a watermark you don't alter the text margins |
Gabriele 23-Aug-2010 [738x2] | correct. |
you can also just put the image below the text boxes in the page template in that case. | |
Graham 23-Aug-2010 [740] | for a floating signature? |
Gabriele 23-Aug-2010 [741x2] | you can use a vbox [ ... ] and put any graphic command inside it. |
a box is "inline", eg, it is treated like it was a character. a vbox is considered more like a paragraph. | |
Graham 23-Aug-2010 [743x2] | Carl should use pdf-maker to generate PDFs of the online docs |
Is qtask using pdf-maker? | |
Gabriele 23-Aug-2010 [745] | no. initially, we wanted to use it for wikis (ie. see my qml to pdf code), but the fact that the pdf was not an exact replica of the html output was not considered acceptable. |
Graham 23-Aug-2010 [746] | I tried this append new-page compose/deep [ textbox 10 10 100 100 [ image 0 0 40 40 (load %247logo.png) ] ] and not seeing any image in the pdf .. |
Gabriele 24-Aug-2010 [747] | graphic commands such as image are separate from text commands. inside a text "context", you can use box or vbox to enter a graphic "context". (also, you don't need the compose, as the dialect will try to evaluate arguments anyway.) So: textbox 10 10 100 100 [ box [image 0 0 40 40 load %247logo.png] ] The difference between BOX and VBOX is that the former is treated like a character, while the latter is treated like a paragraph. (So you can have the former in the middle of a text line.) |
Graham 24-Aug-2010 [748] | ok, I'll try it again .. just with the above I got an error about expecting an image so I added the compose |
Gabriele 24-Aug-2010 [749] | Unless there's a bug, that should work... |
Graham 24-Aug-2010 [750x3] | When I use this command, I don't get an image, and my 13 page pdf stops at the first page |
this is the end of the file endstream endobj 8 0 obj << /Type /Pages /Kids [6 0 R] /Count 1 >> endobj 1 0 obj << /Type /Catalog /Version /1.4 /Outlines 2 0 R /Pages 8 0 R >> endobj 2 0 obj << /Type /Outlines /Count 0 >> endobj 3 0 obj [/PDF /Text /ImageC] endobj xref 0 9 0000000000 65535 f 0000005180 00000 n 0000005259 00000 n 0000005305 00000 n 0000000009 00000 n 0000000111 00000 n 0000000208 00000 n 0000000414 00000 n 0000005123 00000 n trailer << /Size 9 /Root 1 0 R >> startxref 5341 %%EOF | |
there's no png there... | |
Gabriele 25-Aug-2010 [753x3] | ah, sorry, box requires more args, checking... |
box width height depth [...gfx commands...] | |
depth controls the offset relative to the text baseline, for eg. the letter 'q' has a positive depth because the stem goes below the text baseline. | |
Graham 25-Aug-2010 [756x3] | ok, trying again |
append new-page compose/deep [ textbox 10 10 100 100 [ box 60 60 10 [image 0 0 40 40 load %247logo.png] ] ] Doesn't work either | |
similar justify with margins mrgns box iw lh 0 [ image xbl ybl - ih + lh iw ih img ] space 2 | |
Gabriele 26-Aug-2010 [759] | uh... while testing this, i got this: >> i: load http://www.rebol.com/graphics/reb-logo.gif connecting to: www.rebol.com == GIF89a\ufffd >> load read/binary http://www.rebol.com/graphics/reb-logo.gif connecting to: www.rebol.com Segmentation fault |
Graham 26-Aug-2010 [760x2] | linux? |
of course | |
Gabriele 26-Aug-2010 [762x3] | ah, wait, that was probably my fault... (yes, linux, i guess it should not segfault though) |
this works for me: b: layout-pdf [[textbox [box 60 60 10 [image 0 0 40 40 load http://www.rebol.com/graphics/reb-logo.gif]]]] | |
the image comes at the bottom though, which does not look correct, so I'm probably forgetting something... | |
Graham 26-Aug-2010 [765] | Interesting .. I get nothing |
Gabriele 26-Aug-2010 [766x2] | right... i don't do a coordinate transformation, that's the reason for xbl and ybl in the above snippet |
you get xbl (X Bottom Left), ybl, xtr, ytr bound within the graphic block | |
Graham 26-Aug-2010 [768x2] | Copyright (c) 2001-2005, Gabriele Santilli |
is that pdf-maker1 or 2 ? | |
Gabriele 26-Aug-2010 [770x2] | http://www.colellachiara.com/soft/PDFM2/pdf-maker.html Gabriele Santilli <[giesse-:-rebol-:-it]> 17-Nov-2006, 2.34.0 |
v2 was done between 8-Aug-2006 and 17-Nov-2006 | |
Graham 26-Aug-2010 [772x2] | Ok, got it |
got the image. | |
Gabriele 26-Aug-2010 [774x2] | b: layout-pdf [[textbox ["Image: " box 60 60 10 [image xbl ybl 40 40 load http://www.rebol.com/graphics/reb-logo.gif] " inside text"]]] |
That puts the image inside the text correctly. v2 should also give you an error when the dialect is wrong, while v1 did just fail silently. | |
Graham 26-Aug-2010 [776x2] | so this syntax doesn't work with pdf maker 1 ? |
so I got the silent fail | |
Gabriele 26-Aug-2010 [778] | no. v1 does not flow text automatically across pages, does not allow putting graphics within text, does not have the TeX engine, and so on. |
older newer | first last |