CoolFace
Apppublic

PellelNitram/xournalpp_htr

sourceHugging Faceupdated 2d agoView on Hugging Face
0likes
main.lua47 linesDownload Raw Back to plugin
1function initUi()2  app.registerUi({["menu"] = "Xournal++ HTR", ["callback"] = "run", ["accelerator"] = "<Control>F1"});3end4 5function save_file(path)6  if path:len() > 0 then7 8    -- Read settings: I use this (https://stackoverflow.com/a/41176958). An9    -- alternative could have been https://stackoverflow.com/a/41176826. Both10    -- found using G"lua read settings file".11    local config = require "config"12 13    config.filename = '"' .. app.getDocumentStructure()['xoppFilename'] .. '"'14    config.output_file = '"' .. path .. '"'15 16    command = config.python_executable .. " " .. config.xournalpp_htr_path17              .. " -if " .. config.filename18              .. " -of " .. config.output_file19    if config.debug_HTR_command then20      print(command)21    else22      os.execute(command)23    end24 25  end26end27 28function run()29 30  document_structure = app.getDocumentStructure()31 32  if document_structure['xoppFilename']:len() == 0 then33    app.openDialog('Please save document prior to exporting it as searchable PDF!', {"Ok"}, "", true)34  else35    app.fileDialogSave("save_file", "untitled.pdf")36  end37 38end39 40-- TODO: Think of workflow to maximise usability for user41-- TODO: How to store settings? Ideally permanently?42-- TODO: Interesting code from example plugins:43--   - Get filename: https://github.com/xournalpp/xournalpp/blob/master/plugins/Export/main.lua#L2944--   - Toggle logic: https://github.com/xournalpp/xournalpp/blob/master/plugins/HighlightPosition/main.lua#L545--   - UI: https://github.com/xournalpp/xournalpp/blob/master/plugins/MigrateFontSizes/main.lua46--   - OS interaction: https://github.com/xournalpp/xournalpp/blob/master/plugins/QuickScreenshot/main.lua47