[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 112: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
newlispfanclub.alh.net • View topic - Options for paper output?

Options for paper output?

Q&A's, tips, howto's

Options for paper output?

Postby HPW » Tue Oct 28, 2003 8:20 am

HPW
 
Posts: 1376
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Postby Lutz » Wed Oct 29, 2003 12:08 am

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby HPW » Wed Oct 29, 2003 7:08 am

HPW
 
Posts: 1376
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Postby HPW » Thu Dec 18, 2003 10:12 am

HPW
 
Posts: 1376
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Postby nigelbrown » Thu Dec 18, 2003 1:12 pm

nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby HPW » Thu Dec 18, 2003 1:52 pm

HPW
 
Posts: 1376
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Postby eddier » Thu Dec 18, 2003 2:22 pm

You might try generating LaTeX documentation from within newlisp and then calling latex from the (! ) shell command to compile it and dvips (dvi to postscript) from the shell command to print the resulting file. Or if you want the pdf file -- call dvipdf (dvi to pdf) instead of dvips.

I've generated nice output this way in the past.

Eddie
eddier
 
Posts: 289
Joined: Mon Oct 07, 2002 2:48 pm
Location: Blue Mountain College, MS US

Postby nigelbrown » Thu Dec 18, 2003 9:41 pm

nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby nigelbrown » Fri Dec 19, 2003 3:23 pm

nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby nigelbrown » Thu Feb 05, 2004 8:40 pm

below is a context that outputs a pdf directly - it could be used to add extra funionality - create pdf from text file, callable functions that output pdf etc.
I don't have anywhere to put it up on a site. It's just a straight translation from the c - more or less.

; from txt2pdf.c that had header below
; from http://www.planetpdf.com/mainpage.asp?WebPageID=156
; titled "How to convert text to PDF"
;/*
; Copyright 1998
; P. G. Womack, Diss, Norfolk, UK.
; "BugBear"
; Do what you like, but don't claim you wrote it.
;*/
; converted by Nigel
; usage:
; access using (TXT2PDF:txt2psf function_to_provide_text filenamestring)
; file will be opened named from filenamestring (put your own .pdf extension on)
; then function_to_provide_text will be repeatedly called - each call should produce
; either
; a string that will be treated as text with a newline implicitly at the end
; or character \012 that will be treated as formfeed - that is start a new page
; or nil that will signal end of data - pdf will then be finalised and closed, no more calls will be made
; returns true if successful (file created and closed) false if file open fails.
; eg (TXT2PDF:txt2pdf (lambda() (pop '("line1" "line2" "\012" "line1 on newpage" "2nd line"))) "demo.pdf")
;

(context 'TXT2PDF)

(setq page_width 594.0 )
(setq page_depth 828.0 )
(setq margin 30.0 )
(setq font_size 10.0 )
(setq lead_size 10.0 )
(setq object_id 1 )

(setq num_pages 0)
(setq pages '())

(define (store_page id) (begin (push id pages -1) (inc 'num_pages)))

(setq num_xrefs 0)
(setq xrefs '()) ; holdsposition of xrefs as assoc list

(define (start_object id) (begin (push (list id (seek pdfout)) xrefs)
(write-buffer pdfout (format "%d 0 obj\n" id))))
(setq stream_id 0)
(setq stream_len_id 0)
(setq ypos 0.0)

(define (start_page) (begin (setq stream_id object_id)
(inc 'object_id)
(setq stream_len_id object_id)
(inc 'object_id)
(start_object stream_id)
(write-buffer pdfout (format "<< /Length %d 0 R >>\n" stream_len_id))
(write-buffer pdfout "stream\n")
(setq stream_start (seek pdfout))
(write-buffer pdfout (format "BT\n/F0 %g Tf\n" font_size))
(setq ypos (sub page_depth margin))
(write-buffer pdfout (format "%g %g Td\n" margin ypos))
(write-buffer pdfout (format "%g TL\n" lead_size))))

(define (end_page) (begin (setq page_id object_id)
(inc 'object_id)
(store_page page_id)
(write-buffer pdfout "ET\n")
(setq stream_len (- (seek pdfout) stream_start))
(write-buffer pdfout "endstream\nendobj\n")
(start_object stream_len_id)
(write-buffer pdfout (format "%d\nendobj\n" stream_len)) ; "%ld\nendobj\n" newlisp int is 32 bit
(start_object page_id)
(write-buffer pdfout (format "<</Type/Page/Parent %d 0 R/Contents %d 0 R>>\nendobj\n" page_tree_id stream_id))))

(define (do_text pdfgets)
(begin
(start_page)
(while (setq buffer (pdfgets))
(begin
(if (< ypos margin)
(begin
(end_page)
(start_page)))
(if (= (length buffer) 0)
(write-buffer pdfout "T*\n")
(if (= (first buffer) "\012"); formfeed code
(begin
(end_page)
(start_page))
(begin
(write-buffer pdfout "(")
(setq s -1)
(if (!= (nth -1 buffer) "\000") (setq buffer (append buffer "\000"))) ; protect from endless last char
(while (!= (setq c (nth (inc 's) buffer)) "")
(begin
(case c
("(" (write-buffer pdfout "\\"))
(")" (write-buffer pdfout "\\"))
("\\" (write-buffer pdfout "\\")))
(write-buffer pdfout c)))
(write-buffer pdfout ")'\n"))))
(setq ypos (sub ypos lead_size))))
(end_page)))

(define (txt2pdf pdfgets pdffilename) (begin
(set 'pdfout (open pdffilename "write")) ; mod to have txt2pdf to return nil if open fails
(if (= pdfout nil) nil (begin ; do else if file opened ok
(write-buffer pdfout "%%PDF-1.0\n")
(setq page_tree_id object_id)
(inc 'object_id)
(do_text pdfgets)
(setq font_id object_id)
(inc 'object_id)
(start_object font_id)
(write-buffer pdfout "<</Type/Font/Subtype/Type1/BaseFont/Courier/Encoding/WinAnsiEncoding>>\nendobj\n")
(start_object page_tree_id)
(write-buffer pdfout (format "<</Type /Pages /Count %d\n" num_pages))
(write-buffer pdfout "/Kids[\n")
(dolist (ppid pages) (write-buffer pdfout (format "%d 0 R\n" ppid)))
(write-buffer pdfout "]\n")
(write-buffer pdfout (format "/Resources<</ProcSet[/PDF/Text]/Font<</F0 %d 0 R>> >>\n" font_id))
(write-buffer pdfout (format "/MediaBox [ 0 0 %g %g ]\n" page_width page_depth))
(write-buffer pdfout ">>\nendobj\n")
(setq catalog_id object_id)
(inc 'object_id)
(start_object catalog_id)
(write-buffer pdfout (format "<</Type/Catalog/Pages %d 0 R>>\nendobj\n" page_tree_id))
(setq start_xref (seek pdfout))
(write-buffer pdfout "xref\n")
(write-buffer pdfout (format "0 %d\n" object_id))
(write-buffer pdfout "0000000000 65535 f \n")
(dotimes (i (- object_id 1)) (write-buffer pdfout (format "%010d 00000 n \n" (lookup (+ i 1) xrefs)))) ;"%010ld 00000 n \n"
(write-buffer pdfout (format "trailer\n<<\n/Size %d\n/Root %d 0 R\n>>\n" object_id catalog_id))
(write-buffer pdfout (format "startxref\n%d\n%%%%EOF\n" start_xref));"startxref\n%ld\n%%%%EOF\n"
(close pdfout)))))

(context 'MAIN)
nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby nigelbrown » Thu Feb 05, 2004 11:30 pm

Sorry a typo in usage it should of course be
access using (TXT2PDF:txt2pdf function_to_provide_text filenamestring)
see the demo line lower
Nigel
nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby Lutz » Fri Feb 06, 2004 1:33 am

Thanks, wonderful! I will put it on the news website next week in the Tips&Tricks section, if this is Ok with you.

Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby nigelbrown » Fri Feb 06, 2004 1:57 am

Yes that's fine.
A couple of observations from the C-to-newLISP conversion process:

The acceptable format specifier in C %ld (long integer) isn't in newLISP - as all newLISP ints are long and %d handles that - so extra editing of formats was needed. Could newLISP accept ld as a specifier? (that is just treat it as %d)

The editor GVim ftp://ftp.vim.org/pub/vim/pc/gvim62.exe at http://www.vim.org/index.php is a handy text editor that is able to flash matching brackets (menu item Edit|Global Settings|Toggle Showmatch).
I've replaced my previous editor with it for lisp.

Nigel
nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby Lutz » Fri Feb 06, 2004 5:08 pm

thanks, i will look into it

Lutz
Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby Sammo » Mon Feb 09, 2004 2:56 pm

Sammo
 
Posts: 180
Joined: Sat Dec 06, 2003 6:11 pm
Location: Loveland, Colorado USA

Postby HPW » Mon Feb 09, 2004 7:06 pm

HPW
 
Posts: 1376
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Postby Lutz » Tue Feb 10, 2004 1:19 am

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby nigelbrown » Tue Feb 10, 2004 1:52 am

nigelbrown
 
Posts: 429
Joined: Tue Nov 11, 2003 2:11 am
Location: Brisbane, Australia

Postby HPW » Tue Feb 10, 2004 7:37 am

HPW
 
Posts: 1376
Joined: Thu Sep 26, 2002 9:15 am
Location: Germany

Postby Lutz » Tue Feb 10, 2004 1:46 pm

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California

Postby Lutz » Tue Feb 10, 2004 6:02 pm

Lutz
 
Posts: 5279
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California


Return to newLISP in the real world

Who is online

Users browsing this forum: No registered users and 1 guest