Home   Archive   Permalink



Pdf-maker.r: Some comments and questions

Hi, I am using pdf-maker by Gabriele Santilli and I would like to share some info but also make some questions that could be helpful for further reference:
    
Nick's tutorial and other places make reference to pdf-maker, the Rebol file, the manual (a six page pdf document made with pdf-maker.r) and the source code for the manual (that is, the script that, processed by pdf-maker.r produces the manual).
    
The manual states to be valid for version 1.20 alpha
    
Nick's link takes you to http://www.colellachiara.com/soft/Misc/pdf-maker.r where the script identifies itself as version 1.27.1 dated 3 August, 2006
    
1. When you study the source code for the manual, you can see many more instructions that do not appear in the Manual. Some can be derived by comparing the script with the end result but others are a bit more involved.
    
For example, what does the 'p' do? It kind of appears at the end of each 'P'aragraph (or is it at the beginning?)
what does 'as-is' do? is it a kind of html 'pre'?
Why does the instruction 'left margin 10' not seem to work unless it comes with 'as-is with', but in the process introduce extra vertical space?
The instruction 'Space' produces horizontal or vertical space?
Do I need to set the font again when I want to change the size? (the source suggests so).
“Justify” and “Center” can go by themselves but “left” and “right” seem to need to be followed by “align”. Why?
    
Please note that I am not complaining. I am actually very happy with pdf-maker. I just want to feel more sure when I use it.
    
2. In the source, Gabriele uses a special nomenclature to produce an emdash and an apostrophe in the output text:
    
^(97) for the emdash and
^(99) for the apostrophe.
    
What code is this? it is not ASCII (that would be #'a' and #'c') nor HTML-entity codes. I wanted to use the endash. I am thinking to use a loop and check what comes up but will do this once the project is finished just in case a non-printable character actually means 'wipe the hard disk' :)
    
3. The manual states that version 1.20 (and 1.27.1 too, it turns out) uses 'the 14 PostScript standard fonts' only, but there is no further reference to them. A Google search turns different results and the source code for the manual doesn't use them all. I am very new to Rebol and my understanding is very basic. However, I was able to dig into the code and found this:
    
Courier
Courier-Bold
Courier-BoldOblique
Courier-Oblique
    
Helvetica
Helvetica-Bold
Helvetica-BoldOblique
Helvetica-Oblique
    
Times-Bold
Times-BoldItalic
Times-Italic
Times-Roman
    
Symbol
ZapfDingbats
    
Which are valid names to request fonts with in the script. Too bad there was very little else I could understand.
    
4. The website rebol.org talks about pdf-maker but has a link to a different version:
    
http://www.colellachiara.com/soft/PDFM2/pdf-maker.html
    
This version identifies itself as version 2.34.0 dated 17 of November, 2006. This version is quite beefier at 168 KB compared to the 51 KB of version 1.27.1. The documentation also claims that this version uses typesetter.r, a high quality text typesetter based on Tex algorithms, and other Rebol scripts written by Gabriele, promising a user-oriented documentation to be provided later.
    
Does anyone have this documentation or has used this version?
    
I am guessing that LaTex and front ends like Lyx could compete with this kind software. But there is a lot of work done here and having such functionality from within Rebol is inspiring. I would love to know if it's stable and how to use it.
    
I hope that this info is useful. Thanks for your attention.

posted by:   Brother Damian       10-Sep-2016/2:34:24-7:00



point 2. The caret is an escape. Rebol uses ^/ to escape to linefeed. Look up in an ascii table somewhere you'll see that this is 32 positions earlier in the table then the "/" character. Something similar is going on for ^(96).
    
It would be great to have an updated version and one for Red too.

posted by:   Arnold       10-Sep-2016/4:53:34-7:00



Thanks Arnold. After the escape symbol, do you know what the number means or from what table it comes from? I checked ASCII and the Decimal 97 belongs to "a" but produced an em dash and decimal 99 belongs to "c" but produced an apostrophe. Now, hex 97 in ASCII is the em dash but 99 hex produces the trade mark. SO I don't think that Gabriele was using ASCII.
    
On other note I would like to mention that the following code will not print after the first line:
    
R E B O L []
    
do %pdf-maker.r
name: "Homer Simpson"
time: 45
date: now/date
number: 3
    
page1: compose/deep [
    [
         page size 215.9 279.4
         textbox 20 135 176 50 [
         center font Times-Bold 6.33
         "My PDF Report"
         left align font Times-Roman 4.92
         newline
         "Name of Applicant: " (name)
         "Time running: " (time) " mins." newline
         "Date of Test: " (date) newline
         "# of laps: " (number) newline
         ]
     ]
]
    
write/binary %Myreport.pdf layout-pdf page1
call %myreport.pdf
    
Apparently one needs to explicitly cast the non string variables into string, so in order to get the desired result one needs to include:
    
...
time: form 45
date: form now/date
number: form 3
...

posted by:   Brother Damian       11-Sep-2016/15:15-7:00



The mdash here http://www.ascii-code.com/ has HEX code 97.

posted by:   Arnold       11-Sep-2016/16:10:39-7:00



Sorry, you knew that already. Can't find the ^() references in the sourcecode.
    
For the last example, try to break it down up to the point where it does work. Your conclusion is probably correct, sometimes the functions cannot handle wrong types. As you are trying to 'print' to a pdf document you need a string not a number.

posted by:   Arnold       11-Sep-2016/16:25:22-7:00



In the source code for the manual, found here:
http://www.colellachiara.com/soft/Misc/pdf-maker-doc.r
    
In the Block "page-1", in the first textbox block, 4th line says:
    
{^(92)s preliminary documentation ...}
    
;Which becomes an apostrophe and I wrongly identified as ^(99) in my first post. Sorry for that. 92 decimal is a backlash in ASCII and 92 hex is a right single quotation mark, so ASCII is still not a match.
    
;then the 9th and 10th line go:
    
"^(97) Sub-optimal image handling ..."
"^(97) Only the 14 PostScript standard fonts ..."
    
;which produces the em dashes
    


posted by:   Brother Damian       11-Sep-2016/18:24:11-7:00



So these are the hexadecimal values for the symbols used. So that is solved. ' has special meaning in Rebol as you know, so the author wishes to avoid it here. And an emdash (I really hate it if autocorrection makes these from my hyphens) is not standard on most keyboards.

posted by:   Arnold       12-Sep-2016/6:26:53-7:00



I used the pdf maker again. It does what it promises. To be honest having a script or dialect to make it really easy to go from some markup to the format that the pdf-maker uses as input would be very nice to have.
Nevertheless it works for me. Just have a little faith in yourself and test your docs and small changes often. The script is perfect for that, or you can easily adapt your script to be easy to test.

posted by:   Arnold       24-Sep-2016/16:15:16-7:00



Final Thoughts:
    
First. Read my work: https://timeserieslord.github.io/red/
Check out the section titled: What is Your Function?
    
Learn about function chains and FFP. That is what Carl Sassenrath had in mind for you when he created REBOL.
    
Ban from your mind the idea that you need to process strings. Many compiler-based langs as well as VMs with langs force you to work with strings.
    
The REBOL VM does not. This is true for Red too.
    
Let REBOL do the work for you. Try to work with block!(s) and REBOL datatypes! exclusively. That should be your goal for every solution.
    
1) parse your log file into string! tokens
2) convert the string tokens into REBOL datatypes!
3) grab the ones you want.
    
Two functions defined below will let you do this:
    
>> outlog data
== [12-Mar-2016 12:30:02 12-Mar-2016 12:32:56]
    
I use an alike model with parsesets to crush it with any data however messed up.
    
SOLUTION #3
    
tranny: func [
{transform a string into a REBOL datatype!}
value
/local
][
    
    any [
     attempt [if parse to-block value [date!][return to-date value]]
     attempt [if parse to-block value [time!][return to-time value]]
     ;; add other types here
     ]
]
    
    
outlog: func [
{ Return the log file cleaned up}
data [string!]
/local out
][
    
;; data out
out: copy []
    
;; into a block of stupid strings
data: parse/all data " "
    
;; into a block of smart REBOL datatypes!
forall data [
     append out tranny data/1
]
    
;; remove the nones
remove-each j out [none? j]
    
;; out for further processing
return out
]

posted by:   Time Series Lord       24-Sep-2016/16:34:37-7:00



Please delete the above

posted by:   Time Series Lord       24-Sep-2016/16:35:56-7:00



Back to on-topic.
The questions that you have are answered by the code from line 877 and down. Look for "dialect rules".

posted by:   Arnold       26-Sep-2016/3:51:23-7:00