You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@pdfbox.apache.org by "Vorpahl,Lucinda" <vo...@heb.com> on 2015/01/15 16:37:18 UTC

What does appendRawCommands do?

I have the following lines of code for creating my PDF but I'm not sure what the appendRawCommands is doing.

contentStream.drawString("\u0095 Some standard text here");
contentStream.appendRawCommands("12 TL T*");
contentStream.drawString("\u0095 More basic text here, ");
contentStream.appendRawCommands("T*");
contentStream.drawString("  Additional stuff here");
contentStream.appendRawCommands("T*");
contentStream.drawString("\u0095 You know what is here  ");
contentStream.appendRawCommands("T*");
contentStream.drawString("  Yep.");
contentStream.appendRawCommands("T*");
contentStream.drawString("\u0095 One more line");
contentStream.appendRawCommands("T*");
contentStream.drawString("\u0095 Last line");

This is the output:


*         Some standard text here

*         More basic text here,

Additional stuff here

*         You know what is here

Yep.

*         One more line

*         Last line

Is appendRawCommands creating the bullet points?
Why does the first line have "12 TL T*" and the rest only have "T*"

Thanks in advance,
Lucy Vorpahl


RE: What does appendRawCommands do?

Posted by "Vorpahl,Lucinda" <vo...@heb.com>.
Thank you very much for your help.

Lucy

-----Original Message-----
From: John Hewson [mailto:john@jahewson.com] 
Sent: Thursday, January 15, 2015 1:08 PM
To: users@pdfbox.apache.org
Subject: Re: What does appendRawCommands do?

I just realise I didn’t answer this question:

> Is appendRawCommands creating the bullet points?

Yes, \u0095 results in a bullet point. Note that in Unicode, U+0095 is not the bullet character, but is the ASCII control character for “message waiting”. But PDFBox 1.8 does not use Unicode, it uses WinAnsiEncoding where 0x0095 is the “bullet” character.

WinAnsiEncoding  is specific to PDF, but it’s based on https://urldefense.proofpoint.com/v2/url?u=http-3A__en.wikipedia.org_wiki_Windows-2D1250&d=AwIFaQ&c=RI9dKKMRNVHr9NFa7OQiQw&r=46g1Q9l2ygNJoVl15Feuc2oj-eK5kwz0sL2OtXB9UQA&m=bR6SMRip89jzHzUUjQ3M9GTmRcFRZ186x567SN9h6XY&s=EYqsUmcf49zWmyXrDCe-6FEa2P-ET6Kmttl1ioYKgNo&e=  <https://urldefense.proofpoint.com/v2/url?u=http-3A__en.wikipedia.org_wiki_Windows-2D1250&d=AwIFaQ&c=RI9dKKMRNVHr9NFa7OQiQw&r=46g1Q9l2ygNJoVl15Feuc2oj-eK5kwz0sL2OtXB9UQA&m=bR6SMRip89jzHzUUjQ3M9GTmRcFRZ186x567SN9h6XY&s=EYqsUmcf49zWmyXrDCe-6FEa2P-ET6Kmttl1ioYKgNo&e= >

If you switch to PDFBox 2.0 Trunk, you can forget about all this and just use Unicode via the new .showText() API.

-- John

> On 15 Jan 2015, at 07:37, Vorpahl,Lucinda <vo...@heb.com> wrote:
> 
> I have the following lines of code for creating my PDF but I'm not sure what the appendRawCommands is doing.
> 
> contentStream.drawString("\u0095 Some standard text here");
> contentStream.appendRawCommands("12 TL T*");
> contentStream.drawString("\u0095 More basic text here, "); 
> contentStream.appendRawCommands("T*");
> contentStream.drawString("  Additional stuff here"); 
> contentStream.appendRawCommands("T*");
> contentStream.drawString("\u0095 You know what is here  "); 
> contentStream.appendRawCommands("T*");
> contentStream.drawString("  Yep.");
> contentStream.appendRawCommands("T*");
> contentStream.drawString("\u0095 One more line"); 
> contentStream.appendRawCommands("T*");
> contentStream.drawString("\u0095 Last line");
> 
> This is the output:
> 
> 
> *         Some standard text here
> 
> *         More basic text here,
> 
> Additional stuff here
> 
> *         You know what is here
> 
> Yep.
> 
> *         One more line
> 
> *         Last line
> 
> Is appendRawCommands creating the bullet points?
> Why does the first line have "12 TL T*" and the rest only have "T*"
> 
> Thanks in advance,
> Lucy Vorpahl
> 


Re: What does appendRawCommands do?

Posted by John Hewson <jo...@jahewson.com>.
I just realise I didn’t answer this question:

> Is appendRawCommands creating the bullet points?

Yes, \u0095 results in a bullet point. Note that in Unicode, U+0095 is not the bullet character, but is the ASCII control character for “message waiting”. But PDFBox 1.8 does not use Unicode, it uses WinAnsiEncoding where 0x0095 is the “bullet” character.

WinAnsiEncoding  is specific to PDF, but it’s based on http://en.wikipedia.org/wiki/Windows-1250 <http://en.wikipedia.org/wiki/Windows-1250>

If you switch to PDFBox 2.0 Trunk, you can forget about all this and just use Unicode via the new .showText() API.

-- John

> On 15 Jan 2015, at 07:37, Vorpahl,Lucinda <vo...@heb.com> wrote:
> 
> I have the following lines of code for creating my PDF but I'm not sure what the appendRawCommands is doing.
> 
> contentStream.drawString("\u0095 Some standard text here");
> contentStream.appendRawCommands("12 TL T*");
> contentStream.drawString("\u0095 More basic text here, ");
> contentStream.appendRawCommands("T*");
> contentStream.drawString("  Additional stuff here");
> contentStream.appendRawCommands("T*");
> contentStream.drawString("\u0095 You know what is here  ");
> contentStream.appendRawCommands("T*");
> contentStream.drawString("  Yep.");
> contentStream.appendRawCommands("T*");
> contentStream.drawString("\u0095 One more line");
> contentStream.appendRawCommands("T*");
> contentStream.drawString("\u0095 Last line");
> 
> This is the output:
> 
> 
> *         Some standard text here
> 
> *         More basic text here,
> 
> Additional stuff here
> 
> *         You know what is here
> 
> Yep.
> 
> *         One more line
> 
> *         Last line
> 
> Is appendRawCommands creating the bullet points?
> Why does the first line have "12 TL T*" and the rest only have "T*"
> 
> Thanks in advance,
> Lucy Vorpahl
> 


Re: What does appendRawCommands do?

Posted by John Hewson <jo...@jahewson.com>.
Hi Lucy,

12 TL sets the text leading to 12pt, i.e the line-height. The default is zero.
T* moves to start of a new line, and uses the TL value. This does nothing when TL is zero.

The  text operators are documented in full in the PDF specification (ISO 32000:1),
in Section 9.3, you can find a copy here:

http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf <http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf>

You might like to try the 2.0 Trunk version of PDFBox, where we have built-in APIs for these
commands now, so you don’t have to call appendRawCommands. We also have full Unicode
support for TTF fonts.

-- John

> On 15 Jan 2015, at 07:37, Vorpahl,Lucinda <vo...@heb.com> wrote:
> 
> I have the following lines of code for creating my PDF but I'm not sure what the appendRawCommands is doing.
> 
> contentStream.drawString("\u0095 Some standard text here");
> contentStream.appendRawCommands("12 TL T*");
> contentStream.drawString("\u0095 More basic text here, ");
> contentStream.appendRawCommands("T*");
> contentStream.drawString("  Additional stuff here");
> contentStream.appendRawCommands("T*");
> contentStream.drawString("\u0095 You know what is here  ");
> contentStream.appendRawCommands("T*");
> contentStream.drawString("  Yep.");
> contentStream.appendRawCommands("T*");
> contentStream.drawString("\u0095 One more line");
> contentStream.appendRawCommands("T*");
> contentStream.drawString("\u0095 Last line");
> 
> This is the output:
> 
> 
> *         Some standard text here
> 
> *         More basic text here,
> 
> Additional stuff here
> 
> *         You know what is here
> 
> Yep.
> 
> *         One more line
> 
> *         Last line
> 
> Is appendRawCommands creating the bullet points?
> Why does the first line have "12 TL T*" and the rest only have "T*"
> 
> Thanks in advance,
> Lucy Vorpahl
>