Re: Create PDF files in Euphoria
- Posted by Spock Sep 17, 2017
- 1630 views
rneu said...
I will have a sequence of strings in my Euphoria program which I want to be written on a regular A4 page. Also, if possible, a small logo image to be shown on the top of that page. Is this possible?
I use Libharu4eu (but wrapped some more for Orac). It seems to do everything you want. Images are imported directly from files so logos are possible. It has fonts, borders, alignments, regions, .. I like the output. Page numbering is managed by your program rather than the library itself. Here is the top-level function for creating an invoice (that might span multiple pages) :
global function create(seq s) -- s contain the line data -- init PDF library init() if not NewDoc() then return 0 end if -- must call NewDoc() so that page dimensions work.. -- local init define_regions() init_data(s) int PageNumber = 1 -- make report while anydata() do NewPage() header() name_address() info(PageNumber) invoice_lines() sum() -- this is activated only when there is no more data footer() PageNumber += 1 end while -- save to disk save() -- tidy up EndDoc() -- exit return 1 end function
If you want I can bundle the code as a demo that you can modify to suit your requirements.
Spock