0

For example, when I try to compile this code in my document:

\begin{luacode} \pdfextension literal direct{/Span <</ActualText (First paragraph on page one)>> BDC} tex.print("my text") \pdfextension literal direct{EMC} \end{luacode} 

I have a problem with the compilation of the document.

How I can use the command \pdfextension in Lua code?

8
  • 3
    please always make it easy for people to help you by providing a test file that reproduces the error. Commented Mar 20, 2019 at 20:09
  • 3
    You can't/shouldn't use luatex tex-commands like \pdfextension inside a luacode environment, it is only for luacode. Commented Mar 20, 2019 at 20:17
  • But what command i can use in luacode enviroment,to add span in the page. Commented Mar 20, 2019 at 21:04
  • 1
    You should make a complete example so that it is clear where in the page stream you want to inject the BDC operator. Commented Mar 20, 2019 at 22:13
  • 1
    Don't put code in the comments. Edit your question. And if you want me to see your comment you should ping me with @UlrikeFischer. Commented Mar 20, 2019 at 23:27

1 Answer 1

5

I translated your example in the comments to something that compiles below.

But ...

You are using the wrong callback. If you look in the pdf you will see something like this:

%PDF-1.5 %ÌÕÁÔÅØÐÄÆ /Span <</ActualText (test)>> BDC EMC 3 0 obj << /Length 205 >> 

This means that your BDC-operator ended outside the page stream. The pdf is broken.

The documentation describes the callback like this:

This callback is called whenever LuaTEX is ready to move stuff to the main vertical list. You can use this callback to do specialized manipulation of the page building stage like imposition or column balancing.

\documentclass{article} \usepackage{luacode} \pagestyle{empty} \begin{luacode} pdf.setcompresslevel(0) b=0 function f(a) texio.write_nl("Value "..a) if a=="new_graf" then if b%2==0 then pdf.print ("direct","/Span <</ActualText (test)>> BDC ") else pdf.print ("direct","EMC ") end b=b+1 end end luatexbase.add_to_callback("buildpage_filter",f,"filter") \end{luacode} \begin{document} paragraph one paragraph two \end{document} 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.