Avoid writting highlights into read-only PDFs (#5889)

This commit is contained in:
Martín Fernández
2020-02-25 21:26:19 +01:00
committed by GitHub
parent 825b22dd6b
commit 5d103a41f8
2 changed files with 21 additions and 1 deletions

View File

@@ -175,6 +175,14 @@ function PdfDocument:saveHighlight(pageno, item)
local suffix = util.getFileNameSuffix(self.file)
if string.lower(suffix) ~= "pdf" then return end
if self.is_writable == nil then
local handle = io.open(self.file, 'r+b')
self.is_writable = handle ~= nil
if handle then handle:close() end
end
if self.is_writable == false then
return false
end
self.is_edited = true
-- will also need mupdf_h.lua to be evaluated once
-- but this is guaranteed at this point