forked from xournalpp/xournalpp
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add plugin exporting to filename derived from xopp
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
-- Register all Toolbar actions and intialize all UI stuff | ||
function initUi() | ||
app.registerUi({["menu"] = "Export to pdf", ["callback"] = "exportPdf", ["accelerator"] = "<Shift><Alt>p"}); | ||
app.registerUi({["menu"] = "Export to svg", ["callback"] = "exportSvg", ["accelerator"] = "<Shift><Alt>s"}); | ||
app.registerUi({["menu"] = "Export to png", ["callback"] = "exportPng", ["accelerator"] = "<Shift><Alt>n"}); | ||
end | ||
|
||
local DEFAULT_PATH = "/tmp/temp" -- change this to get a different default path for xopp-files that have not been saved yet | ||
|
||
function exportPdf() | ||
local pdfName = getStem() .. "_export.pdf" | ||
app.export({["outputFile"] = pdfName}) | ||
-- use the "range", "background" and "progressiveMode" fields for more customization | ||
end | ||
|
||
function exportSvg() | ||
local svgName = getStem() .. "_export.svg" | ||
app.export({["outputFile"] = svgName}) | ||
-- use the "range", "background" for more customization | ||
end | ||
|
||
function exportPng() | ||
local pngName = getStem() .. "_export.png" | ||
app.export({["outputFile"] = pngName}) | ||
-- use the "range", "background" and "pngDpi", "pngWidth" or "pngHeight" fields for more customization | ||
end | ||
|
||
function getStem() | ||
local xoppName = app.getDocumentStructure()["xoppFilename"] | ||
if (xoppName ~= "" and xoppName ~= nil) then | ||
return xoppName:match("(.+)%..+$") | ||
else | ||
print("Exporting to default path. Consider saving the xopp-file before exporting! ") | ||
return DEFAULT_PATH | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[about] | ||
## Author / Copyright notice | ||
author=Roland Lötscher | ||
|
||
description=Export to pdf, svg and png. | ||
|
||
## If the plugin is packed with Xournal++, use | ||
## <xournalpp> then it gets the same version number | ||
version=<xournalpp> | ||
|
||
[default] | ||
enabled=false | ||
|
||
[plugin] | ||
mainfile=main.lua |