\includegraphics works for PDF files

This commit is contained in:
Marcel Krüger 2020-06-13 03:31:25 +02:00
parent a4b5b89205
commit 0d4199ab4a
2 changed files with 21 additions and 2 deletions

View File

@ -159,7 +159,6 @@ end)
local lastobj = -1 local lastobj = -1
local lastannot = -1 local lastannot = -1
local lastimage = -1
function pdf.newcolorstack(default, mode, page) function pdf.newcolorstack(default, mode, page)
local idx = #colorstacks local idx = #colorstacks
@ -659,6 +658,9 @@ img = {
immediatewrite = function(img, pfile) return imglib_immediatewrite(pfile or get_pfile(), img) end, immediatewrite = function(img, pfile) return imglib_immediatewrite(pfile or get_pfile(), img) end,
} }
local lastimage = -1
local lastimagepages = -1
-- These are very minimal right now but LaTeX isn't using the scaling etc. stuff anyway. -- These are very minimal right now but LaTeX isn't using the scaling etc. stuff anyway.
token.luacmd("saveimageresource", function(imm) token.luacmd("saveimageresource", function(imm)
local attr = token.scan_keyword'attr' and token.scan_string() or nil local attr = token.scan_keyword'attr' and token.scan_string() or nil
@ -679,15 +681,32 @@ token.luacmd("saveimageresource", function(imm)
userpassword = userpassword, userpassword = userpassword,
ownerpassword = ownerpassword, ownerpassword = ownerpassword,
pagebox = pagebox, pagebox = pagebox,
filename = filename,
} }
local pfile = get_pfile() local pfile = get_pfile()
lastimage = imglib.get_num(pfile, img) lastimage = imglib.get_num(pfile, img)
lastimagepages = img.pages or 1
if imm == 'immediate' then if imm == 'immediate' then
imglib_immediatewrite(pfile, img) imglib_immediatewrite(pfile, img)
end end
end, "protected") end, "protected")
token.luacmd("useimageresource", function() token.luacmd("useimageresource", function()
local pfile = get_pfile() local pfile = get_pfile()
local img = assert(imglib.from_num(token.scan_int())) local img = assert(imglib.from_num(token.scan_int()))
imglib_write(pfile, img) imglib_write(pfile, img)
end, "protected") end, "protected")
local value_values = token.values'value'
for i=0,#value_values do
value_values[value_values[i]] = i
end
local integer_code = value_values.integer
token.luacmd("lastsavedimageresourceindex", function()
return integer_code, lastimage
end, "protected", "value")
token.luacmd("lastsavedimageresourcepages", function()
return integer_code, lastimagepages
end, "protected", "value")

View File

@ -4,7 +4,7 @@ local nodenew = node.direct.new
local getwhd = node.direct.getwhd local getwhd = node.direct.getwhd
local setwhd = node.direct.setwhd local setwhd = node.direct.setwhd
local tonode = node.direct.tonode local tonode = node.direct.tonode
local nodewrite = node.direct.write local nodewrite = node.write
local box_fallback = { local box_fallback = {
BleedBox = "CropBox", BleedBox = "CropBox",