
Adobe Acrobat SDK
Inserting Text into PDF Documents
Developing Plug-ins and Applications
Inserting text 66
2. Invoke the
PDETextAdd
method and pass the following arguments:
●
A
PDEText
object that you created.
●
A
PDETextFlags
value that specifies the type of text to add. Specify
kPDETextRun
for a text run.
●
An
ASInt32
value that specifies the index after which to add the text run. You can specify
0
to add
the text run to the beginning.
●
A character pointer that specifies the text to insert into the PDF document.
●
An
ASInt32
value that specifies the length of the text run.
●
The
PDEFont
object that you created. For information, see
“Acquiring fonts” on page 64
.
●
The address of the
PDEGraphicState
object that you created. For information, see
“Creating a
PDEGraphicState object” on page 65
.
●
The size of the
PDEGraphicState
object. You can use the
sizeof
method to get this
information.
●
The address of the
PDETextState
object. You can pass
NULL
.
●
The size of the
PDETextState
object.
●
The address of the
ASFixedMatrix
object that you created. For information, see
“Creating an
ASFixedMatrix object” on page 65
.
●
The address of the
ASFixedMatrix
object that holds the matrix for the line width when stroking
text. It is recommended that you pass
NULL
.
3. Insert text into the page content by invoking the
PDEContentAddElem
method and passing the
following arguments:
●
The
PDEContent
object that you created. For information, see
“Creating a container” on page 63
.
●
The location to where the text is added. Pass
kPDEAfterLast
to add the text to the end of the
PDEContent
object.
●
The
PDEText
object and cast this object to
PDEElement
.
4. Set the page's
PDEContent
back into the page by invoking the
PDPageSetPDEContent
method
and passing the following arguments:
●
A
PDPage
object that you created. For information, see
“Creating a new page” on page 63
.
●
An
ASExtension
object that represents the caller. If you invoke this method from a PDF Library
project, you can pass
NULL
. In contrast, if you invoke this method from a plug-in, you would pass
the
gExtensionID
extension.
The following code example inserts text into a PDF document.
Example 4.7
Inserting text into a PDF document
//Create a PDEText object
pdeText = PDETextCreate();
//Create a character pointer
char *HelloWorldStr = "Hello There";
//Create new text run
PDETextAdd(pdeText, //Text container to add to
kPDETextRun, // kPDETextRun
0, // index