[luatex] Chunks of pdfe.readfromstream()

luigi scarso luigi.scarso at gmail.com
Thu Mar 30 20:51:46 CEST 2023


On Thu, 30 Mar 2023 at 17:03, Andreas Matthias <andreas.matthias at gmail.com>
wrote:

> On Thu, Mar 30, 2023 at 1:54 PM luigi scarso <luigi.scarso at gmail.com>
> wrote:
>
>>
>>
>> On Tue, 14 Mar 2023 at 20:35, Andreas Matthias <
>> andreas.matthias at gmail.com> wrote:
>>
>>> The manual says that
>>>
>>>    str, n = pdfe.readfromstream(<stream>)
>>>
>>> reads the stream in chunks. Now I had expected that `str` is just one
>>> chunk of the whole stream.
>>> But it seems that `str` always contains the whole stream.
>>>
>>> Could someone enlighten me what "read in chunks" means?
>>>
>>>
>> I need a short example .
>>
>
>
> Run texlua with this code:
>
>   local doc = pdfe.open('test.pdf')
>    local page = pdfe.getpage(doc, 1)
>    local stream = page['Contents']
>   pdfe.openstream(stream)
>    local str, n = pdfe.readfromstream(stream)
>    print(str)
>    print(n)
>
> Here test.pdf is:
>
>    \pdfvariable compresslevel = 0
>    \pdfvariable objcompresslevel = 0
>    Lorem ipsum dolor sit amet
>    ... a lot more text here ...
>    \bye
>
> Not matter how long the stream is, pdfe.readfromstream() always returns
> the whole stream.
>

use this as test.pdf
%% context --luatex test.tex
\nopdfcompression
\startTEXpage
\switchtobodyfont[3pt]
\dorecurse{4500}{ Lorem ipsum dolor sit amet    ... a lot more text here
...}
\stopTEXpage

 --
luigi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://tug.org/pipermail/luatex/attachments/20230330/5cd430ba/attachment.html>


More information about the luatex mailing list.