<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hello Heiko,<div><br></div><div><div><blockquote type="cite"><blockquote type="cite">when running the following code, I have a problem that subsequent boxes are misplaced. A warning is issued:<br><br>LuaTeX warning: Misplaced \pdfrestore by (983040sp, 0sp)<br><br>What am I doing wrong?<br></blockquote></blockquote><div><br></div><br><blockquote type="cite">There are two different coordinate<br>systems: PDF and TeX, \pdfrestore restores the graphics state including<br>the current transfer matrix to the state of \pdfsave in the PDF<br>coordinate system. But if the TeX position has moved away, the<br>two coordinate systems are out of sync. Therefore you get a warning<br>that you might shoot yourself in the foot.<br></blockquote><div><br></div><div>I my case, I did get garbled output, so the warning was very good.</div><div><br></div><div>Thanks for your comment. This is what I have now:</div><div><br></div><div>local function scalebox(scalefactor,box)<br>    local pdf_save, pdf_restore, pdf_setmatrix<br>    pdf_save = node.new("whatsit","pdf_save")<br>    pdf_restore = node.new("whatsit","pdf_restore")<br>    pdf_setmatrix = node.new("whatsit","pdf_setmatrix")<br>    pdf_setmatrix.data=string.format("%.4g 0 0 %.4g",scalefactor,scalefactor)<br><br>    local hbox = node.hpack(box)<br>    hbox = node.insert_before(hbox,hbox,pdf_setmatrix)<br>    hbox = node.insert_before(hbox,pdf_setmatrix,pdf_save)<br><br>    hbox = node.hpack(hbox)<br>    hbox.height = box.height * scalefactor<br>    hbox.width = box.width * scalefactor<br>    hbox.depth = 0<br>    node.insert_after(hbox,node.tail(hbox),pdf_restore)<br><br>    local newbox = node.vpack(hbox)<br>    return newbox<br>end</div><div><br></div><div>which seems to work because the box doesn't have any depth. </div><div><br></div><div>Patrick</div><div><br></div><div><a href="https://github.com/speedata/publisher/blob/develop/src/lua/barcodes/barcodes.lua#L10">https://github.com/speedata/publisher/blob/develop/src/lua/barcodes/barcodes.lua#L10</a></div><div><br></div><div><img id="eaf4f77c-ccb4-4b36-a8c2-d895e4718788" height="373" width="750" apple-width="yes" apple-height="yes" src="cid:AAFB1ED2-756F-4A56-B9B8-41E762BDE87E"></div><div><br></div></div></div></body></html>