Enable printing in Docify

This commit is contained in:
Xuan Sang LE
2021-01-30 17:45:45 +00:00
parent 752b2a6f1d
commit b0c2e088f9
15 changed files with 155 additions and 9 deletions

View File

@ -396,6 +396,33 @@ handle.delete = function(param)
end
end
handle.printdoc = function(opt)
local cmd = "lp "
if opt.printer and opt.printer ~= "" then
cmd = cmd .. " -d "..opt.printer
end
if opt.side == 0 then
cmd = cmd.. " -o sides=one-sided"
elseif opt.side == 1 then
cmd = cmd.. " -o sides=two-sided-long-edge"
elseif opt.side == 2 then
cmd = cmd .. " -o sides=two-sided-short-edge"
end
-- orientation landscape
if opt.orientation == 1 then
cmd = cmd.." -o orientation-requested=5"
end
if opt.range == 1 then
cmd = cmd.." -P "..opt.pages
end
cmd = cmd.. " "..vfs.ospath(opt.file)
print(cmd)
os.execute(cmd)
return result("A print job has been posted on server. Check if it successes")
end
if arg.action and handle[arg.action] then
-- check if the database exits