Hi Ulrike,
On Tue, 2025-11-11 at 16:50 +0100, Ulrike Fischer wrote:
> If I compile this example with luatex
>
> \immediate\pdfextension obj {<</before/before>>}
> \immediate\pdfextension obj uncompressed {<</meta/meta>>}
> \immediate\pdfextension obj {<</after/after>>}
> aaa
> \bye
>
> then the PDF contains various uncompressed objects that are not
> present if I do not use the uncompressed object, e.g. the object
> written after it, but also various font objects and the catalog etc:
>
>
> 3 0 obj
> <</meta/meta>>
> endobj
>
> 4 0 obj
> <</after/after>>
I can confirm that I'm seeing this behaviour too.
> How can one stop that?
This appears to be an engine bug; I've attached a patch that appears to
fix it.
> Or alternatively how can one write one
> uncompressed object without affecting the compression of the other
> objects?
I've looked through the engine sources, and there doesn't appear to be
any way to work around this bug from TeX/Lua (without resorting to FFI
trickery at least).
Thanks,
-- Max
From d635ddddf92ffe3dc6a8c17be90b8d06bfe9b570 Mon Sep 17 00:00:00 2001
From: Max Chernoff <[email protected]>
Date: Wed, 12 Nov 2025 02:04:13 -0700
Subject: [PATCH] Also restore pdf->objcompresslevel when restoring
pdf->compress_level.
Right now, if you write a single uncompressed object, no other objects
in the rest of the document will be written as object streams, because
pdf->objcompresslevel is not restored. This patch saves and restores
pdf->objcompresslevel along with pdf->compress_level, meaning that you
can now write a single uncompressed object without affecting the rest of
the document.
---
source/texk/web2c/luatexdir/pdf/pdfobj.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/source/texk/web2c/luatexdir/pdf/pdfobj.c b/source/texk/web2c/luatexdir/pdf/pdfobj.c
index 71d6a943f..d2daa4a95 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfobj.c
+++ b/source/texk/web2c/luatexdir/pdf/pdfobj.c
@@ -30,7 +30,7 @@ void pdf_write_obj(PDF pdf, int k)
const_lstring st;
/*tex The index into |data.s|: */
size_t li;
- int saved_compress_level ;
+ int saved_compress_level, saved_objcompresslevel ;
/*tex Gives compressed objects for |\pdfvariable objcompresslevel| >= |OBJSTM_ALWAYS|: */
int os_threshold = OBJSTM_ALWAYS;
/*tex Possibly a \LUA\ registry reference: */
@@ -40,6 +40,7 @@ void pdf_write_obj(PDF pdf, int k)
/*tex We can have an immediate object before we are initialized. */
ensure_output_state(pdf, ST_HEADER_WRITTEN);
saved_compress_level = pdf->compress_level;
+ saved_objcompresslevel = pdf->objcompresslevel;
/*tex End of a ugly hack. */
if (obj_obj_pdfcompresslevel(pdf, k) > -1) {
/*tex A value of |-1| means ``unset''. */
@@ -127,6 +128,7 @@ void pdf_write_obj(PDF pdf, int k)
luaL_unref(Luas, LUA_REGISTRYINDEX, l);
obj_obj_data(pdf, k) = LUA_NOREF;
pdf->compress_level = saved_compress_level;
+ pdf->objcompresslevel = saved_objcompresslevel;
}
void init_obj_obj(PDF pdf, int k)
--
2.51.1
_______________________________________________
dev-luatex mailing list -- [email protected]
To unsubscribe send an email to [email protected]