Try this: (PDFDocument new compression: false)add: (PDFPage new add: (PDFTextElement new text: 'Hello'; from: 10mm@10mm)); exportTo: 'test.pdf' asFileReference writeStream. Compression causes your string to be gzipâd which is a ByteArray and not a String of any kind. Unfortunately, the write stream is a ZnCharacterWriteStream which is expecting some kind of String. This is going to take some untangling so just turn off compression (which is on by default) and it seems to work.
On Jan 17, 2024, at 4:43â¯PM, Richard O'Keefe <raoknz@gmail.com> wrote:
So the method is expecting some kind of string, but it received a ByteArray, which is NOT any kind of string. What's in the ByteArray? Where did it come from? Why isn't it a string?
On Thu, 18 Jan 2024 at 04:34, sergio ruiz <sergio.rrd@gmail.com> wrote:
Hi, all.
I am working on creating a PDF with Artefact (https://github.com/pharo-contributions/Artefact) and am having an issue running the first example.
the Example looks like:
PDFDocument new add: (PDFPage new add: (PDFTextElement new text: 'Hello'; from: 10mm@10mm)); exportTo: 'test.pdf' asFileReference writeStream.
When running this, I get the error:
Instance of ByteArray did not understand #isByteString
indeed, ByteArray does not have a method called isByteString.
I have tried creating a method that returns either true or false (I tried them both), but I have not successfully built the PDF.
The method calling isByteString looks like:
ZnUTF8Encoder
next: count putAll: string startingAt: offset toStream: stream "Write count characters from string starting at offset to stream." "Overwritten for performance reasons - create a fast path for byte strings"
string isByteString ifTrue: [ self next: count putAllByteString: string startingAt: offset toStream: stream ] ifFalse: [ super next: count putAll: string startingAt: offset toStream: stream ]
I TOTALLY get this. This is a whole bunch of very specific questions. But my ultimate goal is to take a deep dive into stream processing to figure this out.
Thanks!
---- peace, sergio photographer, journalist, visionary
Public Key: https://pgp.key-server.io/pks/lookup?op=get&search=0x69B08F58923AB3A2 #BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV @sergio_101@mastodon.social https://sergio101.com http://www.codeandmusic.com http://www.twitter.com/sergio_101 http://www.facebook.com/sergio101