Lua-pdfgen is a Lua binding library for PDFGen.
It runs on GNU/Linux and requires Lua (>=5.1) and PDFGen.
Authored by: Díaz Devera Víctor Diex Gamar (Máster Vitronic)
MIT license . See LICENSE.
See the Reference Manual.
I needed a fast, convenient and compatible way to create PDF files with the most commonly used Spanish characters.
$ git clone https://gitlab.com/vitronic/lua-pdfgen.git
$ cd lua-pdfgen
lua-pdfgen$ make
lua-pdfgen$ make install # or 'sudo make install' (Ubuntu)
#!/usr/bin/env lua
local pdfgen = require("pdfgen")
local pdf = pdfgen:new()
local pagecount = 10;
PDF_LETTER_WIDTH = 612.0
PDF_LETTER_HEIGHT = 792.0
local options = {
creator = 'Vitronic',
producer= 'producer',
title = 'title',
author = 'author',
subject = 'subject',
date = os.date('%Y%m%d%H%M%SZ')
}
pdf:create(
PDF_LETTER_WIDTH,
PDF_LETTER_HEIGHT,
options
)
pdf:set_font('Times-Roman')
local filename = ("massive-%d.pdf"):format(pagecount);
for i=1, pagecount do
local str = ("page %d"):format(i);
pdf:append_page();
pdf:add_text(nil, str, 12, 50, 20, '0x000000');
pdf:add_image_file(nil, 100, 500, 50, 150, "data/penguin.jpg");
end
print(pdf:save(filename))
pdf:destroy()
The script can be executed at the shell prompt with the standard Lua interpreter:
$ lua test.lua
Other examples can be found in the examples/ directory contained in the release package
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.