Professional Documents
Culture Documents
RTF2PDF
RTF2PDF
API Reference
Table of Contents
Part I Welcome to RTF2PDF / TextDynamic Server
1 Overview
................................................................................................................................... 4
2 QuickStart
................................................................................................................................... 5
3 Troubleshooting
...................................................................................................................................
.NET
9
4 Load Template,
...................................................................................................................................
Update and Save
9
5 ASP.NET
...................................................................................................................................
Example
11
6 ASP.NET
...................................................................................................................................
Live Demos
15
7 Properties
................................................................................................................................... 16
Report
Mem o
Mem o2
PDFCreator
ResultBuffer
AttrHelper
.......................................................................................................................................................... 16
.......................................................................................................................................................... 16
.......................................................................................................................................................... 16
.......................................................................................................................................................... 16
.......................................................................................................................................................... 17
.......................................................................................................................................................... 17
8 Methods
................................................................................................................................... 18
BeginDoc
.......................................................................................................................................................... 18
EndDoc
.......................................................................................................................................................... 18
Print
.......................................................................................................................................................... 18
PrintSecond .......................................................................................................................................................... 19
StartEngine / SetLicense
.......................................................................................................................................................... 19
StopEngine .......................................................................................................................................................... 19
ReleaseInt .......................................................................................................................................................... 19
9 RTF2PDF
...................................................................................................................................
ActiveX
20
10 wPDFControl
...................................................................................................................................
Documentation
22
w PDFControl/RTFtoPDF
..........................................................................................................................................................
Dem o
22
Quick Start - w..........................................................................................................................................................
RTF2PDF / TextDynam ic Server
25
Quick Start - Generic
..........................................................................................................................................................
PDF Creation
27
Tip: Use SaveDC
..........................................................................................................................................................
/ RestoreDC
29
w PDFControl .NET
.......................................................................................................................................................... 30
PDFControl......................................................................................................................................................... 30
PDFPropDlg......................................................................................................................................................... 31
Properties ......................................................................................................................................................... 33
RTF to PDF......................................................................................................................................................... 37
Methods ......................................................................................................................................................... 43
Events
......................................................................................................................................................... 49
w PDFControl DLL
..........................................................................................................................................................
/ ActiveX
50
w PDFControl Methods
..........................................................................................................................................................
and Properties
51
Properties ......................................................................................................................................................... 51
Methods ......................................................................................................................................................... 53
License
.......................................................................................................................................................... 55
56
1 Page Size
................................................................................................................................... 56
General
.......................................................................................................................................................... 56
Different in one
..........................................................................................................................................................
docum ent
56
Sections
.......................................................................................................................................................... 56
2006-2009 by WPCubed GmbH, Munich, Germany
Contents
Labels
II
.......................................................................................................................................................... 57
2 Contents
................................................................................................................................... 57
Text
.......................................................................................................................................................... 59
Tables
.......................................................................................................................................................... 59
Fields
.......................................................................................................................................................... 60
Im ages
.......................................................................................................................................................... 61
Header & Footer
.......................................................................................................................................................... 61
Textboxes
.......................................................................................................................................................... 62
Footnotes
.......................................................................................................................................................... 62
3 Font Attributes
................................................................................................................................... 63
4 Paragraph
...................................................................................................................................
Attributes
65
5 Paragraph
...................................................................................................................................
Styles
66
67
1 General:
...................................................................................................................................
WPDllInt + IWPMemo/IWPEditor
68
Events
.......................................................................................................................................................... 72
RTF2PDF / .........................................................................................................................................................
TextDynamic
72
Exclusive to
.........................................................................................................................................................
TextDynamic
84
Categories .......................................................................................................................................................... 100
Character.........................................................................................................................................................
Attributes Category
100
Character.........................................................................................................................................................
Styles Category
101
Document.........................................................................................................................................................
Properties Category
101
Callback Functions
.........................................................................................................................................................
Category
101
Header and
.........................................................................................................................................................
Footer Support Category
102
Sections ......................................................................................................................................................... 103
Hyperlinks.........................................................................................................................................................
and Bookmarks Category
103
Image Support
.........................................................................................................................................................
Category
103
Load and .........................................................................................................................................................
Save Category
104
Mailmerge.........................................................................................................................................................
Category
107
Position Markers
.........................................................................................................................................................
Category
108
Low level .........................................................................................................................................................
Paragraph IDs Category
109
Printing Category
......................................................................................................................................................... 109
Standard .........................................................................................................................................................
Editing Commands Category
110
Paragraphstyle
.........................................................................................................................................................
Support Category
111
Table Support
.........................................................................................................................................................
Category
112
TextDynamic
.........................................................................................................................................................
CSS strings Category
114
Tabstop Category
......................................................................................................................................................... 115
IWPMem o / IWPEditor
.......................................................................................................................................................... 115
Properties......................................................................................................................................................... 117
Methods ......................................................................................................................................................... 126
2 IWPTextCursor
...................................................................................................................................
(Text creation and cursor positioning)
186
Properties .......................................................................................................................................................... 188
CPCellPtr ......................................................................................................................................................... 188
CPLineNr ......................................................................................................................................................... 188
CPObjPtr ......................................................................................................................................................... 188
CPPageLineNr
......................................................................................................................................................... 188
CPPageNr......................................................................................................................................................... 189
CPParNr ......................................................................................................................................................... 189
CPParPtr ......................................................................................................................................................... 189
CPPosInLine
......................................................................................................................................................... 189
CPPosInPar
......................................................................................................................................................... 189
CPPosition......................................................................................................................................................... 190
CPRow Ptr......................................................................................................................................................... 190
CPStylePtr......................................................................................................................................................... 190
CPTableColNr
......................................................................................................................................................... 190
CPTablePtr
......................................................................................................................................................... 191
II
2006-2009 by WPCubed GmbH, Munich, Germany
III
Contents
IV
IWPTextCursor.InputObject
......................................................................................................................................................... 214
IWPTextCursor.InputCode
......................................................................................................................................................... 216
IWPTextCursor.InputPagebreak
......................................................................................................................................................... 216
IWPTextCursor.InputParagraph
......................................................................................................................................................... 217
IWPTextCursor.InputRow
.........................................................................................................................................................
End
217
IWPTextCursor.InputRow
.........................................................................................................................................................
Start
218
IWPTextCursor.InputSection
......................................................................................................................................................... 219
IWPTextCursor.InputString
......................................................................................................................................................... 220
IWPTextCursor.InputTable
......................................................................................................................................................... 221
IWPTextCursor.InputTabstop
......................................................................................................................................................... 222
IWPTextCursor.InputTextbox
......................................................................................................................................................... 223
IWPTextCursor.InputText
......................................................................................................................................................... 225
IWPTextCursor.InsertRow
......................................................................................................................................................... 225
IWPTextCursor.MarkerCollect
......................................................................................................................................................... 226
IWPTextCursor.MarkerCollectAll
......................................................................................................................................................... 226
IWPTextCursor.MarkerCPPosition
......................................................................................................................................................... 226
IWPTextCursor.MarkerDrop
......................................................................................................................................................... 226
IWPTextCursor.MarkerGoto
......................................................................................................................................................... 227
IWPTextCursor.MarkerSelect
......................................................................................................................................................... 227
IWPTextCursor.MovePosition
......................................................................................................................................................... 227
IWPTextCursor.MoveToBookmark
......................................................................................................................................................... 228
IWPTextCursor.MoveToField
......................................................................................................................................................... 228
IWPTextCursor.MoveToObject
......................................................................................................................................................... 229
IWPTextCursor.MoveToTable
......................................................................................................................................................... 229
IWPTextCursor.Redo
......................................................................................................................................................... 229
IWPTextCursor.ReplaceText
......................................................................................................................................................... 230
IWPTextCursor.ReportConvertTable
......................................................................................................................................................... 230
IWPTextCursor.ReportConvertText
......................................................................................................................................................... 230
IWPTextCursor.ReportInputBand
......................................................................................................................................................... 231
IWPTextCursor.ReportInputGroup
......................................................................................................................................................... 231
IWPTextCursor.ScrollToCP
......................................................................................................................................................... 231
IWPTextCursor.SelectAll
......................................................................................................................................................... 232
IWPTextCursor.SelectLine
......................................................................................................................................................... 232
IWPTextCursor.SelectParagraph
......................................................................................................................................................... 232
IWPTextCursor.SelectTable
......................................................................................................................................................... 232
IWPTextCursor.SelectTableColumn
......................................................................................................................................................... 233
IWPTextCursor.SelectTableRow
......................................................................................................................................................... 233
IWPTextCursor.SelectText
......................................................................................................................................................... 233
IWPTextCursor.SetColWidth
......................................................................................................................................................... 233
IWPTextCursor.SetParName
......................................................................................................................................................... 234
IWPTextCursor.SetRow
.........................................................................................................................................................
Height
234
IWPTextCursor.SetTableLeftRight
......................................................................................................................................................... 235
IWPTextCursor.TableClear
......................................................................................................................................................... 235
IWPTextCursor.TableDelete
......................................................................................................................................................... 236
IWPTextCursor.Undo
......................................................................................................................................................... 236
IWPTextCursor.UndoClear
......................................................................................................................................................... 236
IWPTextCursor.WordCharAttr
......................................................................................................................................................... 236
IWPTextCursor.WordEnum
......................................................................................................................................................... 237
IWPTextCursor.WordHighlight
......................................................................................................................................................... 237
IWPTextCursor.SetColumns
......................................................................................................................................................... 238
IWPTextCursor.SelectCell
......................................................................................................................................................... 239
IWPTextCursor.EnumOpenObj
......................................................................................................................................................... 239
IWPTextCursor.ExitTable
......................................................................................................................................................... 240
IWPTextCursor.TableSplit
......................................................................................................................................................... 240
IWPTextCursor.TableSort
......................................................................................................................................................... 240
IWPTextCursor.ASetCellProp
......................................................................................................................................................... 241
IWPTextCursor.ASetCellStyle
......................................................................................................................................................... 242
IWPTextCursor.MergeCellHorz
......................................................................................................................................................... 243
IV
2006-2009 by WPCubed GmbH, Munich, Germany
3 TextDynamic
...................................................................................................................................
as "Popup" or embedded editor (method wptextCreateDialog)
245
Initialization of
..........................................................................................................................................................
the editor in C++
246
Use WPA Actions
..........................................................................................................................................................
w ith Editor
247
Use Com m ands
.......................................................................................................................................................... 248
Use the COM..........................................................................................................................................................
Interfaces
249
Exam ples .......................................................................................................................................................... 249
Pascal Definition
.......................................................................................................................................................... 251
C / C++ Headerfile
.......................................................................................................................................................... 257
4 Text ...................................................................................................................................
Attributes (access and modify)
263
IWPAttrInterface
.......................................................................................................................................................... 264
Properties......................................................................................................................................................... 267
Methods ......................................................................................................................................................... 267
IWPCharacterAttr
.......................................................................................................................................................... 280
Properties......................................................................................................................................................... 282
Methods ......................................................................................................................................................... 285
5 Text ...................................................................................................................................
Elements (paragraphs, objects, styles)
285
IWPParInterface
.......................................................................................................................................................... 285
Properties......................................................................................................................................................... 288
Methods to
.........................................................................................................................................................
manage attributes
297
Methods to
.........................................................................................................................................................
manage tab stops
303
Methods to
.........................................................................................................................................................
manage text and images
306
Methods to
.........................................................................................................................................................
manage the paragraph List
312
Other methods
......................................................................................................................................................... 318
IWPDataBlock.......................................................................................................................................................... 325
Properties......................................................................................................................................................... 326
Methods ......................................................................................................................................................... 330
IWPTextObj .......................................................................................................................................................... 332
Properties......................................................................................................................................................... 332
Methods ......................................................................................................................................................... 337
IWPNum berStyle
.......................................................................................................................................................... 345
Properties......................................................................................................................................................... 346
Methods ......................................................................................................................................................... 348
6 Document
...................................................................................................................................
Properties (page size, labels)
350
IWPPageSize.......................................................................................................................................................... 350
Properties......................................................................................................................................................... 351
Methods ......................................................................................................................................................... 353
IWPPageSizeList
.......................................................................................................................................................... 354
Properties......................................................................................................................................................... 355
Methods ......................................................................................................................................................... 356
IWPPrintParam
..........................................................................................................................................................
eter
357
Properties......................................................................................................................................................... 357
Methods ......................................................................................................................................................... 359
IWPMeasurePageParam
.......................................................................................................................................................... 359
Properties......................................................................................................................................................... 360
7 GUI Properties
................................................................................................................................... 0
8 Mailmerge
................................................................................................................................... 361
Create Merge
..........................................................................................................................................................
Fields
362
Insert Data .......................................................................................................................................................... 363
Use event.........................................................................................................................................................
MS Access
364
If Interface
.........................................................................................................................................................
cannot be used
365
Highlight/HideFields
.......................................................................................................................................................... 365
Append to Editor
..........................................................................................................................................................
#2
365
Contents
VI
Create Mailing
..........................................................................................................................................................
Labels
366
C# Code ......................................................................................................................................................... 367
VB Code ......................................................................................................................................................... 368
Resulting .........................................................................................................................................................
Label Sheet
369
interface IWPFieldContents
.......................................................................................................................................................... 369
Properties......................................................................................................................................................... 370
Methods ......................................................................................................................................................... 372
9 Reporting
................................................................................................................................... 378
Introduction .......................................................................................................................................................... 378
Comparison
.........................................................................................................................................................
to "usual" reporting
379
Example ......................................................................................................................................................... 380
Token to Tem
..........................................................................................................................................................
plate Conversion
380
General Syntax
.........................................................................................................................................................
- Fields
381
Bands ......................................................................................................................................................... 382
Groups ......................................................................................................................................................... 382
Parameters
.........................................................................................................................................................
for Fields
383
Parameters
.........................................................................................................................................................
for Bands and Groups
384
Example Template
......................................................................................................................................................... 384
Event driven..........................................................................................................................................................
reporting
386
VS2008 Reporting
..........................................................................................................................................................
Dem o
388
Basis
......................................................................................................................................................... 388
File Menu ......................................................................................................................................................... 392
Use conditions
.........................................................................................................................................................
for bands
393
View Menu
.........................................................................................................................................................
- (Hide/Show Template)
393
RTF2PDF - Reporting
..........................................................................................................................................................
C# Sam ple
394
DB-Description
..........................................................................................................................................................
and Tem plate architecture
395
MS Access Exam
..........................................................................................................................................................
ple
396
MS Access
.........................................................................................................................................................
code
397
DAO Example
.........................................................................................................................................................
to create DB-Description
398
API
.......................................................................................................................................................... 401
IWPReport......................................................................................................................................................... 401
IWPReportBand
......................................................................................................................................................... 417
IWPReportVar
......................................................................................................................................................... 426
10 Spellcheck
................................................................................................................................... 0
11 PDF Creation,
...................................................................................................................................
Email
430
IWPPdfCreator
.......................................................................................................................................................... 430
Properties......................................................................................................................................................... 430
Methods ......................................................................................................................................................... 433
12 Helpers
................................................................................................................................... 436
IWPTextWriter
.......................................................................................................................................................... 436
Properties......................................................................................................................................................... 436
Methods ......................................................................................................................................................... 436
IWPPicture .......................................................................................................................................................... 437
IWPStream - ..........................................................................................................................................................
Stream 2WPStream
437
13 WPAT_codes
................................................................................................................................... 438
Character Attributes
.......................................................................................................................................................... 439
Predefined Color
..........................................................................................................................................................
Index Values
440
Paragraph Attributes
.......................................................................................................................................................... 440
Num bering Attributes
.......................................................................................................................................................... 441
Border Attributes
.......................................................................................................................................................... 443
Table Size and
..........................................................................................................................................................
Position
444
445
1 RTF2PDF
...................................................................................................................................
in ASP.NET
445
2 ASP TransferHelper
...................................................................................................................................
(RTF2PDF)
446
VI
2006-2009 by WPCubed GmbH, Munich, Germany
VII
8 Use TextDynamic
...................................................................................................................................
in C++ (VS2008)
461
461
463
Index
Product Page
PDFControl
API Reference
Support forum
Technical Note:
The component wRTF2PDF is based on our word processing component TextDynamic plus the
PDF engine wPDFControl. It does everything what wPDFControl and much of what TextDynamic
does. It has been optimized to work on a server, or webserver. It does not print but it can
produce PDF and other file formats fast and effectively. It can also export documents page by
page as metafile. Please see our demo web server www.rtf-net.com.
We recommend to program with RTF2PDF similar to TextDynamic - but as an invisible, server
control. Using the interface IWPEditor you have access to powerful and effective means to
create text or tables in code.
While TextDynamic is a visual tool, RTF2PDF has been optimized to work in the background. It
can be easily used with ASP or ASP.NET to create HTML or PDF response output. Since the API
is so similar to the API of TextDynamic you can use almost the same code in your ASP page as
you used for your desktop application. Due to its nature it does not offer any GUI elements and
Properties
Memo2
Print - exports the text in editor PDFCreator - modify the PDF properties
#1
ResultBuffer - read the created PDF data as array of
PrintSecond - exports the text
bytes.
in editor #2. Use this to export a
PDFFile in PDFCreator must be set to "memory"
report!
Also see the TranferHelper class.
StartEngine /SetLicense - set
license key and initialize.
Other Interfaces:
IWPAttrInterface
IWPCharacterAttr
IWPDataBlock
IWPEditor
IWPFieldContents
IWPMapi
IWPMeasurePagePara
This interface is used by the OnMeasurePage event.
m
IWPNumberStyle
IWPPageSize
IWPPageSizeList
Use this list to create set of rectangles and fill them with text
IWPParInterface
IWPPdfCreator
IWPPicture
IWPPrintParameter
IWPStream
IWPTextCursor
IWPTextObj
IWPTextWriter
IWPReportVar
Also see:
wPDFControl Methods and Properties
2.1
Overview
2.2
QuickStart
The conversion of a RTF file to PDF does not require much code.
d) Create Bookmarks
PDF Bookmarks are the optional table of content entries. RTF2PDF is able to create those
strings automatically from the loaded text. To do so the paragraphs which should appear in this
list should be marked with the property WPAT.ParIsOutline.
You can use the Memo.TextCommandStr to mark paragraphs which either use a certain style or
which start with certain text to be used in the outline.
To create the TOC as text (within the document) use
Cursor.CPPosition = 0xFFFFFF;
Cursor.InputParagraph(0,"");
rtF2PDF1.Memo.TextCommand(2, 2);
C) Simple ASP.NET demo which sends the PDF as response
RTF2PDF pdf = new RTF2PDF();
pdf.Memo.LoadFromFile("somtext.rtf", true, "AUTO");
pdf.PdfCreator.PDFFile = "memory";
// remove any output
Response.Clear();
// Add new header
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Type", "application/pdf");
// Set a file name which is displayed
Response.AddHeader("Content-Disposition","inline;filename=PortableDocument.pdf");
// Write the PDF data
Response.Clear();
// Finish
pdf.Dispose();
D) Activate Format mode optimized for HTML
a) Use Memo.SetBProp
Group 7 : wpAsWebPage
b) Use RtF2PDF1.Command(1312, 1) // WPCOM_SELECT_HTML_MODE = 1312;
E) Use the optional reporting feature
using wPDF;
using WPDynamic;
private void button1_Click(object sender, System.EventArgs e)
{
// Set License with Reportion Option
rtF2PDF2.SetLicense( "---", "---", 0);
// Load a File
rtF2PDF2.Memo.LoadFromFile(@"c:\Template_With_Tokens.RTF", false, "");
// Use the Token To Template Conversion
rtF2PDF2.Memo.TextCommandStr(17,0, "");
// Create the Report (will be in Memo2)
rtF2PDF2.Report.CreateReport();
// Set Output Filename
rtF2PDF2.FileName = @"c:\test.pdf";
// And convert Memo2 to PDF
rtF2PDF2.PrintSecond();
}
We are also using this event to loop each group 10 times:
2.3
Troubleshooting .NET
1) References
using wPDF;
using WPDynamic;
also add a reference to the correct wPDF3.DLL.
(There is one for the demo and one for the full version)
2) Copy Engine to the bin folder
For the demo wPDFControlDemo.DLL, for the full version wRTF2PDF03.DLL
3) With full version make sure to set the license key. The License key must enable RTF (and
optional Reporting and/or Server) features
pdf.SetLicense("...", "...", xxx );
4) If you need to run it on a server and need the best possible threading performance
Please use special RTF2PDF Server License. It is at least 25% faster due to optimized code.
Troubleshooting
In case You use the wRTF2PDF demo DLL and see the error "Runtime 207" when closing the
application please deactivate the Visual Studio 2008 hosting process by removing the check
here:
2.4
Here we work with a template which does not only contain data field placeholder but also
tables.
10
B
<<B>>
C
<<C>>
D
<<D>>
<<SUMA>>
End
11
else
{
Cursor.CPTableRowNr = 1; // goto row # 1
Memo.CurrPar.SetPtr( Cursor.CPRowPtr );
while(rowcount-->0) Memo.CurrPar.Duplicate();
}
}
2.5
ASP.NET Example
File Webform1.aspx.cs
12
2 cm
pdf.Memo.CurrPar.Alignment = 2; // right
pdf.Memo.CurrPar.SpaceAfter = 30; // Distance between image
and line
pdf.Memo.TextCursor.InputString("\r",0); // one line
pdf.Memo.CurrPar.Borders = 2; // Top Border
pdf.Memo.CurrPar.ParASet(
(int)WPDynamic.WPAT.BorderWidth, 30 ); // 1pt border
width
create the footer text
pdf.Memo.TextCursor.InputFooter(0,"","");
pdf.Memo.CurrAttr.SetFontSize(8);
// Current Date
pdf.Memo.TextCursor.InputFieldObject(
"DATE","\\@ \"dd. mmmm yyyy\"","");
pdf.Memo.TextCursor.InputString(", ",0);
pdf.Memo.TextCursor.InputFieldObject("TIME","","");
// right tab in margin, dot filling
pdf.Memo.TextCursor.InputTabstop(true,0xFFFF,1,1);
pdf.Memo.TextCursor.InputString("\t",0);
pdf.Memo.TextCursor.InputFieldObject("PAGE","","");
pdf.Memo.TextCursor.InputString("/",0);
pdf.Memo.TextCursor.InputFieldObject("NUMPAGES","","");
pdf.Memo.CurrPar.Borders = 2; // Top Border
create some text, in this case just a table.
13
pdf.Memo.TextCursor.InputImage(
"c:\\inetpub\\wwwroot\\cs_logo.png",0);
pdf.Memo.CurrObj._SetObjType(100);
pdf.Memo.CurrObj.ScaleSize(567,0,0); // Scale to width = 1
cm
pdf.Memo.CurrObj.LoadFromFile(
"c:\\inetpub\\wwwroot\\WebForm1.aspx.cs");
Add some paragraphs
store current attributes
pdf.Memo.TextCursor.InputParagraph(2,"");
pdf.Memo.TextCursor.InputParagraph(2,"");
int save_ca = pdf.Memo.CurrAttr.CharAttrIndex;
add some text and modify the writing mode
pdf.Memo.TextCursor.InputString(
"This is the RTF data for the table:\r",0);
pdf.Memo.CurrAttr.SetFontSize(8);
pdf.Memo.CurrAttr.SetFontface("Courier New");
Now save the current text as RTF and insert it here as ANSI text.
pdf.Memo.LoadFromString(
pdf.Memo.SaveToString(false, "RTF-nobinary"),
true, "ANSI"
);
Restore current writing mode
// We restore the character attributes used before
pdf.Memo.CurrAttr.CharAttrIndex = save_ca;
and add an icon to open this document in RTF format.
// And create an icon to attach the RTF source
pdf.Memo.TextCursor.InputString("\r\rClick to open the
document: ",0);
pdf.Memo.TextCursor.InputImage("c:\\inetpub\\wwwroot\
\rtf_logo.png",0);
pdf.Memo.CurrObj._SetObjType(100);
pdf.Memo.CurrObj.ScaleSize(567,0,0); // Scale to width = 1
cm
We create a stream,
save the document to this stream and load it into the "RTF" icon.
System.IO.Stream str = new System.IO.MemoryStream();
pdf.Memo.SaveToStream(
new WPDynamic.Stream2WPStream(str) ,false,"RTF");
pdf.Memo.CurrObj.LoadFromStream("Document.RTF",
new WPDynamic.Stream2WPStream(str));
Select the "in memory" PDF creation mode on web server (requires "Internet Server"
License)
pdf.PdfCreator.PDFFile = "memory";
pdf.PdfCreator.FontMode = 0; // embed all fonts!
try
{
Reformat the text
pdf.Memo.ReformatAll(false,false);
And create PDF
2006-2009 by WPCubed GmbH, Munich, Germany
14
pdf.Print();
Initialize the HTTP headers.
// remove any output
Response.Clear();
// Add new header
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Type", "application/pdf");
// Set a file name which is displayed
Response.AddHeader("Content-Disposition","inline;
filename=PortableDocument.pdf");
// Write the PDF data
Response.Clear();
and use "ResultBuffer" to assign the Response
Response.BinaryWrite(pdf.ResultBuffer);
}
catch
{
Response.Write("Internal Error in PDF Creation");
}
}
finally
{
pdf.Dispose(); // Don't forget!
Response.End();
}
}
#region automatically created code [...]
}
}
Note: Often only the compiled DLL (here RTF2.DLL) is required for the ASP program. The other
files which may be created by your developing tool are not created and can confuse the web
2006-2009 by WPCubed GmbH, Munich, Germany
15
server. The one line test.aspx mentioned above was enough to start this program!
2.6
On our test server server at www.rtf-net.com we host some asp.net demos. You can
click on the button
and the underlying C# source will be displayed as PDF
page. Naturally this PDF was created from the current source code which was
formatted and exported by RTF2PDF! Using the other buttons you can see the
output of the demo, in PDF optionally also in HTM and RTF format.
16
2.7
Properties
2.7.1
Report
Applies to
Rtf2Pdf
Declaration
IWPReport Report;
Description
Reporting is an optional feature which is activated by the license key.
Usually you will only use the "Token to Template Conversion".
2.7.2
Memo
Applies to
Rtf2Pdf
Declaration
IWPEditor Memo;
Description
This is the interface to load text into the editor #1. With RTF2PDF it uses the interface
IWPEditor while TextDynamic uses IWPMemo. IWPEditor implements a subset of the methods in
IWPMemo since some do not make sense for an invisible control. You can use Memo.TextCursor
to add text using code.
2.7.3
Memo2
Applies to
Rtf2Pdf
Declaration
IWPEditor Memo2;
Description
This is the interface to load text into the editor #2.
With RTF2PDF it uses the interface IWPEditor while TextDynamic uses IWPMemo. IWPEditor
implements a subset of the methods in IWPMemo since some do not make sense for an invisible
control. You can use Memo.TextCursor to add text using code.
2.7.4
PDFCreator
Applies to
Rtf2Pdf
Declaration
IWPPdfCreator PDFCreator;
Description
This interface can be used to change the properties of the PDF engine. We recommend to use
17
this interface instead of the properties provided on class level since this makes the code
compatible to TextDynamic.
2.7.5
ResultBuffer
Applies to
Rtf2Pdf
Declaration
property ResultBuffer: Variant;
byte[] ResultBuffer;
Description
This property provides the result of the PDF creation as memory buffer (variant array of
bytes).
Also see the "ASP TransferHelper" - it avoids flooding the server.
Note: RTF2PDF may be only used on a web server when you have the Server License of
RTF2PDF / wPDFControl!
Example: (Response is the ASP object defined in event Page_Load.)
2.7.6
AttrHelper
Applies to
Rtf2Pdf
Declaration
IWPAttrInterface AttrHelper;
Description
This attribute interface can be used to interpret and create character attribute index values.
This code first assigns the attribute index values which represents the character attributes
"Courier New, 10.5pt, green" to an integer variable and then inserts text which will use this
attributes
IWPAttrInterface help = wpdf.AttrHelper;
help.Clear();
help.SetFontface("Courier New");
2006-2009 by WPCubed GmbH, Munich, Germany
18
help.SetColor(wpdllInt1.ToRGB(Color.Green));
help.SetFontSize(10.5F);
int standard = help.CharAttrIndex;
wpdllInt1.TextCursor.InputString("Hello World", standard);
Category
Character Attributes
2.8
Methods
2.8.1
BeginDoc
Applies to
Rtf2Pdf
Declaration
function BeginDoc(const FileName: WideString; UseStream: Integer): Integer;
Description
This method starts a PDF document.
2.8.2
EndDoc
Applies to
Rtf2Pdf
Declaration
procedure EndDoc;
Description
The method closes a PDF document started with BeginDoc.
2.8.3
Applies to
Rtf2Pdf
Declaration
function Print: Integer;
Description
Use this method to print the contents of editor #1. This is the the same as using PDFCreator.
Print();
VB6 Note:
If you are using VB6 you cannot use this method since Visual basic overrides this name with
special functionality.
19
2.8.4
PrintSecond
Applies to
Rtf2Pdf
Declaration
function PrintSecond: Integer;
Description
Use this method to print the contents of editor #2. This is the the same as using PDFCreator.
PrintSecond();
2.8.5
StartEngine / SetLicense
Applies to
Rtf2Pdf
used by OCX:
function StartEngine(const DLLName: WideString; const LicenseName: WideString;
const LicenseCode: WideString; LicenseNumber: Integer): WordBool;
used by .NET Assembly:
public bool SetLicense(String Name, String Code, uint Number)
This method must be used to start the PDF and text creation.
2.8.6
StopEngine
Applies to
Rtf2Pdf
Declaration
procedure StopEngine;
Description
This method de allocates the memory which was initialized by StartEngine.
Only used by OCX and native C interface.
2.8.7
ReleaseInt
This method (it is exclusive to the .NET assembly) releases a reference to a programming
interface which was retrieved from wRTF2PDF / TextDynamic Server.
It is necessary to use this method at the end of the methods which use an interface to make
sure the garbage collection frees the interface at once. Otherwise, when the editor has been
20
disposed already, it can happen that the garbage collection accesses memory which has been
freed.
Example:
2.9
RTF2PDF ActiveX
The RTF2PDF ActiveX interface can be used very similar to the .NET Interface.
Note: In VB6 you will have to execute command #1305 to export the text, the
method "Print" is overridden by VB6.
Here we included some simple VB / VBS examples:
In Visual Basic 6 we created this form:
From the button we call the following code. It uses the old style "commands" which
were used until RTF2PDF V3.5 was released.
Private Sub Command1_Click()
' Initiate the OCX
Set PDF = CreateObject("wPDF_X01.PDFControl")
' Start Engine, last param =LIC_CODE
If PDF.StartEngine(DLLNAME.Text, "LIC_NAME", "LIC_KEY", 0) Then
' Start a PDF document
If PDF.BeginDoc(Replace(RTFFileName.Text, ".rtf", ".pdf"), 0) Then
' Before RTF2PDF V3.5 you would have used this commands:
PDF.ExecIntCommand 1000, 0 ' init RTF conversion
PDF.ExecStrCommand 1002, RTFFileName.Text ' load RTF file
PDF.ExecIntCommand 1100, 0 ' convert it
' Finish PDF creation
PDF.EndDoc
PDF.StopEngine
Else
2006-2009 by WPCubed GmbH, Munich, Germany
21
With RTF2PDF V3 we can use the integrated interfaces which make it easy to not only
convert a file but also change it before the conversion.
Private Sub Command1_Click()
' Initiate the OCX (if it is not already on the form)
Set PDF = CreateObject('wPDF_X01.PDFControl')
' Start Engine, last param =LIC_CODE
If PDF.StartEngine(DLLNAME.Text, "LIC_NAME", "LIC_KEY", 0) Then
' Load the file, TRUE would insert/append it
If PDF.Memo.LoadFromFile(RTFFileName.Text, False, "AUTO") Then
PDF.PDFCreator.PDFFile = Replace(RTFFileName.Text, ".rtf", ".pdf")
' Convert it
' VB6 does not let us call PDF.PDFCretor.Print so we use a command instead
PDF.ExecIntCommand 1305, 0
' Finish PDF creation
Else
MsgBox "Cannot load RTF file " + RTFFileName.Text
End If
PDF.StopEngine
Else
MsgBox "Cannot load RTF2PDF Engine from " + DLLNAME.Text
End If
End Sub
We added some code to replace some text and select landscape orientation
22
2.10
wPDFControl Documentation
The component wPDFControl was created to make it easy for programmers to add
PDF support to their application. It is based on the popular PDF engine 'wPDF' which
has been successful on the Delphi and C++Builder market since the year 2000.
Our component wRTF2PDF/TextDynamic Server offers the same possibility as
wPDFControl. It does everything what wPDFControl does but, of course, its main
feature is the integrated powerful text rendering engine.
Since wRTF2PDF V3.5 it is also possible to create text and save in RTF or HTML, even
MIME format. This is possible since the component exports all of its internal word
processing abilities through a set of interfaces. This interfaces are in fact mostly the
same as the interfaces used by our visual word processing control "TextDynamic".
Only the interface IWPMemo has been replaced by a different interface (IWPEditor)
which contains about 70% of the methods originally found in IWPMemo.
wPDFControl can be used as .NET control, as ActiveX and also as regular DLL. For the
DLL we have included a C++ include file. This manual describes the use with .NET.
On page 2 you can specify the engine dll and, with registered version, set your license keys
23
You can specify integer values for certain properties, for example a "1" in the field FontMode will
embed all fonts.
24
We integrated a simple print to HDC (Device Handle) demo. You can change the resolution and
the text.
RTF to PDF conversion is only useable if you use the licensed RTF2PDF DLL or if you use the
wPDFControl DEMO version. Here you can export a RTF, HTM or WPT file:
25
The editor used on this page can be licensed as product TextDynamic (.NET and OCX, C+
+).
26
Borland C# Builder: Click right on the toolbox and select 'Customize'. Add the path of the
assembly wPDF.DLL (3rd page on the dialog).
Please activate the 3 components 'PDFControl, PDFPropDlg, RTF2PDF' which are all in the
namespace 'wPDF'.
When you use the included demo projects or create your own project you always need to add a
reference to the wPDF assembly installed in the wPDFControl directory under
\DLL\.NET\Demo\wPDF.DLL or \DLL\.NET\Full\wPDF.DLL.
Please note that your application will always need
a) wPDF.DLL and
b) either of wPDFControlDemo.DLL or wRTF2PDF0x.DLL in its directory to run.
27
28
run.
Which of this DLLs are required depends on wether you are using the demo, the standard
PDFControl or the enhanced RTF2PDF control which includes the PDF functionality with added
RTF export functions.
B) Add the components to the form
Select the PDFControl and click on the form.
Select the PDFPropDlg component and click on the form.
Connect both component by selecting the PDFControl instance in the property 'PDFPropDlg.
PDFControl'.
C) Add a button to the form to show the important PDF properties
In the OnClick event handler of button1 please use the code:
if(pdfControl1.BeginDoc(filename))
2006-2009 by WPCubed GmbH, Munich, Germany
29
{
Font font = new Font("Arial", 10);
SolidBrush brush = new SolidBrush(Color.Black);
Pen pen = new Pen(Color.Red, 1);
pdfControl1.StartPage();
pdfControl1.Canvas.DrawString("Hello World",
font, brush,40, 50);
pdfControl1.Canvas.DrawRectangle(pen, 20,20,300,300);
pdfControl1.EndPage();
}
We have added a "font manager" to make it easier to use fonts. You don't have to create a
font object, only to change the property pdfControl1.Font like this:
pdfControl2.Font.Size = 11;
pdfControl2.Font.Color = Color.Red;
pdfControl2.TextOut("Hello ",40, 50);
pdfControl2.Font.Style = FontStyle.Bold;
pdfControl2.TextOut("PDFCONTROL ");
When you pass "\n" a new line will be created by advancing using
the last font height and resetting x to the position defined the last time with TextOut(string,x,
y). The intern position pointer will be advanced by using the return value of the MeasureString
function.
30
}
SaveDC / RestoreDC is also useful when working with clipping rectangles. It is not required for
the Clipping Paths which make their own brackets.
31
In addition there is the property 'Canvas' which is a true 'Graphics' object to be used with your
.NET drawing code.
EVENTS
The event 'OnNamedEvent' will be triggered for all events under 'No active page' and 'PDF page
is open'.
Esspecially useful is 'AfterStartPage' to draw a watermark on each page. This can also be used
when you export and RTF file using RTF2PDF:
2.10.5.2 PDFPropDlg
This component displays this dialog when the procedure Execute() is called:
To use it you need to assign its property 'PDFControl' to either an instance of PDFControl or
2006-2009 by WPCubed GmbH, Munich, Germany
32
RTF2PDF.
the first page with some standard properties
33
Before the dialog is displayed the event BeforeShowDialog is triggered. You can use it to
change the captions and or visibility status of certain elements:
private void pdfPropDlg1_BeforeShowDialog(object Sender, wPDF.ConfigPDF Dialog)
{
Dialog.OKBtn.Text = "Start"; // Change the button text
Dialog.linklabel.Visible = false; // Hide the URL label
}
This dialog does not publish all properties - only those which are likely of interest for the user of
your application.
2.10.5.3 Properties
2.10.5.3 A) PDF Options
Property PageMode
By modifying this property you can select how the PDF file has to be displayed when the reader
opens it.
Property Thumbnails
If this property is set to 'Monochrome' or 'Color' the PDF export component will create
thumbnails in the PDF file.
Please note the the Acrobat(R) Reader Version 5 will create thumbnails automatically if none are
found in a PDF document. This thumbnails have a high resolution since they are created using
the complete information of a page.
Property TextCompression
By modifying this property you can let the PDF engine compress text. By using compression the
file will be reasonable smaller. On the other had compression will create binary data rather than
ASCII data. Please note that bitmaps and embedded fonts will be always compressed, either
using Deflate or JPEG compression.
Property JPEGCompressMode
wPDF can compress bitmaps using JPEG. This will work only for true color bitmaps (24 bits/pixel)
and if you have set the desired quality in this property.
34
Property Encoding
If data in the PDF file is binary it can be encoded to be ASCII again. Binary data can be either
compressed text or graphics. You can select HEX encoding or ASCII95 which is more effective
then HEX.
Property FontMode
Using this property you can decide weather TrueType fonts should be embedded in the PDF file
or not. If fonts were not embedded in the PDF file text can be displayed wrongly if the used
fonts are not installed on the PC of the reader of the PDF file. On the other hand embedded
fonts causes the PDF files to be much larger. The size of the usual font file is 150KB! The
embedding also slows the creation process down.
You can set wpOnEmbedFonts in property ExtraMessages to get a message (event OnError)
once font data is embedded.
UseTrueTypeFonts : use true type fonts but does not embed the font data.
EmbedTrueTypeFonts : embed data of all used fonts. (You can still use ExcludedFonts to
specify certain standard fonts)
EmbedSymbolTrueTypeFonts : embed only symbol true type fonts. (such as WingDings,
etc.)
UseBase14Type1Fonts : Do not use true type. When this mode is selected you can only
use Arial, Courier New and Times New Roman fonts.
Subset Embedding: Since version 2 it is now possible to re duce the s iz e o f the
e m be dde d da ta by removing the description for unused characters.
There are 2 options which do this for you:
EmbedSubsetCharsets will embed all the characters which are used in the codepage you
selected.
EmbedSubsetUsedChar includes only those characters which have been used and so
produces the smallest files.
2.10.5.3 B) Extra Options
PDFOptions
CreateAutoLinks - if active the PDF engine will create web links over text which starts
with http://. This makes it easy to create a link to a web page.
Canvas.TextOut("http://www.wptools.de",10,20);
Please note that the autolink feature requires that the complete link is printed at once.
Links which are inside longer text strings are not recognized.
Note: You can always create links using the Hyperlink procedure.
PDFMode
makes it possible to change the way the drawing commands are interpreted. For standard
output this property should remain unchanged but if you create the output in your application
its use might be required.
NoBITBLTFillRect: BitBlt is not used to draw a filled rectangle.
WhiteBrushIsTransparent: Do not fill objects which use a white background. Please note that
this has no effect on bitmaps, only on rectangles or text which is printed opaque.
35
ExactTextPositioning: In general the PDF engine draws text to not only match the input but
also look good. If your application requires that each character has to be at the same position
as in the input you can use this flag to get a 1:1 output. (Implementation note: In the PDF file
an efficient multi string output command is used, not several single text drawing commands)
NoTextRectClipping: Text can be clipped to its bounding box. To switch this off you can use this
flag. It is a good idea to use this flag if your application uses a lot of TextRect() without
expecting clipping.
ClipRectSupport: IntersectClipRect() and SelectClipRgn() are supported.
DontStackWorldModifications: If your application uses the windows function SetWindowOrgEx
() a lot please set this flag. Normally please do not use this flag. It is only required if you see a
small, 1 pixel shift in vertical or horizontal lines. If you have access to the printing code you can
add SaveDC/RestoreDC around blocks which work with a different origin or resolution to avoid
this small visual problem in the created PDF file. Normally you should not use this option!
NoTextRectClipping: Use the windows text output API you can provide a rectangle which is
used to clip you are just printing. This is useful if you are printing table cells and don't want to
overprint the contents of the neighbor cell. Usually this clipping rectangle is not active and wPDF
will not add unnecessary clipping - but if your application uses this clipping without a real need
for it, you can improve the quality of the PDF file by switching this flag on. This will skip the
creation of clipping rectangles for text output commands.
DontAdjustTextSpacing: wPDF will normally use the character and word spacing to render the
text to match the width requirement set by windows. This is necessary because the fonts in PDF
have a slightly different width than calculated by windows. The reason are rounding errors in
windows (or visual optimation) which works with integer positions while PDF uses floating
points.
If you use this flag wPDF will not try to enlarge or shrink the text. Normally you won't see a
problem, except that you are printing text lines which consist of different parts (font styles fro
example).
This flag has no effect if wpExactTextPoitioning is active.
DontCropBitmaps: Using the command StretchDIB you can specify a rectangle of the source
bitmap which will be printed in the destination rectangle. Unless this flag is active the PDF
engine will internally remove the unprinted data.
DontCropBitmaps: The PDF engine will crop images if they are only partly painted. You can use
this flag to switch this mode off.
AllowTransparentBit: Monochrome bitmaps can be optionally painted transparently if they are
painted using an OR "ROP" mode or if the flag wpWhiteBrushIsTransparent. This will set the PDF
format version to V1.3.
DevMode
This property controls the PDF engine. You can use SetIProp(10, value) to update this
property.
bit
bit
bit
bit
bit
bit
bit
bit
bit
bit
bit
bit
bit
1: NoBITBLTFillRect
2: NeverFill
3: WhiteBrushIsTransparent
4: ExactTextPositioning
5: NoTextRectClipping
6: ClipRectSupport
7: DontStackWorldModifications
8: DontAdjustTextSpacing
9: DontCropBitmaps
10: AllowTransparentBit
11: AlwaysHighResPDF
12. NeverHighResPDF
13: UseFontWidthArgument
36
37
38
C example code to create a PDF engine, load a file and print it to PDF.
pdf=wpdfInitializeEx(&Info);
if(wpdfBeginDoc(pdf,"C:\\aTestPDF.pdf",0))
39
{
wpdfExecCommand(pdf,1000,0,"",0);
wpdfExecCommand(pdf,1002,0,"C:\\test.RTF",0);
wpdfExecCommand(pdf,1100,0,"",0);
wpdfEndDoc(pdf);
}
wpdfFinalize(pdf);
You can use the header file wPDF.H and wpdf_class.h for convenient binding.
Tip: Please also see: Commands to print text (to printer, not PDF!)
Example VB.NET Code to convert a RTF file to PDF:
If PDF.StartEngine(DLLNAME.Text, "", "", 0) Then ' you your license info here !
If PDF.BeginDoc(PDFNAME.Text, 0) > 0 Then ' Start a PDF document
PDF.ExecIntCommand(1000, 0) ' Initialize the RTF engine
PDF.ExecIntCommand(1024, 1) ' use the printer as reference (suggested)
PDF.ExecStrCommand(1002, RTFNAME.Text) ' Load a RTF file
PDF.ExecIntCommand(1100, 0) ' Export this RTF file to PDF
PDF.EndDoc() ' Close the PDF document
End If
End If
? WPCOM_RTFINIT
= 1000
= 1002
= 1003
40
? WPCOM_RTFMAKEFIELDS= 1004
Converts <fieldnames> in the loaded RTF data into the special fields (insertpoints) which can
be used for mailmerge. .
? WPCOM_RTFMERGE
= 1005
Starts the mailmerge process. Please note that you can execute this, write a PDF file and
execute it again without having to reload the RTF data! The data is retrieved using the
OnGetText callback/event procedure.
? WPCOM_RTFSAVE
= 1006
= 1007
= 1010
Set the page-width of the current RTF file to the width specified in the parameter value as
twips (1/1440 inch).
? WPCOM_RTF_PAGEHEIGHT = 1011
Set the page-height of the current RTF file to the height specified in the parameter value as
twips (1/1440 inch).
? WPCOM_RTF_MARGINLEFT = 1012
Set the left margin of the current RTF file to 'value'.
? WPCOM_RTF_MARGINRIGHT = 1013
Set the right margin of the current RTF file to 'value'.
? WPCOM_RTF_MARGINTOP
= 1014
41
? WPCOM_RTF_PAGEROTATION = 1021
Changes the rotation of the PDF page.
To print landscape use the value 90.
? WPCOM_RTF_PAGEZOOM
= 1022
Sets the zoom value for the RTF to PDF conversion. It can be used to shrink or enlarge the
text.
To print 2 A4 pages on one A3 page use columns=2, Rotation=90, zoom=100. To print 2 A4
pages on one A4 page use zoom=50!
? WPCOM_RTF_READEROPTIONS = 1023
This command changes a few options for the RTF reader:
Bit 0: all borders which use the width 0 should be invisible
Bit 1: the file is loaded in landscape mode
Bit 2: the page width and page height is swapped at load time
? WPCOM_RTF_USE_PRINTER = 1024
Here you can switch on and off the use of the current printer driver for measuring the text.
Since the printer has a higher resolution this causes a better output (less rounding errors)
but it will require that a printer is installed.
Value=1 switches the mode on
Value=1 switches the mode off (default)
= 1100
42
Memo.TextCommandStr
Memo.TextCommandStr
Memo.TextCommandStr
Memo.TextCommandStr
ID
ID
ID
ID
11
12
13
14
Print Text
Get Printernames
BeginPrint
EndPrint
WPCOM_PRINT
= 1321;
WPCOM_PRINT2 = 1322;
WPCOM_BEGIN_PRINT = 1323;
WPCOM_END_PRINT = 1324;
Example C#
System.Windows.Forms.OpenFileDialog OpenDia =
new System.Windows.Forms.OpenFileDialog();
OpenDia.Filter = "RTF Files|*.RTF";
if(OpenDia.ShowDialog()==System.Windows.Forms.DialogResult.OK)
{
rtF2PDF1.LoadRTF(OpenDia.FileName);
rtF2PDF1.Export("C:\\Test.PDF");
}
2.10.5.5 Methods
2.10.5.5 A) Initialisation
Creating metafile with wPDFControl is as easy as 1 - 2 - 3 or better as
BeginDoc - DrawImage - EndDoc.
If you need a a "Graphics" object to draw to, you need to open a 'page' first. To open a PDF
page use StartPage.
BeginDoc - StartPage - Canvas.DrawString(..) - EndPage - EndDoc.
Note: Using 'CloseCanvas' you can always flush the graphic output stored in the Canvas
property to the PDF file.
To use registered version of PDFControl and RTF2PDF you need to execute the function
SetLicense(String Name, String Code, uint Number)
2006-2009 by WPCubed GmbH, Munich, Germany
43
44
to pass your license name, the code and the number. This activates the PDF engine.
Note:
Version 2 uses a license key similar to
(a) StartEngine("somename", "xxxxyyyy", 123456);
Version 3 can use a key such as
(b) StartEngine("somename", "xxxxyyyy@zzzzz", 123456);
(note the @ sign)
or this
(c) StartEngine("somename", "WWW-XXXX-YYYY-ZZZZ",
123456);
RTF2PDF V3.5 and later will only work with the key using schema
(c)!
New: You can use the demo application to create a key file:
45
BeginDoc/EndDoc
// Use this function to set your license information
public bool SetLicense(String Name, String Code, uint Number)
// Use this function to start a new PDF file
// using the filename set in property FileName
public bool BeginDoc()
// Use this function to start a new PDF file using give filename
public bool BeginDoc(String FileName)
// Use this function to start a new PDF stream (not a file)
public bool BeginDoc(Stream OutStream)
// EndDoc closes a PDF file which has been opened with BeginDoc
public void EndDoc()
StartPage/EndPage
// StartPage starts a new page in a PDF file opened with BeginDoc.
// Y and Y are measured pt, this is 1 inch / 72
public bool StartPage(int w, int h, bool landscape)
// Starts a page to make that image exactly fit. You can sepcify a zooming value
public bool StartPage(Image image, int ZoomValue)
// Starts a page with a certain ePage
// format: Letter, Legal, Executive, DinA3, DinA4, DinA5 or DinA6
public bool StartPage(ePage format, bool landscape)
// Starts a page using the DefaultPageSize
public bool StartPage()
// Closes a PDF page and writes it
public void EndPage()
StartWatermark/EndWatermark
// Starts a watermark with a certain name
// and ePage format: Letter, Legal, Executive, DinA3, DinA4, DinA5 or DinA6
public bool StartWatermark(String Name,ePage format)
// Starts a watermark with the DafaultPageSize and a certain name
public bool StartWatermark(String Name)
/ Closes a PDF watermark and writes it
public void EndWatermark()
2.10.5.5 B) DrawWatermark
The PDF engine supports watermarks. The watermarks can be created once and used on as
many pages as you like.
The DLL can even import PDF data and convert the imported pages into watermarks which are
2006-2009 by WPCubed GmbH, Munich, Germany
46
names "inpageN" (with N = 1..count of pages). With the function DrawWatermark you can tell
the PDF engine to use one of the stored watermarks. You simply have to pass the name of it. If
you want to rotate the watermarks to any degree you can do so. But please note that a PDF
file with a rotated watermark will not print on all printers. Especially postscript printers seem to
not like this feature.
Important is also that on a landscape page the watermark will be also landscape. This means
that the watermark has to be portrait before you use it. It will automatically be rotated by
using it on a landscape page.
To create a watermark use the function StartWatermark.
To draw a watermark use
public void DrawWatermark(String Name, int Rotation)
Rotation can be 0, 90 or 180.
2.10.5.5 C) Image Output
wPDFControl provides the function DrawImage() with several alternatives to draw a metafile
or a bitmap.
If no page has been opened with StartPage a page will be automatically opened in either the
DefaultPageSIze, or, if ZoomValue is not 0 to match the (zoomed) size of the image or metafile.
Possible Parameters:
image :
FileName:
x,y,w,h :
(1/72 inch)
ZoomValue:
public
public
public
public
public
public
int
int
int
int
int
int
int ZoomValue)
int x, int y, int w, int h)
ZoomValue)
x, int y, int w, int h)
Speciality for metafiles only: - DrawMetafile let you specify the x and y resolution which was
used to create the metafile.
This can be useful if the PDFEngine does not pick up the stretching value correctly. (This
function implies the ZoomValue set to 100)
public void DrawMetafile(Metafile metafile, int xres, int yres)
2.10.5.5 D) Hyperlinks
Hyperlinks mark a certain position on the PDF page which can be clicked by the user to either
open a certain website or jump to a poition in the PDF file which has been or will be marked with
a "BookMark".
To create a link you can use
public void Hyperlink(int x, int y, int w, int h, String BookMark)
2006-2009 by WPCubed GmbH, Munich, Germany
47
or
public void Hyperlink(Rectangle Rect, String BookMark)
Please note that both functions are using the current Canvas coordinate trasnformation - this
means you can use the same coordinates you use for DrawString(), Line() etc.
To create a weblink the bookmark must start with "http://"
To create a link to a certain file it must be start with "Launch://"
2.10.5.5 E) Bookmarks
Bookmarks can be used to mark link destinations in a PDF file.
To create a bookmark you can use
public void Bookmark(int x, int y, String BookMark)
or
public void Bookmark(Rectangle Rect, String BookMark)
Please note that both functions are using the current Canvas coordinate trasnformation - this
means you can use the same coordinates you use for DrawString(), Line() etc.
2.10.5.5 F) Outlines
Outlines are displayed in a seperate window by Acrobat Destiller and a good way to navigate a
document.
To create an entry use
Create an Outline level as jump to a certain bookmark
public void Outline(String Text, String Bookmark)
Create an Outline level as jump to the current page
public void Outline(String Text)
Create an Outline level as jump to a certain location on the page measured in pt
public void Outline(int x, int y, String Text)
Create an Outline level as jump to a certain location on the page measured in pt
public void Outline(Rectangle Rect, String Text)
To build the outline tree use
public void OutlineChild() // one level down
public void OutlineParent() // one level up
public void OutlineParent(int n) // n levels up
Example:
pdfControl2.Outline("Level 1");
pdfControl2.OutlineChild(); // Child on Level 2
pdfControl2.Outline("Level 2 a");
pdfControl2.Outline("Level 2 b");
pdfControl2.OutlineChild(); // Child on Level 3
pdfControl2.Outline("Level 3 a");
pdfControl2.OutlineParent(2); // Go 2 Levels up
pdfControl2.Outline("Level 1");
2006-2009 by WPCubed GmbH, Munich, Germany
48
49
typedef void (__stdcall WPDF_Hyperlink)(WPDFEnviroment PdfEnv, int x, int y,int w,int h,ch
typedef void (__stdcall WPDF_Bookmark)(WPDFEnviroment PdfEnv, int x, int y,char *Name);
typedef void (__stdcall WPDF_Outline)(WPDFEnviroment PdfEnv, int level, int x, int y,char
// Attribute
typedef void
typedef void
typedef void
int
typedef void
typedef void
funtions
(__stdcall WPDF_SetTextDefaultAttr)(WPDFEnviroment PdfEnv, char *FontName, in
(__stdcall WPDF_SetTextAttr)(WPDFEnviroment PdfEnv, char *FontName, int Size,
(__stdcall WPDF_SetTextAttrEx)(WPDFEnviroment PdfEnv, char *FontName, int Cha
Size, int Bold, int Italic,int Underline, unsigned int Color);
(__stdcall WPDF_SetPenAttr)(WPDFEnviroment PdfEnv, int Style, int Width, int
(__stdcall WPDF_SetBrushAttr)(WPDFEnviroment PdfEnv, int Style, int Color);
// Set License Key. This function only exists in the registered DLL, notz in the demo!
typedef void (__stdcall WPDF_SetLicenseKey)(unsigned long number, char *Name, char *Code);
2.10.5.6 Events
PDFControl publishes this events:
On Error is triggered for example if a bitmap cannot be converted by the PDF Engine.
OnGetText is triggered to let you specify the contents for a certain field (see MailMerge)
50
The Events under 'No active page' are triggered during the PDF creation. Do not use the
'Canvas' property inside your event handler for this events.
The 2 events under 'PDF page is open' is triggered to let you draw to the current PDF page
while it is open.
11);
51
52
53
bool
bool
bool
bool
void
BeginDoc();
BeginDoc(Stream OutStream);
BeginDoc(string FileName);
BeginDocMem();
EndDoc();
Create an outline item - you can mark a line in the text to be an outline.
public
public
public
public
public
public
public
void
void
void
void
void
void
void
Outline(string Text);
Outline(Rectangle Rect, string Text);
Outline(string Text, string Bookmark);
Outline(int x, int y, string Text);
OutlineChild();
OutlineParent();
OutlineParent(int levels);
Create a bookmark - such an bookmark can be a jump destination for a hyperlink. Bookmarks in
the text will be used, too.
public void Bookmark(Rectangle Rect, string BookMark);
public void Bookmark(int x, int y, string BookMark);
Export an image (any image in the text will be exported. See InputImage)
public
public
public
public
public
public
public
public
public
54
bool
bool
bool
bool
void
StartPage();
StartPage(Image image, int ZoomValue);
StartPage(ePage format, bool landscape);
StartPage(int w, int h, bool landscape);
EndPage();
bool
bool
bool
void
StartWatermark(string Name);
StartWatermark(string Name, ePage format);
StartWatermark(string Name, int w, int h);
EndWatermark();
int
int
int
int
int
Command(int
Command(int
Command(int
Command(int
Command(int
id);
id, int Value);
id, string Text);
id, int Value, string Text);
id, int Value, IntPtr Buffer, int BufferLen);
55
2.10.8 License
License Agreement for the wPDFControl and wRTF2PDF
Version 2 and Version 3
Copyright (C) 2003-2009 by WPCubed GmbH Germany
WEB : http://www.pdfcontrol.com
mail to: [email protected]
*** General
The software supplied may be used by one person on as many computer systems as that
person uses. Group programming projects making use of this software must purchase a copy of
the software for each member of
the group.
Contact WPCubed GmbH for "Team" and "Site" licensing agreements. This documentation
and the library are provided "as is" without warranty of any kind, either expressed or implied,
including but not limited to the implied warranties of merchantability and/or suitability for a
particular purpose. The user assumes the entire risk of any damage caused by this software.
In no event shall Julian Ziersch or WPCubed GmbH be liable for damage of any kind, loss of
data, loss of profits, interruption of business or other pecuniary losses arising directly or
indirectly from the use
of the program.
Any liability of the seller will be exclusively limited to replacement of the product or refund of
purchase price.
*** Demo Version
The demo version of the library may only be used to evaluate this product. The projects
which were created using the demo version may not be distributed. The demo version will
show a nag screen - this makes also the DLL much larger. The demo also includes the RTF
engine RTF2PDF - which is not included in the standard wPDFControl.DLL!
The demo displays a nag screen and prints a watermark.
*** wPDFControl Standard License
This License enables you to use our PDF engine technology in all your products and distribute
it to your customers without the need to pay any royalties. Important: You may not distribute
any of the included source files or object files or use the technology in a module
(ActiveX, COM, VCL ...) which can be used by other developers in any
kind of programming language or developing environment or which can be embedded into other
programs. This also prohibits the use our technology in universal PDF creation tools like a
virtual printer driver or a universal RTF to PDF converter which is used from the command line.
The DLL may only be used to create PDF files from the data processed by the same
application or application environment. Unless you have purchased the server license you
may not use the wPDF technology in any programs (services, CGIs, ActiveServers ...) which
will work on Internet servers to create PDF files to be distributed
over the WEB. As "Creator" of the PDF file always "wPDF by WPCubed GmbH" will be written
to the created PDF file.
Please note that you have to send you license key to the DLL to activate it. Please use
wpdfSetLicenseKey()
*** wPDFControl Server License
56
In Addition to the standard license you may also use the PDF creation technology in any
programs (services, CGIs, ActiveServers ...) which will work on one Internet server to create
PDF files to be distributed over the WEB.
3.1
Page Size
Like all word processor TextDynamic let You set up a certain page size.
More unusual is having different page sizes within one document. TextDynamic can do this,
too.
It is possible to change the page orientation within the document, and also change the margins.
It is also possible to show lines to mark the non printable area or similar, fixed margins. Such
line and their positions can be controlled through Memo.TextCommand(24,..)
You can also use a special label printing feature. Here the page is subdivided into rectangles.
Each "page" is printed to one of the rectangle.
3.1.1
General
3.1.2
If you need different page sizes within one document You can
a) use the PageSizeList
b) use the OnMeasurePage event
c) use Sections
3.1.3
Sections
Sections are used to use formatting options which are only valid within a certain part of a
document. For example one section may use landscape, the next may use portrait page
orientation. It is also possible that a certain header or footer is used for one section only.
2006-2009 by WPCubed GmbH, Munich, Germany
57
A document may have multiple sections. A section always starts with a paragraph, it is not
possible to change sections within one paragraph.
A new section is started with TextCursor.InputSection.
This method returns a reference to a IWPPageSize interface which can be used to modify the
properties of the new section.
When you want a certain property to be valid only for this section, You need to add a bit to its
"Select" property. That property can be accessed through IWPPageSize.GetProp and
IWPPageSize.SetProp.
The ID of the section is also available through GetProp/SetProp. This ID can be used in Memo.
BlockAdd to create a header or footer which is only used by that individual section.
3.1.4
Labels
Using the interface LabelDef you can quickly print labels. It is also possible to preview
the label sheets just like they would be printed. It is even possible to edit the text on
the label sheets. Also see IWPLabelDef.
3.2
Contents
58
Up to 16 different attribute types are supported for individual characters. Some of this
attributes are reserved.
This are:
1: the Font, such as "Arial"
2: the charset, such as ansi, baltic, russian etc.
3: the size in points, such as 11pt or 8.5pt
4: t he c ha ra c t e r w idt h - t his prope rt y is re se rv e d
5: a spe c ia l c ha ra c t e r e ffe c t , t his is a lso re se rv e d
6: a bit field which controls which of 15 flags are used (CharStyleMask). This flags are used for
"bold", "italic" ...
7: a bit field to activate each of the 15 flags (CharStyleON)
8: a text color
9: a background color
10: the letter spacing
11: a re se rv e d prope rt y . Ple a se do not use it .
12: a re se rv e d prope rt y . Ple a se do not use it .
13: a special underline mode, such as dotted or double
14: the underline color
15: t he t e xt la ngua ge c ode . T his is not use d y e t .
16: a t e xt st y le she e t
All the attributes can be undefined as well. In this case the value for the text is inherited by
the definition in a preceding SPAN style element, the current paragraph or the paragraph style
which is used by this paragraph.
Consequently each attribute defined in a paragraph style is overridden by the attributes defined
for a character, if this character has such a definition.
Therefore the character style, such as "bold", "italic", use two bitfields for definition. One to
enable the slot (6=mask), the other (on=7) to switch it on or off. The engine however does not
need the enable flag if the flag is set in the "on" bit field. But if it is set in "mask" and not set in
the "on", this means the style is forced to be off, even if a possible paragraph style has this
style enabled.
This graphic shows how attributes are stored in a paragraph style, a paragraph and the
attribute cache:
In this chapter we discuss how text and other elements are added to the document.
Text * Tables * Fields * Images * Header & Footer * Textboxes * Footnotes
3.2.1
59
Text
3.2.2
Tables
Tables in TextDynamic are represented by nested paragraphs. The table, table row and cell are
paragraph objects which are children of each other. cells in the same rows are siblings to each
other, as are rows.
The structure is so just as it is known from HTML:
<table>
<tr>
<td>A</td><td>B</td>
</tr>
</table>
2006-2009 by WPCubed GmbH, Munich, Germany
60
wRTF2PDF / TextDynamic Server supports 4 different ways to create a table by code. We offer
so many possibilities because the data which has to be placed into the table cells can come in
different ways and order. In general we favourize the use of a callback to fill the cell text, but
it is not always possible to callbacks. The possibility to select from different methods makes it
easy to adapt existing logic to work with wRTF2PDF / TextDynamic Server.
Method 1 - use callback:
Call TextCursor.AddTable and use the event OnCreateNewCell to format and fill the cell. If you
do not know the count of rows in advance pass 100000 and abort the creation loop inside the
OnCreateNewCell event using the variable parameter "AbortAtRowEnd".
Tip: Alternatively to the callback you can use the method ASetCellProp to modify a group of
cells after the complete table was created.
Adv a nt a ge : Table is created automatically, only cells which need modification need 'attention'.
Disa dv a nt a ge : Callback function can be difficult to read and maintain. Sometimes callback is not
possible (script languages)
Method 2 - simulate user input:
Call TextCursor.AddTable - then use the properties CPTableRowNr, CPTableColNr to "move
around" and insert text using InputString. You can also move the cursor using CPMoveNextRow,
CPMoveNextCell which would be faster.
Adv a nt a ge : Table is created automatically, only cells which need modification need 'attention'.
Disa dv a nt a ge : can be slow with large tables
Method 3 - create from top to bottom:
Use TextCursor.InputTable, then InputRowStart, as many InputCell ass needed and
InputRowEnd to close the current row. Create new row with InputRowStart and so on.
3.2.3
Fields
TextDynamic supports two different kind of fields. First the fields which are text located with
field start and -end markers. Such text can span multiple lines, paragraphs even pages. And
there are fieldobjects. This fields are handles as a single character and cannot span multiple
lines.
The first kind of fields are used for merge fields and edit fields. Use TextCursor.InputField to
create such a field.
To create a field object use IWPTextCursor.InputFieldObject.
If you need to modify the contents of all fields in the text the obvious way to do it is using
2006-2009 by WPCubed GmbH, Munich, Germany
61
Memo.MergeText. But You can also use EnumTextObjects to trigger an event for all markers of
a certain kind in the text. Inside the event You can read and change the contents of the field.
If you need to avoid the callback event You can use CPMoveNextObject.
3.2.4
Images
3.2.5
Here we talk about the header and footer areas which may be printed on certain or all pages.
They are implemented as layers which means in general they need to be activated to be
editable.
Here You see a header text in edit mode.
Internally headers and footers are implemented as "RTF Data Block" objects, just like the body
of the document.
This API is used to add and find such objects: BlockAdd, BlockAppend, BlockFind
To delete a block (such a header or footer text) call the "Delete" method published by the
interface IWPDataBlock.
You can also use this API to create header and footers:
IWPTextCursor.InputFooter
IWPTextCursor.InputHeader
To leave the header or footer use IWPTextCursor.GotoBody.
62
Normally the user can switch any header or footer element into edit mode by double clicking on
it. This can also be switched off, using Memo.SetBProp(2,3,1), also see wpEditOptionsEx. While
editing the body, the user sees the header and footer in shades of gray. This mode can be
disabled using Memo.SetBProp(6, 19, 1), also see wpViewOptions.
To switch the layer into edit mode under program control, set the property WorkOnText to true.
Now all text insertion and manipulation (InputText ...) is performed in the selected
RTFDataBlock.
You can now insert page numbering:
IWPTextCursor TextCursor;
TextCursor = WpdllInt1.Memo.TextCursor;
TextCursor.InputFieldObject("PAGE", "", "1");
TextCursor.InputText("/");
TextCursor.InputFieldObject("NUMPAGES", "", "9");
There is also a dialog to create, locate and delete header and footer elements.
It is displayed by the wpaDiaManageHeaderFooter Action. You can show it with wpaProcess("
DiaManageHeaderFooter", "").
A header text may also contain images. If this images are managed relatively to the page they
can also be moved down the body of the document. This feature can be used to create
watermarks. (BTW: The integrated PDF engine will make sure, the image is not embedded only
once.)
To create a header or footer only for a certain section, the section ID may be specified for the
layer.
3.2.6
Textboxes
Text boxes are movable layers with text. You need the "premium" license to use them.
They can be displayed in two states: Selected and movable or in edit mode.
To create a text box use the API IWPTextCursor.InputTextbox. Internally they are also
managed as "RTF Data Blocks".
To leave the header or footer use IWPTextCursor.GotoBody.
3.2.7
Footnotes
Footnotes are only available with the "premium" edition. They consist of a reference in the text,
the footnote number and the text layer, which is automatically placed at the bottom of the
page with the reference.
63
You can create a new footnote with TextCursor.InputFootnote. After the creation of a header,
footer, textbox or footnote texts you can use GotoBody() to return to the body text to create
more text there. When editing the footnote, just press ESCAPE.
3.3
Font Attributes
In this topic we want to draw Your attention to various possibilities how to change the
character attributes.
i.e. we want to insert the text "this is bold text".
Solution A) - here we simulate typing into the editor.
(please click on the highlighted names to get more information about the respective methods
and the parameters)
IWPMemo Memo = wpdllInt1.Memo;
IWPTextCursor TextCursor = Memo.TextCursor;
IWPAttrInterface Attr = Memo.TextAttr;
Attr.Clear();
Attr.SetFontface("Courier New");
Attr.SetFontSize(11);
TextCursor.InputText("this is");
Attr.IncludeStyles(1);
TextCursor.InputText("bold");
Attr.ExcludeStyles(1);
TextCursor.InputText(" ");
Attr.SetColor( wpdllInt1.ToRGB(Color.Red) );
Attr.IncludeStyles(4);
TextCursor.InputText("text");
64
65
and remove properties, the other properties will not be changed. Please note, that with this
property the character attributes are changed, not the attributes stored in the paragraph or a
paragraph style. To change those use CurrPar.ParASet in IWPParInterface.
3.4
Paragraph Attributes
TextDynamic supports various paragraph attributes. Not only indents and spacing, but also
paragraph color, shading and numbering.
Memo.CurrPar can be used to indent the current paragraph:
IWPMemo Memo = wpdllInt1.Memo;
IWPParInterface Attr = Memo.CurrPar;
Attr.ParASet((int)WPAT.IndentLeft, 360);
Attr.ParASet((int)WPAT.IndentFirst, -360);
wpdllInt1.Focus();
It is also possible to modify all selected paragraphs.
To do so Attr.SetProp(1,1) must be called before the process to create a paragraph list, and
SetProp(1,0) must be called to clear it.
In this example we also modify the tab stops and insert text in each paragraph.
IWPMemo Memo = wpdllInt1.Memo;
IWPParInterface Attr = Memo.CurrPar;
Attr.SetProp(1, 1);
try
{
Attr.ParASet((int)WPAT.IndentLeft, 1440);
Attr.ParASet((int)WPAT.IndentFirst, -1440);
Attr.TabAdd(1440, 0, 0, 0);
// Insert text at the start of each paragraph
Attr.InsertText(0, "-\t", -1);
}
finally
{
Attr.SetProp(1, 0);
}
Memo.Reformat();
wpdllInt1.Focus();
Most of the IWPParInterface methods and properties can work with a paragraph list.
We added the icon
2006-2009 by WPCubed GmbH, Munich, Germany
66
which do.
When using ParASet You need to use an id (WPAT_code) to identify the attribute plus the
value.
This are the most important IDs for paragraph attributes:
WPAT_IndentLeft = 17 - the left indent in twips
WPAT_IndentRight = 18; - the right indent in twips
WPAT_IndentFirst = 19; - the first indent in twips (can be negative, too)
WPAT_SpaceBefore = 20 - the space before a paragraph
WPAT_SpaceAfter = 21; - the space after a paragraph
WPAT_LineHeight = 22; - the LineHeight in in % ( Has priority over WPAT_SpaceBetween)
WPAT_SpaceBetween = 23; - the space between paragraphs. When negative : Absolute,
When Positive minimum
// padding, only in tables:
WPAT_PaddingLeft = 24 - Distance from Border to Text in twips (CSS = padding) tscellpaddt /
trpaddl
WPAT_PaddingRight = 25 - Distance from Border to Text (CSS = padding)
WPAT_PaddingTop = 26- Distance from Border to Text (CSS = padding)
WPAT_PaddingBottom = 27- Distance from Border to Text (CSS = padding)
// Alignment
WPAT_Alignment = 29 - horizontal alignment: 0=left, 1=center, 2=right, 3=justified
WPAT_VertAlignment = 30 - vertical alignment: 0=top, 1=center, 2=bottom
3.5
Paragraph Styles
A paragraph style includes font, color and spacing settings applied to an entire paragraph. The
attributes of the style will only be used, if they were not "overridden" by either the paragraph
attributes or the character attributes.
This code creates a new style:
IWPMemo Memo = wpdllInt1.Memo;
IWPParInterface PAttr = Memo.CurrStyle;
IWPAttrInterface CAttr = Memo.CurrStyleAttr;
Memo.SelectStyle("Heading1");
PAttr.IndentLeft = 1440;
CAttr.SetFontface("Tahoma");
CAttr.SetFontSize(12);
With this code the current or the selected paragraphs will use the new styles:
IWPMemo Memo = wpdllInt1.Memo;
IWPParInterface Attr = Memo.CurrPar;
Attr.SetProp(1, 1); // --> Work with selection
try
{
Attr.StyleName = "Heading1";
Attr.ClearCharAttr();
2006-2009 by WPCubed GmbH, Munich, Germany
67
}
finally
{
Attr.SetProp(1, 0);
}
Memo.Reformat();
wpdllInt1.Focus();
Please note that the attributes in a style are only used, if they are not overridden by the
paragraph or character attributes. Here we use ClearCharAttr to make sure, the characters do
not have their own attributes.
For a more selective control apply the style using ParStrCommand( 9, x, name ). If bit 1 is set
in X, the character attributes, which are used by the selected style, are cleared, if bit 2 is set,
the paragraph attributes are cleared.
So, we should better use this code:
IWPMemo Memo = wpdllInt1.Memo;
IWPParInterface Attr = Memo.CurrPar;
Attr.SetProp(1, 1); // work with selected text
try
{
// Select the style and remove the attributes which would
// otherwise override the setting in the style sheet
Attr.ParStrCommand(9, 3, "Heading1");
}
finally
{
Attr.SetProp(1, 0);
}
Memo.Reformat();
wpdllInt1.Focus();
68
4.1
The WPDLLInt object is the central part of the TextDynamic word processing
component. It publishes some methods to initialize the control and several interfaces.
Most important are the interfaces Memo and Memo2.
To load the the DLL use SetDLLName
To initialize the engine and set Your License keys use EditorStart
To initialize the editor and select the editing mode (single editor, split screen...) use
SetEditorMode.
The interface Memo is used to access and program the editor #1.
The TextDynamic control also includes a secondary editing engine. It can be use to
display thumbnails, display the result of a reporting or mail merge process or it can be
used to display the same text as Editor #1 at a different location and zoom setting
("splitscreen").
The second engine can be programmed through interface Memo2.
Since in certain modes the user can work freely with both editors, You can use
interface CurrMemo to program the editor which is currently active. The objects
Memo, Memo2 and CurrMemo all include the properties and methods of the in case
of IWPMemo interface.
69
The interface IWPMemo publishes sub interfaces to change the font and paragraph
attributes of the text (TextAttr, CurrAttr, CurSelAttr), to move the cursor and insert
text or data (TextCursor). It includes methods to load and save the text (
LoadFromFile ...), methods modify the behavior and display of the editor (SetBProp,
SetIProp) and properties to change the layout and display. (LayoutMode, WordWrap,
AutoZoom).
Work with the powerful mail merge, create documents under program control using
the TextCursor API or the optional reporting.
Quick Links:
Configure the Editor
Getting Started
You can access Memo.PageSizes to format the text to let it fit into a series of
rectangles. Each page can be retrieved easily as a metafile.
To convert the text to PDF using the integrated PDF converter
To prepare and send e-mails use the property Mapi.
In one package we deliver an OCX to be used in Visual Basic 6, MS Access or Visual
FoxPro (or other development tools with a decent Active X support) and a .NET
assembly (written in C#) to be used in dotNET applications (C#, VB.NET, Delphi.
NET). The source for the .NET assembly is provided with the license.
For Syntax Highlighting see Memo.TextCommandStr
Also see "Categories", "Tasks", "Mailmerge" and "Reporting"
70
IWPPdfCreator
Memo
Memo2
CurrMemo
TextCursor
IWPMemo.TextCursor
PdfCreator
IWPSpell
IWPMemo.SpellCtrl
IWPMAPI
IWPMemo.MAPI
PageSize
IWPMemo.PageSize
CurrObj
CurrSelObj
IWPMemo.CurrObj
IWPMemo.CurrSelObj
Contents.
EmbeddedObject
Contents.FieldObject
CurrPar.CharObj
Events: OnFieldEnter
OnFieldLeave
OnHyperlink
OnTextObjectMouse
OnLoadExtImage
OnBeforeSaveImage
OnAfterSaveImage
OnTextObjectGetText
OnEnumTextObj
CurrPar
IWPMemo.CurrPar
CurrStyle
IWPMemo.CurrStyle
IWPMemo
IWPTextCursor
IWPPageSize
IWPTextObj
IWPParInterface
_
IWPAttrInterface
IWPMemo.TextAttr
71
CurrParAttr
Modify font attributes of all characters in
IWPMemo.CurrParAttr
_
Event OnEnumParOrStyle current paragraph.
Event OnCreateNewCell
CurrStyleAttr
Modify font attributes defined by current
_
IWPMemo.CurrStyleAttr style.
IWPFieldContents.
Modify font attributes of mail merge
_
FieldAttr
field.
IWPParInterface.CharAttr Modify font attributes of certain
_
()
character in paragraph.
_
IWPMemo.CurrAttr
Modify the current writing mode
CurrStyleAttr
Modify font attributes defined by current
_
IWPMemo.CurrStyleAttr style.
IWPMemo.
IWPPrintParameter
Modify print options.
PrintParameter
Memo.BlockFind
Memo.BlockAdd
IWPDataBlock
Manage header and footer texts.
Memo.ActiveText
Event
2006-2009 by WPCubed GmbH, Munich, Germany
72
OnEnumDataBlocks
Mailmerge - replace fields with text or
images.
Provide code for custom actions added
IWPDllButton
Event OnButtonClick
to internal toolbars.
Modify appearance of hyperlinks and
IWPCharacterAttr Memo.SpecialTextAttr()
other "special" text.
Create and manage a report DBIWPReport
Property Report
Description. Show report template
editor.
IWPLabelDef
Property Memo.LabelDef Edit, preview and print mailing labels.
IWPFieldContents
Event OnFieldGetText
4.1.1
Events
4.1.1.1
RTF2PDF / TextDynamic
4.1.1.1 A) OnAfterSaveImage
This event is triggered after an image was saved.
Declaration C#
OnAfterSaveImage(Object Sender, int Editor, IWPTextObj TextObj);
Declaration OCX
OnAfterSaveImage(ByVal Editor As Long, ByVal TextObj As WPTDynInt.IWPTextObj)
This event is triggered after an image was saved. You can use it to reset the changes in case
you used the event OnBeforeSaveImage to temporarily update the properties of the object.
Category
Image Support
4.1.1.1 B) OnBeforeSaveImage
Declaration C#
OnBeforeSaveImage(Object Sender, int Editor, IWPTextWriter Writer, IWPTextObj TextObject,
ref bool DontSave)
Declaration OCX
OnBeforeSaveImage(ByVal Editor As Long, ByVal Writer As WPTDynInt.IWPTextWriter, ByVal
TextObject As WPTDynInt.IWPTextObj, DontSave As Boolean)
This event allows it to change the properties of an object before it is saved. You can for
example update the contents or the file name property.
Parameters
Editor
Writer
TextObject
DontSave
Category
Image Support
2006-2009 by WPCubed GmbH, Munich, Germany
73
4.1.1.1 C) OnClear
Declaration C#
OnClear(Object Sender, int Editor)
Declaration OCX
OnClear(ByVal Editor As Long)
This event is triggered after the text was cleared. You can use it to set the default text
attributes.
4.1.1.1 D) OnCreateNewCell
Declaration C#
OnCreateNewCellEvent(Object Sender, int ColNr, int RowNr, IWPParInterface CellText,
IWPAttrInterface CellAttr, int EventParam, ref bool AbortAtRowEnd)
Declaration OCX
OnCreateNewCell(ByVal ColNr As Long, ByVal RowNr As Long, ByVal CellText As WPTDynInt.
IWPParInterface, ByVal CellAttr As WPTDynInt.IWPAttrInterface, ByVal EventParam As Long,
AbortAtRowEnd As Boolean)
This event is triggered by method AddTable only if the variable EventParam was passed with a
value <> 0.
The event makes it easy to assign text and attributes to each new cell.
VB Example:
C# Example:
We use this event handler for OnCreateNewCell. The event is triggered for each created cell.
The parameter EventParam is the value which was passed to AddTable. Please note that the
last parameter must be re f bool Abort At Row End - "out" instead of "ref" will not work.
private void WPDLLInt1_OnCreateNewCell(object Sender, int ColNr, int RowNr,
WPDynamic.IWPParInterface CellText,
WPDynamic.IWPAttrInterface CellAttr,
int EventParam, ref bool AbortAtRowEnd)
{
CellText.SetText("some text",0);
}
74
WPDLLInt1.TextCursor.AddTable(
"data", // optional name for table
3, //columns
10, //rows
true, // borders
1, // EventParam (!=0 to trigger callback)
false,// create header rows
false // create footer rows
);
The value passed as parameter EventParam is provided to the event as well. If this parameter
is 0, the event will not be triggered.
Note: To create a paragraph after the table created with AddTable call InputParagraph with
Mode=2
Parameters
ColNr
RowNr
CellText
CellAttr
EventParam
AbortAtRowEnd
Category
Callback Functions
Table Support
4.1.1.1 E) OnEnumDataBlocks
Declaration C#
OnEnumDataBlocks(Object Sender, IWPDataBlock DataBlock, int EventParam)
Declaration OCX
OnEnumDataBlocks(ByVal DataBlock As WPTDynInt.IWPDataBlock, ByVal EventParam As Long)
This event is triggered by the method EnumDataBlocks. It is useful to check all header and
footer texts, and, with TextDynamic "Premium" all current text objects and footnotes. A
reference to the DataBlock is passed as parameter. The parameter EventParam is the integere
value which was provided to EnumDataBlocks().
2006-2009 by WPCubed GmbH, Munich, Germany
75
Category
Callback Functions
4.1.1.1 F) OnEnumParOrStyle
Declaration C#
OnEnumParOrStyle(Object Sender, bool IsControlPar, int StartPos, int Count, IWPParInterface
ParText, IWPAttrInterface ParAttr, int EventParam, ref bool Abort);
Declaration OCX
OnEnumParOrStyle(ByVal IsControlPar As Boolean, ByVal StartPos As Long, ByVal Count As
Long, ByVal ParText As WPTDynInt.IWPParInterface, ByVal ParAttr As WPTDynInt.
IWPAttrInterface, ByVal EventParam As Long, Abort As Boolean)
The boolean Abort is set to true in case the word was not found in the dictionary. Note: To
implement a pop up menu the event OnMouseDownWord can be used.
Category
Callback Functions
4.1.1.1 G) OnEnumTextObj
Declaration C#
OnEnumTextObj(Object Sender, TextObjTypes ObjType, string Name, string Command,
IWPTextObj Obj, int EventParam, ref bool Abort)
Declaration OCX
OnEnumTextObj(ByVal ObjType As WPTDynInt.TxTextObjTypes, ByVal Name As String, ByVal
Command As String, ByVal Obj As WPTDynInt.IWPTextObj, ByVal EventParam As Long, Abort As
Boolean)
Category
Callback Functions
2006-2009 by WPCubed GmbH, Munich, Germany
76
4.1.1.1 H) OnError
Declaration C#
OnError(Object Sender, int Group, int Nr, string Msg)
Declaration OCX
OnError(ByVal Group As Long, ByVal Nr As Long, ByVal Msg As String)
The event is triggered when an erro happens inside the TextDynamic engine. The error message
is provided as string "Msg".
Parameters
Group
Nr
77
C# Example:
Random rnd = new Random();
private void wpdllInt2_OnFieldGetText(
object Sender,
int Editor,
string FieldName,
IWPFieldContents Contents)
{
if (FieldName == "NAME")
Contents.StringValue = "Julian Ziersch";
else Contents.StringValue = Convert.ToString(rnd.NextDouble());
}
It is also possible to create or update an image which is placed inside the field. To make this as
easy as possible there are two functions LoadImage and LoadPicture. Both methods will not
simply replace the contents of the field with a new image but reuse an existing image container
object.
Hint: In our product WPTools the event with similar functionality was named
OnMailMergeGetText.
78
To create a hyperlink inside the field use InputHyperlink. You can also load a file with formatted
text using LoadText
To create a table with data inside the field execute AddTable. The event OnCreateNewCell can
be used to format and fill each new cell.
If you know that you do not need the field after the merge process you can execute
DeleteField. The field markers, not the contents will be removed.
An interface to access the current field is provided as property FieldObject. You can use this
interface to read other properties of the merge field.
Notes:
If you are using the Active-X and your developing system does not provide access to the
interface passed as parameter, use the property EventField instead.
The event is also used for report group variables in the "add:" mode. Here only the StringValue
may be modified. The property FieldObject will be null in this case!
The reporting engine will also trigger the event OnFieldGetText to evaluate fields which were
used in band conditions such as ?fieldname=null and ?fieldname#null.
In this case the property IsMergefield =false. Use Contents.ExecStrCommand to modify the
field state property.
4.1.1.1 J) OnGetSpecialText
Member of WPDLLInt
Declaration C#
OnGetSpecialText(Object Sender, int Editor, int PageNr, DataBlockKind Kind, ref int SelectedID
);
Declaration OCX
OnGetSpecialText(ByVal Editor As Long, ByVal PageNr As Long, ByVal Kind As Long, SelectedID
As Long)
This event is used to select a certain header or footer for certain pages. For an example see
Name.
Category
Hader and Footer Support
4.1.1.1 K) OnInitializePar
Declaration C#
OnInitializePar(Object Sender, int Editor, IWPParInterface Paragraph)
Declaration OCX
OnInitializePar(ByVal Editor As Long, ByVal Paragraph As WPTDynInt.IWPParInterface)
This event allows it to change the properties of the paragraph and the text according to its
contents. It is triggered before the paragraph is formatted.
This (kind of silly) example shades the paragraph if it contains the text "shade" somewhere and
removes the shading if it does not:
79
Else
Paragraph.ParShading = 0
End If
End Sub
4.1.1.1 L) OnLoadExtImage
Declaration C#
OnLoadExtImage(Object Sender, int Editor, string LoadPath, string URL, IWPTextObj TextObj,
ref bool Ok);
Declaration OCX
OnLoadExtImage(ByVal Editor As Long, ByVal LoadPath As String, ByVal URL As String, ByVal
TextObj As WPTDynInt.IWPTextObj, OK As Boolean)
This event is triggered during text loading. If images are not imbedded but linked (only a name
is in the file) this event can be used to load the image from a directory or data base.
When you load the image in your code set the variable OK to true - then the default code will
be skipped (it tries to locate the image data in the same directory as the loaded file).
To load an image use the interface TextObj.
4.1.1.1 M) OnLoadExtString
Declaration C#
OnLoadExtString(Object Sender, int Editor, string LoadPath, string URL, object DataStream, ref
bool Ok)
Declaration OCX
OnLoadExtString(ByVal Editor As Long, ByVal LoadPath As String, ByVal URL As String, ByVal
DataStream As IWPStream, OK As Boolean)
This event is triggered by the HTML reader to load an external CSS style sheet.
4.1.1.1 N) OnLoadText
Declaration C#
void OnLoadText(Object Sender, int Editor, string Filename)
Declaration OCX
OnLoadText(ByVal Editor As Long, ByVal filename As String)
This event is triggered after a file was loaded. It can be used to update the caption of a
window to display the current file name.
4.1.1.1 O) OnMeasurePage
Declaration C#
OnMeasurePage(Object Sender, int Editor, int PageNr, IWPMeasurePageParam Size)
Declaration OCX
OnMeasurePage(ByVal Editor As Long, ByVal PageNr As Long, ByVal Size As WPTDynInt.
IWPMeasurePageParam)
TextDynamic supports different page sizes in one document using RTF sections. If you want to
change the page size for certain pages using code it you should use this event. You can easily
update the properties in the parameter interface Size. The modified size will be only used for
the page with the number "PageNr".
80
Category
Modify the layout of the text display
4.1.1.1 P) OnNotify
Declaration C#
OnNotify(Object Sender, int Editor, int MsgID);
Declaration OCX
OnNotify(ByVal Editor As Long, ByVal MsgID As Long)
Currently this message IDs are supported:
MSGID_ChangedActiveText=21: The editor changed between header and body text.
MSGID_MouseWheelAtStart=23: The mouse wheel was used to scroll to the very start.
MSGID_MouseWheelAtEnd=24: The mousesue wheel was used to scroll to the very end.
MSGID_ChangeLastFileName=27: Last file name was changed.
MSGID_ChangeModified=28 The modified property was changed.
MSGID_SelectWatermark = 29; Application may choose a new watermark.
Current page can be read using Memo.TextCommand(25, 0, 0). See C# Example there.
4.1.1.1 Q) OnPaintWatermark
Declaration C#
OnPaintWatermark(
Object Sender,
int Editor,
int Mode,
Graphics Canvas,
float X, float Y, float X1, float Y1, float Xres, float Yres);
The .NET assembly uses different parameters than the OCX for this event type.
It passes the coordinates and the resolution as floating point variables and instead of a device
handle (HDC) it passes a reference to a .NET Graphics object as drawing surface "Canvas".
Declaration OCX
OnPaintWatermark(ByVal Editor As Long, ByVal Mode As Long, ByVal DC As Long, ByVal X As
Long, ByVal Y As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal Xres As Long, ByVal Yres As
Long)
This event can be used to paint into the background of any page.
( If you need to select a watermark which was loaded using Command(143) please use OnNotify
. Example. )
Parameters:
The page rectangle and specified by X,Y,X1,Y1. This values are based on the resolution
specified by XRes ansd YRes.
The lower 3 bytes of parameter "Mode" is the current page number.
81
Example:
4.1.1.1 R) OnReadFormulaVar
Declaration C#
OnReadFormulaVar(Object Sender, string Name, IWPReportBand BandContext, int CountInGroup,
out double Value);
Declaration OCX
OnReadFormulaVar(ByVal Name As String, ByVal BandContext As WPTDynInt.IWPReportBand,
ByVal CountInGroup As Long, Value As Double)
This event is use by the reporting engine (see interface IWPReport).
It is triggered to read the value of a variable which is used in a formula. Please don't mix up
with group variables used by the reporting engine, those group variables contain the formulas
which itself contain the variables which trigger this event. In fact any unknown name inside a
formula will trigger the event OnReadFormulaVar.
The formula "TABLE.PRICE*TABLE.AMOUNT" will trigget the event twice, first to read "TABLE.
PRICE" then to read "TABLE.AMOUNT".
Parameters
Name
BandContext
CountInGroup
82
Value
Category
Reporting
4.1.1.1 S) OnReportState
This event is used by the reporting engine (see interface IWPReport) to create and navigate in
data sets.
Also required is even OnFieldGetText to read field values.
Declaration C#
OnReportState(object Sender, string Name, int State, WPDynamic.IWPReportBand Band, ref
bool Abort)
Declaration OCX
OnReportState(ByVal Name As String, ByVal State As Long, _
ByVal Band As WPTDynInt.IWPReportBand, Abort As Boolean)
This event occurs during report creation. It gives you a chance to prepare a database query,
to advance to the next record and to prepare the attributes of the bands.
Parameters
Name:
This is the name of the band.
State:
This parameter is used to check the current processing state of the reporting engine:
0 (REP_BeforeProcessGroup): A reporting group is about to be started/looped. You
need to set "Abort" to false, otherwise the group will not be processed. Usually you
will need to prepare a sub query and set "Abort" to true in case the query is empty.
The event will also occur when the group is processed again - Count is >0 in this case.
1 (REP_PrepareText): A text band is prepared. It will be used next. Usually you have
nothing to do - but you can modify the properties of the band paragraphs.
After the band was pre pa re d, all paragraphs will be copied to editor #2 in the
TextDynamic control and after that the event OnFieldGetText will be fired for all merge
fields in the text.
2 : not used
3 (REP_PrepareHeader): A header band is prepared.
4 : not used
5 (REP_AfterProcessGroupData): The group data has been processed completely. You
can use this state to sum up totals.
6 (REP_PrepareFooter): A footer band is prepared.
7: not used
8 (REP_AfterProcessGroup): The group was processed. You can use this event to move
2006-2009 by WPCubed GmbH, Munich, Germany
83
to next record.
Example:
This simplified C# example code loops all groups in the report template 10 times.
It has been created to be used as template in Your Application.
// This event is used to start, prepare and close a report group
// Usually you would use the "Name" to select a certain database,
// rewind it depending on State and set "Abort" to true
// when the last record was reached when State=0.
private void wpdllInt2_OnReportState(
object Sender,
string Name, int State,
IWPReportBand Band,
ref bool Abort)
{
switch(State)
{
case 0: //REP_BeforeProcessGroup
{
// If Band.Count=1 take "Name" to open a data base query
and
// move to first Record.
// Set Abort to TRUE if the query has the state
"EOF" (EndOfFile)
// Here also Set total variables to 0.
Abort = Band.Count>10;
break;
}
case 1: //REP_PrepareText
{
// We can process a text band depending on a condition
break;
}
case 3: //REP_PrepareHeader
{
// We can process a header band depending on a condition
break;
}
case 5: //REP_AfterProcessGroupData
{
// Take the named data set and post process the current
row.
// This event will only be triggerd if the group contained
// a data row. You can use it to calculate totals.
// (Band.Count will be -1 in this event)
break;
}
case 6: //REP_PrepareFooter
{
// We can process a footer band depending on a condition
break;
2006-2009 by WPCubed GmbH, Munich, Germany
84
Note:
If you are using the Active-X and your developing system does not provide access to the
interface passed as parameter, use the property EventReportBand instead.
Category
Reporting
4.1.1.1 T) OnTextObjectGetText
Declaration C#
OnObjectGetText(Object Sender, int Editor, int PageNr, IWPTextObj TextObj)
Declaration OCX
OnTextObjectGetText(ByVal Editor As Long, ByVal CurrPage As Long, ByVal Obj As WPTDynInt.
IWPTextObj)
This event can be used to display custom text inside of text objects. There are several
standard objects, such as the page number, the page count, time and date fields. All this
objects are - in contrast to merge fields - handled as one character only. This means the
contents cannot contain a line wrap. But unlike merge fields, which really c ont a in text, the text
displayed by the text objects is retrieved before the object is painted. You can see the effect
with the TIME field - here the current time is updated every time the screen is refreshed.
The contents of the object with an unknown name (not PAGE, NUMPAGES etc) is by default
retrieved from the object property Params. This property is read from and written to RTF. Inside
the event OnTextObjectGetText you can update the property Params to display custom
information, for example the current file path, the name of the author or any text you need.
This VB code inserts a text object:
WPDLLInt1.TextCursor.InputFieldObject "DYNAMIC", "", ""
Exclusive to TextDynamic
4.1.1.2 A) OnBeforeOverwriteFile
Member of WPDLLInt
Declaration C#
OnBeforeOverwriteFile(Object Sender, int Editor, string filename, bool OnlySelection, ref bool
Abort);
Declaration OCX
OnBeforeOverwriteFile(ByVal Editor As Long, ByVal filename As String, ByVal OnlySelection As
2006-2009 by WPCubed GmbH, Munich, Germany
85
The interface IWPDllButton provides access to the properties of the button. Most important is
property "Name" which can be set in the toolbar description.
Example VB6:
Note:
If you are using the Active-X and your developing system does not provide access to the
interface passed as parameter, use instead either the property EventButton or Memo.
TextCommandStr(33,...)
86
4.1.1.2 C) OnChangePosition
Member of WPDLLInt
Declaration C#
OnChangePosition(Object Sender, int Editor)
Declaration OCX
OnChangePosition(ByVal Editor As Long)
This event is triggered when the position of the insertion marker (=cursor) is changed. You can
use it to update the statusbar.
The position of the cursor, paragraph number, page number and similar, can be retrieved using
the CP* properties published by TextCursor and CurrMemo.TextCursor.
However, in general we recommend to use OnUpdateGUI to update all status items, not only
the status bar but also the enabled/disabled/checked state of menu items and buttons.
Category
Display Status Information
4.1.1.2 D) OnChangeSelection
Member of WPDLLInt
Declaration C#
OnChangeSelection(Object Sender, int Editor)
Declaration OCX
OnChangeSelection(ByVal Editor As Long)
This event is triggered when the selection has been changed. The event is triggered
asynchronly after the change has been performed, the next time the application is idle.
Category
Display Status Information
4.1.1.2 E) OnChangeText
Member of WPDLLInt
Declaration C#
TextChanged(EventArgs e)
Here the standard event is used. You can cast e to wpEventArgs which contains the property Editor.
Declaration OCX
OnChangeText(ByVal Editor As Long)
The event will be triggered after the text was modified. OnChangingText will be triggered before
the change.
4.1.1.2 F) OnChangeViewMode
Member of WPDLLInt
Declaration C#
OnChangeViewMode(Object Sender, int Editor, int AutoZoom, int Zooming)
87
Declaration OCX
OnChangeViewMode(ByVal Editor As Long, ByVal AutoZoom As Long, ByVal Zooming As Long)
This event is triggered when the view mode has been changed. This happens when the zooming
or layout mode is updated.
Parameters
Editor
AutoZoom
0: AutoZoom Off
1: Show full page width
2: Show full page (width + height)
3: Adjust column count - display as many
pages in a row as possible
4: Adjust column count and distance - display
as many pages in a row as possible and adjust
the distance if the pages have different sizes
Category
Display Status Information
4.1.1.2 G) OnChangingText
This event is triggered before the text is modified.
Member of WPDLLInt
Declaration C#
OnChangingTextEvent(Object Sender, int Editor, ref bool AllowChange)
Declaration OCX
OnChangingText(ByVal Editor As Long, AllowChange As Boolean)
When using VB6 better use the standard event Validate(Cancel As Boolean) which allows it
to cancel the operation which would modify the text.
4.1.1.2 H) OnClick
Member of WPDLLInt
Declaration C#
Click(EventArgs e)
Here the standard event is used. You can cast e to wpEventArgs which contains the property Editor.
Declaration OCX
OnClick(ByVal Editor As Long, Handled As Boolean)
This event is triggered when the use clicks inside the editor. You can set the variable "Handled"
to true in case the default code should not be executed.
4.1.1.2 I) OnClickCreateHeaderFooter
Member of WPDLLInt
Declaration C#
OnClickCreateHeaderFooter(Object Sender, int Editor, int Kind, ref int Range);
Declaration OCX
OnClickCreateHeaderFooter(ByVal Editor As Long, ByVal Kind As Long, Range As Long)
88
This event is triggered when the user clicks double into the top or buttom margin areas. You
can use the variables Kind and Range if you want to create a new header or footer.
VB Example:
Private Sub WPDLLInt1_OnClickCreateHeaderFooter(ByVal Editor As Long, ByVal Kind As Long,
If Kind = 1 Then
WPDLLInt1.TextCursor.InputHeader Range, "", ""
Else
WPDLLInt1.TextCursor.InputFooter Range, "", ""
End If
End Sub
Parameters
Kind
Range
Category
Hader and Footer Support
4.1.1.2 J) OnClickPage
Member of WPDLLInt
Declaration C#
OnClickPage(Object Sender, int Editor, int PageNr);
Declaration OCX
OnClickPage(ByVal Editor As Long, ByVal PageNr As Long)
This events is triggered when the user clicks on a page.
4.1.1.2 K) OnDblClick
Member of WPDLLInt
Declaration C#
DblClick(EventArgs e)
Here the standard event is used. You can cast e to wpEventArgs which contains the property Editor.
Declaration OCX
OnDblClick(ByVal Editor As Long, Handled As Boolean)
This event procedure is called after the user clicked twice. You can set the variable Handled to
true to skip the default code.
4.1.1.2 L) OnFieldEnter
Member of WPDLLInt
Declaration C#
OnEnterField(Object Sender, int Editor, string Fieldname, IWPTextObj Field)
Declaration OCX
OnFieldEnter(ByVal Editor As Long, ByVal FieldName As String, ByVal Field As WPTDynInt.
IWPTextObj)
When in formular editing mode (see SetEnableFlags) this event will be triggered when the cursor
89
Declaration OCX
OnMouseDown(ByVal Editor As Long, ByVal Button As Long, ByVal Shift As Long, ByVal X As
Long, ByVal Y As Long)
This event occurs when the user presses the mouse button. The parameter Shift can be used
to check the state of the control keys. The parameter Button will be 0 for left button, 1 for
right and 2 for the middle button.
Parameters
2006-2009 by WPCubed GmbH, Munich, Germany
90
Editor
Button
Shift
A
1
2
4
Editor
4.1.1.2 P) OnMouseDownWord
Member of WPDLLInt
Declaration C#
OnMouseDownWord(Object Sender, int Editor, int Button, int Shift, int X, int Y, IWPParInterface
Paragraph, int PosInPar, int Count)
Declaration OCX
OnMouseDownWord(ByVal Editor As Long, ByVal Button As Long, ByVal Shift As Long, ByVal X
As Long, ByVal Y As Long, ByVal Paragraph As WPTDynInt.IWPParInterface, ByVal PosInPar As
Long, ByVal Count As Long)
This event is triggered when the user clicks on any of the words in the text. It will be also fired
when the context menu key is being pressed.
Usually you will use the event to display a popup menu. Using the parameter Paragraph you can
read and change the text at the position the click was performed.
This event is also used by custom spellchecking which can be activated using Command(907).
If you use this event to show a custom popup dialog please use Memo.SetBProp(0, 19, -1) to
deactivate the default popup dialog.
Tip: If custom spellchecking was activated using Command(907) and the word was marked to
be wrong, bit 10 (value 512) will be set in the bit field "Shift". The current word will be selected
in this case. In the event handler you can show a popup menu and either remove the misspellmarker or also replace the text. The misspell-marker will be removed if either Paragraph.
ReplaceText or Paragraph.ReplaceCharAttr was used inside the event handler.
Note: The .NET ContextMenu Show() method already returns before the Click events of the
items have been triggered, to solve this problem you need to call method Application.DoEvents
after Show.
This example shows how to display a popup menu to change the current word:
91
contextMenu1.MenuItems.Add(0, men2);
men2.Click += new System.EventHandler(this.SpellMen_ChangeWord);
// Initialize global variables
TextWasOK = false;
NewText = "";
// Display popup and wait
contextMenu1.Show(wpdllInt1,new Point(X,Y));
// Popup was closed
// Now trigger the Click events
Application.DoEvents();
// and change the text
if(NewText!="")
Paragraph.ReplaceText(PosInPar,Count,NewText);
// or just force the removal of the misspell-marker
else if (TextWasOK)
Paragraph.ReplaceCharAttr(PosInPar,0,0);
}
private void SpellMen_IgnoreWord(object sender, System.EventArgs e)
{
TextWasOK = true;
}
private void SpellMen_ChangeWord(object sender, System.EventArgs e)
{
TextWasOK = true;
NewText = ((MenuItem)sender).Text;
}
4.1.1.2 Q) OnMouseMove
Member of WPDLLInt
Declaration C#
MouseMove(MouseEventArgs e)
The .NET assembly uses the standard event type MouseMove. The passed MouseEventArgs can be casted to the
wpMouseEventArgs type to read the property "Editor".
Declaration OCX
OnMouseMove(ByVal Editor As Long, ByVal Shift As Long, ByVal X As Long, ByVal Y As Long)
This event occurs when the user moves the mouse over the editor.
Parameters
Editor
Shift
Editor
4.1.1.2 R) OnMouseUp
Member of WPDLLInt
Declaration C#
2006-2009 by WPCubed GmbH, Munich, Germany
92
MouseUp(MouseEventArgs e)
The .NET assembly uses the standard event type MouseUp.
The passed MouseEventArgs can be casted to the wpMouseEventArgs type to read the
property "Editor".
Declaration OCX
OnMouseUp(ByVal Editor As Long, ByVal Button As Long, ByVal Shift As Long, ByVal X As Long,
ByVal Y As Long)
This event occurs when the user releases the mouse button. The parameter Shift can be used
to check the state of the control keys. The parameter Button will be 0 for left button, 1 for
right and 2 for the middle button.
Parameters
Editor
Button
Shift
A
1
2
4
Editor
VB6 Example:
VB6: This code checks for a click into a merge field and then updates its contents:
Private Sub WPDLLInt1_OnMouseUp(ByVal Editor As Long, ByVal Button As Long, ByVal Shift As
Dim Memo As IWPMemo
Dim Obj As IWPTextObj
Set Memo = WPDLLInt1.Memo
Set Obj = Memo.GetObjAtXY(X, Y, 0, -1)
If Not Obj Is Nothing Then
Obj.EmbeddedText = "new text"
Memo.ReformatAll False, True
End If
End Sub
C#: This event handler also checks for e merge field and opens a dialog to edit the embedded
text.
private void wpdllInt1_MouseUp(object sender, MouseEventArgs e)
{
wpMouseEventArgs me = (wpMouseEventArgs)e;
IWPMemo Memo;
if (me.Editor == 2)
Memo = wpdllInt1.Memo2;
else Memo = wpdllInt1.Memo;
IWPTextCursor Cursor = Memo.TextCursor;
//This is a simple form with a lable and a textbox + a OK and cancel Button
Form2 f = new Form2();
try
{
// Set Dialog Position
93
int x = 0, y = 0;
Memo.GetXY(8, ref x, ref y);
f.StartPosition = FormStartPosition.Manual;
f.Left = me.X + x;
f.Top = me.Y + y;
// Which Button was pressed?
if (me.Button == MouseButtons.Left)
f.Text = "Left";
else if (me.Button == MouseButtons.Middle)
f.Text = "Middle";
if (me.Button == MouseButtons.Right)
f.Text = "Right";
// Possibility: get Position
// int cppos=0;
// Memo.GetPosAtXY(2, me.X + x, me.Y + y, out cppos);
// Find Field at current mouse position and open a form to edit
the field contents
IWPTextObj obj = Memo.GetObjAtXY(0,0, 1, -1);
if (obj != null)
{
f.label1.Text = obj.Name;
f.textBox1.Text = obj.EmbeddedText;
if (f.ShowDialog(this) == DialogResult.OK)
{
obj.EmbeddedText = f.textBox1.Text;
Memo.ReformatAll(false, true);
}
}
}
finally
{
f.Dispose();
}
}
4.1.1.2 S) OnShowHint
Member of WPDLLInt
Declaration C#
OnShowHint(Object Sender, int X, int Y, string Hint, ref bool Ignore);
Declaration OCX
OnShowHint(ByVal X As Long, ByVal Y As Long, ByVal Hint As String, Ignore As Boolean)
This event can be used to display a hint message, for example in the status bar of the
application. The event will be fired when the mouse hovers one of the buttons.
Private void wpdllInt1_OnShowHint(Object Sender, int X, int Y, String Hint, ref bool Ignor
{
stHint.Text = Hint;
Ignore = True;
}
94
4.1.1.2 T) OnTextObjectMouse
Member of WPDLLInt
Declaration C#
OnTextObjectMouse(Object Sender, int Editor, int State, IWPTextObj TextObj, ref bool Ignore);
Declaration OCX
OnTextObjectMouse(ByVal Editor As Long, ByVal State As Long, ByVal TextObj As WPTDynInt.
IWPTextObj, Ignore As Boolean)
This event is used for different actions the user can perform with an object:
State = 3: the use presses the middle mouse button.
State = 2: the use presses the right mouse button.
State = 1: the use presses the left mouse button.
State = 0: the user moves the mouse over the object
State = -1: the use releases the left mouse button.
State = -2: the use releases the right mouse button.
State = -3: the use releases the middle mouse button.
Using the reference to the object TextObj you can manipulate it. To switch a text frame
(TextDynamic "Premium") you can call procedure Contents_edit.
4.1.1.2 U) OnUndoChange
Member of WPDLLInt
Declaration C#
OnUndoChange(Object Sender, int Editor, int Flags)
Declaration OCX
OnUndoChange(ByVal Editor As Long, ByVal Flags As Long)
This event is triggered to let you change the enabled state of menu items which execute the
Undo / Redo methods.
Parameter "Flags" is a bitfield:
bit 1 : text is selected
bit 2 : undo is possible
bit 3 : redo is possible
Category
Display Status Information
4.1.1.2 V) OnUpdateGUI
This is the main event to update any custom toolbar and menu.
Member of WPDLLInt
Declaration C#
OnUpdateGUIEvent(Object Sender, int Editor, int UpdateFlags, int StateFlags, int PageNr, int
PageCount, int LineNr)
Declaration OCX
OnUpdateGUI(ByVal Editor As Long, ByVal UpdateFlags As Long, ByVal StateFlags As Long,
ByVal PageNr As Long, ByVal PageCount As Long, ByVal LineNr As Long)
The event can be used to show the current position in a statusbar:
95
private void wpdllInt1_OnUpdateGUI(object Sender, int Editor, int UpdateFlags, int StateFl
{
int wpa_italic = wpdllInt1.wpaGetID("Italic");
byte[] stateflags = wpdllInt1.wpaGetFlags(0); // Current editor
btItalic.Pushed =(stateflags[wpa_italic] & 2)!=0;
}
In this example we use wpaGetID to get the ID for a certain action to make the process better
to understand. In a real world application you would use wpaGetID() only once and then save
the result id in an integer property added to the button or menu class. (see example "First C#
Application" in the manual)
Note: You can use wpaSetFlags to modify certain internal states. This makes it possible to
disable internal buttons under program control.
Also see: IWPAttrInterface TextAttr;
Parameters
Editor
UpdateFlags
The bitfield UpdateFlags selects the elements of the GUI which need update:
bit 1 (1): Selection has been changed/
bit 2 (2): Undo/Redo state has been changed
bit 3 (4): Paragraph properties have been changed
bit 4 (8): Character attributes have been changed
bit 5 (16): The Layout mode was changed
bit 6 (32): Cursor position has been changed
bit 7 (64): The Readonly property was changed
bit 8 (128): The editor features/license has been changed
Usually you do not have to use this parameter. It is internally used to update
the flag array in a more effective way.
StateFlags
96
PageNr
PageCount
LineNr
VB 6 Example:
Here we took the automatically created MDI example and converted it to use TextDynamic. The
way a the toolbar is processed here is not optimal - it uses fixed names. We would recommend
to use IDs in the toolbar and use a separate array to match the button to the action.
This is the code which simply uses the original logic:
Private Sub rtfText_OnUpdateGUI(ByVal Editor As Long, ByVal UpdateFlags As Long, ByVal Sta
Dim s As String ' the returned array is a string
Dim i As Integer ' we need the index of a certain action
Dim Bytes() As Byte ' we need a bytes array to test the flags
' Retrieve the setting of all atcions
s = rtfText.wpaGetFlags(0) ' this are the flags for the current editor
Bytes = StrConv(s, vbFromUnicode) ' convert string to bytes
97
Category
Display Status Information
4.1.1.2 W) OnKeyDown
Member of WPDLLInt
Declaration C#
KeyDown(KeyEventArgs e)
Here the standard event is used.
You need to cast e to wpKeyEventArgs which contains the properties Editor, Shift, Alt
and Control.
private void wpdllInt1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if(((wpKeyEventArgs)e).Control)
MessageBox.Show("Control");
}
Declaration OCX
OnKeyDown(ByVal Editor As Long, Key As Integer, ByVal Shift As Long)
This event is triggered when the user presses a key on the keyboard.
Parameters
Editor: The editor number, 1 or 2
Key: The key board number as VK_ value
Shift: A bit field representing the state of the control keys:
1 : Shift key
2 : ALT key
4 : Ctrl key
Example VB6:
Private Sub WPDLLInt1_OnKeyDown(ByVal Editor As Long, Key As Integer, ByVal Shift As Long)
If Shift = 4 Then
' Ctrl+B
If Key = Asc("B") Then
WPDLLInt1.TextAttr.ToggleStyle (0)
' Ctrl+I
ElseIf Key = Asc("I") Then
WPDLLInt1.TextAttr.ToggleStyle (1)
' Ctrl+U
ElseIf Key = Asc("U") Then
WPDLLInt1.TextAttr.ToggleStyle (2)
2006-2009 by WPCubed GmbH, Munich, Germany
98
End If
End If
End Sub
Trouble shooting:
If your code does not work please check if you have a global short cut which reverts the
change.
4.1.1.2 X) OnKeyPress
Member of WPDLLInt
Declaration C#
KeyPress(KeyPressEventArgs e)
Here the standard event is used.
You need to cast e to wpKeyEventArgs which contains the properties Editor, Shift, Alt
and Control:
if ((wpKeyEventArgs)e).Control) ...
Declaration OCX
OnKeyPress(ByVal Editor As Long, Key As Byte)
This event is triggered when the user types on the keyboard. It receives the key as character
value.
You can use this event to implement short cuts, for example activate 'bold' when Ctrl+B is
pressed:
Example VB6 (also see OnKeyDown):
Private Sub WPDLLInt1_OnKeyPress(ByVal Editor As Long, Key As Byte)
Dim Memo As IWPMemo
If Editor = 2 Then Set Memo = WPDLLInt1.Memo2 Else: Set Memo = WPDLLInt1.Memo
If Key = 2 Then ' Ctrl B
If Memo.TextCursor.IsSelected Then
Memo.CurrSelAttr.ToggleStyle (0)
Else
Memo.CurrAttr.ToggleStyle (0) ' set bold!
End If
Key = 0
End If
End Sub
4.1.1.2 Y) OnKeyUp
Member of WPDLLInt
Declaration C#
KeyUp(KeyEventArgs e)
Here the standard event is used. You can cast e to wpKeyEventArgs which contains the properties Editor, Shift,
Alt and C ontrol.
Declaration OCX
OnKeyUp(ByVal Editor As Long, Key As Integer, ByVal Shift As Long)
This event is triggered when the user releases a key on the keyboard.
Parameters
99
Declaration OCX
OnLeaveEditor(ByVal Editor As Long)
4.1.1.2 AA) OnCompleteWord
Member of WPDLLInt
Declaration C#
OnCompleteWordEvent(Object Sender, int Editor, ref byte LastChar);
Declaration OCX
OnCompleteWord(ByVal Editor As Long, LastChar As Byte)
This event allows it to implement auto completion and makro functionality. If the user types in a
word and then presses a word delimiting character, this event is triggered. The delimiting
character will be passes as parameter LastChar. You can set it to 0 if you do not want to use it
in the text, for example if the character is a control key.
To read or update the last word use SelText. You can also use LoadFromString to insert a block
of formatted text at cursor position.
VB Example:
Private Sub WPDLLInt1_OnCompleteWord(ByVal Editor As Long, LastChar As Byte)
Dim w As String
w = WPDLLInt1.CurrMemo.SelText
If w = "mfg" Then
WPDLLInt1.CurrMemo.SelText = "Mit freundlichen Gren"
ElseIf w = "logo" Then
WPDLLInt1.TextCursor.InputImage "c:\logo.png", 0
End If
End Sub
4.1.1.2 AB) OnEnterEditor
Member of WPDLLInt
Declaration C#
Enter(EventArgs e)
Here the standard event is used. You can cast e to wpEventArgs which contains the property Editor.
Declaration OCX
OnEnterEditor(ByVal Editor As Long)
This event procedure is called after the cursor entered one of the internal editors.
100
4.1.2
Categories
Character Attributes
Character Styles
Methods to read and write the attributes, bold, italic, underlined ...
Methods to load and save the text as file, stream or string. (RTF,
XML, HTML ...)
Hyperlinks and
Bookmarks
Image Support
Callback Functions
Table Support
Mailmerge
TextDynamic CSS
strings
Document Properties
Attribute IDs
Position Markers
Lowlevel Paragraph IDs Paragraph IDs can be used to change "current" paragraph
Logical MDI Support
Printing
Reporting
4.1.2.1
Methods
IWPFieldContents.FieldAttr
IWPAttrInterface.CharAttrIndex
IWPParInterface.CharAttr
IWPParInterface.GetCharAttr
IWPParInterface.ReplaceCharAttr
IWPParInterface.SetCharAttr
IWPTextCursor.WordCharAttr
101
Methods to read and write the attributes, bold, italic, underlined ...
Description
The character styles are saved as bits inside the character attribute record. TextDynamic
supports the flags bold, italic, underline, strikeout, super script, sub script, hidden, uppercase,
lowercase, no-proof, double strikeout and protected. Two flags are reserved.
Inside the attribute record two properties are taken for all this flags, one bitfield to enable/
disable the attribute (WPAT_CharStyleON=7), a second attribute to check that a certain flag is
used (WPAT_CharStyleMask=6). The methods in this category hide the complicated handling
from the developer.
Other Methods
IWPAttrInterface.ExcludeStyles
IWPAttrInterface.GetStyles
IWPAttrInterface.IncludeStyles
IWPAttrInterface.SetStyles
IWPAttrInterface.ToggleStyle
GetFontSize
Write Property
SetFontface
SetFontSize
4.1.2.3
Properties
none
Methods
IWPEditor.GetRTFVariable
IWPEditor.SetRTFVariable
4.1.2.4
102
Events
OnCreateNewCell
Methods
IWPFieldContents.AddTable
OnEnumDataBlocks
IWPEditor.EnumDataBlocks
OnEnumParOrStyle
IWPEditor.EnumParagraphs
OnEnumTextObj
IWPEditor.EnumParSiblings
IWPEditor.EnumParStyles
IWPEditor.EnumSelParagraphs
IWPEditor.EnumTextObj
IWPTextCursor.AddTable
4.1.2.5
See Properties of
IWPDataBlock
Events
OnClickCreateHeaderFooter
(not in RTF2PDF)
Methods
IWPEditor.BlockAdd
IWPEditor.BlockAppend
IWPEditor.BlockFind
IWPEditor.FindFooter
103
IWPEditor.FindHeader
IWPTextCursor.GotoBody
IWPTextCursor.InputFooter
IWPTextCursor.InputHeader
4.1.2.6
Sections
Methods
Memo.SpecialTextAttr
IWPFieldContents.InputHyperlink
IWPMemo.GetObjAtXY
IWPTextCursor.InputBookmark
IWPTextCursor.InputHyperlink
IWPTextCursor.MoveToBookmark
Tip: You can use IWPMemo.EnumTextObj to read the url and text of all hyperlinks.
Also see: Example: Convert to HTML
4.1.2.8
104
In all cases the IWPTextObj interface is used to read and write the properties of the reference
object.
Events
OnAfterSaveImage
Methods
Memo.InsertGraphicDialog
OnBeforeSaveImage
IWPParInterface.InsertNewObject
IWPTextCursor.InputImage
IWPTextCursor.InputPicture
IWPTextObj.LoadFromFile
IWPTextObj.SetContentsID
4.1.2.9
Methods
IWPFieldContents.LoadText
IWPEditor.Save
IWPEditor.LastFileName
IWPEditor.GetPageAsMetafile
IWPEditor.SavePageAsMetafile
IWPEditor.Modified
IWPEditor.InsertGraphicDialog
IWPEditor.SaveToFile
IWPEditor.SelText
IWPEditor.Load
IWPEditor.SaveToStream
IWPEditor.Text
IWPEditor.LoadEx
IWPEditor.SaveToString
IWPEditor.LoadFromFile
IWPEditor.SaveToVar
IWPEditor.LoadFromStream
IWPParInterface.LoadFromFile
IWPEditor.LoadFromString
IWPParInterface.
LoadFromString
IWPEditor.LoadFromVar
IWPEditor.SaveAs
IWPParInterface.SaveToString
IWPPdfCreator.Print
IWPTextObj.LoadFromFile
IWPTextObj.LoadFromStream
Many methods which save text also use a boolean value to toggle between saving the complete
text/selection only.
The loading methods also use a parameter to select the insert at "cursor position" mode.
Please also note that it is possible to load inside a paragraph or cell, and it is also possible to
load the text into the "data block" which represents a header, footer, text box or footnote.
If you load and save to a blob field we recommend to use GetTextVar / SetTextVar. This works
much faster than using strings and avoids problems which are caused by unicode compression.
GetTextVar can be also used to read the binary data which should be used for an ASP
Response.
105
When using streams in .NET applications you need the Stream2WPStream utility class. It
needs to be created for each load and save operation.
System.IO.Stream str = new System.IO.MemoryStream();
Memo.SaveToStream( new WPDynamic.Stream2WPStream(str) ,false,"RTF");
str.Position = 0;
Memo.LoadFromStream(new WPDynamic.Stream2WPStream(str), true, "AUTO");
List of options possible in a "format string":
Option "-..."
codepage
12xx
utf8
onlybody
ignorefonts
ignorefonts
ize
nostyles
nonumstyles
noimages
basetext
What it does
nomergefiel
ds
nohyperlink
do not save hyperlinks
s
nobookmarks don't save bookmarks
dont save or load
novariables "RTFVariables" (also
known as "Document
Properties")
try to convert all binary
nobinary
to ASCII
nopageinfo do not save or load page
size information
ignorekeepn don't load the keepn flag
from RTF
ignorerowme do not load row merging
rge
from RTF
ignorecolla don't save table rows
which are hidden by
psedpar
WPReporter
dontaddrtfv only load those content
of RTF variables which
ariables
are present in collection
load header and footer
complete
information although we
2006-2009 by WPCubed GmbH, Munich, Germany
AN
HTM
RTF RTF
HTML
MIME
SI
L
WPT WPT
UNIC
REA WRI
WRIT
*.
*.
REA
READ WRITE
ODE
D TE
E
msg
txt
D
X
X
X
X
X
106
alwaysembed
nonumberpro
ps
nospanstyle
s
nocharstyle
s
ignorerowme
rge
dontfixattr
ignorerowhe
ight
onlyusedsty
les
onlystandar
dheadfoot
NoStartTags
abbreviated
nosectionda
ta
ignorehtml
107
X
X
X
X
Update and read out data fields in the text. (See Introduction)
Description
The mailmerge process offered by wRTF2PDF / TextDynamic Server is one of its
most popular features.
It updates the text inside certain field objects. It can also update image objects.
Since the fields are usually not deleted by the update process it is possible to update
the data later again. Mail merge is more than just search & replace.
It is also possible to read out the text in case the user has edited it. Like hyperlinks
merge fields use paired objects. One object marks the start of the field, the other the
2006-2009 by WPCubed GmbH, Munich, Germany
108
Methods
IWPFieldContents.StringValue
IWPFieldContents.ContinueOptions
IWPEditor.LabelDef
IWPEditor.AppendOtherText
IWPEditor.ShowFields
IWPEditor.CurrObj this is the field
which was added using InputField
last.
IWPEditor.DeleteParWithCondition
IWPEditor.MergeText
IWPEditor.RTFDataAppendTo
IWPTextCursor.FieldsFromTokens
(akna. "ReplaceTokens")
IWPTextCursor.InputField
IWPTextCursor.MoveToField
Note: The field markers and are usually visible. To hide the markers use
Memo.SpecialTextAttr(wpInsertpoints).Hidden = True
Also see:
Command ID 16 - Syntax Highlighting - highlight tokens, i.e. <<name>>
Command ID 17 - Token To Template Conversion - convert tokens to fields
Command ID 15 - Update ShowFields Mode - display field names instead of and .
4.1.2.11 Position Markers Category
Methods to temporarily save cursor position
Description
The markers can be used to save the position of the cursor temporarily so you can return to
that position without any delay. Markers will not change the text and do not survive load&save
operations.
Most insert methods adjust the markers automatically, so they work better than simply storing
and assigning the "CPPosition".
Properties
none
Methods
IWPTextCursor.MarkerCollect
IWPTextCursor.MarkerCollectAll
IWPTextCursor.MarkerCPPosition
IWPTextCursor.MarkerDrop
IWPTextCursor.MarkerGoto
2006-2009 by WPCubed GmbH, Munich, Germany
109
IWPTextCursor.MarkerSelect
If you just need to move back or forward in the text please also do not use "CPPosition" but
one of these methods from IWPTextCursor:
CPMoveAfterTable
CPMoveNextRow
CPMoveBack
CPMoveNextTable
CPMoveBeforeTable
CPMoveParentTable
CPMoveNext
CPMovePrevCell
CPMoveNextBand
CPMovePrevObject
CPMoveNextCell
CPMovePrevPar
CPMoveNextGroup
CPMovePrevRow
CPMoveNextObject
CPMovePrevTable
CPMoveNextPar
4.1.2.12 Lowlevel Paragraph IDs Category
Paragraph IDs can be used to change "current" paragraph
Description
When working with the IWPParInterface, Paragraph IDs make it possible to switch between
Next, Previous, Children and Parent Paragraphs.
So you can actually use the property CurrPar to access, evaluate and modify all paragraph in
the internal XML like paragraph tree.
Get ID:
IWPParInterface.GetPtr
Set ID:
IWPParInterface.SetPtr
a) previous in list (i.e. previous paragraph, cell to the left)
IWPParInterface.GetPtrPrev
b) first child or 0 (i.e. first cell in table row, first row in
table, second paragraph in cell)
IWPParInterface.GetPtrChild
c) parent or 0 (i.e parent row of cell, parent table of row)
IWPParInterface.GetPtrParent
d) next in list (i.e. next paragraph, cell to the right)
IWPParInterface.GetPtrNext
Please do not save the Ptr value to be used at a later time in the application. This can cause
severe problems when the paragraph was deleted.
Please also see the low level move methods - they provide a save way to loop all
paragraphs in the current document or text block.
4.1.2.13 Printing Category
Properties and methods for printing
Properties
2006-2009 by WPCubed GmbH, Munich, Germany
110
IWPMemo.PageSizeList
IWPMemo.PrintParameter
Methods
Select Printer
Memo.TextCommandStr(10, name).
or WPDLLInt.SelectPrinter
Start Printing:
Memo.TextCommandStr(11, range).
or IWPMemo.Print and
IWPMemo.PrintPages
Create printing cue:
WPDLLInt.BeginPrint
WPDLLInt.EndPrint
Alternatively you can use
Memo.TextCommandStr 13
and Memo.TextCommandStr ID 14
to use the optional PDF export:
IWPPdfCreator.Print
Also see:
Memo.TextCommandStr ID 34 -Print To File
Tip:
When using RTF2PDF / TextDynamic Server in DLL mode (not using the COM interfaces) this
command IDs are available:
Methods
IWPEditor.CopyToClipboard
IWPEditor.CutToClipboard
IWPEditor.PasteFromClipboard
IWPTextCursor.EnabledProtection
IWPTextCursor.SelectAll
IWPTextCursor.SelectLine
IWPTextCursor.SelectParagraph
IWPTextCursor.SelectTable
111
Methods
IWPMemo.DeleteStyle
IWPMemo.CurrStyleAttr
IWPMemo.EnumParStyles
IWPParInterface.StyleName
IWPMemo.SelectStyle
IWPTextCursor.CPStylePtr
IWPTextCursor.InputParagraph
IWPTextObj.StyleName
Memo.LoadNumberStyles
Memo.SaveNumberStyles
Memo.LoadStyleSheet
Memo.SaveStyleSheet
also see:
IWPParInterface.ParStrCommand
WPA Actions:
DiaOneStyle - edit one style
112
ParStyleSelection
- select the paragraph style list in the toolbar (see example above)
4.1.2.16 Table Support Category
In wRTF2PDF / TextDynamic Server tables are handled the same as HTML table. On table object
contains table rows which contain table cell objects. In wRTF2PDF / TextDynamic Server all this
objects internally are paragraph objects, only the property ParagraphType selects a different
mode. This makes it possible to replace an empty paragraph with a table by simply changing its
mode and adding row and cell children to it.
wRTF2PDF / TextDynamic Server supports 4 different ways to create a table by code. We offer
so many possibilities because the data which has to be placed into the table cells can come in
113
different ways and order. In general we favourize the use of a callback to fill the cell text, but
it is not always possible to callbacks. The possibility to select from different methods makes it
easy to adapt existing logic to work with wRTF2PDF / TextDynamic Server.
Method 1 - use callback:
Call TextCursor.AddTable and use the event OnCreateNewCell to format and fill the cell. If you
do not know the count of rows in advance pass 100000 and abort the creation loop inside the
OnCreateNewCell event using the variable parameter "AbortAtRowEnd".
Tip: Alternatively to the callback you can use the method ASetCellProp to modify a group of
cells after the complete table was created.
Adv a nt a ge : Table is created automatically, only cells which need modification need 'attention'.
Disa dv a nt a ge : Callback function can be difficult to read and maintain. Sometimes callback is not
possible (script languages)
Method 2 - simulate user input:
Call TextCursor.AddTable - then use the properties CPTableRowNr, CPTableColNr to "move
around" and insert text using InputString. You can also move the cursor using CPMoveNextRow,
CPMoveNextCell which would be faster.
Adv a nt a ge : Table is created automatically, only cells which need modification need 'attention'.
Disa dv a nt a ge : can be slow with large tables
Method 3 - create from top to bottom:
Use TextCursor.InputTable, then InputRowStart, as many InputCell ass needed and
InputRowEnd to close the current row. Create new row with InputRowStart and so on.
Properties
IWPParInterface.
CellCommand
Methods
IWPDataBlock.
AppendParagraph
Methods
IWPTextCursor.CPMoveNextCell
IWPParInterface.
CellName
IWPFieldContents.AddTable
IWPTextCursor.CPMoveNextTable
IWPEditor.Tables_WidthFixed
IWPParInterface.
IsColMerge
IWPEditor.Tables_WidthPC
IWPTextCursor.
CPMoveParentTable
IWPParInterface.
IsFooterRow
IWPParInterface.AppendChild
IWPTextCursor.InputCell
IWPParInterface.SetParType
IWPTextCursor.InputRowEnd
IWPReportBand.AddTable
IWPTextCursor.InputRowStart
IWPTextCursor.AddTable
IWPTextCursor.InputTable
IWPTextCursor.AppendRow
IWPTextCursor.SelectTable
IWPParInterface.
IsHeaderRow
IWPParInterface.
IWPTextCursor.CPMoveNextRow
114
IsRowMerge
IWPParInterface.
WidthTW
IWPTextCursor.
CPTableColNr
IWPTextCursor.
CPTablePtr
IWPTextCursor.
CPTableRowNr
IWPTextCursor.
CombineCellHorz
IWPTextCursor.SelectTableColumn
IWPTextCursor.
CombineCellVert
IWPTextCursor.SetTableLeftRight
IWPTextCursor.
CPMoveAfterTable
IWPTextCursor.TableDelete
IWPTextCursor.SelectTableRow
IWPTextCursor.TableClear
IWPTextCursor.
CPMoveBeforeTable
Event
OnCreateNewCell
Methods to quickly modify an existing table without user interaction:
IWPTextCursor.ExitTable
IWPTextCursor.TableSplit
IWPTextCursor.TableSort
IWPTextCursor.ASetCellProp
IWPTextCursor.MergeCellHorz
IWPTextCursor.MergeCellVert
IWPTextCursor.ASetCellStyle
Also available:
TextCommand(13) combines all adjacent tables. Returns the count of deleted tables.
TextCommand(14) tries to create merged cells for cells which are wider than the others in a
column. Returns the count of changed tables.
Methods
IWPAttrInterface.GetWPCSS
IWPParInterface.ParWPCSS
IWPAttrInterface.SetWPCSS
Also see:
SelectStyle
LoadNumberStyles
SaveNumberStyles
LoadStyleSheet
SaveStyleSheet
115
4.1.3
IWPMemo / IWPEditor
I W PEditor also publishes other interfaces, such as TextCursor. This interface contains
the method to move the cursor and to insert and create text, text boxes and tables.
You can use Memo.Statistic to retrieve information about the count of words, lines
and pages.
116
Properties
ActiveText
Methods
Activate
AutoZoom
AppendOtherText
ColorDesktop
BlockAdd
ColorHighlight
BlockAppend
ColorHighlightText
BlockFind
ColorPaper
Clear
CurrAttr
ClientToScreen
CurrBand
CopyToClipboard
CurrentZooming
CutToClipboard
CurrGroup
DebugShowParProps
CurrObj
DeleteLeadingSpace
CurrPar
DeletePage
CurrParAttr
DeleteParWithCondition
CurrSelAttr
DeleteStyle
CurrSelObj
DeleteTrailingSpaces
CurrStyle
EnumDataBlocks
CurrStyleAttr
EnumParagraphs
DefaultIOFormat
EnumParSiblings
EditingMode
EnumParStyles
Focussed
EnumSelParagraphs
FormCompletion
EnumTextObj
GUIMode
FindFooter
Hidden
FindHeader
InitialDir
GetMouseXY
LabelDef
GetNumberStyle
LastFileName
GetObjAtXY
LayoutMode
GetPageAsMetafile
Modified
GetPosAtXY
PageSize
GetRTFVariable
PageSizeList
GetXY
PrintParameter
InsertGraphicDialog
Readonly
Load
SelText
LoadEx
ShowFields
LoadFromFile
Text
LoadFromStream
TextCursor
LoadFromString
TextReadFormat
LoadFromVar
Methods
117
TextWriteFormat
TopOffset
WordWrap
Zooming
DefaultAttr
4.1.3.1
Properties
4.1.3.1 A) ActiveText
Declaration
IWPDataBlock ActiveText;
Description
This is a IWPDataBlock reference to the current (active) text layer. This can be the body text
or a header or footer text. If you have a premium license this can be also the text of a footnote
or the text inside of a text box. To make a certain text block active set its property
WorkOnText to true.
4.1.3.1 B) TextAttr
Declaration
IWPAttrInterface TextAttr;
Description
This is the interface to the change the current writing (CurrAttr) attribute of the active editor
unless text is selected.
In case text has been is selected the properties of the selected text (CurrSelAttr) will be
updated.
To change paragraph attributes please use CurrPar.
This property is used best to apply and read the text attributes to implement a custom toolbar.
Example:
private void wpdllInt1_OnUpdateGUI(
object Sender,
int Editor,
int UpdateFlags,
int StateFlags,
int PageNr,
int PageCount,
int LineNr)
{
string n = "";
wpdllInt1.Memo.TextAttr.GetFontface(ref n);
FontCombo.Text = n;
}
If a function of TextAttr returns FALSE this means the default attribute is used for this
property.
The default text attributes can be changed in Memo.DefaultAttr.
118
IMPORTANT:
Memo.TextAttr provides either a reference to CurrAttr or to CurrSelAttr, depending on the
state of TextCursor.IsSelected. Please note, that an initialization before the selection
process will cause the wrong interface to be provided.
This will code not modify the attribute of "some text":
IWPMemo Memo = wpdllInt1.Memo;
IWPTextCursor TextCursor = Memo.TextCursor;
IWPAttrInterface Attr = Memo.TextAttr;
bool ok = false;
int cp = TextCursor.MarkerDrop(0);
// Use FindText.- If "MoveCursor=false", the text will be selected
TextCursor.FindText("some text", true, false, false, false, ref ok);
if (ok)
{
Attr.Clear();
Attr.SetFontface("Arial");
}
TextCursor.MarkerGoto(true, cp);
4.1.3.1 C) CurrAttr
Declaration
IWPAttrInterface CurrAttr;
Description
This is the interface to the current writing attribute of the active editor.
119
You can use it to change character attributes, such as the font name.
To change paragraph attributes please use CurrPar.
Please also see TextAttr and the topic "Font Attributes".
4.1.3.1 D) CurrSelAttr
Declaration
IWPAttrInterface CurrSelAttr;
Description
This interface can be used to change the attributes of the text which is currently selected.
Also see TextAttr!
4.1.3.1 E) CurrParAttr
Declaration
IWPAttrInterface CurrParAttr;
Description
This is the interface to manipulate the text attributes of the text in the current paragraph
(the paragraph the cursor is located within).
You can use this interface to change the font of all characters in the paragraph. If you only
need to change the attribute of certain characters in the paragraph use either CharAttr or
SetCharAttr.
Example: The current paragraph should be bold and use the font "Verdana" with 10 pt.
IWPAttrInterface parattr = Memo.CurrParAttr;
parattr.IncludeStyles(1);
parattr.SetFontface("Verdana");
parattr.SetFontSize(10);
Do not use this interface to modify the attributes of the paragraph itself, such as the indent or
also the default font for a paragraph.
4.1.3.1 F) CurrPar
Declaration
IWPParInterface CurrPar;
Description
This is the interface to manipulate the current paragraph. This is the paragraph the cursor
(insertion marker) is located within.
When currently text is selected, CurrPar can be used to modify the attributes of the
selected text.
You can use this interface to read the text, to manipulate the text and to change the
attributes of the paragraph. To change the attributes of all characters in this paragraph use
the interface provided by CurrParAttr. If you only need to change the attribute of certain
characters use either CharAttr or SetCharAttr.
120
Example:
To define a font + size which is used for each new documents please use
Command ID 18 - Set default font and size
4.1.3.1 H) CurrBand
Declaration
WPReportBand CurrBand;
121
Description
Reserved
4.1.3.1 I) CurrentZooming
Declaration
int CurrentZooming;
Description
This is the current zooming value. It is automatically adjusted when auto zooming is enabled.
4.1.3.1 J) CurrGroup
Declaration
IWPReportBand CurrGroup;
Description
Reserved
4.1.3.1 K) CurrObj
Declaration
IWPTextObj CurrObj;
Description
This is the interface to the object interface of the current object. The current object is the
object which has been inserted last. Since the mail merge facility also uses text objects, you
can also use CurrObj to manipulate fields created by InputField
This C# code inserts a horizontal line and then changes it's color to red.
wpdllInt1.TextCursor.InputObject(TextObjTypes.wpobjHorizontalLine,"","",0);
IWPTextObj obj = wpdllInt1.CurrObj;
if(obj!=null)
obj.IntParam = wpdllInt1.ToRGB(Color.Red);
Cursor As IWPTextCursor
Field As IWPTextObj
Cursor = WPDLLInt1.Memo.TextCursor
Field = WPDLLInt1.Memo.CurrObj
122
IWPTextObj CurrSelObj;
Description
This interface will be null unless an object is selected. If the property is != null you can use it
to manipulate and examine the selected object.
Load new image data into the currently selected object:
IWPTextObj selobj = wpdllInt1.CurrSellObj;
if ((selobj!=null)&&
(selobj.ObjType==TextObjTypes.wpobjImage))
{
selobj.LoadFromFile("c:\\Test.bmp");
}
4.1.3.1 M) CurrStyle
Declaration
IWPParInterface CurrStyle;
Description
This property can be used to manipulate the current style.
The "current style" is the style which has been added last or which was located by function
SelectStyle()
Please note that the same interface type is used for styles and for paragraphs. This has to do
with the internal implementation of paragraphs which inherit all properties and methods of
styles.
When you use a IWPParInterface to manipulate a style the methods which change the text will
have no effect. But you can use the properties, i.e. IndentLeft to change the left indent
defined by this style.
Of course it is possible to use WPCSS strings to read the properties of a paragraph and assign
to a style and vice versa.
VB.NET example:
Memo.CurrStyle.Alignment = 1 '0=lLeft, 1=Center, 2=Right, 3=Justified
Please note that you need to execute ReformatAll(true, true) after you have changed a style.
4.1.3.1 N) CurrStyleAttr
Declaration
IWPAttrInterface CurrStyleAttr;
Description
This interface is used to change the character attributes defined by the current style. Also see
CurrStyle and SelectStyle.
VB.NET example:
Memo.CurrStyleAttr.SetFontface("Courier New")
Memo.CurrStyleAttr.SetFontSize("12")
Notes:
123
You need to execute ReformatAll(true, true) after you have changed a style.
The character attributes defined by a style will be only used by text which does not override
these attributes. When you insert new text you can clear all writing attributes using Memo.
CurrAttr.Clear().
4.1.3.1 O) LabelDef
Interface to display labe sheet and change label setup
Declaration
IWPLabelDef LabelDef;
Description
Using the LabelDef interface you can quickly print labels. It is also possible to preview the label
sheets just like they would be printed. It is even possible to edit the text on the label sheets.
You can also specify the lablel number to start with. All parameters of a label can be specified,
using CM or Inch values.
This C# code copies the current text (it expects this to be an address, about 5 lines) 30 times
- each one on a new page. Then it activates the other text and activates the label display for
this text.
124
}
// and display the label sheet
wpdllInt1.Memo.RTFDataSelect("LABELS");
// and activates label display
wpdllInt1.Memo.LabelDef.Caption = "WPCubed GmbH";
wpdllInt1.Memo.LabelDef.Active = true;
}
else
// switch back to normal text
wpdllInt1.Memo.RTFDataSelect("@@FIRST@@");
}
Category
Mailmerge
4.1.3.1 P) LastFileName
Declaration
string LastFileName;
Description
The last file name which was used for file load or save.
4.1.3.1 Q) PageSize
Declaration
IWPPageSize PageSize;
Description
You can use this interface to modify the page size information stored with the document.
All properties are twips values. 1 twip = 1/1440 inch.
The method SetPageWH can be used to set multiple values. The value -1 means the current
value is unchanged.
wpdllInt1.Memo.PageSize.SetPageWH(-1, -1, 720, 720, 720, 720);
To make the current page size the default for new documents use Memo.TextCommandStr
(19,0,"");
wpdllInt1.Memo.TextCommandStr(19, 0, "");
4.1.3.1 R) PageSizeList
Declaration
IWPPageSizeList PageSizeList;
Description
The page size list allows it to provide a different page size (and margins) for each page in the
document. Together with method GetPageAsMetafile this list makes it easy to display or print a
document in a list of rectangular areas. The PageSizeList can be switched on and off using its
property "Active". When it is active the page sizes defined in the document are overridden and
the event OnMeasurePage is not been triggered.
125
Usually you have to execute ReformatAll to update the screen and layout information. (Not
required by toggling "Active" or changing the Resolution.
4.1.3.1 S) PrintParameter
Declaration
IWPPrintParameter PrintParameter;
Description
This interface provides access to special printing options. You can print only the odd or even
pages.
4.1.3.1 T) SelText
Declaration
string SelText;
Description
The property can be used to read the currently selected text as string. It does not save any
special characters (such as object anchors) or formatting information. It works a lot faster
than SaveToString since it does not have to use the text writer classes. You can also assign a
value to this property to insert a string.
SelText can be used within the event OnCompleteWord to implement text macros.
Note: To insert RTF or HTML formatted strings instead of SelText use LoadFromString.
Also see
Memo.TextCommandStr ID 35/36/37 to change and read paragraphs, lines and words at cursor
position.
4.1.3.1 U) Text
Get/Set text as unicode string
Declaration
string Text;
When Reading:
Retrieves the text in the editor as unicode string. Table cells will be delimited with TAB
caracters, each paragraph and row will be closed with \r\n.
Use SaveToString to retrieve the text as RTF, ANSI, HTML or WPT string.
When Writing:
Load the text from a unicode string. Use LoadFromString to load the text as RTF, ANSI, HTML
or WPT string. LoadFromString(string,true,"AUTO") will detect the format automatically.
This property works differently to Text and Text2 which always save formatting information and
is able to load formatted text.
4.1.3.1 V) TextCursor
Methods and properties to insert text and change current position.
Declaration
IWPTextCursor TextCursor;
Description
This is the interface to the current cursor object.
126
The cursor interface contains most methods to create text and the properties which read and
modify the current position in the text.
Please refer to IWPTextCursor for a list of methiods.
.NET: We recommend to assign the value of "TextCursor" to a variable and call wpdllint.
ReleaseInt( variable ) when the reference is not any longer required.
4.1.3.1 W) SpecialTextAttr
Declaration
IWPCharacterAttr SpecialTextAttr([In] SpecialTextSel Select);
Description
The method SpecialTextAttr() makes it possible to modify the appearance of hyperlinks, fields
and other text. It provides you with a reference to the interface IWPCharacterAttr to change
several properties. The parameter "Select" may have the following values:
0 :
1 :
2 :
3 :
4 :
5 :
6 :
7 :
8 :
9 :
10:
11:
Example:
WPDLLInt1.SpecialTextAttr(SpecialTextSel.wpInsertpoints).Hidden = true;
WPDLLInt1.SpecialTextAttr(SpecialTextSel.wpInsertpoints).CodeTextColor = 0;
4.1.3.2
Methods
4.1.3.2 A) AppendOtherText
Append the contents of second editor
Declaration
void AppendOtherText([In] int Mode);
Description
This procedure appends the text stored in the respective other editor (in case two editors are
active in the control). You can use this methods with mail merge to create a long text with
multiple letters.
To use AppendOtherText please initialize TextDynamic in the double editor mode, using
SetEditorMode(1,...).
Alternatively you can use RTFDataAppendTo.
Parameter "Mode":
0: simply append the other text.
127
Category
Mailmerge
4.1.3.2 B) BlockAdd
Creates or selects a header or footer text layer
Declaration
IWPDataBlock BlockAdd([In] DataBlockKind Kind, [In] DataBlockRange Range, [In]
string Name, [In] int SectionID);
Description
This method is used to select an existing (with matching Range/Name) or create a new header
or footer text block. An interface to the created block is returned as IWPDataBlock reference.
This method works similar as TextCursor.InputHeader and TextCursor.InputFooter but will not
modify the cursor position.
128
4.1.3.2 C) BlockAppend
Creates a new header or footer layer
Declaration
IWPDataBlock BlockAppend([In] DataBlockKind Kind);
Description
This method is used to create a new header or footer text block. An interface to the created
block is returned as IWPDataBlock reference so you can modify the properties.
Note: Please don't forget to call ReleaseInt() with the returned interface at the end of your
code.
Dim header As IWPDataBlock
129
130
4.1.3.2 H) PasteFromClipboard
Declaration
void PasteFromClipboard();
Description
Paste text from clipboard.
Category
Standard Editing Commands
4.1.3.2 I) DebugShowParProps
Display messagebox with paragraph properties
Declaration
void DebugShowParProps();
Description
This method can be used to check which attributes are used by the current paragraph.
TextDynamic:
A Message box will be displayed which displays the attributes and the attributes of
ancestor paragraphs and styles.
RTF2PDF:
A debug message is sent which includes the attributes and the attributes of ancestor
paragraphs and styles
4.1.3.2 J) DeleteLeadingSpace
Declaration
void DeleteLeadingSpace([In] bool EmptyFields, [In] bool InFirstPar);
Description
This procedure deletes all empty paragraphs at the beginning of the text. Also see methods
see DeleteTrailingSpaces and DeleteParWithCondition.
Parameters
InFirstPar
EmptyFields
4.1.3.2 K) DeletePage
Deletes a certain logical page
Declaration
void DeletePage([In] int PageNr);
Description
The text has to be reformatted for this method to work. The procedure will try to delete the
text which is displayed on the given page.
131
4.1.3.2 L) DeleteParWithCondition
Extensible function to delete paragraphs
Declaration
void DeleteParWithCondition([In] int Condition);
Description
This method has been reserved for intelligent paragraph deletion.
The following Conditions are supported:
0 : If a paragraph contains empty merge field(s) and no text, it is deleted. You can use it when
doing mailmerge to erase empty lines.
New: You can hide a paragraph temporarily if you add the value 256 to the mode id.
If you also add 512 the previously already hidden paragraphs stay hidden.
Use the mode 257 to show all paragraphs again.
Category
Mailmerge
4.1.3.2 M) DeleteStyle
Declaration
void DeleteStyle([In] string StyleName);
Description
This method deletes the style with the given name.
Category
Paragraphstyle Support
4.1.3.2 N) DeleteTrailingSpaces
Declaration
void DeleteTrailingSpaces([In] bool EmptyFields);
Description
This method deletes spaces and empty paragraphs at the end of the text. Also see methods
see DeleteLeadingSpace and DeleteParWithCondition.
Parameters
EmptyFields
4.1.3.2 O) EnumDataBlocks
Declaration
void EnumDataBlocks([In] int EventParam);
Description
With EnumDataBlocks the event OnEnumDataBlocks will be called for each text layer in the
document.
Parameters
EventParam
132
Category
Callback Functions
4.1.3.2 P) EnumParagraphs
Declaration
void EnumParagraphs([In] bool OnlyActiveText, [In] int EventParam);
Description
The event OnEnumParOrStyle will be called for all paragraphs in the Document.
You can use TextCursor.CheckState(10) to force the PropChanged event which is required to
update a data bound control.
Parameters
OnlyActiveText
EventParam
Example:
Make all "bold" text "italic". This uses the method IWPParInterface.ParCommand.
133
Description
Enumerate all paragraphs in current paragraph nesting level and call event OnEnumParOrStyle.
This are the siblings of the current paragraph. The function can be used if you need to check or
modify all paragraphs in a cell.
Parameters
FromStart
EventParam
Category
Callback Functions
4.1.3.2 R) EnumParStyles
Declaration
void EnumParStyles([In] int EventParam);
Description
The event OnEnumParOrStyle will be called for all paragraph styles which are defined.
Parameters
EventParam
To save the styles to a file use TextComandStr(28, filename) - to load the file use
TextComandStr(29, filename)
Category
Callback Functions
Paragraphstyle Support
4.1.3.2 S) EnumSelParagraphs
Declaration
int EnumSelParagraphs([In] bool OnlyCompletePars, [In] bool ControlParsToo, [In]
int EventParam);
Description
The event OnEnumParOrStyle will be called for the selected paragraphs.
Parameters
OnlyCompletePars
ControlParsToo
EventParam
Category
Callback Functions
4.1.3.2 T) EnumTextObj
Declaration
int EnumTextObj([In] TextObjTypes ObjType, [In] bool OnlyActiveText, [In] string
2006-2009 by WPCubed GmbH, Munich, Germany
134
ObjType
OnlyActiveText
NameStartsWith
EventParam
Category
Callback Functions
4.1.3.2 U) SelectStyle
Declaration
void SelectStyle(string StyleName);
Description
Selects a certain style. The style can be then manipulated through interface CurrStyle and
CurrStyleAttr.
VB.NET example:
'initialize the reference to "Memo"
Dim Memo As IWPEditor
Memo = Me.WpdllInt1.Memo
'Create a new header (for all pages) and place the cursor inside
Memo.TextCursor.InputHeader(0, "", "")
'create a text style called "myStyle", this is not used for the actual header,
confusing isn't it
'Selects a certain style. The style can be then manipulated through interface
CurrStyle.
Memo.SelectStyle("myStyle")
'This interface is used to change the character attributes defined by the
current style.
Memo.CurrStyleAttr.SetFontface("Times New Roman")
Memo.CurrStyleAttr.SetFontSize("32")
'Now set paragraph attributes
Memo.CurrStyle.Alignment = 1 '0=lLeft, 1=Center, 2=Right, 3=Justified
'now apply this style to the current paragraph
Memo.CurrAttr.Clear()
135
136
Level
137
Special Mode: If ID>0 the value -1000 will cause the deletion of this style.
This is the outline level between 1 and 9
0 selects simple numbering (not nestable)
Returns
IWPNumberStyle reference or null if undefined.
You can also use it to modify the outline (level<>0)
Example:
IWPNumberStyle NStyle = rtF2PDF1.Memo.GetNumberStyle(0, 0, 1);
NStyle.ASet((int)WPAT.NumberMODE,1); // Make it Arabic 1. 2. 3. ...
rtF2PDF1.ReleaseInt(NStyle);
Note: Please don't forget to call ReleaseInt() with the returned interface at the end of your
code.
4.1.3.2 AC) GetObjAtXY
This method searches for an object at a certain x,y position.
Declaration
IWPTextObj IWPTextObj GetObjAtXY([In] int X, [In] int Y, [In] int TypeMask, [In]
int Mode);
Description
The Result is a reference to the IWPTextObj interface. If no object was found the result will be
null.
This code locates the hyperlink at the mouse position:
private void wpdllInt1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
IWPMemo Memo = wpdllInt1.CurrMemo;
IWPTextObj obj = Memo.GetObjAtXY(e.X, e.Y, 0, 2);
}
Parameters
X
Mode
Category
Hyperlinks and Bookmarks
138
Mode
out
CPPos
For .NET Drag and Drop set the property AllowDrop to true.
Then you need two event handlers:
private void wpdllInt1_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
wpdllInt1.TextCursor.InputText("Dropped text");
wpdllInt1.Reformat();
}
private void wpdllInt1_DragOver(object sender, System.Windows.Forms.DragEventArgs e)
{
int pos;
if (wpdllInt1.Memo.GetPosAtXY(0,0,-1, out pos))
{
139
wpdllInt1.Memo.TextCursor.CPPosition= pos;
e.Effect=DragDropEffects.All;
else e.Effect=DragDropEffects.None;
}
4.1.3.2 AE) GetRTFVariable
Declaration
string GetRTFVariable([In] string Name);
Description
Retrieves the value of a certain string variable which was stored with the document.
Category
Document Properties
4.1.3.2 AF) GetXY
Retrieves different X,Y positions from the editor
Declaration
void GetXY([In] int Mode, [In, Out] ref int X, [In, Out] ref int Y);
Description
You can use this method to receive different coordinate values. Mode selects the property to
read:
0: X and Y are the position of the cursor in editor X,Y coordinates.
1: X and Y are the position of the cursor in client X,Y coordinates.
2: X and Y are the position of the cursor in screen X,Y coordinates.
3: X and Y are the position of the cursor on the page in twips (inch /1440).
4 : X and Y are the baseline of the current paragraph in client coordinates.
5 : X and Y are the baseline of the current paragraph in screen coordinates.
6 : X and Y are the upper left corner of the selected text in screen coordinates.
7 : X and Y are the lower right corner of the selected text in screen coordinates.
8 : X and Y are the upper left corner of editor in screen coordinates.
9 : X and Y are the lower right corner of the editor in screen coordinates.
10: Get horizontal and vertical scroll position.
11: Set horizontal and vertical scroll position. Use value=-1 to not set the X or Y scrolling.
12: X and Y are the width and height of the virtual desktop inside the editor.
13: X and Y are the width and height of the text.
14: X and Y are physical margin used by the current printer. (PrintXOffset, PrintYOffset)
15: X and Y are the current logical horizontal and vertical resolution used by the rendering
engine. Usually this value is 600. (CurrentXPixelsPerInch, CurrentYPixelsPerInch)
16: X and Y are the current mouse cursor position.
Example VB6:
Dim x As Long
Dim y As Long
Memo.GetXY 2, x, y
Category
Coordinate Conversion
4.1.3.2 AG) LoadFromFile
Declaration
bool LoadFromFile([In] string filename, [In] bool Insert, [In] string FormatStr
);
140
Description
Load a file into this editor.
Parameters
filename The name of the file
Insert
true to insert the file at the cursor position, otherwise the complete text is replaced.
FormatSt
Select the reader and set options.
r
This VB.NET example code display a file open dialog and loads the selected file into the editor.
Dim OpenFileDialog As New OpenFileDialog
OpenFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.
MyDocuments
OpenFileDialog.Filter = "Textfiles (*.rtf,*.wpt,*.htm,*.html)|*.rtf;*.wpt;*.
htm;*.html|All Files (*.*)|*.*"
If (OpenFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK)
Then
Dim FileName As String = OpenFileDialog.FileName
Dim memo As WPDynamic.IWPMemo
memo = WpdllInt1.Memo
If (memo Is Nothing) Or _
Not memo.LoadFromFile(FileName, False, "AUTO") Then
MessageBox.Show("Cannot load " + FileName)
End If
End If
Tip: In ASP projects you can use Server.MapPath(".") to get the current directory.
if (!wpdllint1.Memo.LoadFromFile(Server.MapPath(".") + "test.rtf",true,""))
wpdllint1.TextCursor.InputText("Cannot open file TEST.RTF");
141
Parameters
Stream
Insert
true to insert the file at the cursor position, otherwise the complete text is replaced.
FormatS
Select the reader and set options. see FormatStrings.
tr
Category
Load and Save
4.1.3.2 AI) LoadFromString
Declaration
bool LoadFromString([In] string Data, [In] bool Insert, [In] string FormatStr);
Description
Load data into this editor.
Parameters
Data - The text to be "loaded".
Insert - true to insert the file at the cursor position, otherwise the complete text is replaced.
FormatStr - Select the reader and set options. See FormatStrings.
Tip: In many cases using LoadFromVar will be more efficient:
editorToPreview.Memo.LoadFromVar(
editorToBePreviewed.Memo.SaveToVar(false, "RTF"),
false, "RTF");
Category
Load and Save
4.1.3.2 AJ) LoadFromVar
Loads the data from a variant variable
Applies to
IWPMemo
Declaration
bool LoadFromVar([In, MarshalAs(UnmanagedType.Struct)] object Data, [In] bool
Insert, [In] string FormatStr);
Description
This method loads or inserts the contents of a variant - usually a variant array of bytes. You
can use this method to load the data saved by SaveToVar.
Note: variant array of bytes work much more efficient to store RTF data than strings.
C# Example - copy text from one editor to another using SaveToVar/LoadFromVar
object currtext = wpdllInt1.Memo.SaveToVar(false, "WPT");
wpdllInt2.Memo.LoadFromVar(currtext, false, "AUTO");
Parameters
142
SelectionOnly
FormatStr
This VB.NET example code display a file save dialog and saves the text in the editor:
Dim SaveFileDialog As New SaveFileDialog
SaveFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.
MyDocuments
SaveFileDialog.Filter = "Textfiles (*.rtf,*.wpt,*.htm,*.html)|*.rtf;*.wpt;*.
htm;*.html|All Files (*.*)|*.*"
If (SaveFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK)
Then
Dim FileName As String = SaveFileDialog.FileName
If Not WpdllInt1 Is Nothing Then
Dim memo As WPDynamic.IWPMemo
memo = WpdllInt1.Memo
If Not memo.SaveToFile(FileName, False, "AUTO") Then
MessageBox.Show("Cannot write " + FileName)
End If
End If
End If
If you want to send an HTML e-mail from Outlook You can use this VB code:
143
Category
Load and Save
4.1.3.2 AL) SaveToStream
Declaration
bool SaveToStream([In] object Stream, [In] bool OnlySelection, [In] string
FormatStr);
Description
Save data to a stream.
.NET: The stream converter Stream2WPStream must be re-created for each load and save
operation!
Example:
System.IO.Stream str = new System.IO.MemoryStream();
Memo.SaveToStream( new WPDynamic.Stream2WPStream(str) ,false,"RTF");
str.Position = 0;
Memo.LoadFromStream(new WPDynamic.Stream2WPStream(str), true, "AUTO");
Tip: You can use SaveToStream to load into an .NET array of bytes:
144
145
The name of the fields to be merged. You can use the wildcard * to process a group
of fields, i.e. MergeText("CustomerDB.*").
Please also see Category Mailmerge and the "Mail merge API introduction".
4.1.3.2 AP) Print
Declaration
void Print();
Description
Print the text. Optionally use BeginPrint/EndPrint to print several texts into one printing cue.
Note: When using Visual Basic 6, instead of method "Print" please use PrintPages 1,999999.
Note: You can also use Memo.TextCommandStr(11, range). to start printing. Here you can
select odd or even pages and also pass a pages list.
New: The standard version of the product RTF2PDF / TextDynamic Server now also prints (but
not threadsavely).
2006-2009 by WPCubed GmbH, Munich, Germany
146
Category
Printing
4.1.3.2 AQ) PrintPages
Declaration
void PrintPages([In] int FromPage, [In] int ToPage);
Description
Print a range of pages. Optionally use BeginPrint/EndPrint to print several texts into one printing
cue.
New: The standard version of the product RTF2PDF / TextDynamic Server now also prints (but
not threadsavely).
Category
Printing
4.1.3.2 AR) PtrCommand
Declaration
int PtrCommand([In] int PtrComID, [In] int PtrValue, [In] int param, [In] string
StrParam);
Description
Reserved for custom enhancements.
4.1.3.2 AS) Reformat
Declaration
void Reformat();
Description
Formats the text the next time the application is idle. Formatting is required after the creation
of text, for example using TextCursor.InputString.
Please also see TextCommand ID 18, here we added options to force reformat and spellcheck.
4.1.3.2 AT) ReformatAll
Declaration
void ReformatAll([In] bool InitAll, [In] bool Repaint);
Description
Formats the text at once.
Optionally initializes (= calculate the font heights) and paints it.
Formatting is required after the creation of text, for example using TextCursor.InputString.
Initialization is only required after paragraph styles have been updated, otherwise the engine
knows which paragraphs have to be initialized.
The formatting is performed at once, not in the next idle phase. If called in a loop, this can slow
down the program significantly!
147
Therefore please also see TextCommand( 18, ..) which is used to start the reformat process
in the next idle phase. Especially when used inside of events, this would be the better way to
initialize the text.
Unique ID
Caption
Short Caption
Category
Logical MDI Support
4.1.3.2 AV) RTFDataAppendTo
Declaration
void RTFDataAppendTo([In, MarshalAs(UnmanagedType.BStr)] string Name, [In] int
Options);
Description
This method can be used to append the current text to an existing or new text buffer. The
name of the buffer is specified as parameter one.
When you are done with the merging you can switch to the result buffer using RTFDataSelect.
This C# code copies the current text (it expects this to be an address, about 5 lines) 30 times
- each one on a new page. Then it activates the other text and activates the label display for
this text.
private void LabelEdit_Click(object sender, System.EventArgs e)
{
LabelEdit.Checked = !LabelEdit.Checked;
if (LabelEdit.Checked)
{
// Delete the label text
wpdllInt1.Memo.RTFDataDelete("LABELS");
// Make 30 copies
for (int i = 0; i < 30; i++)
{
wpdllInt1.Memo.RTFDataAppendTo("LABELS", 1);
}
// and display the label sheet
wpdllInt1.Memo.RTFDataSelect("LABELS");
// and activates label display
2006-2009 by WPCubed GmbH, Munich, Germany
148
Please avoid to append the text to the source element (itself) - this causes the text to
grow exponentially.
Parameters:
Name
Options
The name of the destination RTF data element. Use any name or @@FIRST@@
for text in first editor and @@SECOND@@ for text in second editor (unless
RTFDataSelect was used to display different element).
This is a bit-field
1: Create a new page break before each copy
2: Don't copy merge fields
4: Don't copy bookmark tags
8: Don't copy images
64: Create a new section
128: assign page format of the source to the section
256: set the Reset-Outline-Numbers flag for the new section
Category
Logical MDI Support
Mailmerge
4.1.3.2 AW) RTFDataDelete
Declaration
void RTFDataDelete([In, MarshalAs(UnmanagedType.BStr)] string Name);
Description
Deletes a document with a given name.
Please make sure you select another, valid document before the deletion.
We recommend to not delete the last RTFData object but to clear it.
Category
Logical MDI Support
Logical MDI Support
4.1.3.2 AX) RTFDataSelect
Declaration
bool RTFDataSelect([In] string Name);
Description
Selects a document stored by the TextDynamic controller.
The name of the standard document used be editor #1 is "@@FIRST@@", for editor #2 it is
"@@SECOND@@". But it is possible to add additional documents using RTFDataAdd.
Category
Logical MDI Support
149
150
Category
Load and Save
4.1.3.2 AZ) SavePageAsMetafile
Declaration
bool SavePageAsMetafile(int PageNr, string : Filename, int Options, int
BackgroundColor);
Description
Creates a EMF file from a certain page. Also see method GetPageAsMetafile.
Also see the commands to create bitmap files (BMP, PNG and TIFF).
Parameters:
PageNr :
The number of the page to be saved. The first is 0.
Filename:
The enhanced metafile (*.EMF) file to be created.
Options:
a bit field:
4: display a frame for the page margins
8: optimized for PDF export. We recommend to always set this bit!
16: also print selection marker
32: do not print watermarks
64: do not print header and footer
128: do not print images
256: print table grid lines.
512: Export embedded meta-files as bitmaps
BackgroundColor: A background color as RGB value
Example:
// Create a preview (thumbnail) of the
document INSIDE the
// document. We use a temporary file.
string tempfile = System.IO.Path.GetTempFileName();
string emf_tempfile = tempfile + ".EMF";
try
{
// Format the text, othewise SavePageAsMetafile does not work
Memo.ReformatAll(true,false);
// save this page as image
Memo.SavePageAsMetafile(0,emf_tempfile,8,0);
// and insert it here
TextCursor.InputText("Preview of this page :");
151
TextCursor.InputImage(emf_tempfile,0);
Memo.CurrObj.Frame = 1;
// Scale to 30 % of the original size
Memo.CurrObj.ScaleSize(0,0,30);
// The preview does not contain the image which jsut has been inserted
// so recreate the image file and load it in the image aian
Memo.ReformatAll(false,false);
Memo.SavePageAsMetafile(0,emf_tempfile,8,0);
Memo.CurrObj.Contents_LoadFromFile(emf_tempfile);
}
finally
{
// Delete the temporary files
System.IO.File.Delete(emf_tempfile);
System.IO.File.Delete(tempfile);
}
Category
Load and Save
4.1.3.2 BA) GetPageAsBitmap
Declaration
int GetPageAsBitmap(
int PageNr;
string filename;
int Xres;
int Yres;
int Mode);
Description
This API controls the RTF to Bitmap conversion of wRTF2PDF / TextDynamic Server. It is
possible to save certain pages as BMP or PNG files.
There is also the option to export to multipage TIFF files - with TextDynamic this requires
the "Premium" or "Server" License, with wRTF2PDF TextDynamic Server it requires "Server"
License!
Usually this method is used to create monochrome TIFF files for storage and fax.
Those files can also be dithered, to make colored text and images better visible.
Note: When the operation fails a negative value is returned.
Parameters:
PageNr - an Integer. This is the page which should be exported.
filename - a string. The name of the fiel which should be created. (In TIFF mode it has to be
"last" when the last page was added)
Xres, Yres - two integers. The resolution for the created bitmap.
Mode - a bitfield.
152
The first 4 bits are reserved to store the bit depth. Currently only 1 and 24 are supported
the next bits select the export mode
A) - Format Selection
256 - select PNG format
512 - select TIFF format (requires special license).
Create a new file if the filename is <> "". Otherwise add a new page.
otherwise a BMP filer is written
B) Options for TIFFS
1024 - used with TIFF, close the open TIFF file.
You can also pass "last" as filename with Options = 0 .
2048 - used for monochrome TIFF files only. Switch on dithering. (new in V1.61)
C) Rendering options
4096 - also display selection
8192 - do not print watermarks
16384 - do not print header and footer
32768 - do not print images
65536 - display grid lines for tables
Example - Create multipage TIFF file:
IWPMemo Memo = wpdllInt1.Memo;
// Open Tiff (Mode=512). Bit depth=1
Memo.GetPageAsBitmap(0, "c:\\rtftotiff.tif", 300, 300, 512+1);
// add all pages (convert until result is negative), select dithering (Mode 2048)
int i = 0;
while (Memo.GetPageAsBitmap(i, "", 300, 300, 512+2048+1)>0) i++;
// Close the file
Memo.GetPageAsBitmap(0, "last", 300, 300, 1024);
Group
Group
Group
Group
Group
Group
Group
Group
Group
Group
Group
Group
Group
Group
Group
Group
Group
153
0 : wpVarBOptions
1 : wpEditOptions
2 : wpEditOptionsEx
3 : wpProtectProp
4 : wpClickableCodes
5 : wpWriteObjectMode
6 : wpViewOptions
7 : wpAsWebPage
8 : wpFormatOptions
9 : wpFormatOptionsEx
10 : wpAcceptFilesOptions
11 : wpPrintOptions
12 : wpClipboardOptions
13 : Security Options.
14 : Global Security Options
15: wpFormatOptionsEx2
16: ViewOptionsEx
Note: Within .NET projects you can use the enum BPropSel to select the group, for
154
If the second parameter id=-1 and the value =-1 the complete set of flags will
be cleared.
155
? Group 2 : wpEditOptionsEx
Group 2 : Options for Editing - also see "EditOptions"
Also see Group 17: EditOptionsEx2
usage: Memo.SetBProp(2, X, -1) to deactivate, Memo.SetBProp(2, X, 1) to
activate.
0: wpDisableSelection // The user cannot select text (see ViewOptions to hide selection)
1: wpDisableCaret // The caret (insertion point marker at cursor position) is not displayed
2: wpDisableGetFocus // The editor will never receive the focus
3: wpDisableEditOfNonBodyDataBlocks // in Pagelayout mode other DataBlocks (header footer)
cannot be selected for edtiting with a click of the mouse
4: wpAllowCursorInRow // the cursor can be placed in row end marker to create a new row with
return
5: wpTextObjectMoving // move text objects (ObjType=wpobjTextObj)
6: wpTextObjectSelecting // By defualt allow selectiong of text objects
7: wpNoAutoWordStartEndFieldSelection // Normally a complete field is selected when the
cursor is moved over the start or end of a mail merge field. unless wpNoAutoWordSelection is
used.
8: wpDisableAutoCharsetSelection // If true the charset is not retrieved by checking the
current keyboard layout when the user types
9: wpIgnoreSingleCellSelection // No cell selection by pointing in bottom left corner
10: wpTABMovesToNextEditField // used with forms
11: wpDblClickCreateHeaderFooter // Double click in Margin creates header/footer for all pages.
Use 'OnClickCreateHeaderFooter' event to modify 'range'
12: wpRepaintOnFieldMove // When the cursor moves to a different field the form is repainted.
This is important if you use code to highlight the current field. (using event:
OnGetAttributeColor)
13: wpKeepCellsWhenCombiningCells // use the HTML way to combine cells horizontally
14: wpAllowSplitOfCombinedCellsOnly // use the HTML way to split cells dont allow split if not
combined
15: wpDontClearStylesInNew // If defined Action 'New' will not clear the defined styles
16: wpDontResetPagesizeInNew // If defined clearing the text will not set up the default page
size
17: wpSetDefaultAttrInNew // If defined "New" will preset the writing attributes to the default
18: wpAllowDrawDropBetweenTextBlocks
19: wpDisableFastInitOnTyping // Disable the improved typing performance in large paragraphs
20: wpDontTriggerPopupInContextEvent // Changes the time the event OnMouseDownWord is
triggered (old behaviour)
21: wpAlwaysColWidthPC // Column Width always in %
22: wpDisableXPosLineUpDown - When using cursor up/down stay in same char pos, not x pos
23: wpDontInitSelTextAttrWithDefaultFont - Display empty font / size selector when current
attributes are default attributes
24: wpDontSelectCellOnSpreadsheetMovement - Do not select next cell when using TAB in a
table
25: wpScrollLineWise when suing scroll bar up/down button scroll line wise
26: wpZoomWithMouseWheel - zoom in and out when pressing CTRL while using mouse wheel
27: wpTableRowResizingWithCTRL - allow table row resizing only when also CTRL is pressed
(overrides wpTableRowResizing in group 1).
If the second parameter id=-1 and the value =-1 the complete set of flags will
be cleared.
156
? Group 3 : wpProtectProp
Group 3 : Select which text or which objects should be protected
usage: Memo.SetBProp(3, X, -1) to deactivate, Memo.SetBProp(3, X, 1) to
activate.
If the second parameter id=-1 and the value =-1 the complete set of flags will
be cleared.
? Group 4 : wpClickableCodes
Group 4 : Select which object types are used as "hyper links".
usage: Memo.SetBProp(4, X, -1) to deactivate, Memo.SetBProp(4, X, 1) to
activate.
1: wpobjMergeField // merge fields
2: wpobjHyperlink // [default] - hyperlink objects
3: wpobjBookmark // bookmarks
Note, the objects which can be used to mark clickable text (= hyperlinks) area always used in
pairs, such as <a>...</a>
If the second parameter id=-1 and the value =-1 the complete set of flags will
be cleared.
? Group 5 : wpWriteObjectMode
Group 5 : Change the way embedded images are saved
usage: Memo.SetBProp(5, X, -1) to deactivate, Memo.SetBProp(5, X, 1) to
157
activate.
0:
1:
2:
3:
4:
5:
If the second parameter id=-1 and the value =-1 the value "wobRTF" will be
selected.
? Group 6 : wpViewOptions
Group 6 : Change the way the text is displayed in the editor. Also see ViewOptionsEx.
If you use a split screen editor both editors can use different modes.
usage: Memo.SetBProp(6, X, -1) to deactivate, Memo.SetBProp(6, X, 1) to
activate.
0: wpShowGridlines - show the grid lines for tables
1: wpDisableHotStyles - do not use any fly over effects for links
2: wpShowCR - display "" symbol - also see wpShowCRButNotInCells.
3: wpShowFF - display symbol for hard page breaks
4: wpShowNL - display symbol for line breaks Char(10)
5: wpShowSPC - display dots for spaces
6: wpShowHardSPC - display dots for hard spaces Char(160)
7: wpShowTAB - display arrows for tabstops
8: wpShowParCalcNames // Display the names assigned using property WPAT_PAR_NAME
9: wpShowParCalcCommands // Display the formulas
10: wpShowParNames // Display the names assigned using property TParagraph.Name
11: wpNoEndOfDocumentLine // If enabled a line will be displayed in normal mode at the bottom.
(Ignore the "no")
12: wpHideSelection // Selection possible but not displayed
13: wpHideSelectionNonFocussed // selection not displayed when not focussed
14: wpHideSelectionNonFocussedAndInactive // Selection not displayed if not active (not
connected to toolbar)
15: wpTraditionalMisspellMarkers [default] Draw "Word like" curly underlines (default)
16: wpDisableMisspellMarkers // Do not draw curly underlines
17: wpShowPageNRinGap // Display a page number between the pages (only when using the
page gap mode)
18: wpDrawFineUnderlines // Underlines are always one pixel
19: wpDontGrayHeaderFooterInLayout // header and footer texts are not grayed out. (more:
header&footer)
20: wpInfiniteTextArea // When scrolling over the end of the document the start is displayed
agaian
21: wpDontPaintPageFrame // Do not draw the rectangle around page
22: wpCenterPaintPages // center the pages in the window horizontally
23: wpUseOwnDoubleBuffer // Usually a shared double buffer is used, this deactivates the
caching
24: wpDrawPageMarginLines // mark the page margins on the virtual page
25: wpDontDrawSectionMarker // don't draw an arrow on the left side when a section starts
26: wpDrawHeaderFooterLines // draw a rectangle round header and footer areas
27: wpDontDisplayScrollPageHint // if set, don't display page number hint when using scrollbar
28: wpDontDrawObjectAnchors // do not draw the anchors for a movable object
29: wpShowCRButNotInCells [default] - similar to wpShowCR but don't display "" in tables cells
If the second parameter id=-1 and the value =-1 the complete set of flags will
2006-2009 by WPCubed GmbH, Munich, Germany
158
be cleared.
? Group 7 : Webpage Mode
Group 7 : Format the text using a special routine which is optimized for HTML.
It will not preserve all features which are possible in RTF, such as aligned or movable images.
usage: Memo.SetBProp(7, X, -1) to deactivate, Memo.SetBProp(7, X, 1) to
activate.
Flags:
0 : activate/deactivate the "as webpage" display.
When this mode is activated a different formatting procedure is used to measure the tables
more like a webbrowser. Not all text features are supported in the webpage mode.
RTF2PDF Tip: You can also use RtF2PDF1.Command(1312, 1).
Note: You can use TextCommandStr(6,"..") to enable the provided HTTP DLL to load linked
images.
Refine the "as webpage" mode using this flags:
1 : wpNoMinimumWidth - on/off
2 : wpNoMinimumHeight - on/off
reserved for future: 3 : wpLimitToPageWidth - on/off - default on
If the second parameter id=-1 and the value =-1 the complete set of flags will
be cleared.
C# Example:
// Activate HTML Formatting
memo.SetBProp(WPDynamic.BPropSel.wpViewOptionsEx, 0, 1);
? Group 8 : wpFormatOptions
Group 8 : Modify the formatting routine. Also see FormatOptionsEx.
usage: Memo.SetBProp(8, X, -1) to deactivate, Memo.SetBProp(8, X, 1) to
activate.
0: wpDisableAutosizeTables // Default - we suggest to enable this flag. Otherwise tables
imported from RTF can look wrong
1: wpNoMinimumCellPadding // Do not add a one pixel padding to all cells
2: wpfDontBreakTables // *1) do not break tables at all. Also see :
wpKeepTogetherAdjacentTables in FormatOptionsEx
3: wpfDontBreakTableRows // do not break table rows
4: wpDontClipCells // do not clip cells if absolute row heights are used
5: wpfIgnoreMinimumRowheight // Do not use the row height property
6: wpfIgnoreMaximumRowheight // Do not use the row maximum height property
7: wpTableRowIndicator // *2) must be combined with EditOptionsEx : AllowCursorInRow
8: wpfIgnoreKeep // *3) The WPAT_ParKeep property is ignored (do not break par)
159
9: wpfIgnoreKeepN // The WPAT_ParKeepN property is ignored (do not break adjacent par)
10: wpfKeepOutlineWithNext // Text which uses the WPAT_ParIsOutline property is kept with
the next text
11: wpfAvoidWidows // Avoid single lines on old page
12: wpfAvoidOrphans // Avoid single lines on new page
13: wpfCenterOnPageVert // Center text on all pages
14: wpfHangingIndentWithTab // V5: first tab in paragraph jumps to indent first (this always
happens if no tabs are set!) // the left indent will be handled as first tabstop not only if the tab
is the // first character but also if the text before the tab fits into the first indent. (="Word"
like)
15: wpfDontTabToIndentFirst // The oposite to : aFormatOption([wpfHangingIndentWithTab
16: wpJustifySoftLinebreaks // Justify \n
17: wpJustifyHardLinebreaks // Justify \r
18: wpUseHyphenation // Use soft hyphens in the text (inserted with Ctrl + '-')
19: wpFooterMinimumDistanceToText // The footer texts start after the body text and does not
keep a certain distance to the text
20: wpShowBookmarkCodes // display bookmark tags
21: wpShowHyperlinkCodes // display hyperlinks tags
22: wpShowSPANCodes // display SPAN tags
23: wpShowInvisibleText // show text which would be otherwise hidden
Experimental flags:
24: wpfHideEmptyParElements // reserved: Can be used when editing HTML files with nested
DIV elements
26: wpWriteRightToLeft // activate RTL (right-to-left) writing.
27: wpAutoWriteRightToLeft // reserved
32: wpActivateRTLMode // if active, the whole text uses RTL writing
Troubleshooting flags
25: wpfXMLOutlineMode // Debugging mode: Show paragraph tree similar XML in IE
28: wpUseAbsoluteFontHeight // Calculate the height of the text using the font size alone
29: wpfAlwaysFormatWithScreenRes // .. even if RM600 is defined in WPCtrMemo
30: wpDisableSpeedReformat // format only the current page and the next page on regular
input
31: wpDontAdjustFloatingImagePosition // do not adjust image position to keep it on the page
If the second parameter id=-1 and the value =-1 the complete set of flags will
be cleared.
Note:
*1) Breaking up table rows and tables on different pages can be generally deactivated. If a
table does not fit on next page, it will be divided anyway.
*2) When the cursor is at the end of a row, a new row can be created by pressing "Enter"
*3) "Keep" control avoids breaking up certain paragraphs on several pages.
It tries to keep paragraphs together. KeepN keeps this paragraph with the next on one pages.
? Group 9 : wpFormatOptionsEx
Group 9 : Modify the formatting routine.
usage: Memo.SetBProp(9, X, -1) to deactivate, Memo.SetBProp(9, X, 1) to
activate.
0: wpDontAddExternalFontLeading // When measuring the font height don't add the // value
defined for a font: Metrics.tmExternalLeading. This improves compatibility to WPTools 4 //
Alternatively set global variable WPDoNotAddExternalFontLeading := TRUE to // activate this
mode for all editors!
1: wpfKeepTablesInTextArea // If defined avoid that table go into right margin
2: wpKeepTogetherAlwaysNewPage // if : wpfDontBreakTables is used a table which is too large
2006-2009 by WPCubed GmbH, Munich, Germany
160
wpfNestedNumberingInTableCells
wpfNumberingControlledByStyles
wpfSectionsRestartFootnoteNumbers
wpfDontIgnoreKeepNInTable
If the second parameter id=-1 and the value =-1 the complete set of flags will
be cleared.
? Group 10 : wpAcceptFilesOptions
Group 10 : Change the way files are handled when dropped on an editor.
This mode is only used when "AcceptFiles" has been switched on using SetBProp( 0, 11, 1)
usage: Memo.SetBProp(10, X, -1) to deactivate, Memo.SetBProp(10, X, 1) to
2006-2009 by WPCubed GmbH, Munich, Germany
161
activate.
0:
1:
2:
3:
If the second parameter id=-1 and the value =-1 the complete set of flags will
be cleared.
? Group 11 : wpPrintOptions
Group 11 : Modify the way printing is performed
usage: Memo.SetBProp(11, X, -1) to deactivate, Memo.SetBProp(11, X, 1) to
activate.
0: wpDoNotChangePrinterDefaults
1: wpIgnoreBorders
2: wpIgnoreShading
3: wpIgnoreText
4: wpIgnoreGraphics
5: wpUsePrintPageNumber
6: wpDontPrintWatermark
7: wpDontReadPapernamesFromPrinter
8: wpAlwaysHideFieldmarkers //hide field markers in PrintDialog
9: wpDontAllowSelectionPrinting
10: value=-1: read, otherwise the duplex mode. Possible values: 0=Don't change duplex,
1=None, 2=Horizontal, 3=Vertical
11: wpCompareWidthHeightToDetectLandscape (default=on)
12: wpAllColorsAreBlack - print colors in gray scale
If the second parameter id=-1 and the value =-1 the complete set of flags will
be cleared.
? Group 12 : wpClipboardOptions
Group 12 : Modify the clipboard is used. Here also Drag&Drop is customized
usage: Memo.SetBProp(12, X, -1) to deactivate, Memo.SetBProp(12, X, 1) to
activate.
0: wpcoNoInternalDragAndDrop //Switch off the internal drag&drop
1: wpcoNoDragAndDropFromOutside // Allow only Drop from within
2: wpcoAlwaysDeleteInDragSource // Delete dragged source text if from different editor too!
3: wpcoDontMoveCursorDuringDrag // Do not show cursor when dragging
4: wpcoNoAutoSelSpaceExtension // Don't select preceding or trailing spaces when doing
Drag&Drop
5: wpDontHideCaret // do not hide the caret while selection is active
Enable/Disable certain formats:
6: wpcoDontPasteWPT // Don_t paste the internal proprietary WPT format
7: wpcoDontPasteRTF // don't paste ANSI
8: wpcoDontPasteANSI
162
9: wpcoDontPasteUNICODE
10: wpcoPasteHTMLWhenAvailable // not recommended - paste HTML when availbale
11: wpcoDontPasteGraphics // don't paste graphics (unless embedded in RTF text)
12: wpcoDontCopyRTF // Do not copy RTF
13: wpcoDontCopyANSI
14: wpcoDontCopyUNICODE
15: wpcoDontCopyWPT
This flags change the way pasted text is handled:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
If the second parameter id=-1 and the value =-1 the complete set of flags will
be cleared.
? Group 13 : Security Options.
Group 13 : Security Options.
This flags allows it to avoid that the user copy or saves text from this editor.
usage: Memo.SetBProp(13, X, -1) to deactivate, Memo.SetBProp(13, X, 1) to
activate.
1 : DontUseGlobalSettings - this editor should not use the global settings (group 14).
2 : Do not allow any paste operation
3 : Do not allwo any copy operation
4 : Do only allow copy and paste within the application, paste in other application is not
possible. (The clipboard contents is encrypted with a dynamic password)
5 : Save dialogs and buttons are disabled.
6 : Load dialogs and buttons are disabled.
7 : Print dialogs and buttons are disabled.
100: Set flag 4, 5 and 6 and disable any subsequent change to this property.
If the second parameter id=-1 and the value =-1 the complete set of flags will
be cleared.
? Group 14 : Global Security Options
Group 14 : Global Security Options.
163
If the second parameter id=-1 and the value =-1 the complete set of flags will
be cleared.
.
? Group 15: wpFormatOptionsEx2
Group 15 : Modify the formatting routine.
usage: Memo.SetBProp(9, X, -1) to deactivate, Memo.SetBProp(9, X, 1) to
activate.
1:
2:
3:
4:
5:
6:
7:
If the second parameter id=-1 and the value =-1 the complete set of flags will
be cleared.
? Group 16: ViewOptionsEx
Group 16 : Change the way the text is formatted and displayed in the editor. Also See
ViewOptions.
If you use a split screen editor both editors can use different modes.
usage: Memo.SetBProp(16, X, -1) to deactivate, Memo.SetBProp(16, X, 1) to
activate.
0:
1:
2:
3:
4:
164
5:
6:
7:
8:
0:
1:
2:
3:
4:
5:
6:
165
Example VB6:
WPDLLInt1.Memo.LayoutMode = wplayNormal
WPDLLInt1.Memo.SetIProp 5, 70 ' x-offset from left to text
WPDLLInt1.Memo.SetIProp 6, 70
'y-offset from top to text
4.1.3.2 BD) SetWYSIWYGMode
Declaration
procedure SetWYSIWYGMode(Mode: Integer)
Description
This mode changes the rendering and formatting:
Mode=0 - best option for perfect printing
Default - format to printer, do not use special "Kerning" Mode
Mode=1:
format to printer and use special "Kerning" Mode
Mode=2 - best option for perfect screen display
format for screen, do not use special "Kerning" Mode
Mode=3:
format for screen and use special "Kerning" Mode
Mode = 4 - best option for good printing and good display
Change the formatting resolution to work best with screen and printer. This also changes the
line breaks, so we decided to not make it the default mode.
166
167
Letters, Characters
Parameters
Mode
Pages
Count of pages
Paragraphs
Lines
Count of lines
Tables
Count of tables
Rows
Images
Words
Count of words
Letters
Characters
Category
Display Status Information
4.1.3.2 BH) Tables_WidthFixed
Declaration
void Tables_WidthFixed();
Description
Process all tables in the text to change any variable column width to a fixed width (twips).
Category
Table Support
4.1.3.2 BI) Tables_WidthPC
Declaration
void Tables_WidthPC([In] bool Enable);
Description
Process all tables in the text to change any fixed column width to a variable width (%).
Category
Table Support
4.1.3.2 BJ) TextCommand
Declaration
int TextCommand([In] int ComID, [In] int paramA, [In] int paramB);
Description
This method has been reserved for custom enhancements.
2006-2009 by WPCubed GmbH, Munich, Germany
168
169
170
Arrow)
Command ID: 22
Deletes the tab stop at position paramA
Command ID: 23
Clears all tabs tops in the selected text or the current paragraph.
? Command 24: Draw lines and background, Page Size, Force Pagecount
Using this command various page size and drawing options can be changed.
paramA selects the id of the option, paramB changes it.
1) Set the current and, at the same time, the default page size.
ParamA can be one of this IDs, paramB is expected to be a twip value.
WIPR_PAGE_WIDTH = 1;
WIPR_PAGE_HEIGHT = 2;
WIPR_PAGE_LEFT_MARGIN = 3;
WIPR_PAGE_RIGHT_MARGIN = 4;
WIPR_PAGE_TOP_MARGIN = 5;
WIPR_PAGE_BOTTOM_MARGIN = 6;
WIPR_PAGE_HEADER_MARGIN = 7;
WIPRPAGE_FOOTER_MARGIN = 8;
Alternatively the page size can be changed using the interface PageSize.
171
ParamB can be
0 : Draw a rectangle at the top left area
1 : Draw a rectangle at the top right area
2 : Draw lines in a certain offset of the borders of the page. (Don't mix up with the margins)
3 : Draw lines in a certain offset of the borders of the page.
Exchange the left and right offset for even pages.
4: Draw the lines only on the first page.
Use this IDs to set the offset values in twips. If a value remains 0, the line is not drawn.
WIPR_ED1_PAGE_LINEOFFSET_LEFT = 11;
WIPR_ED1_PAGE_LINEOFFSET_RIGHT = 12;
WIPR_ED1_PAGE_LINEOFFSET_TOP = 13;
WIPR_ED1_PAGE_LINEOFFSET_BOTTOM = 14;
Note: You need to use Command(24, 9, 4) to activate the display.
Example: Draw lines Memo.TextCommand(24,
Memo.TextCommand(24,
Memo.TextCommand(24,
Memo.TextCommand(24,
Memo.TextCommand(24,
Memo.TextCommand(24,
WIPR_ED1_PAGES_MINCOUNT = 15
Forces the text to have at least the given number of pages. The added pages are drawn
empty.
b)
WIPR_ED1_PAGES_MAXCOUNT = 16
Any additional pages than the given number are not displayed.
On screen a "plus sign"
is displayed if the page
count exceeds the
count of displayed
pages:
c) WIPR_ED1_PAGES_MULTIPLICATOR = 18
Forces the page count to be dividable by the given value. If required, empty pages are
appended.
Please note, that a second editor can show the same text with a different count of pages.
For example the thumbnail view will display less then X pages unless You also execute the same
code for "Memo2".
4) Read the current page Count
Use either TextCursor.PageCount or this command with the id WIPR_ED1_PAGECOUNT = 17
2006-2009 by WPCubed GmbH, Munich, Germany
172
Note:
In case You cannot use the COM Interface IWPMemo, this feature is also available by sending
the windows message 1031 to the editor.
Parameters wparam as paramA, lparam as paramB.
If you need to modify editor#2, just add the value 100 to wparam.
Also see "TextDynamic as Popup Editor (method wptextCreateDialog)".
? Command 25: Select Watermark Image
You can use Command(143,..) to load a watermark image into a "slot".
Using the Memo.Command 25 it is possible to select during the OnNotify event a watermark of a
certain slot.
If paramA is 0, the method will return the page number which is about to be painted.
If paramA=1, the slot with the number paramB will be selected.
Example:
Load the watermarks as metafiles using Command(143):
private void button5_Click(object sender, System.EventArgs e)
{
// Fill 3 slots and activate the display
wpdllInt1.Command( 143, 0, @"c:\1.emf");
wpdllInt1.Command( 143, 1, @"c:\2.emf");
wpdllInt1.Command( 143, 2, @"c:\5.emf");
wpdllInt1.ProcessWPA("ShowWatermark", "1");
}
Select the watermark in the OnNotify Event:
private void wpdllInt1_OnNotify(object Sender, int Editor, int MsgID)
{
if (MsgID==29)
{
int pagenr =
wpdllInt1.Memo.TextCommand( 25, 0, 0);
if ( pagenr==0) // Page 1, select slot 0
wpdllInt1.Memo.TextCommand( 25, 1, 0);
else if ( pagenr==4) // Page 5, select slot 2
wpdllInt1.Memo.TextCommand( 25, 1, 2);
else // otherwise select slot 1
wpdllInt1.Memo.TextCommand( 25, 1, 1);
}
}
173
174
This command activates the HTTP access dll. You need to pass the DLL activation key
as string parameter. Using an empty string will unload the DLL. The DLL will be always
searched in same directory as the main TextDynamic engine.
The DLL name is always wphttpget.dll, or with TextDynamic demo: wphttpget_demo.
dll.
The HTTP DLL can be licensed
42 for Single License
http://shareit1.element-5.de/cart.html?PRODUCT[300326575]=1
105 for Site / Team License
http://shareit1.element-5.de/cart.html?PRODUCT[300326576]=1
Once the DLL is loaded all referenced CSS and IMG data will be loaded through the
methods exported by the DLL.
Example:
wpdllInt1.Memo.TextCommandStr(6, 1, "HTTP_DEMO_MODE");
wpdllInt1.Memo.LoadFromFile(@"http://www.wpcubed.com/");
175
Note: You should also activate a new HTML formatting method to format tables
differently
see Memo.SetBProp Group 7 : wpAsWebPage
? Command ID 7 & 8 - set ParIsOutline flag
ID 7:
Processes all paragraphs of the body text to select paragraphs to be used as PDF bookmark
(outline).
StrParam="" - disables all WPAT.ParIsOutline property.
If the paragraph uses the style with the name provided as StrParam set the ParIsOutline level
provided as Param. If Param = 0 or if the paragraph does not contain any text (objects are
ignored) the property will be set to 0.
You can set the WPAT.ParIsOutline property in paragraph styles as well.
This command is a shortcut for the following C# code with the advantage that it does not
modify the cursor position.
ID 8:
Processes all paragraphs of the body text to select paragraphs to be used as PDF bookmark
(outline).
StrParam="" - disables all WPAT.ParIsOutline property.
If the paragraph starts with StrParam set the ParIsOutline level provided as Param. If Param =
0 the property will be set to 0.
2006-2009 by WPCubed GmbH, Munich, Germany
176
<b>|</b>.
If text is currently selected the tags will be created around the selected text, if no text is
selected the cursor | will be placed within the tags.
You can also specify parameters:
Memo.TextCommandStr(9, 0, "span style=\"font-face:Arial\"") creates
style="font-face:Arial">|</span>.
<span
177
wpdllInt1.Memo.TextCommandStr(17, 3, "");
wpdllInt1.Memo.MergeText("");
b) Create reporting template:
wpdllInt1.SetEditorMode(
EditorMode.wpmodDoubleEditor,
EditorXMode.wpmodexToolbar|
EditorXMode.wpmodexPDFExport|
2006-2009 by WPCubed GmbH, Munich, Germany
178
EditorXMode.wpmodexSpellcheck|
EditorXMode.wpmodexTables|
EditorXMode.wpmodexReporting,
EditorGUI.wpguiRuler|
EditorGUI.wpguiHorzScrollBar|
EditorGUI.wpguiVertScrollBar|
EditorGUI.wpguiPanelH1,
EditorGUI.wpguiDontSet);
wpdllInt1.Memo.TextCommandStr(17, 0, "");
Category
Mailmerge
? Command ID 18 - Set default font and size
This command sets the default font name and size. It only needs to be called once.
The font will be applied the next time the editor is cleared.
To disable the default font pass -1 as integer parameter.
Example VB:
Private Sub Command4_Click()
WPDLLInt1.Memo.TextCommandStr 18, 22, "Courier New"
End Sub
? Command ID 19 - Make the current page size the default
This command makes the current page size the page size which will be used for new
documents.
// Set PageSize (use smaller margins, 720 twips)
wpdllInt1.Memo.PageSize.SetPageWH(-1, -1, 720, 720, 720, 720);
// This should be also used for new documents
wpdllInt1.Memo.TextCommandStr(19, 0, "");
? Command ID 20 - Insert Annotation Object
This command will insert an "annotation object".
The string parameter will be used as Caption.
Annotation objects are painted as little yellow square.
Note: Annotation Objects are currently only used with special XML import/export.
? Command IDs 21-27 Export Pages as BMP, PNG and TIFF.
New:
We added the new API Memo.GetPageAsBitmap which handles this functionality.
So this commands are obsolete.
179
Not e : Ple a se c a ll M e m o.Re form a t All(fa lse ,fa lse ) if t he e dit or w a s dy na m ic a lly c re a t e d.
C o m m a nds to co ntro l the bitm a p e xpo rt:
21: Se t t he e xport re solut ion t o t he v a lue of pa ra m . T he de fa ult is 200 dpi. Ple a se a v oid t oo
la rge v a lue s if y ou w a r e xport ing c olor im a ge s. T he m e m ory c onsum pt ion of t he w orking
bit m a p is huge . (T he st ring pa ra m e t e r is ignore d)
If y ou ne e d diffe re nt re solut ions for X a nd Y v a lue s, ple a se m ult iply t he Y re solut ion w it h 10000
a nd a dd it :
wpdllInt1.Memo.TextCommandStr(24, XResolution + YResolution * 10000, "");
180
MessageBox.Show(
wpdllInt1.Memo.TextCommandStr(26, 0, "") + " page(s) were exporte
};
}
Name
Hint
Caption
Param (a string)
Font
Action (a string)
WPActionStyle (a number converted to string)
2006-2009 by WPCubed GmbH, Munich, Germany
181
182
Use mode=1 to enable this mode and also use the parameter path to set the directory, where
the files should be stored.
Use mode=2 to get the count of attached images
You can use GetAttachment to read each single name.
Use mode=3 to delete all files which are listed in the attachment list.
The provided path (directory) will be used to save the images.
It is not necessary to use the format string imgpath:"..." in the save method unless You want
to override the path.
4.1.3.2 BN) GetAttachment
Declaration
function GetAttachment(Index: Integer): WideString;
Description
Reads the name of an attached file. See PrepareAttachmentList.
4.1.3.2 BO) SetInitialPath
Declaration
procedure SetInitialPath(Id: Integer; const Value: WideString)
Description
Sets various initial directories for file open dialogs:
Use id to select
0 : directory for text load and save. This is the same as property InitialDir
1 : directory for the insert graphic dialog
2 : directory for loading and saving styles sheets
4.1.3.2 BP) GetInitialPath
Declaration
function GetInitialPath(Id: Integer): WideString;
Description
Reads various initial directories for file open dialogs:
Use id to select
0 : directory for text load and save. This is the same as property InitialDir
1 : directory for the insert graphic dialog.
2 : directory for loading and saving styles sheets
4.1.3.2 BQ) ActivateSyntaxHighlighter
Declaration
int ActivateSyntaxHighlighter(int Mode; string param)
183
Description
TextDynamic includes a versatile syntax highlighting interface.
It internally has the possibility to change the attributes of the text (i.e. apply color green for
comments) or just add virtual marks. In any case the visible attributes will be updated as the
user types.
Currently available is syntax highlighting for XML, for fields and for field and band tokens.
Memo.ActivateSyntaxHighlighter( param, strparam) selects the internal Syntax
Highlighting Mode.
param selects the mode:
0 - disables the highlighting,
1 - selects the HTML / XML highlighter. (Attributes are applied to the text)
2 - selects the HTML / XML highlighter. (Attributes are virtual, they are not applied to the text)
3 - highlight fields using the syntax <<...>> - see Mailmerge (Attributes are not applied)
4 - highlight fields and bands using the syntax <<...>> - see "Tokens to Template Conversion
" (Attributes are not applied). To actually convert the tokes use TextCommandStr(17).
Example:
184
Mailmerge
4.1.3.2 BR) SetXMLSchema
Declaration
int SetXMLSchema(string Value; int Mode)
Description
This feature is used to manage an XML schema which is used to create popup menus
(Mode=0-5) and to load a CSS stylesheet to highlight the text in certain tags (Mode=6 + 7).
Note: This method requires the "Premium" License. Since it is an editing feature, You can not
use it in TextDynamic Se rv e r.
You can load an XML schema file, i.e:
This information will be used to create a popup menu when the user clicks inside the text. The User can now select a tag fro
In the present version the control does not check rules in the schema, such as maxOccurs.
? A) Manage XML Schema
Mode=0: Set the schema mode. The first parameter can have this values:
"clear" - clear schema and disable the XML editing
"off" - don't clear the schema, but switch editing off
"on" - enable XML editing and XML Popup
Mode=1: Load the schema from the file "Value". Use SetXMLSchema("on",0) to activate XML editing!
Mode=2: Save the schema to a file.
2006-2009 by WPCubed GmbH, Munich, Germany
185
Mode=4: Load XML data from a file into the editor. Alternatively this can be done using the regular load methods when using
Mode=5: Save XML data in editor to a file. Alternatively this can be done using the regular save methods when using the form
Example:
wpdllInt1.Memo.SetXMLSchema(@"\XMLSchema\naturwissenschaften.xml", 4);
wpdllInt1.Memo.SetXMLSchema(@"\XMLSchema\naturwissenschaften.xsd", 1);
wpdllInt1.Memo.SetXMLSchema("on", 0);
? B) Load CSS Stylesheet
186
? C) Example Code
Example Code C#:
wpdllInt1.Memo.SetXMLSchema("some_xml.xml", 4);
wpdllInt1.Memo.SetXMLSchema("some_schema.xsd", 1);
wpdllInt1.Memo.LoadStyleSheet("some_stylesheet.css");
wpdllInt1.Memo.SetXMLSchema("on", 6); // CSS Mode
wpdllInt1.Memo.SetXMLSchema("on", 0); // XML Mode
4.1.3.2 BS) GetXMLTags
Declaration
function GetXMLTags(Mode: Integer): WideString
Description
The method is reserved
4.1.3.2 BT) ShowContextMenu
Declaration
function ShowContextMenu(Mode: Integer): Integer
Description
This method displays the current context menu at the cursor position. It does the same as
pressing the "Context Menu" key on the keyboard.
4.1.3.2 BU) InitHTMLMode
Declaration
procedure InitHTMLMode(Mode: Integer; const ParamStr: WideString; param: Integer)
Description
This method initialites the HTTP
4.2
Properties
Methods
CPCellPtr
AddTable
CPLineNr
AppendRow
CPObjPtr
CheckState
CPPageLineNr
Clear
CPPageNr
CombineCellHorz
CPParNr
CombineCellVert
CPParPtr
CPMoveAfterTable
CPPosInLine
CPMoveBack
CPPosInPar
CPMoveBeforeTable
CPPosition
CPMoveNext
CPRowPtr
CPMoveNextBand
CPStylePtr
CPMoveNextCell
CPTableColNr
CPMoveNextGroup
CPTablePtr
CPMoveNextObject
CPTableRowNr CPMoveNextPar
IsSelected
CPMoveNextRow
PageCount
CPMoveNextTable
CPMoveParentTable
CPMovePrevCell
CPMovePrevObject
CPMovePrevPar
CPMovePrevRow
CPMovePrevTable
CPMoveToGroup
CPOpenObj
EnumOpenObj
Delete
DisableProtection
DisableUndo
EnabledProtection
EnableUndo
FieldsFromTokens
FindText
187
Methods
Methods
GetParName
MarkerCollect
GotoBody
MarkerCollectAll
GotoEnd
MarkerCPPositio
n
GotoStart
MarkerDrop
HideSelection
MarkerGoto
InputBookmark
InputCalculatedFiel MarkerSelect
d
MovePosition
MoveToField
InputCell
(locates next/
InputCustomHTML
previous field)
InputEmbeddedDat
MoveToBookmar
a
k
InputField
MoveToTable
InputFieldObject
Redo
InputFooter
ReplaceText
InputFootnote
ReportConvertTa
InputHeader
ble
ClearAllHeaders
ReportConvertTe
ClearAllFooters
xt
InputHTML
ReportInputBan
d
InputHyperlink
ReportInputGrou
InputImage
p
InputObject
ScrollToCP
InputPagebreak
SelectAll
InputParagraph
SelectLine
InputPicture
InputPictureStream SelectParagraph
SelectTable
SelectTableColu
InputRowEnd
mn
InputRowStart
SelectTableRow
InputSection
SelectText
InputString
SetColWidth
InputTable
SetParName
InputTabstop
SetRowHeight
InputText
SetTableLeftRigh
InputTextbox
t
InsertRow
TableClear
ExitTable
TableDelete
TableSplit
Undo
TableSort
UndoClear
ASetCellProp
WordCharAttr
ASetCellStyle
188
MergeCellHorz
MergeCellVert
4.2.1
Properties
4.2.1.1
CPCellPtr
WordEnum
WordHighlight
Applies to
IWPTextCursor
Declaration
int CPCellPtr;
Description
This is a low level paragraph reference to the cell the cursor is located within.
4.2.1.2
CPLineNr
Applies to
IWPTextCursor
Declaration
int CPLineNr;
Description
This is the number of the current line from start of the text.
Category
Display Status Information
Also see
Memo.TextCommandStr ID 35/36/37 to change and read paragraphs, lines and words at cursor
position.
4.2.1.3
CPObjPtr
Applies to
IWPTextCursor
Declaration
int CPObjPtr;
Description
This is a low level text object reference to the object at cursor position.
4.2.1.4
CPPageLineNr
Applies to
IWPTextCursor
Declaration
int CPPageLineNr;
Description
This is the number of the current line from start of the page.
CPPageNr
Applies to
IWPTextCursor
Declaration
int CPPageNr;
Description
This is the number of the current page.
Category
Display Status Information
4.2.1.6
CPParNr
Applies to
IWPTextCursor
Declaration
int CPParNr;
Description
This is the number of the current paragraph.
4.2.1.7
CPParPtr
Applies to
IWPTextCursor
Declaration
int CPParPtr;
Description
This is a low level paragraph reference to the paragraph the cursor is located within.
4.2.1.8
CPPosInLine
Applies to
IWPTextCursor
Declaration
int CPPosInLine;
Description
This is the position in the current line.
Category
Display Status Information
4.2.1.9
CPPosInPar
Applies to
IWPTextCursor
Declaration
189
190
int CPPosInPar;
Description
This is the position in the current paragraph.
4.2.1.10 CPPosition
Applies to
IWPTextCursor
Declaration
int CPPosition;
Description
This is the absolute position in characters from the beginning of the text. Paragraph breaks
count as 1.
Category
Display Status Information
4.2.1.11 CPRowPtr
Applies to
IWPTextCursor
Declaration
int CPRowPtr;
Description
This is a low level paragraph reference to the row the cursor is located within.
4.2.1.12 CPStylePtr
Applies to
IWPTextCursor
Declaration
int CPStylePtr;
Description
This is the number of the style the current paragraph uses. You can assign 0 to clear the style
reference.
4.2.1.13 CPTableColNr
Applies to
IWPTextCursor
Declaration
int CPTableColNr;
Description
This is the number of the current column.
Category
Table Support
191
192
4.2.2
Methods
4.2.2.1
IWPTextCursor.AddTable
ColCount
RowCount
Border
EventParam
CreateHeader
CreateFooter
Tip: You can use the methods ASetCellProp and ASetCellStyle to quickly modify the properties,
text and styles of certain cells in an existing table.
Category
Callback Functions
Table Support
2006-2009 by WPCubed GmbH, Munich, Germany
193
IWPTextCursor.AppendRow
Applies to
IWPTextCursor
Declaration
bool AppendRow(string TableName, int FooterCount);
Description
This method will append a row to a table. It is the prefect tool to modify a calculated table in
an invoice since it can reserve a variable count of rows at the bottom of the table as footer
rows.
If operation was successful (result=true) the cursor will be positioned in the first cell of the new
row.
Parameters
If specified the table with this name will be
searched and extended.
TableName
FooterCount
The text in the row is not duplicated unless the mode DuplicateWithText has been activated
using Memo.SetBProp(18,1);
Category
Table Support
4.2.2.3
IWPTextCursor.CheckState
Applies to
IWPTextCursor
Declaration
function CheckState(Which: Integer): WordBool;
Description
Checks several states:
WPSTAT_ISSELECTED = 0;
Return true if currently text is selected.
WPSTAT_INTABLE = 1;
Return true if the cursor is currently inside a table.
WPSTAT_ISEMPTY = 2;
Return true if the text is empty.
WPSTAT_ISFIRSTLINE = 3;
Return true if the cursor is in the first line of the text.
WPSTAT_ISLASTLINE = 4;
194
4.2.2.4
IWPTextCursor.Clear
Applies to
IWPTextCursor
Declaration
procedure Clear;
Description
Clears the current text layer (data block) - does not clear number- or paragraph styles.
4.2.2.5
IWPTextCursor.CombineCellHorz
Applies to
IWPTextCursor
Declaration
function CombineCellHorz: WordBool;
Description
Merges the selected cells horizontally. Also see IWPTextCursor.MergeCellHorz.
2006-2009 by WPCubed GmbH, Munich, Germany
195
Category
Table Support
4.2.2.6 IWPTextCursor.CombineCellVert
Applies to
IWPTextCursor
Declaration
function CombineCellVert: WordBool;
Description
Merges the selected cells vertically. Also see IWPTextCursor.MergeCellVert.
Category
Table Support
4.2.2.7
IWPTextCursor.CPMoveAfterTable
Applies to
IWPTextCursor
Declaration
function CPMoveAfterTable(CreateIfNotExist: WordBool): WordBool;
Description
Moves the cursor at first regular paragraph after the table(s) at the current position. If
CreateIfNotExist = true a new paragraph will be created if there is no regular paragraph.
Category
Table Support
4.2.2.8
IWPTextCursor.CPMoveBack
Applies to
IWPTextCursor
Declaration
function CPMoveBack: WordBool;
Description
Moves the cursor back one character. If this was successful return true, otherwise false.
4.2.2.9
IWPTextCursor.CPMoveBeforeTable
Applies to
IWPTextCursor
Declaration
function CPMoveBeforeTable(CreateIfNotExist: WordBool): WordBool;
Description
Skips table(s) at current position. Optionally create a new regular paragraph at the beginning of
the text.
Category
Table Support
196
4.2.2.10 IWPTextCursor.CPMoveNext
Applies to
IWPTextCursor
Declaration
function CPMoveNext: WordBool;
Description
Moves the cursor one character to the right. If this was successful return true, otherwise false.
4.2.2.11 IWPTextCursor.CPMoveNextBand
Applies to
IWPTextCursor
Declaration
function CPMoveNextBand: WordBool;
Description
__Reserved__
4.2.2.12 IWPTextCursor.CPMoveNextCell
Applies to
IWPTextCursor
Declaration
function CPMoveNextCell: WordBool;
Description
Move to the cell to the right. If in last cell return false.
Category
Table Support
4.2.2.13 IWPTextCursor.CPMoveNextGroup
Applies to
IWPTextCursor
Declaration
function CPMoveNextGroup: WordBool;
Description
__Reserved__
4.2.2.14 IWPTextCursor.CPMoveNextObject
Applies to
IWPTextCursor
Declaration
function CPMoveNextObject(ObjType: TxTextObjTypes; DontSkipCloseTags: WordBool):
WordBool;
197
Description
Locate next object of a given object type.
It will skip closing tags unless the second parameter is true.
You can access the properties of the object or field using CurrObj.
Please also see Memo.EnumTextObj if you need to check all objects in a text.
4.2.2.15 IWPTextCursor.CPMoveNextPar
Applies to
IWPTextCursor
Declaration
function CPMoveNextPar(CreateIfNotExists: WordBool): WordBool;
Description
Move to next paragraph.
4.2.2.16 IWPTextCursor.CPMoveNextRow
Applies to
IWPTextCursor
Declaration
function CPMoveNextRow(CreateIfNotExist: WordBool): WordBool;
Description
Move to next row in this table. If the cursor is at the end of a table, optionally a new row can
be created by duplicating the current row.
The text in the row is not duplicated unless the mode DuplicateWithText has been activated
using Memo.SetBProp(18,1);
Example:
IWPMemo Memo;
Memo = WPDLLInt1.Memo;
IWPTextCursor TextCursor = Memo.TextCursor;
// Only one row
TextCursor.AddTable(
"data", 3, 1, true,
0, // EventParam =0, no event!
false,// create header rows
false // create footer rows
);
// append rows
for (int r = 0; r < 10; r++)
{
// Create new row - if not in first
if (r > 0) TextCursor.CPMoveNextRow(true);
// and create the text
for (int c = 0; c < 3; c++)
198
199
4.2.2.20 IWPTextCursor.CPMovePrevObject
Applies to
IWPTextCursor
Declaration
function CPMovePrevObject(ObjType: TxTextObjTypes): WordBool;
Description
Locate previous object of a given object type.
4.2.2.21 IWPTextCursor.CPMovePrevPar
Applies to
IWPTextCursor
Declaration
function CPMovePrevPar: WordBool;
Description
Move to previous paragraph.
4.2.2.22 IWPTextCursor.CPMovePrevRow
Applies to
IWPTextCursor
Declaration
function CPMovePrevRow: WordBool;
Description
Move to previous row. If at start of table return false.
4.2.2.23 IWPTextCursor.CPMovePrevTable
Applies to
IWPTextCursor
Declaration
function CPMovePrevTable: WordBool;
Description
Move to previos table before the current table.
4.2.2.24 IWPTextCursor.CPMoveToGroup
Applies to
IWPTextCursor
Declaration
function CPMoveToGroup(const Name: WideString; InsideOfCurrentGroup: WordBool;
CreateIfNotExist: WordBool; BandElement: Integer): WordBool;
Description
200
__Reserved__
4.2.2.25 IWPTextCursor.CPOpenObj
Applies to
IWPTextCursor
Declaration
function CPOpenObj(ObjTypMask: Integer): IWPTextObj;
Description
Checks which objects are open at the current position. Returns a IWPTextObj interface or null if
no object is found. Use ObjTypMask=0 it will find any open object, otherwise the specified
object type must match.
Note: Please don't forget to call ReleaseInt() with the returned interface at the end of your
code.
4.2.2.26 IWPTextCursor.Delete
Applies to
IWPTextCursor
Declaration
procedure Delete(CharCount: Integer);
Description
Delete "CharCount" characters at the current position. Will also delete paragraph breaks.
4.2.2.27 IWPTextCursor.DisableProtection
Applies to
IWPTextCursor
Declaration
procedure DisableProtection;
Description
Disable the protection of the text temporarily. Enable the protection with EnableProtection.
4.2.2.28 IWPTextCursor.DisableUndo
Applies to
IWPTextCursor
Declaration
procedure DisableUndo;
Description
Disable undo temporarily.
Category
Standard Editing Commands
201
4.2.2.29 IWPTextCursor.EnabledProtection
Applies to
IWPTextCursor
Declaration
procedure EnabledProtection;
Description
Use after DisableProtection to enable to protect the text again.
Category
Standard Editing Commands
4.2.2.30 IWPTextCursor.EnableUndo
Applies to
IWPTextCursor
Declaration
procedure EnableUndo;
Description
Enable undo after it was dsiabled with DisableUndo.
Category
Standard Editing Commands
4.2.2.31 IWPTextCursor.FieldsFromTokens
Applies to
IWPTextCursor
Declaration
void FieldsFromTokens(string StartText, string EndText, string FieldPreText);
Description
Create a merge template by conversion of specially marked fields, i.e [NAME] will be converted
into DB.NAME.
Alternatively You can use the Token To Template Conversion
Please also see Syntax Highlighting since it is possible to highlight fields while the user writes.
Tip: The method FieldsFromTokens does the same as "ReplaceTokens" in the VCL product
WPTools.
Parameters
StartText - The field marker start, i.e. "["
EndText - The field marker end, i.e. "]"
FieldPreText - The text which will be added at the beginning of each field, i.e. "DB.".
Category
Mailmerge
202
4.2.2.32 IWPTextCursor.FindText
Applies to
IWPTextCursor
Declaration
void FindText(
string Text,
bool FromStart,
bool CaseSensitive,
bool MoveCursor,
bool WholeWords,
ref bool Found);
Description
Locates a text and either moves the cursor before its location or selects the text with the
cursor being after the found text.
Use Memo.SetIProp(11,-1) to make FindText search backwards.
Parameters
Text
FromStart
CaseSensitive
MoveCursor
WholeWords
Found
System.Windows.Forms.TextBox FindWhat;
System.Windows.Forms.CheckBox chkWholeWord;
System.Windows.Forms.CheckBox chkCaseSensitive;
System.Windows.Forms.RadioButton chkDown;
System.Windows.Forms.RadioButton chkUp;
System.Windows.Forms.Button btnFindButton;
System.Windows.Forms.Button btnCancelButton;
System.Windows.Forms.CheckBox chkFromStart;
2006-2009 by WPCubed GmbH, Munich, Germany
203
204
4.2.2.33 IWPTextCursor.GetParName
Applies to
IWPTextCursor
Declaration
string GetParName(int ParagraphPtr);
Description
Retrieves the name for a paragraph with the given ID.
ParagraphPtr must be a valid paragraph ID or one of the following constants:
1: Reads the name of the current paragraph
2: Reads the name to the parent table of this paragraph.
3: Reads the name to the parent-parent table of this paragraph.
4.2.2.34 IWPTextCursor.GotoBody
Applies to
IWPTextCursor
Declaration
procedure GotoBody;
Description
After the creation of a header, footer, textbox or footnote texts you can use GotoBody() to
return to the body text to create more text there.
Category
Hader and Footer Support
4.2.2.35 IWPTextCursor.GotoEnd
Applies to
IWPTextCursor
Declaration
procedure GotoEnd;
Description
Move cursor to the end of the text.
4.2.2.36 IWPTextCursor.GotoStart
Applies to
IWPTextCursor
Declaration
procedure GotoStart;
Description
205
The formula
DefaultText
4.2.2.40 IWPTextCursor.InputCell
Applies to
IWPTextCursor
Declaration
void InputCell(string Text, sting StyleName);
Description
Creates a new Cell in the row which was started with InputRowStart. The borders will be added
if bit 1 was set in the mode parameter for method InputRowStart. You can also change the
border and other paragraph attributes by accessing the interface CurrPar.
2006-2009 by WPCubed GmbH, Munich, Germany
206
Parameters
Text : Initialization text for this cell. You can use CurrPar to modify the cell.
Stylename : Name of the paragraph style this cell should use.
Example:
Create a table with inserted mail merge fields.
IWPMemo Memo;
Memo = WPDLLInt1.Memo;
IWPTextCursor TextCursor = Memo.TextCursor;
IWPAttrInterface CurrParAttr = Memo.CurrParAttr;
IWPParInterface par = Memo.CurrPar;
TextCursor.InputTable(0, "data");
For (int r = 1; r <= 10; r++)
{
TextCursor.InputRowStart(1);
if (r & 1 == 1) // odd rows
{
for (int c = 0; c < 3; c++)
{
TextCursor.InputCell("", "");
if (c < 2) par.ParASet((int)WPAT.COLWIDTH_PC, 20 * 100);
if (c == 2) par.ParASet((int)WPAT.COLWIDTH_PC, 60 * 100);
207
Category
Table Support
4.2.2.41 IWPTextCursor.InputCustomHTML
Applies to
IWPTextCursor
Declaration
procedure InputCustomHTML(const HTMLCode: WideString; const DisplayedText:
WideString);
Description
Creates a text object which will export custom HTML code when writing the HTML file.
4.2.2.42 IWPTextCursor.InputEmbeddedData
Applies to
IWPTextCursor
Declaration
int InputEmbeddedData( string imagefilename, int Mode,string datafilename, string dataparams,
int datamode);
This method can be used to create a certain object which can also hold binary data. The binary
data will be embedded into a PDF file when the internal PDF creation (optional feature) is used.
It is not possible to change the image later using IWPTextObj.LoadFromStream and IWPTextObj.
LoadFromFile, these methods will update the attached data, not the image. The method
Contents_LoadFromFile however will update the image data.
Parameters
The image file, may be BMP, WMF, EMF, JPG or PNG format.
imagefilenam
e
You can also use "pin", "graph", "tag" and "clip" to create an icon. The icon will be
only displayed by Acrobat Reader after the export to PDF.
Mode
Optional parameter list. You can use the parameter names contents and title.
Example: "\"Contents=this is hint text\",\"Title=Headline for the hint window\""
datamode
should be 0
Returns
0 if not successful. Otherwise the interface CurrObj can be used to change image properties.
C# Example
wpdllInt1.Memo.TextCursor.InputEmbeddedData(
Display in AcrobatReader
208
"CLIP",
0,
"C:\\my document.rtf",
"\"Contents=this is hint text\",\"Title=Headline for the hint window\"",
0);
You can load data from a stream in this object by using CurrObj.LoadFromStream
System.IO.Stream str = new System.IO.MemoryStream();
pdf.Memo.SaveToStream(
new WPDynamic.Stream2WPStream(str) ,false,"RTF");
pdf.Memo.CurrObj.LoadFromStream("Document.RTF",
new WPDynamic.Stream2WPStream(str));
4.2.2.43 IWPTextCursor.InputField
Applies to
IWPTextCursor
Declaration
int InputField(string Name, string Text, bool CursorWithin)
Description
To insert a field use is method. It expects the name of the field and the initial text. The boolean
parameter controls if the cursor should be placed inside (true) or after the new field (false).
Using the t rue you can insert multiple paragraphs or an image inside of the field.
Parameters
Name
Text
CursorWithin
"True" to place the cursor within the field markers (to add more text or an
image), otherwise use "false".
Example:
IWPTextCursor TextCursor;
TextCursor = wpdllint1.Memo.TextCursor;
TextCursor.InputField("NAME","This is the name field",false);
After you inserted a field you can manipulate the created fieldmarkes using the interface
CurrObj. For example you can use Memo.CurrObj.Mode = 2 to convert this field into an "edit
field". Such fields mark the only editable text when the editor is in "FormCompletion" Mode.
Please also see Category Mailmerge and the "mail merge API introduction".
4.2.2.44 IWPTextCursor.InputFieldObject
Applies to
IWPTextCursor
Declaration
int InputFieldObject(string Name, string Command, string DefaultText)
209
Description
Creates a text object. This are single objects which are updated by the the event
OnTextObjectGetText.
The following field names are predefined:
"PAGE" : The current page number. Parameter "Command" must be empty
"NEXTPAGE": Page number of the next page, empty string if last page
"PRIORPAGE": Previous page number, empty string if first page
"NUMPAGES": Count of pages
"DATE": The current date
"TIME": The current time
"SECTIONPAGES": Count of pages in this section
The Products RTF2PDF and TextDynamic also define this status items:
ENGINE_DLLUPTIME: seconds since loading the engine
ENGINE_UPTIME: seconds the engine object is alive
ENGINE_COUNT: total count of created engine objects since loading the engine
ENGINE_VERSION: the engine version, for example "3.50.5"
ENGINE_INFO: display dll-uptime, count, version and current date in one sentence.
SYSTEM_UPTIME: display the system uptime (using GetTickCount API)
When you need to create HTML text you can use a field with the name "HTMLCODE" and any
custom code as "command" to insert custom HTML tags into the HTML text.
Example:
This code inserts page numbering objects:
IWPTextCursor TextCursor;
TextCursor = WpdllInt1.Memo.TextCursor;
TextCursor.InputFieldObject("PAGE", "", "1");
TextCursor.InputText("/");
TextCursor.InputFieldObject("NUMPAGES", "", "9");
Note: The following action names are available. They can be used with wpaProcess or in the
menus defined inside the PCC file.
InsertTextFieldPAGE,
InsertTextFieldNEXTPAGE,
InsertTextFieldPRIORPAGE,
InsertTextFieldNUMPAGES,
InsertTextFieldSECTIONPAGES,
InsertTextFieldDATE,
InsertTextFieldTIME,
Note:
Also see function InputObject().
4.2.2.45 IWPTextCursor.InputFooter
Applies to
IWPTextCursor
Declaration
void InputFooter(int Range, string name, string Text)
Description
Create a footer with the specified "Range" selection. Please also see InputHeader and BlockAdd.
2006-2009 by WPCubed GmbH, Munich, Germany
210
Parameters
Range
Name
Text
4.2.2.46 IWPTextCursor.InputFootnote
Applies to
IWPTextCursor
Declaration
int InputFootnote( int Mode, string Text)
Description
Creates a footnote - optionally places cursor in new footnote so you can use "Input" methods
to add text.
Requires "premium" license.
Unless the footnote support (with premium license or demo) was activated with
SetEditorMode, no footnote will be created!
Parameters
WPDLLInt1.TextCursor.InputHeader(
0,
// OnAllPages
"", // no name
// The text with HTML tags
"Custom <b>Header</b>"+
// Insert tab char and set right tab at 9000 twips
"<tab right=9000/>"+
// Insert page number text object
"page <pagenr/>"+
// Insert page count text object
"/<pagecount/>");
211
212
Mode
Returns
0 if not successful. Otherwise the interface CurrObj can be used to change image properties.
Tip
To create a text box use IWPTextCursor.InputTextbox. (Requires premium license)
213
Category
Image Support
4.2.2.51 IWPTextCursor.InputPicture
Applies to
IWPTextCursor
Declaration
int InputPicture(IUnknown Picture, int Width, int Height);
Description
Insert a picture. If you use the OCX you can use any IPicture reference.
Please also see InputPictureStream which is useful to insert dynamically created images.
When using .NET convert an "Image" using the Image2Picture class: TextCursor.InputPicture
(new WPDynamic.Image2Picture(pictureBox1.Image),0,0) to get a reference usable for the
"Picture" parameter.
Parameters
Picture : IPicture reference, or, with .NET, instance of WPDynamic.Image2Picture.
Width: 0 or the desired width in twips (= 1/1440 inch)
Height : 0 or the desired height in twips
Tip
To create a text box use IWPTextCursor.InputTextbox. (Requires premium license)
Returns
0 if not successful. Otherwise the interface CurrObj can be used to change imaget properties.
Category
Image Support
4.2.2.52 IWPTextCursor.InputPictureStream
Applies to
IWPTextCursor
Declaration
int InputPictureStream(IUnknown Stream, string FileExt, int Width, int Height);
Description
Insert a picture data specified as Stream.
Parameters:
Stream: If you use the OCX you can use any IStream reference.
When using .NET convert an "Stream" using the Stream2WPStream class: TextCursor.
InputPictureStream(new WPDynamic.Stream2WPStream(stream1),".PNG",0,0);
FileExt: The file extension - it is used to use the correct loading algorithm. Values can be
"BMP", "EMF", "WMF", "JPG" and "PNG"
Width: 0 or the desired width in twips (= 1/1440 twips)
Height: 0 or the desired height in twips
Returns
0 if not successful. Otherwise the interface CurrObj can be used to change image properties.
214
Example 1:
Create a file stream from an image file and insert it.
IWPTextCursor TextCursor = WPDLLInt1.Memo.TextCursor;
FileStream stream = new FileStream(
"C:\\WPCubedLogo.jpg",FileMode.Open);
TextCursor.InputPictureStream(
new WPDynamic.Stream2WPStream(stream),"jpg",
0,0);
stream.Close();
Width and Height are always measured in twips (= 1/1440 inch). If 0, the content width and
height will be used.
Example 2:
Create an image "on the fly" and insert it.
Bitmap aBitmap = new Bitmap(320, 200);
Graphics aGraphic = Graphics.FromImage(aBitmap);
System.IO.MemoryStream aStream = new System.IO.MemoryStream();
IWPMemo Memo = wpdllInt1.Memo;
IWPTextCursor TextCursor = Memo.TextCursor;
aGraphic.Clear(Color.AntiqueWhite);
SolidBrush RedBrush = new SolidBrush(Color.Red);
aGraphic.FillEllipse(RedBrush, 10, 10, 300, 180);
aBitmap.Save(aStream,System.Drawing.Imaging.ImageFormat.Bmp);
TextCursor.InputPictureStream(new WPDynamic.Stream2WPStream(aStream), "BMP", 0,
0);
// clean up
aStream.Dispose();
aGraphic.Dispose();
aBitmap.Dispose();
// ReleaseInt was added to TextDynamic V1.31
wpdllInt1.ReleaseInt(TextCursor);
wpdllInt1.ReleaseInt(Memo);
4.2.2.53 IWPTextCursor.InputObject
Applies to
IWPTextCursor
Declaration
int InputObject(TextObjTypes ObjType, string Name, string Command, int Mode)
Description
Creates different object kinds at cursor position. It can be used to create a single object and
an object pair.
Note: If you need to create a "text object" you can also use InputFieldObject, for mail merge
fields use InputField.
Parameters
ObjType
215
TextObjTypes:
0=(default, will create "text object")
1=merge field,
2=hyperlink,
3=bookmark,
7=text object,
8=page reference,
11=footnote,
12=image, text box or other classes (see name)
13=horizontal lines (use IWPTextObj.SetProp(19, color) to change the color)
The name of the new object.
This can be the name of a page reference, bookmark or mail-merge field.
"Text objects" can use the following predefined names:
'PAGE', 'NEXTPAGE', 'PRIORPAGE', 'NUMPAGES', 'DATE', 'TIME' and
'SECTIONPAGES'. You can use other names but then have to use the event
OnTextObjectGetText to provide the text which should be actually
displayed.
Name
If You specify ObjType=12 You can specify a custom obj class name here.
Please ask WPCubed for availability and customization of special objects.
Command
Mode
If bit 1 is set an object pair will be created. The cursor will be placed within
both objects.
Bit 2 activates the "editable" mode used for form fields. This must be
combined with ObjType=1
Returns
0 if not successful. Otherwise the interface CurrObj can be used to change object properties.
Enum TextObjTypes:
216
4.2.2.54 IWPTextCursor.InputCode
Applies to
IWPTextCursor
Declaration
int InputCode( int Mode: Integer; string Par1: WideString; string Par2: WideString);
Description
This Method creates a text object pair of type "wpobjCode". This type is reserved for XML
editing.
Par1 will be assigned to the name, Par2 will be assigned to the "Source" property of the object.
The following mode bits can be set
1 : WrapSelectedText
2 : DeleteSelectedText
4: PlaceCursorAfterStart
8: DropMarkersOutside
16: DropMarkersInside
4.2.2.55 IWPTextCursor.InputPagebreak
Applies to
IWPTextCursor
217
Declaration
procedure InputPagebreak;
Description
Creates a page break. If the current position is not at the start of a paragraph it will first
create a paragraph break at the current position and insert the page break before the new
paragraph.
InputPagebreak Example
Mode
Bits:
1 : Start a new page before new paragraph
2 : If currently in table append the new
paragraph after the table. (Alternative:
IWPTextCursor.ExitTable)
StyleName
Category
Paragraphstyle Support
4.2.2.57 IWPTextCursor.InputRowEnd
Applies to
IWPTextCursor
Declaration
procedure InputRowEnd;
Description
Closes a row which was started with InputRowStart.
Category
2006-2009 by WPCubed GmbH, Munich, Germany
218
Table Support
4.2.2.58 IWPTextCursor.InputRowStart
Applies to
IWPTextCursor
Declaration
procedure InputRowStart(Mode: Integer);
Description
Start a new row. This is only possible after InputTable or after InputRowEnd.
Parameters
Mode
This VB.NET example creates a table with merged cells and alternated use of paragraph
styles:
'Initialize Styles
Dim headsty As String = "TableHeaderStyle"
Memo.SelectStyle(headsty)
Memo.CurrStyle.ParColor = WpdllInt1.ColorToRGB(Color.Black)
Memo.CurrStyle.ParShading = 30 ' 30% shading
'Style for odd rows (is empty)
Memo.SelectStyle("DataOdd")
'Style for even rows (shaded)
Memo.SelectStyle("DataEven")
Memo.CurrStyle.ParColor = WpdllInt1.ColorToRGB(Color.Blue)
Memo.CurrStyle.ParShading = 20 ' 20% blue
'Create a table
TextCursor.InputTable(0, "")
TextCursor.InputRowStart(1) ' with border
' Now 3 cells merged as two one
TextCursor.InputCell("This is the header text", headsty)
Cell.Alignment = 1 'center
TextCursor.InputCell("", headsty)
Cell.IsColMerge = True
TextCursor.InputCell("", headsty)
Cell.IsColMerge = True
TextCursor.InputRowEnd()
' Now some rows below, 3 columns each
Dim i As Integer = 1
Dim sty As String
While i <= 10
If (i And 1) = 0 Then
sty = "DataEven"
Else
sty = "DataOdd"
End If
TextCursor.InputRowStart(1)
TextCursor.InputCell(i, sty)
Cell.ParASet(WPAT.COLWIDTH_PC, 10 * 100) ' 10%
Cell.ParAAddBits(WPAT.CharStyleON, 1) 'Bold
Cell.ParAAddBits(WPAT.CharStyleMask, 1) 'Bold
TextCursor.InputCell("", sty)
Cell.ParASet(WPAT.COLWIDTH_PC, 45 * 100) ' 45%
TextCursor.InputCell("", sty)
Cell.ParASet(WPAT.COLWIDTH_PC, 45 * 100) ' 45%
TextCursor.InputRowEnd()
i = i + 1
End While
219
220
Example:
// a) Create
IWPPageSize sect;
sect = wpdllInt1.TextCursor.InputSection(1);
sect.Landscape = true;
wpdllInt1.ReleaseInt(sect);
// b) Modify
IWPPageSize sect;
sect = wpdllInt1.TextCursor.InputSection(-1);
if (sect!=null)
{
sect.Landscape = true;
wpdllInt1.ReleaseInt(sect);
}
Note: the select flag (use SetProp/GetProp) to set and read it will be automatically set when a
property is changed.
Returns
Reference to IWPPageSize interface to modify the page size used by this section.
4.2.2.60 IWPTextCursor.InputString
Applies to
IWPTextCursor
Declaration
procedure InputString(const Text: WideString; CharAttrIndex: Integer);
Description
Inserts a string at cursor position
Parameters
Text
CharAttrIndex
221
Tip:
To read the character at the current position use
Memo.CurrPar.GetChar(Memo.TextCursor.CPPosInPar)
Example:
// We need this interfaces for text creation
IWPMemo Memo = WPDLLInt1.Memo;
IWPTextCursor TextCursor = Memo.TextCursor;
IWPAttrInterface AttrHelper = WPDLLInt1.AttrHelper;
// Calculate a character style index value
AttrHelper.Clear();
AttrHelper.SetFontface("Times New Roman");
AttrHelper.SetFontSize(11);
AttrHelper.IncludeStyles(2); // Italic
int mycharattr = AttrHelper.CharAttrIndex;
// and insert some text
TextCursor.InputString("Hello World", mycharattr);
4.2.2.61 IWPTextCursor.InputTable
Creates and fills a table not using a callback
Applies to
IWPTextCursor
Declaration
void InputTable(int Width, string Name);
Description
Creates a table object. Create each row with InputRowStart followed by some InputCell and
finished by InputRowEnd. Use InputParagraph to create text after the table. You can use
MoveToTable to later locate the table.
Note: Please make sure to create an empty paragraph at the end of a text - otherwise some
RTF readers have problems to load it. To do so use InputParagraph when the table is complete.
This C# example creates a table with 10 rows and 3 columns:
IWPMemo Memo;
Memo = WPDLLInt1.Memo;
IWPTextCursor TextCursor = Memo.TextCursor;
IWPAttrInterface CurrParAttr = Memo.CurrParAttr;
TextCursor.InputTable(0, "data");
For (int r = 0; r < 10; r++)
{
TextCursor.InputRowStart(1);
For(int c = 0; c < 3; c++)
{
TextCursor.InputCell("some text", "");
// This cell should use bold Text
If(c==0)CurrParAttr.IncludeStyles(1);
}
TextCursor.InputRowEnd();
}
TextCursor.InputParagraph(0,"");
Memo.Reformat();
222
This code creates a table by appending one row and one cell after each other. After the
creation of each cell this cell can be modified using the CurrParAttr and CurrPar interfaces.
The table is created named as "data". So you can use TextCursor.MoveToTable("data") to
move the cursor to the first cell in this table anytime later.
You can use CurrPar and CurrParAttr to modify the tables, rows and cells right after the have
been created.
This C# example creates a table with 5 rows and 2 cells, width = 10 and 90%:
IWPMemo memo = wpdllInt1.Memo;
IWPAttrInterface atr = wpdllInt1.AttrHelper;
IWPParInterface par = memo.CurrPar;
IWPAttrInterface parattr = memo.CurrParAttr;
IWPTextCursor cursor = memo.TextCursor;
// Start a table
cursor.InputTable(0,"");
// use 50 % of the page width
par.ParASet((int)WPAT.BoxWidth_PC, 50*100);
// Now create 5 rows
For (int r = 1; r <= 5; r++)
{
cursor.InputRowStart(0);
// With 2 cells Each, 10 And 90 % width
cursor.InputCell(r.ToString(),"");
par.ParASet((int)WPAT.COLWIDTH_PC, 10*100);
par.ParColor = wpdllInt1.ColorToRGB(Color.Gray);
parattr.IncludeStyles(1); // bold Text
// The second cell uses different Text attributes
cursor.InputCell("","");
par.ParASet((int)WPAT.COLWIDTH_PC, 90*100);
// Append normal Text
atr.Clear();
par.AppendText("Normal ", atr.CharAttrIndex);
atr.IncludeStyles(1); // bold Text
par.AppendText("and bold", atr.CharAttrIndex);
// This row is finished
cursor.InputRowEnd();
}
// Format And display
memo.ReformatAll(False, True);
Category
Table Support
4.2.2.62 IWPTextCursor.InputTabstop
Applies to
IWPTextCursor
Declaration
procedure InputTabstop(ClearAllTabs: WordBool; Value: Integer; Kind: Integer;
FillMode: Integer);
Description
This method creates a tab-stop and also inserts the tab character. It can optionally clear the
existing tabstops. If you only want to define a tab-stop but do not need to insert the tab
2006-2009 by WPCubed GmbH, Munich, Germany
223
Value
Kind
Fill
This VB.NET example code inserts page numbering objects aligned at the right margin of the
page. You can use it to add page numbers in a header or footer texts.
Dim Memo As IWPEditor
Memo = WpdllInt1.Memo
Dim TextCursor As IWPTextCursor
TextCursor = Memo.TextCursor
TextCursor.InputText(" Page ")
TextCursor.InputTabstop(False, _
Memo.PageSize.PageWidth - Memo.PageSize.LeftMargin - Memo.PageSize.
RightMargin, _
1, 1)
TextCursor.InputObject(TextObjTypes.wpobjTextObject, "PAGE", "", 0)
TextCursor.InputText(" of ")
TextCursor.InputObject(TextObjTypes.wpobjTextObject, "NUMPAGES", "", 0)
4.2.2.63 IWPTextCursor.InputTextbox
Applies to
IWPTextCursor
Declaration
int InputTextbox(int Width, string Text);
Description
Creates a text box. If no text was specified the cursor will be placed within the text object
layer. You can use InputText to add more text. This feature requires the "premium" license, it is
always available in RTF2PDF.
After the insertion of the text box you can set the relative location using
Memo.CurrObj.RelX = twips value;
Memo.CurrObj.RelY = twips value;
Using CurrObj.Frame You can select the type of frame (border) which is drawn for the box.
Please note that after GotoBody the interface CurrObj cannot be used anymore.
2006-2009 by WPCubed GmbH, Munich, Germany
224
Unless the text box support (with premium license or demo) was activated with
SetEditorMode, no textbox will be created!
Parameters:
Width : The Width of the box in twips. The height is always determined by the contained text.
Text : The initialization text - may contain HTML or RTF tags. To create an empty box use
"CLEAR". If no text was specified (except "CLEAR") the cursor will be places inside the new text
box. You can fill in text and then call GotoBody when you are done.
Returns
0 if not successful. Otherwise the interface CurrObj can be used to change object properties.
Tips:
Using CurrObj.property Wrap you can change the way the text wraps around the box.
RelX and RelY are the offset coordinates (in twips) to the anchor point. By default is the anchor
point the origin of the current paragraph. If you want to make the current page the origin use
PositionMode = 2
Example:
TextCursor.InputTextbox(2880, "");
// Save writing mode, then enter some text
int save_ch = Memo.CurrAttr.CharAttrIndex;
Memo.CurrAttr.SetFontSize(8);
for (int i = 0; i < 10; i++)
TextCursor.InputText("text box with wrapped text ");
Memo.CurrPar.Alignment = 3; // justified text
Memo.CurrObj.RelX = 3500;
Memo.CurrObj.RelY = 720;
Memo.CurrObj.Wrap = 4;
Memo.CurrObj.Frame = 1;
TextCursor.GotoBody();
Memo.CurrAttr.CharAttrIndex = save_ch;
Memo.CurrPar.Alignment = 3;
for (int i = 0; i < 30; i++)
TextCursor.InputText("some wrapped text ");
2006-2009 by WPCubed GmbH, Munich, Germany
225
VB Example:
Dim
Dim
Set
Set
Memo As IWPMemo
Cursor As IWPTextCursor
Memo = WPDLLInt1.Memo
Cursor = Memo.TextCursor
'find out how to set to set the relx to the actual cursor position.
Dim x As Long
Dim y As Long
Dim page As Long
' this would check the mouse coordinates
' Memo.GetMouseXY page, x, y
' this checks the text cursor position
Memo.GetXY 3, x, y
4.2.2.64 IWPTextCursor.InputText
Applies to
IWPTextCursor
Declaration
procedure InputText(const Text: WideString);
Description
Writes some text suing current writing attributes. You can use InputString if you want to
specify a character attribute index.
4.2.2.65 IWPTextCursor.InsertRow
Applies to
IWPTextCursor
Declaration
function InsertRow(Before: WordBool): WordBool;
Description
Insert a row after the current row. With parameter "Before"=true the row will be inserted before
the current.
The text in the row is not duplicated unless the mode DuplicateWithText has been activated
226
using Memo.SetBProp(18,1);
Tip: A table row can also be duplicated using the CurrPar interface. Here we first let the CurrPar
interface modify the current row and then call Duplicate():
Cursor.CPTableRowNr = 1; // goto row 1
Memo.CurrPar.SetPtr( Cursor.CPRowPtr );
while(rowcount-->0) Memo.CurrPar.Duplicate();
4.2.2.66 IWPTextCursor.MarkerCollect
Applies to
IWPTextCursor
Declaration
procedure MarkerCollect(ID: Integer);
Description
Remove the marker with the given ID.
Category
Position Markers
4.2.2.67 IWPTextCursor.MarkerCollectAll
Applies to
IWPTextCursor
Declaration
procedure MarkerCollectAll;
Description
Remove all markers.
Category
Position Markers
4.2.2.68 IWPTextCursor.MarkerCPPosition
Applies to
IWPTextCursor
Declaration
function MarkerCPPosition(ID: Integer): Integer;
Description
Calculate the character position which matches the marker with the given ID.
Category
Position Markers
4.2.2.69 IWPTextCursor.MarkerDrop
Applies to
IWPTextCursor
Declaration
int MarkerDrop(int Mode);
Description
Insert a marker and return the ID.
Mode can be
0 : drop a maker at the cursor position
1 : drop the marker at the start of the selection
2 : drop the marker at the end of the selection
Category
Position Markers
4.2.2.70 IWPTextCursor.MarkerGoto
Applies to
IWPTextCursor
Declaration
void MarkerGoto(bool Collect; int ID);
Description
Move the cursor to a marker, optionally collect it.
Category
Position Markers
4.2.2.71 IWPTextCursor.MarkerSelect
Applies to
IWPTextCursor
Declaration
procedure MarkerSelect(StartID: Integer; EndID: Integer);
Description
Select the text between marker with ID#1 and ID#2.
Category
Position Markers
4.2.2.72 IWPTextCursor.MovePosition
Applies to
IWPTextCursor
Declaration
void MovePosition(int MoveMode, bool SelectText);
Description
Moves the cursor, optionally select text.
Parameters
MoveMode
0
1
2
3
4
5
6
= LineStart
= Line End
= Page Up
= Page Down
= Start of Text (Home)
= End of Text
= Cursor left
227
228
SelectText
If parameter SelectText = true the text will be selected from current to new
position.
4.2.2.73 IWPTextCursor.MoveToBookmark
Applies to
IWPTextCursor
Declaration
function MoveToBookmark(const Name: WideString): WordBool;
Description
Moves the cursor to the specified bookmark. Returns true if bookmark was found, false if it was
not found.
Category
Hyperlinks and Bookmarks
4.2.2.74 IWPTextCursor.MoveToField
Applies to
IWPTextCursor
Declaration
bool MoveToField( string Name, int Mode, int Option);
This is a versatile methods to jump to and between mail merge fields:
Mode = 0:
Locate the first field in the text, or the first field with the provided name if parameter "name"
was not empty.
Mode = 1:
Locate the next field in the text, or the next field with the provided name if parameter "name"
was not empty.
Mode = 2:
Locate previous field
Mode = 3
Locate the last field
If bit 1 was set in parameter "option" the cursor will be positioned after the field object.
This example will move to all fields (from current position) and select the text.
if(wpdllInt1.Memo.TextCursor.MoveToField("",1,1))
wpdllInt1.Memo.CurrObj.Select(2)
229
4.2.2.75 IWPTextCursor.MoveToObject
Applies to
IWPTextCursor
Declaration
bool MoveToObject( int ObjType, string Name);
This method can be used to find a certain object with the given type and the given name.
4.2.2.76 IWPTextCursor.MoveToTable
Applies to
IWPTextCursor
Declaration
bool MoveToTable(string Name);
Description
Moves to a table with a given name. The methods AddTable and InputTable allow it to give the
table a name. If no table was found the result value will be false.
if (TextCursor.MoveToTable("MYTABLE"))
{
int val, sum = 0,i = 1;
Random rnd = new Random();
while(true)
{
TextCursor.CPTableColNr = 0; // First Cell
TextCursor.InputText(i.ToString());
TextCursor.CPMoveNextCell();
val = rnd.Next(1000);
TextCursor.InputText(val.ToString());
TextCursor.CPMoveNextCell();
sum+=val;
TextCursor.InputText(sum.ToString());
if (!TextCursor.CPMoveNextRow(false)) break;
}
}
You may pass an empty string to locate the first table in the document. "{NESTEDTABLE}" will
locate the first nested table in the current table cell. "{NEXTTABLE}" will locate the next table
within the current nesting level. In case a table was found the cursor will be always moved into
the first cell of the table.
Tip: You can use the methods ASetCellProp and ASetCellStyle to quickly modify the properties,
text and styles of certain cells in an existing table.
4.2.2.77 IWPTextCursor.Redo
Applies to
IWPTextCursor
Declaration
function Redo: WordBool;
230
Description
Undoes the last UNDO action.
Category
Standard Editing Commands
4.2.2.78 IWPTextCursor.ReplaceText
Applies to
IWPTextCursor
Declaration
function ReplaceText(const Text: WideString; const NewText: WideString;
FromStart: WordBool; CaseSensitive: WordBool; WholeWords: WordBool; ReplaceAll:
WordBool): Integer;
Description
Replaces Text
Parameters
Text
NewText
FromStart
CaseSensitive
WholeWords
ReplaceAll
Replace all
Returns
The count of replacements
4.2.2.79 IWPTextCursor.ReportConvertTable
Applies to
IWPTextCursor
Declaration
procedure ReportConvertTable(const GroupName: WideString; Options: Integer);
Description
Convert the current table into a reporting group.
Parameters
GroupName
Options
Reserved
Category
Reporting
4.2.2.80 IWPTextCursor.ReportConvertText
Applies to
IWPTextCursor
Declaration
procedure ReportConvertText(const GroupName: WideString; Options: Integer);
Description
Convert the current document into a reporting group.
Parameters
GroupName
Options
Reserved
Category
Reporting
4.2.2.81 IWPTextCursor.ReportInputBand
Applies to
IWPTextCursor
Declaration
procedure ReportInputBand(Typ: Integer; const Name: WideString; Options:
Integer);
Description
__RESERVED__
Category
Reporting
4.2.2.82 IWPTextCursor.ReportInputGroup
Applies to
IWPTextCursor
Declaration
procedure ReportInputGroup(const Name: WideString; Options: Integer; Were:
Integer);
Description
__RESERVED__
Category
Reporting
4.2.2.83 IWPTextCursor.ScrollToCP
Applies to
IWPTextCursor
Declaration
void ScrollToCP();
Description
Scrolls to the current paragraph.
231
232
4.2.2.84 IWPTextCursor.SelectAll
Applies to
IWPTextCursor
Declaration
procedure SelectAll;
Description
Select the complete text
Category
Standard Editing Commands
4.2.2.85 IWPTextCursor.SelectLine
Applies to
IWPTextCursor
Declaration
procedure SelectLine;
Description
Select the current line
Category
Standard Editing Commands
4.2.2.86 IWPTextCursor.SelectParagraph
Applies to
IWPTextCursor
Declaration
procedure SelectParagraph;
Description
Select the current paragraph
Category
Standard Editing Commands
4.2.2.87 IWPTextCursor.SelectTable
Applies to
IWPTextCursor
Declaration
procedure SelectTable;
Description
Select the current table
Category
Standard Editing Commands
Table Support
SelEnd
4.2.2.91 IWPTextCursor.SetColWidth
Applies to
IWPTextCursor
Declaration
function SetColWidth(Mode: Integer; Value: Integer; IsPercent: WordBool):
WordBool;
Description
Modify the width of the current column.
Parameters
Mode
Value
233
234
IsPercent
4.2.2.92 IWPTextCursor.SetParName
Applies to
IWPTextCursor
Declaration
function SetParName(ParagraphPtr: Integer; const Name: WideString): WordBool;
Description
Set the name of the paragraph with the given ID.
ParagraphPtr must be a valid paragraph ID or one of the following constants:
1: Assigns the name of the current paragraph
2: Assigns the name to the parent table of this paragraph. Returns false if not in a table. The
table name can be used in MoveToTable.
3: Assigns the name to the parent-parent table of this paragraph. Returns false if not in a
nested table.
Note: CurrPar.ParStrCommand can also change table or paragraph names.
Also see: IWPTextCursor.GetParName
4.2.2.93 IWPTextCursor.SetRowHeight
Applies to
IWPTextCursor
Declaration
bool SetRowHeight(int Mode, int MinHeight, int MaxHeight);
Description
Set the height of the current row or all rows in the table.
Parameters
Mode
0: change only current row
1: change all rows in current table
2: change rows which have selected cells.
MinHeight 0 or the minimum height in twips
MaxHeigh 0 or the maximum heigt in twips
t
Important
Please make sure that either MinHeight or MaxHeight is 0 since in RTF format only one of this
values can be stored (tag: \trrh).
235
4.2.2.94 IWPTextCursor.SetTableLeftRight
Change width and margins.
Applies to
IWPTextCursor
Declaration
bool SetTableLeftRight(int LeftTW, int RightTW, int WidthTW, int WidthPC);
Description
Change the width and the margins of the current table.
Parameters
LeftTW
-1 or the new left offset in twips
RightTW
WidthTW
WidthPC
Category
Table Support
4.2.2.95 IWPTextCursor.TableClear
Initialize a table.
Applies to
IWPTextCursor
Declaration
procedure TableClear(KeepHeader: Integer; KeepFooter: Integer; KeepBody:
Integer; KeepProtected: WordBool; KeepFields: WordBool; KeepColsLeft: Integer;
KeepColsRight: Integer);
Description
Versatile function to initialize the current table. It can delete not required table body rows,
clear required body rows but protect header and footer rows.
Parameters
KeepHeader
KeepFooter
KeepBody
KeepProtected
KeepFields
KeepColsLeft
KeepColsRight
Category
Table Support
236
4.2.2.96 IWPTextCursor.TableDelete
Applies to
IWPTextCursor
Declaration
function TableDelete: WordBool;
Description
Deletes the current table.
Category
Table Support
4.2.2.97 IWPTextCursor.Undo
Applies to
IWPTextCursor
Declaration
function Undo: WordBool;
Description
Undeos the last change to the text.
Category
Standard Editing Commands
4.2.2.98 IWPTextCursor.UndoClear
Applies to
IWPTextCursor
Declaration
procedure UndoClear;
Description
Clears the undo buffer.
Category
Standard Editing Commands
4.2.2.99 IWPTextCursor.WordCharAttr
Applies to
IWPTextCursor
Declaration
function WordCharAttr(const AWord: WideString; CaseSensitive: WordBool;
OnylActiveText: WordBool; CharAttrIndex: Integer): Integer;
Description
Method to assign a certain character attribute index to certain words in the text.
Parameters
AWord
CaseSensitive
OnlyActiveText
Category
Character Attributes
4.2.2.100 IWPTextCursor.WordEnum
Applies to
IWPTextCursor
Declaration
function WordEnum(const AWord: WideString; CaseSensitive: WordBool;
OnlyActiveText: WordBool; ParamForEvent: LongWord): Integer;
Description
Triggers the event OnEnumParOrStyle for all occurances of the given word. (A "word" is text
which is enclosed in space or punctation characters!)
C# Example to make all occurances of "td" (not case sensitive) bold and replace it with
"TextDynamic".
CaseSensitive
OnlyActiveText
ParamForEvent
4.2.2.101 IWPTextCursor.WordHighlight
Applies to
2006-2009 by WPCubed GmbH, Munich, Germany
237
238
IWPTextCursor
Declaration
function WordHighlight(const AWord: WideString; CaseSensitive: WordBool;
OnlyActiveText: WordBool; RemoveHighlight: WordBool): Integer;
Description
Applies a temporary highlight flag to certain words
wpdllInt1.TextCursor.WordHighlight("test",
false,false,!checkBox1.Checked);
Parameters
AWord
CaseSensitive
OnlyActiveText
RemoveHighlight
4.2.2.102 IWPTextCursor.SetColumns
Applies to
IWPTextCursor
Declaration
int SetColumns( int Command,
int Value);
Description
Applies properties to control the text column feature (not table columns). You need the
"Premium" license to use this feature.
The following command IDs are supported:
0
1
2
3
4
5
:
:
:
:
:
:
239
Memo.Reformat();
4.2.2.103 IWPTextCursor.SelectCell
Applies to
IWPTextCursor
Declaration
void SelectCell( bool AddToSelection);
Description
Activate the selection mode for the current cell. It is possible to select several cells to apply an
attribute using CuurSelAttr.
TextCursor.SelectCell(true);
TextCursor.CPMoveNextCell();
TextCursor.SelectCell(true);
TextCursor.CPMoveNextRow(false);
TextCursor.SelectCell(true);
Memo.CurrSelAttr.AttrSET((int)WPAT.ShadingValue, 10);
Memo.CurrSelAttr.AttrSET((int)WPAT.FGColor, 2);
TextCursor.HideSelection();
4.2.2.104 IWPTextCursor.EnumOpenObj
Applies to
IWPTextCursor
240
Declaration
int EnumOpenObj( int ObjType, int EventParam);
Description
This method calls the event OnEnumTextObj for all open markers at the current position.
4.2.2.105 IWPTextCursor.ExitTable
Applies to
IWPTextCursor
Declaration
void ExitTable();
Description
Leaves the current table. The cursor is located in the next paragraph after the table. If
necessary a new paragraph will be created.
TextCursor.ExitTable();
TextCursor.InputText("Text after the table");
4.2.2.106 IWPTextCursor.TableSplit
Applies to
IWPTextCursor
Declaration
bool TableSplit(bool BeforeRow);
Description
Splits the table after or before the current row.
Example :
TextCursor.TableSplit(false);
TextCursor.ExitTable();
TextCursor.InputText("Text between tables");
Memo.ReformatAll(false, true);
4.2.2.107 IWPTextCursor.TableSort
Applies to
IWPTextCursor
Declaration
bool TableSort(int HeaderRows, int FooterRow, int SelectColumn, int Method);
Description
This method sorts the rows in a table.
The given count of header and footer rows are not sorted. You can pass -1 to let header and
footer rows be auto detected.
241
:
:
:
:
4.2.2.108 IWPTextCursor.ASetCellProp
Applies to
IWPTextCursor
Declaration
void ASetCellProp(int HeaderRows, bool OddRows, bool EvenRows, int FooterRows,
int FromColumn, int ToColumn, int WPAT_Code, int Value, int Mode);
Description
Applies a certain attribute to either header, footer or body rows. For table body rows you can
select if odd and/or even rows should be changed.
The value of HeaderRows or FooterRows must be the negative to leave this rows unchanged!
242
It is possible to only set a range (1...n ) of columns or a complete rows with both FromColumn
and TopColumn = 0.
The parameter Mode changes the way the attribute is applied:
-3 : clear all character attributes (from the text!)
-2 : clear all paragraph attributes
-1 : remove the given attribute
0 : set the attribute
1 : OR the attribute with the value
2 : AND NOT the attribute with the value
3 : Increase the value of the attribute by the given amount
4 : Set the row number as text
5 : Set the row number as literal A..Z as text
6 : Merges with previous row. (Not in first cell of the selected from-to range!)
Example:
4.2.2.109 IWPTextCursor.ASetCellStyle
Applies to
IWPTextCursor
Declaration
void ASetCellStyle(int HeaderRows, [In] bool OddRows, bool EvenRows, int
FooterRows, int FromColumn, int ToColumn, string StyleName, int Mode);
Description
Applies a certain attribute to either header, footer or body rows. For table body rows you can
select if odd and/or even rows should be changed.
The value of HeaderRows or FooterRows must be the negative to leave this rows unchanged!
It is possible to only set a range (1...n ) of columns or a complete rows with both FromColumn
and ToColumn = 0.
If parameter Modes<33 it is used as bit-field:
0 : Select the paragraph style (adds it if necessary)
1 : Select the paragraph style and clear the paragraph attributes
2 : Select the paragraph style and clear the character attributes stored in the paragraph
2006-2009 by WPCubed GmbH, Munich, Germany
Example:
4.2.2.110 IWPTextCursor.MergeCellHorz
Applies to
IWPTextCursor
Declaration
bool MergeCellHorz(int CellCount);
Description
Merges the selected cells with CellCount = 0 (same effect as CombineCellHorz).
Otherwise, CellCount must be >1, the number of cells are merged:
243
244
4.2.2.111 IWPTextCursor.MergeCellVert
Applies to
IWPTextCursor
Declaration
bool MergeCellVert(int CellCount);
Description
Merges the selected cells when CellCount = 0. In this case the method works like
CombineCellVert.
Otherwise the number of Rows (CellCount must be >1) are vertically merged:
4.2.2.112 IWPTextCursor.ClearAllHeaders
Applies to
IWPTextCursor
Declaration
void ClearAllHeaders();
Description
Clears all headers in the text.
4.2.2.113 IWPTextCursor.ClearAllFooters
Applies to
IWPTextCursor
Declaration
void ClearAllFooters();
Description
Clears all footers in the text.
4.2.3
This C# example loops through the text and create HTML which consist only of <p> and <a> t
IWPMemo Memo = wpdllInt1.Memo;
StringBuilder HtmlText = new StringBuilder();
IWPTextCursor TextCursor;
IWPTextObj Obj;
IWPParInterface par = Memo.CurrPar;
bool parstart = true;
Memo = wpdllInt1.Memo;
TextCursor = Memo.TextCursor;
Obj = Memo.CurrObj;
2006-2009 by WPCubed GmbH, Munich, Germany
245
TextCursor.GotoStart();
while(true)
{
if (parstart)
{
HtmlText.Append("<p>");
parstart = false;
}
if (TextCursor.CPObjPtr!=0)
{
if (Obj.ObjType==TextObjTypes.wpobjHyperlink)
{
HtmlText.Append("<a href=\"");
HtmlText.Append(Obj.Command);
HtmlText.Append("\">");
HtmlText.Append(Obj.EmbeddedText);
HtmlText.Append("</a>");
Obj.MoveCursor(4); // Before end tag - we skip later
}
}
else if (TextCursor.CPPosInPar>=par.CharCount)
{
HtmlText.Append("</p>\r\n");
parstart = true;
}
else HtmlText.Append( (char)par.GetChar(TextCursor.CPPosInPar), 1 );
if (!TextCursor.CPMoveNext()) break;
}
MessageBox.Show(HtmlText.ToString(),"");
4.3
246
To do so, the DLL exports a single procedure to create a complete editor window.
There are still various possibilities to customize the editor. Only the DLL is used in this case, no
ActiveX or .NET wrapper.
This method has been created to allow editing fast, with a minimum programming interface.
4.3.1
Only a few lines of code are required to build a verstile and powerful editor in Visual Studio
2008:
Our demo uses this code to initialize the "create" function
// Pointer to TextDynamic
fkt_wptextCreateDialog* wptextCreateDialog;
Later, in
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
this code is executed:
1) Creation of editor
case WM_CREATE:
2006-2009 by WPCubed GmbH, Munich, Germany
247
{
DefWindowProc(hWnd, message, wParam, lParam);
unsigned long editorw; //not used
static TDCreateDialogParam param;
if(InitTD())
{
param.size = sizeof(param);
param.modes = 1;
param.editor_mode = 4; // with thumbnails
param.editor_xmode = 255; // all features
param.editor_gui1 = 478;
param.editor1_layoutmode = 7; // Full Layout
param.editor1_autozoom = 1; // Width
// We can set all "Memo.SetBProp" flags.
// Using Group=0, ID=11 (bit 11) we activate Image
drag&drop
param.Memo1_SetBProp_ADD[0] = (1024 * 2); // Bit 11 ->
AcceptFiles
param.pccfile = "{dll}buttons.pcc";
edhwnd = wptextCreateDialog(hWnd, ¶m, 10, 10, 300,
300, &editorw );
}
2) Sizing of the editor
case WM_SIZE:
DefWindowProc(hWnd, message, wParam, lParam);
if(edhwnd)
{
RECT Rect;
GetClientRect(hWnd, &Rect);
MoveWindow(edhwnd, Rect.left, Rect.top, Rect.right-Rect.left,
Rect.bottom-Rect.top, false);
}
break;
3) Avoid flickering
case WM_ERASEBKGND: //<--break;
Thats All!
4.3.2
Using the editor window handle, it is also possible to send commands to the editor
using the window API SendMessage.
Very easy to use are the "wpa Actions".
Simply use this message IDs to send the action names to the current, the first or
the second editor.
248
WMP_WPA_PROCESS
WMP_WPA_PROCESS_1
WMP_WPA_PROCESS_2
You can use all "wpa" action names, such as "diaOpen", "diaSave" etc. See complete
List.
This pascal code will show the file open dialog:
SendMessage(EditorHwnd, 1051,
Integer(PChar('diaOpen')), 0);
case WM_COMMAND:
wmId
= LOWORD(wParam);
wmEvent = HIWORD(wParam);
switch (wmId)
{
case ID_FILE_LOAD:
SendMessage(edhwnd, 1051, (int)((char *)"diaOpen"), 0);
break;
case ID_FILE_SAVE:
SendMessage(edhwnd, 1051, (int)((char *)"diaSaveAs"),
0);
break;
4.3.3
Use Commands
- for c
- for e
- for e
249
=
=
=
=
WPDLL_COM
WPDLL_COM
WPDLL_COM
WPDLL_COM
+
+
+
+
26;
27;
28;
29;
//
//
//
//
buffer1=filename, buffer2=forma
buffer1=filename, buffer2=forma
buffer1=str, buffer2=format, pa
out: datastring, buffer2=format
4.3.4
= 145;
= 146;
// Result :=
// Result :=
IWPMemo of Editor 1
IWPMemo of Editor 2
The definition of the Interfaces (TLB) is included in the TextDynamic OCX. You can
import this TLB into Your project and autogenerate a the definition code.
4.3.5
Examples
Here we show how to access the embedded editor. The variable edhwnd is the
window handle of the editor. It is returned by the method fkt_wptextCreateDialog.
Please see Initialization of the editor in C++
Load the file c:\test.rtf into the editor. We use the command
WPDLL_COM_TEXT_LOADFILE (See c++ header)
SendMessage(edhwnd, 1042, WPDLL_COM_TEXT_LOADFILE,(int)((char *)"c:\
\TEST.RTF"));
2006-2009 by WPCubed GmbH, Munich, Germany
250
251
Set a certain fixed page count. The editor should always display 8 pages. Please also
see Memo.TextCommand(24).
4.3.6
Pascal Definition
unit WPDLL_CreateDlgInt;
// ----------------------------------------------------------------------------// Create TextDynamic Interface
252
// Date: 5.10.2009
// ----------------------------------------------------------------------------interface
uses Windows;
type
fkt_wptextDialogCB = function(
handle : HWND;
code
: Integer; // mesage id
iparam : Integer; //
lparam : Cardinal;
sparam : PAnsiChar;
memo
: Pointer // IWPMemo // can be null. Current editor
) : Integer;
fkt_wptextDialogShow = function(
handle : HWND;
code
: Integer; // message id
memo
: Pointer; // IWPMemo; // can be null. First editor
memo2
: Pointer // IWPMemo // can be null. Second editor
) : Integer;
// AnsiChar version
TDCreateDialogParam = packed record
size
: Integer;
// window
modes
: Integer;
// 1=show statusbar
// 2=modal dialog
toppanel_height: Integer;
// 1=show status
border
: Integer;
// EditorStart (or use wptextSetLicense)
licensename: PAnsiChar;
licensekey : PAnsiChar;
// SetLayout(pccfile, pcclayout, pccpasswd,
// pcclayout defaults to "default"
// pccpasswd defaults to ""
pccfile : PAnsiChar;
pcclayout : PAnsiChar;
pccpasswd : PAnsiChar;
"main", "main")
// SetEditorMode
editor_mode : Integer;
editor_xmode : Integer;
editor_gui1 : Integer;
editor_gui2 : Integer;
// Layoutmode and Zoom (-1 = default, unchanged)
editor1_layoutmode : Integer;
editor1_autozoom : Integer;
editor1_zoom : Integer;
editor2_layoutmode : Integer;
253
editor2_autozoom : Integer;
editor2_zoom : Integer; // Ignored for thumbnailmode
// Toolbar Colors
toolbar_mode, toolbar_colfrom, toolbar_colto : Cardinal;
// Background Colors
desktop_mode : Cardinal;
desktop_colfrom : Cardinal;
desktop_colto : Cardinal;
// SetBProp - Index=Group, Bit Nr=Id, ADD to set, DEL to clear
Memo1_SetBProp_ADD : array[0..19] of Cardinal;
Memo1_SetBProp_DEL : array[0..19] of Cardinal;
Memo2_SetBProp_ADD : array[0..19] of Cardinal;
Memo2_SetBProp_DEL : array[0..19] of Cardinal;
// Load a file
loadfile : PAnsiChar;
loadfilemode : Integer; // Reserved;
// Callbacks
msgwindow : HWND;
OnQueryClose : fkt_wptextDialogCB; // result=0 -> may not close
AfterShow
: fkt_wptextDialogShow; // After show dialog - now can modify
// Spellcheck
spell_inifile : PChar;
spell_langid : Integer; // selected language
spell_modes
: Integer; // Activate SpellAsYouGo ...
end;
PTDCreateDialogParam = ^TDCreateDialogParam;
254
WMP_WPA_PROCESS_2
WPSYS_ABOUTBOX
WPSYS_CLEAR
WPSYS_SETLANGUAGE
WPSYS_SETSPLITTERPOS
WPSYS_GETSHOWHINT
WPSYS_SETSHOWHINT
WPDLL_SYS
WPDLL_SYS
WPDLL_SYS
WPDLL_SYS
WPDLL_SYS
WPDLL_SYS
+
+
+
+
+
+
16;
17;
18;
19;
20;
21;
//
//
//
//
//
//
- f
255
WPDLL_COM_DROP_MARKER
WPDLL_COM_COLLECT_MARKER
// --- DATA_PARAM_ ....
WPDLL_COM_ACTIVATE
WPDLL_COM_TEXT_LOADSTREAM
WPDLL_COM_TEXT_SAVESTREAM
WPDLL_COM_ProcessWPA
WPDLL_COM_CheckWPA
WPDLL_COM_FindHeader
WPDLL_COM_FindFooter
WPDLL_COM_GetRTFVariable
WPDLL_COM_SetRTFVariable
=
=
=
=
=
=
WPDLL_COM
WPDLL_COM
WPDLL_COM
WPDLL_COM
WPDLL_COM
WPDLL_COM
+
+
+
+
+
+
56;
57;
58;
59;
60;
61;
//
//
//
//
//
//
WPDLL_COM_TextCursor
= WPDLL_COM + 62; // Result := IWPTextCursor
WPDLL_COM_PDFCreator
= WPDLL_COM + 63; // Result := IWPPdfCreator
WPDLL_COM_TextAttr
= WPDLL_COM + 64; // Result := CurrSelAttr or CurrAttr
WPDLL_COM_GetIDWPA
= WPDLL_COM + 65; // Result := if for wpa action
WPDLL_COM_GetExceptionList = WPDLL_COM + 66; // Result := list of recent exceptions
WPDLL_COM_GetMAPI
= WPDLL_COM + 67; // Result := IWPMapi Interface
WPDLL_COM_GetSPELL
= WPDLL_COM + 68; // Result := IWPSpell Interface
// Input Commands (if possible better use IWPTextCursor!)
WPDLL_COM_InputText
= WPDLL_COM + 70; // Param=width in %, negativ=absolute twip
WPDLL_COM_InputParagraph
= WPDLL_COM + 71; // Param=Mode, Buffer=StyleName
WPDLL_COM_InputSection
= WPDLL_COM + 72; // reserved , param=mode
WPDLL_COM_InputTable
= WPDLL_COM + 73; // buffer=name
WPDLL_COM_InputTableRowStart= WPDLL_COM + 74; // param=Mode
WPDLL_COM_InputTableCell
= WPDLL_COM + 75; // buffer=StyleName, buffer2=Text
WPDLL_COM_InputTableRowEnd = WPDLL_COM + 76; // Don't forget!
WPDLL_COM_InputField
= WPDLL_COM + 77; // buffer=name, buffer2=text
WPDLL_COM_InputHyperLink
= WPDLL_COM + 78; // buffer=URL, buffer2=text (wrap text if
WPDLL_COM_InputBookmark
= WPDLL_COM + 79; // buffer=name, buffer2=text (wrap text if
WPDLL_COM_InputImage
= WPDLL_COM + 80; // param=1=link, buffer=FileName
WPDLL_COM_InputClearTabstop = WPDLL_COM + 81; // clears all tabs
WPDLL_COM_InputTabstop
= WPDLL_COM + 82; // param=Value, param2=kind, param3=FillMo
WPDLL_COM_InputObject
= WPDLL_COM + 83; // param=Typ, param2=mode, buffer=name, bu
WPDLL_COM_InputHeader
= WPDLL_COM + 84; // param=Range, buffer=text (rtf, html)
WPDLL_COM_InputFooter
= WPDLL_COM + 85; // param=Range, buffer=text (rtf, html)
WPDLL_COM_InputFootnote
= WPDLL_COM + 86; // param=mode, buffer=text
WPDLL_COM_InputTextbox
= WPDLL_COM + 87; // param=width, buffer=text (rtf, html)
WPDLL_COM_InputPicture
= WPDLL_COM + 88; // param=w, param2=h + UParam = IPicture i
WPDLL_COM_InputPictureStream= WPDLL_COM + 89; // param=w, param2=h + UParam = IStream in
// The next 3 also set the result string to the current value
WPDLL_COM_INITIALDIR
= WPDLL_COM + 90; // Set the initial directory for file open
WPDLL_COM_INITIALGRAPHICDIR = WPDLL_COM + 91; // Set the initial image directory for ima
WPDLL_COM_LASTFILENAME
= WPDLL_COM + 92; // Retrieve the filename of the last loade
256
WPDLL_COM_PrintToDC
WPDLL_COM_PrintToDCGetH
WPDLL_COM_EvGetButton
WPDLL_COM_EvGetContents
WPDLL_COM_EvGetBand
=
=
=
=
=
WPDLL_COM
WPDLL_COM
WPDLL_COM
WPDLL_COM
WPDLL_COM
+
+
+
+
+
= WPDLL_COM + 121;
// same as PDFCreator Print 1. Optionally a
= WPDLL_COM + 122; // same as PDFCreator PrintSecond
// for Editor#2
WIPR_ED2_PAGE_WIDTH = 101;
WIPR_ED2_PAGE_HEIGHT = 102;
WIPR_ED2_PAGE_LEFT_MARGIN = 103;
WIPR_ED2_PAGE_RIGHT_MARGIN = 104;
WIPR_ED2_PAGE_TOP_MARGIN = 105;
WIPR_ED2_PAGE_BOTTOM_MARGIN = 106;
WIPR_ED2_PAGE_HEADER_MARGIN = 107;
WIPR_ED2_PAGE_FOOTER_MARGIN = 108;
WIPR_ED2_PAGE_DRAW_MODE = 109; // Background image, address ...
WIPR_ED2_PAGE_LINE_MODE = 110; // 0=adress top-left, 1=addres top right, 2=lineoffset
WIPR_ED2_PAGE_LINEOFFSET_LEFT = 111;
WIPR_ED2_PAGE_LINEOFFSET_RIGHT = 112;
WIPR_ED2_PAGE_LINEOFFSET_TOP = 113;
WIPR_ED2_PAGE_LINEOFFSET_BOTTOM = 114;
WIPR_ED2_PAGES_MINCOUNT = 115;
WIPR_ED2_PAGES_MAXCOUNT = 116;
WIPR_ED2_PAGES_COUNT = 117;
WIPR_ED2_PAGES_MULTIPLICATOR = 118;
257
DIALOG_Find=3;
// = wpaSearch
DIALOG_Replace=4;
// = wpaReplace
DIALOG_OPEN=5;
// = wpaOpen
DIALOG_SAVE=6;
// = wpaSave
DIALOG_SAVEAS=7;
// = wpaSaveAs
DIALOG_Preview=8;
DIALOG_PageProp=9;
DIALOG_PagePropPaperNames=10; // like PageProp but show paper names, too
DIALOG_SectionProp=11; // reserved
DIALOG_ParagraphProp=12;
DIALOG_Tabstops=13;
DIALOG_Bullet=14;
DIALOG_BulletOutlines=15; // Bullets and Numbers and Outlines
DIALOG_ParagraphBorder=16;
DIALOG_StyleSheet=17;
DIALOG_OneStyle=18;
DIALOG_Spellcheck=19;
DIALOG_SpellOptions=20;
DIALOG_ExportToWord=21;
DIALOG_ExportToPDF=22;
DIALOG_INSSymbol=23;
DIALOG_INSTable=24;
DIALOG_INSGRAPHIC=25;
DIALOG_INSGRAPHICLINK=26;
DIALOG_INSTextBox=27;
DIALOG_INSHyperlink=28;
DIALOG_INSBookmark=29;
DIALOG_INSFields=30;
DIALOG_ReportBands=31;
DIALOG_PDFProperties=32;
DIALOG_PrintLabels=33;
DIALOG_PrintBooklet=34;
DIALOG_DocInfo=35; // info + stats
DIALOG_Templates=36; // quick replacement
DIALOG_DocVariable=37; // caption=caption param=name (RTFVariable!)
DIALOG_WPAbout=38; // TextDynamic about form
DIALOG_WPDebug=39; // Debug form with current paragraph attributes
DIALOG_MessageBox=40; // caption=caption param=text
DIALOG_PagePropPaperTray=41;
DIALOG_ManageFormulas=42;
DIALOG_ManageHeaderFooter=43;
DIALOG_FontSelect = 44; // Standard Font Dialog
implementation
end.
4.3.7
//
//
//
//
//
C / C++ Headerfile
TDCreateDlg.h
----------------------------------------------------------------------------Create TextDynamic Interface
Date: 5.10.2009
-----------------------------------------------------------------------------
// For callbacks
2006-2009 by WPCubed GmbH, Munich, Germany
258
// AnsiChar version
typedef struct
{
int size;
// window
int modes;
// 1=show statusbar
// 2=modal dialog
int toppanel_height;
// 1=show status
int border;
// EditorStart (or use wptextSetLicense)
char *licensename; //
char *licensekey; // : PAnsiChar;
// SetLayout(pccfile, pcclayout, pccpasswd,
// pcclayout defaults to "default"
// pccpasswd defaults to ""
char *pccfile; //,
char *pcclayout; //,
char *pccpasswd; // : PAnsiChar;
"main", "main")
// SetEditorMode
int editor_mode; //,
int editor_xmode; //,
int editor_gui1; //,
int editor_gui2; //
// Layoutmode and Zoom (-1 = default, unchanged)
int editor1_layoutmode; //
int editor1_autozoom; //
int editor1_zoom; //
int editor2_layoutmode; //
int editor2_autozoom; //
int editor2_zoom; // // Ignored for thumbnailmode
// Toolbar Colors
unsigned long toolbar_mode;
unsigned long toolbar_colfrom;
259
Colors
desktop_mode;
desktop_colfrom;
desktop_colto;
// Load a file
char *loadfile;
int loadfilemode;
// Callbacks
unsigned long msgwindow;
fkt_wptextDialogCB OnQueryClose; // result=0 -> may not close
fkt_wptextDialogShow AfterShow; // After show dialog - now can modify
// Spellcheck
char *spell_inifile;
int spell_langid; // selected language
int spell_modes; // Activate SpellAsYouGo ...
} TDCreateDialogParam;
typedef HWND (__stdcall fkt_wptextCreateDialog)
( HWND parent,
TDCreateDialogParam *params,
int x,
int y,
int w,
int h,
unsigned long *ed
);
// Constants
#define WMP_DLLBASE 1029 // WM_USER ...
#define WPDLL_SYS
10 // System commands
#define WPDLL_DATA 100 // Create new data
#define WPDLL_GUI 1000 // GUI commands, enable, disable etc
#define WPDLL_COM 9000 // ..9999 Commands sent to the editor, change attributes etc
#define
WMP_EXCOMMAND WMP_DLLBASE + 1 // lparam=ptr to TCOMEditDataCommand record, wpa
#define
WMP_SETIPROP WMP_DLLBASE + 2 // Set Integer Property: wparam=id, lparam value
// ids - modify Editor #1 (also see Memo.TextCommand)
#define
WIPR_ED1_PAGE_WIDTH 1
#define
WIPR_ED1_PAGE_HEIGHT 2
#define
WIPR_ED1_PAGE_LEFT_MARGIN 3
#define
WIPR_ED1_PAGE_RIGHT_MARGIN 4
#define
WIPR_ED1_PAGE_TOP_MARGIN 5
#define
WIPR_ED1_PAGE_BOTTOM_MARGIN 6
#define
WIPR_ED1_PAGE_HEADER_MARGIN 7
#define
WIPR_ED1_PAGE_FOOTER_MARGIN 8
260
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
// for Editor#2
#define
WIPR_ED2_PAGE_WIDTH 101
#define
WIPR_ED2_PAGE_HEIGHT 102
#define
WIPR_ED2_PAGE_LEFT_MARGIN 103
#define
WIPR_ED2_PAGE_RIGHT_MARGIN 104
#define
WIPR_ED2_PAGE_TOP_MARGIN 105
#define
WIPR_ED2_PAGE_BOTTOM_MARGIN 106
#define
WIPR_ED2_PAGE_HEADER_MARGIN 107
#define
WIPR_ED2_PAGE_FOOTER_MARGIN 108
#define
WIPR_ED2_PAGE_DRAW_MODE 109 // Background image, address ...
#define
WIPR_ED2_PAGE_LINE_MODE 110 // 0=adress top-left, 1=addres top right, 2=lineo
#define
WIPR_ED2_PAGE_LINEOFFSET_LEFT 111
#define
WIPR_ED2_PAGE_LINEOFFSET_RIGHT 112
#define
WIPR_ED2_PAGE_LINEOFFSET_TOP 113
#define
WIPR_ED2_PAGE_LINEOFFSET_BOTTOM 114
#define
WIPR_ED2_PAGES_MINCOUNT 115
#define
WIPR_ED2_PAGES_MAXCOUNT 116
#define
WIPR_ED2_PAGES_COUNT 117
#define
WIPR_ED2_PAGES_MULTIPLICATOR 118
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
#define
261
#define WPDLL_COM_STYLE_GETLIST
WPDLL_COM + 8 // read comma separated list.
// Use WPDLL_DATA_GETSTRING to read it!
#define WPDLL_COM_STYLE_GETWPCSS WPDLL_COM + 9
// Read WPCSS - one style
#define WPDLL_COM_STYLE_SETWPCSS WPDLL_COM + 10 // Set WPCSS - one style
#define WPDLL_COM_STYLE_GETALLASSTR WPDLL_COM + 11 // Read all as string (Param=Format:
#define WPDLL_COM_STYLE_SETALLASSTR WPDLL_COM + 12 // Set all as string (Param=Format: 0
#define WPDLL_COM_STYLE_SAVEFILE
WPDLL_COM + 13 // Save all to file
#define WPDLL_COM_STYLE_LOADFILE
WPDLL_COM + 14 // Load all from file
// MAIN EDIT COMMANDS - some are superseded ---------------------------------#define WPDLL_COM_TEXT_CLEAR
WPDLL_COM + 15 // Clear the text, Param=1 "ClearEx",
#define WPDLL_COM_TEXT_CLEARBODY
WPDLL_COM + 16 // Clear only body, keep header+foote
#define WPDLL_COM_TEXT_BACKUP
WPDLL_COM + 17 // backup template, Bit1 to ignore pa
#define WPDLL_COM_TEXT_RESTORE
WPDLL_COM + 18 // restore template
#define WPDLL_COM_TEXT_HIDESEL
WPDLL_COM + 19 // hide selection
#define WPDLL_COM_TEXT_SELECTALL
WPDLL_COM + 20 // select all
#define WPDLL_COM_TEXT_BEGINENDPRINT WPDLL_COM + 21 // BeginPrint/EndPrint (Param=Begin)
#define WPDLL_COM_TEXT_PRINT
WPDLL_COM + 22 // print, optionla Param, Param2 to s
#define WPDLL_COM_TEXT_SELECTPRINTER WPDLL_COM + 23 // select printer 'name'
#define WPDLL_COM_TEXT_PRINTDIA
WPDLL_COM + 24 // print dialog
// Sow a DIALOG_....
#define WPDLL_COM_TEXT_DIALOG
WPDLL_COM + 25 // show modal dialog (preview etc)
// Load and save commands
#define WPDLL_COM_TEXT_LOADFILE
#define WPDLL_COM_TEXT_LOADSTR
#define WPDLL_COM_TEXT_SAVESTR
#define WPDLL_COM_POS_SET
#define
POSGOTO_POSITION
0 //
#define
POSGOTO_PAR
1 //
#define
POSGOTO_POSINPAR
2 //
#define
POSGOTO_PAGE
3 //
#define
POSGOTO_FIELD
4 //
#define
POSGOTO_Bookmark
5 //
#define WPDLL_COM_POS_GET
// --- POS_PARAM_ ....
#define WPDLL_COM_POS_SELECT
// subset of POS_PARAM_
#define WPDLL_COM_MOVE
#define WPDLL_COM_DROP_MARKER
#define WPDLL_COM_COLLECT_MARKER
// --- DATA_PARAM_ ....
#define WPDLL_COM_ACTIVATE
#define WPDLL_COM_TEXT_LOADSTREAM
#define WPDLL_COM_TEXT_SAVESTREAM
WPDLL_COM + 33
WPDLL_COM + 34
WPDLL_COM + 35
WPDLL_COM + 36
WPDLL_COM + 37
WPDLL_COM + 38
//
//
//
//
//
//
#define
#define
#define
#define
#define
#define
WPDLL_COM_ProcessWPA
WPDLL_COM_CheckWPA
WPDLL_COM_FindHeader
WPDLL_COM_FindFooter
WPDLL_COM_GetRTFVariable
WPDLL_COM_SetRTFVariable
WPDLL_COM
WPDLL_COM
WPDLL_COM
WPDLL_COM
WPDLL_COM
WPDLL_COM
#define
#define
WPDLL_COM_TextCursor
WPDLL_COM_PDFCreator
WPDLL_COM + 62
WPDLL_COM + 63
+
+
+
+
+
+
56
57
58
59
60
61
// Result :=
// Result :=
IWPTextCursor
IWPPdfCreator
262
#define WPDLL_COM_TextAttr
WPDLL_COM + 64 // Result := CurrSelAttr or CurrAttr
#define WPDLL_COM_GetIDWPA
WPDLL_COM + 65 // Result := if for wpa action
#define WPDLL_COM_GetExceptionList WPDLL_COM + 66 // Result := list of recent exceptio
#define WPDLL_COM_GetMAPI
WPDLL_COM + 67 // Result := IWPMapi Interface
#define WPDLL_COM_GetSPELL
WPDLL_COM + 68 // Result := IWPSpell Interface
// Input Commands (if possible better use IWPTextCursor!)
#define WPDLL_COM_InputText
WPDLL_COM + 70 // Param=width in %, negativ=absolute
#define WPDLL_COM_InputParagraph
WPDLL_COM + 71 // Param=Mode, Buffer=StyleName
#define WPDLL_COM_InputSection
WPDLL_COM + 72 // reserved , param=mode
#define WPDLL_COM_InputTable
WPDLL_COM + 73 // buffer=name
#define WPDLL_COM_InputTableRowStart WPDLL_COM + 74 // param=Mode
#define WPDLL_COM_InputTableCell
WPDLL_COM + 75 // buffer=StyleName, buffer2=Text
#define WPDLL_COM_InputTableRowEnd WPDLL_COM + 76 // Don't forget!
#define WPDLL_COM_InputField
WPDLL_COM + 77 // buffer=name, buffer2=text
#define WPDLL_COM_InputHyperLink
WPDLL_COM + 78 // buffer=URL, buffer2=text (wrap te
#define WPDLL_COM_InputBookmark
WPDLL_COM + 79 // buffer=name, buffer2=text (wrap te
#define WPDLL_COM_InputImage
WPDLL_COM + 80 // param=1=link, buffer=FileName
#define WPDLL_COM_InputClearTabstop WPDLL_COM + 81 // clears all tabs
#define WPDLL_COM_InputTabstop
WPDLL_COM + 82 // param=Value, param2=kind, param3=F
#define WPDLL_COM_InputObject
WPDLL_COM + 83 // param=Typ, param2=mode, buffer=nam
#define WPDLL_COM_InputHeader
WPDLL_COM + 84 // param=Range, buffer=text (rtf, htm
#define WPDLL_COM_InputFooter
WPDLL_COM + 85 // param=Range, buffer=text (rtf, htm
#define WPDLL_COM_InputFootnote
WPDLL_COM + 86 // param=mode, buffer=text
#define WPDLL_COM_InputTextbox
WPDLL_COM + 87 // param=width, buffer=text (rtf, htm
#define WPDLL_COM_InputPicture
WPDLL_COM + 88 // param=w, param2=h + UParam IPictur
#define WPDLL_COM_InputPictureStream WPDLL_COM + 89 // param=w, param2=h + UParam IStrea
// The following ignore an empty string. They always set the current result string to the
// Use WPDLL_DATA_GETSTRING to retrive the current string
#define WPDLL_COM_INITIALDIR
WPDLL_COM + 90 // Set the initial directory for file
#define WPDLL_COM_INITIALGRAPHICDIR WPDLL_COM + 91 // Set the initial image directory fo
#define WPDLL_COM_LASTFILENAME WPDLL_COM + 92 // Set / retrieve the current file name
#define
#define
#define
#define
#define
#define
WPDLL_COM_CreateReport
WPDLL_COM + 111
WPDLL_COM_GETINTERFACE
WPDLL_COM + 112
WPDLL_COM_GETXY
WPDLL_COM + 113
#define
#define
#define
#define
#define
WPDLL_COM_PrintToDC
WPDLL_COM_PrintToDCGetH
WPDLL_COM_EvGetButton
WPDLL_COM_EvGetContents
WPDLL_COM_EvGetBand
WPDLL_COM
WPDLL_COM
WPDLL_COM
WPDLL_COM
WPDLL_COM
+
+
+
+
+
114
115
116
117
118
// for IViewObjectExImpl::Draw
// get height - in twips
// Helper for VisualFoxPRO
WPDLL_COM_PrintPDF
WPDLL_COM_PrintPDF2
WPDLL_COM + 121
WPDLL_COM + 122
// Some commands write an ansi string. This command is used to retrieve the result string
// Call it with a null buffer to get the size, call it again with a correctly dimensioned
263
4.4
264
If you need to modify paragraph attributes, such as indent, tab stops, shading please use the
interface IWPParInterface which is provided by Memo.CurrPar.
4.4.1
IWPAttrInterface
This important interface is used to update the character attributes and paragraph attributes.
The interface is published by property CurrAttr, TextAttr and CurrSelAttr. CurrAttr changes the
current writing mode, CurrSelAttr the selected text and TextAttr provides automatically the
CurrAttr or CurrSelAttr if text is selected.
You can use TextAttr to fill your own toolbar with life, in case you do not want to use the
inbuilt toolbar to change the attributes of the text. You can also use it to implement hotkeys,
for example toggle 'bold' when pressing Ctrl+B.
The default text attributes can be changed in Memo.DefaultAttr. (If a function of TextAttr
returns FALSE this means the default attribute is used for this property.)
The instance "AttrHelper" can be used to calculate CharAttrIndex values to be used with
TextCursor.InputString.
A different instance is published as property CurrParAttr (Memo.CurrParAttr or RTFDataBlock.
CurrParAttr). Here any change will affect all characters in this paragraph. Please note that
it will not change the properties stored by the paragraph itself, but the properties used by the
individual characters - in the attribute cache.
If you need to change the character attributes stored in the paragraph object you can use the
method CurrPar.ParASet.
CurrStyleAttr is used to change the character attributes defined by a style. You can use
SelectStyle to create a new paragraph style or select an existing style to be modified. To apply
a style a style to a paragraph, you can use the property StyleName.
The interface IWPAttrInterface has several methods to read and write properties.
The basic methods which can access all attributes are AttrGet, AttrDel and AttrSet. These
methods expect the property ID (WPAT...) - Please see the list of the available WPAT codes. If
the AttrGet function returns the value false, the value has not been defined. This means the
inherited or the default value will be used for this property. This three basic functions will
modify the character attributes for IDs <=16, for IDs >16 the current paragraph / selected
paragraphs will be modified. You can use Memo.TextAttr.AttrSET((int)WPAT.IndentLeft, 360) to
change the indent of the current paragraph or all selected paragraphs, in case text was
selected.
The other methods only affect the character attributes. For other changes on paragraphs or
styles use IWPParInterface.
The property CharAttrIndex represents the writing mode as index into the attribute cache.
The value can be used with TextCursor.InputText("some text", x). You can store it into an
integer variable if you need to temporarily change the writing mode. When you are done simply
assign the value and you can use the previous writing mode. Please note that clearing the text
makes the index values invalid!
Please note: The methods to read a property "Get...." all return a boolean value. If this
value is FALSE, this means the property is not used, the property uses the default
value.
With .NET use the API ColorTranslator.FromWin32(rgb) to convert a RGB value into the Color
Methods
AttrGet
Methods
IncludeStyles
AttrSet
NrToColor
BeginUpdate
SetBGColor
Clear
SetBGColorNr
ColorToNr
SetCharStyleSheetName
EndUpdate
SetCharWidth
ExcludeStyles
GetBGColor
SetColorNr
GetBGColorNr
SetFontCharset
GetCharStyleSheetName
SetFontface
GetCharWidth
SetFontSize
GetColor
SetStyles
GetColorNr
SetTextLanguage
GetFontCharset
SetUnderlineColor
GetFontface
SetUnderlineColorNr
GetFontSize
SetUnderlineMode
GetStyles
SetWPCSS
GetTextLanguage
ToggleStyle
GetUnderlineColor
GetUnderlineColorNr
GetUnderlineMode
GetWPCSS
IWPAttrInterface Example
265
266
This C# example code creates text to show the possible underline modes.
string[] cnames = new string[]
[OBJECT]
{ "WPUND_Standard"
[OBJECT]
, "WPUND_Dotted"
, "WPUND_Dashed"
, "WPUND_Dashdotted"
, "WPUND_Dashdotdotted"
, "WPUND_Double"
, "WPUND_Heavywave"
, "WPUND_Longdashed"
, "WPUND_Thick"
, "WPUND_Thickdotted"
, "WPUND_Thickdashed"
, "WPUND_Thickdashdotted"
, "WPUND_Thickdashdotdotted"
, "WPUND_Thicklongdashed"
, "WPUND_Doublewave"
, "WPUND_WordUnderline"
, "WPUND_wave"
, "WPUND_curlyunderline" };
IWPMemo Memo = WPDLLInt1.Memo;
IWPAttrInterface CurrAttr = Memo.CurrAttr;
IWPTextCursor TextCursor = Memo.TextCursor;
Memo.Clear(false,false);
CurrAttr.Clear();
CurrAttr.SetFontface("Verdana");
//150% Line Height
CurrAttr.AttrSET((int)WPAT.LineHeight, 150);
int m = 1;
foreach (string s in cnames)
267
{
TextCursor.InputParagraph(0, "");
CurrAttr.SetUnderlineMode(m);
CurrAttr.SetUnderlineColor(WPDLLInt1.ToRGB(Color.Red));
TextCursor.InputText(m.ToString());
TextCursor.InputText(" = ");
TextCursor.InputText(s);
m++;
}
Memo.Reformat();
4.4.1.1
Properties
4.4.1.1 A) CharAttrIndex
Index of the attribute record which holds character properties.
Applies to
IWPAttrInterface
Declaration
int CharAttrIndex;
Description
The wRTF2PDF / TextDynamic Server word processing engine stores the attributes of
characters in attribute records. This records hold 16 different attributes.
To reduce memory consumption the text only contains the reference, the index value, of the
attribute record.
This property can be read and written. After you have assigned an index value you can use
methods such as GetFontFace to read the actually used property elements. Methods such as
InsertText can use such index values, as well. This makes it possible, if you intend to create
text in program code, to first create a set of index values for different parts of the text and
then use this pre calculated index values when creating the text.
Please note that the Attribute array is cleared when the the text is cleared.
The interface IWPAttrInterface can be also used to manipulate the current style In this case it
is not possible to read CharAttrIndex. The interface is only used as helper to set font
attributes, a index into the attribute cache is not created in this case.
This interface is also used to manipulate a "current" paragraph (Memo.CurrPar or RTFDataBlock.
CurrPar). In this case reading CharAttrIndex will return the value which was applied last, it is
the "default" attribute for a paragraph .
Category
Character Attributes
4.4.1.2
Methods
4.4.1.2 A) IWPAttrInterface.AttrSet
Applies to
IWPAttrInterface
Declaration
procedure AttrSet(WPAT_Code: Integer; Value: Integer);
Description
268
269
4.4.1.2 E) IWPAttrInterface.Clear
Applies to
IWPAttrInterface
Declaration
void Clear()
Description
This method clears all properties - the default attributes or the inherited values (from a style or
the current paragraph) will be then used for the text.
See SelectStyle for an example.
4.4.1.2 F) IWPAttrInterface.ColorToNr
Applies to
IWPAttrInterface
Declaration
int ColorToNr(string ColorName);
Description
This method can be used to convert a color value defined by a string (same syntax as used by
CSS) to a number which can be used by AttrSet or SetBGColorNr and SetColorNr.
Also see IWPAttrInterface.NrToColor which converts a color id into a string describing the color.
Example:
Memo.CurrAttr.SetFontSize(8);
Memo.CurrAttr.SetColorNr( Memo.CurrAttr.ColorToNr("red") );
TextCursor.InputText("Some red text");
Memo.CurrAttr.SetColorNr(-1);
4.4.1.2 G) IWPAttrInterface.EndUpdate
Applies to
IWPAttrInterface
Declaration
function EndUpdate: Boolean;
Description
This method has to be used after BeginUpdate.
4.4.1.2 H) IWPAttrInterface.IncludeStyles
Applies to
IWPAttrInterface
Declaration
procedure IncludeStyles(Element: WrtStyle);
2006-2009 by WPCubed GmbH, Munich, Germany
270
Description
This method adds a certain character style flag.
Parameters
Element
Category
Character Styles
4.4.1.2 I) IWPAttrInterface.ExcludeStyles
Applies to
IWPAttrInterface
Declaration
procedure ExcludeStyles(Element: WrtStyle);
Description
This method is used to remove a certain character style flag.
Parameters
Element
Category
Character Styles
4.4.1.2 J) IWPAttrInterface.GetBGColor
Applies to
IWPAttrInterface
Declaration
271
272
value.
In .NET applications you can use the utility function ToRGB to convert a Color member into a
RGB value. Example:
WPDLLInt1.ToRGB(Color.Red)
Description
This function reads the size used by the text. The parameter is a 32 bit floating point value.
4.4.1.2 S) IWPAttrInterface.GetStyles
Applies to
IWPAttrInterface
Declaration
function GetStyles(var Styles: WrtStyle): Boolean;
Description
This method retrieves the character style flags which are used.
Returns
this bitfield:
1 : Bold text. (C# wrapper defines enum element WPSTY.BOLD)
2 : Italic text. (C# wrapper defines enum element WPSTY.ITALIC)
4 : Underlined text. (C# wrapper defines enum element WPSTY.UNDERLINE)
8 : Strikeout text. (C# wrapper defines enum element WPSTY.STRIKEOUT)
16 : Text in super-script (C# wrapper defines enum element WPSTY.SUPERSCRIPT)
32 : Text in sub-script (C# wrapper defines enum element WPSTY.SUBSCRIPT)
64 : Hidden text, (C# wrapper: WPYST.HIDDEN)
128 : Uppercase text. (C# wrapper: WPYST.UPPERCASE)
256 : reserved.
512 : Lowercase text. (C# wrapper: WPYST.LOWERCASE)
1024 : Text which should be excluded from spellcheck (WPSTY.NOPROOF)
2048 : Double strikeout (WPSTY.DBLSTRIKEOUT)
4096 : reserved.
8192 : protected text (WPSTY.PROTECTED)
Category
Character Styles
4.4.1.2 T) IWPAttrInterface.GetTextLanguage
Applies to
IWPAttrInterface
Declaration
function GetTextLanguage(var Mode: Integer): Boolean;
Description
This method reads the language id used with this text. It is currently not used.
4.4.1.2 U) IWPAttrInterface.GetUnderlineColor
Applies to
IWPAttrInterface
Declaration
function GetUnderlineColor(var RGB: TColor): Boolean;
Description
This method reads the color used for underlines.
273
274
4.4.1.2 V) IWPAttrInterface.GetUnderlineColorNr
Applies to
IWPAttrInterface
Declaration
function GetUnderlineColorNr(var ColorNr: Integer): Boolean;
Description
This method reads the color used for underlines as index value.
4.4.1.2 W) IWPAttrInterface.GetUnderlineMode
Applies to
IWPAttrInterface
Declaration
function GetUnderlineMode(var Mode: Integer): Boolean;
Description
This method reads the mode used for underlines. This are the available values.
.
4.4.1.2 X) IWPAttrInterface.GetWPCSS
Get Definition as string.
Applies to
IWPAttrInterface
Declaration
function GetWPCSS: WideString;
Description
2006-2009 by WPCubed GmbH, Munich, Germany
275
This function creates a string with the values of all properties which are defined (which are not
"default").
This method is very useful to quickly save the current attributes to be applied later using
SetWPCSS.
Category
TextDynamic CSS strings
4.4.1.2 Y) IWPAttrInterface.NrToColor
Applies to
IWPAttrInterface
Declaration
string NrToColor(int NrToColor);
Description
The engine internally saves colors as index values. This method converts an index into a RGB
value.
The method can be used to convert the IDs the AttrGet function will retrieve. GetColor and
GetBGColor will already return a color value.
4.4.1.2 Z) IWPAttrInterface.SetBGColor
Applies to
IWPAttrInterface
Declaration
procedure SetBGColor(RGB: TColor);
Description
This method is used to set the background color for characters, also known as highlighting. The
parameter is a RGB value.
In .NET applications you can use the utility function ToRGB to convert a Color member into a
RGB value. Example:
WPDLLInt1.ToRGB(Color.Red)
.
4.4.1.2 AA) IWPAttrInterface.SetBGColorNr
Applies to
IWPAttrInterface
Declaration
void SetBGColorNr(int ColorNr);
Description
This method is used to set the background color for characters, also known as highlighting. The
parameter is the internal index value used by the RTF engine.
The methods ColorToNr and NrToColor are used to convert between index values and RGB
values.
276
277
Styles
278
Category
Character Styles
4.4.1.2 AJ) IWPAttrInterface.SetTextLanguage
Applies to
IWPAttrInterface
Declaration
procedure SetTextLanguage(Mode: Integer);
Description
This method is used to set the language for the text. This method is currently not used.
4.4.1.2 AK) IWPAttrInterface.SetUnderlineColor
Applies to
IWPAttrInterface
Declaration
procedure SetUnderlineColor(Color: TColor);
Description
This method sets the color for the underline as RGB value. See example "Underline Modes".
4.4.1.2 AL) IWPAttrInterface.SetUnderlineColorNr
Applies to
IWPAttrInterface
Declaration
procedure SetUnderlineColorNr(ColorNr: Integer);
Description
This method sets the color for the underline as color index value.
279
C#:
private void WPDLLInt1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
IWPMemo Memo;
280
if (((WPDynamic.wpKeyPressEventArgs)e).Editor==2 )
Memo = WPDLLInt1.Memo2;
else Memo = WPDLLInt1.Memo;
if (e.KeyChar==(Char)2) // Ctrl+B to toggle "Bold"
{ if (Memo.TextCursor.IsSelected)
Memo.CurrSelAttr.ToggleStyle((int)WPWRT.BOLD);
else Memo.CurrSelAttr.ToggleStyle((int)WPWRT.BOLD);
}
}
VB6 (see intro):
Case "Fett"
ActiveForm.rtfText.CurrAttr.ToggleStyle 0
Case "Kursiv"
ActiveForm.rtfText.CurrAttr.ToggleStyle 1
Case "Unterstrichen"
ActiveForm.rtfText.CurrAttr.ToggleStyle 2
Parameters
Element
Category
Character Styles
4.4.2
IWPCharacterAttr
281
Properties
BackgroundColor
Properties
Italic
Bold
StrikeOut
CodeTextColor
SubScript
DoubleUnderline
SuperScript
Hidden
TextColor
HotEffect
Underline
HotTextColor
UnderlineColo
r
Method
SetCodeText
The properties Bold, Italic, StrikeOut, SubScript, SuperScript and Underline use the
type ThreeState. It is an enum with this values:
tsIgnore = 0: do not use the property
282
Properties
4.4.2.1 A) BackgroundColor
Applies to
IWPCharacterAttr
Declaration
int BackgroundColor;
Description
The background color as RGB value, can be used for merged text, bookmarked text and
hyperlinks.
4.4.2.1 B) Bold
Applies to
IWPCharacterAttr
Declaration
ThreeState Bold;
Description
Use a bold font, can be used for merged text, bookmarked text and hyperlinks.
4.4.2.1 C) CodeTextColor
Applies to
IWPCharacterAttr
Declaration
property CodeTextColor: Integer read Get_CodeTextColor write Set_CodeTextColor;
Description
The color used to display the object markers used by merge fields and bookmarks.
4.4.2.1 D) DoubleUnderline
Applies to
IWPCharacterAttr
Declaration
property DoubleUnderline: WordBool read Get_DoubleUnderline write
Set_DoubleUnderline;
Description
Use double underlining, can be used for merged text, bookmarked text and hyperlinks.
4.4.2.1 E) Hidden
Applies to
IWPCharacterAttr
2006-2009 by WPCubed GmbH, Munich, Germany
Declaration
bool Hidden;
Description
Hide the code objects
4.4.2.1 F) HotEffect
Applies to
IWPCharacterAttr
Declaration
property HotEffect: Integer read Get_HotEffect write Set_HotEffect;
Description
When the mouse is moved over the text it is automatically highlighted. (hover effect)
4.4.2.1 G) HotTextColor
Applies to
IWPCharacterAttr
Declaration
property HotTextColor: Integer read Get_HotTextColor write Set_HotTextColor;
Description
When the mouse is moved over the text it is automatically highlighted. (hover effect)
4.4.2.1 H) Italic
Applies to
IWPCharacterAttr
Declaration
ThreeState Italic;
Description
Use an italic font, can be used for merged text, bookmarked text and hyperlinks.
4.4.2.1 I) StrikeOut
Applies to
IWPCharacterAttr
Declaration
ThreeState StrikeOut;
Description
Use tsTrue (value=1) to strike out the text.
4.4.2.1 J) SubScript
Applies to
IWPCharacterAttr
2006-2009 by WPCubed GmbH, Munich, Germany
283
284
Declaration
ThreeState SubScript;
Description
Use a subscript font.
4.4.2.1 K) SuperScript
Applies to
IWPCharacterAttr
Declaration
ThreeState SuperScript;
Description
Use a superscript font.
4.4.2.1 L) TextColor
Applies to
IWPCharacterAttr
Declaration
ThreeState TextColor;
Description
The color for the embedded text. This does not change the color for the objects.
4.4.2.1 M) Underline
Applies to
IWPCharacterAttr
Declaration
ThreeState Underline;
Description
Use underlining.
4.4.2.1 N) UnderlineColor
Applies to
IWPCharacterAttr
Declaration
int UnderlineColor;
Description
Change the color for the underline.
285
Methods
4.4.2.2 A) IWPCharacterAttr.SetCodeText
Applies to
IWPCharacterAttr
Declaration
procedure SetCodeText(Select: Integer; const Text: WideString);
Description
To change the text which is displayed by start and end markers You can use the method
SetCodeText. Use first parameter =1 to change start marker, 2 to change end marker. The
string may contain placeholders: "%N" displays the name, "%S" displays the Source property of
the text object, "%Y" displays the name of the style used by this object, "%P" displays the
Params property.
SetCodeText Example
wpdllInt1.TextCursor.InputField("NAME","WPCubed GmbH",false);
4.5
wpdllInt1.SpecialTextAttr(
Using IWPParInterface you get access to the current paragraph. You can change the text or
change the attributes.
IWPParInterface is also used to modify paragraph styles. Here you cannot add text but You can
change the attributes.
This three basic function IWPAttrInterface.AttrDel, IWPAttrInterface.AttrGet, IWPAttrInterface.
AttrSet will modify the character attributes for IDs <=16, for IDs >16 the current paragraph /
selected paragraphs will be modified. You can use Memo.TextAttr.AttrSET((int)WPAT.
IndentLeft, 360) to change the indent of the current paragraph or all selected paragraphs, in
case text was selected.
IWPDataBlock provides low level access to the paragraph tree. You can use it to append
paragraphs and to delete header or footer.
IWPTextObj provides access to objects such as field markers and hyperlinks, but also images.
IWPNumberStyle can be used to create and modify numbering styles.
4.5.1
IWPParInterface
286
To do so, You first need to call SetProp(1,1) and when done SetProp(1,0). We
highlighted the methods with this ability with this symbol:
// Create style 2
wpdllInt1.Memo.SelectStyle("Style2");
style.Alignment = 2;
Tip: A table row can be duplicated using the CurrPar interface. Here we first let the
CurrPar interface modify the current row and then call Duplicate():
Cursor.CPTableRowNr = 1; // goto row 1
Memo.CurrPar.SetPtr( Cursor.CPRowPtr );
while(rowcount-->0) Memo.CurrPar.Duplicate();
Overview:
Properties:
Alignment
Methods
AppendChild
Methods
ParAAddBits
AlignmentVert
AppendNext
ParAClear
Borders
AppendText
ParADel
CellCommand
CharAttr
ParADelBits
CellName
CharObj
ParAGet
CharCount
ClearCharAttr
ParAInc
IndentFirst
DeleteChar
IndentLeft
DeleteParagraph
IndentRight
DeleteParEnd
ParASet
(also see Convert utility
for font name and color
values)
IsColMerge
Duplicate
IsFooterRow
GetAllText
IsHeaderRow
GetChar
IsHidden
GetCharAttr
IsNewPage
GetParType
IsProtected
GetProp
IsRowMerge
GetPtr
LineHeight
GetPtrChild
NumberLevel
GetPtrNext
NumberMode
GetPtrParent
ParColor
GetPtrPrev
ParCSS
GetSubText
ParShading
GetText
ParWPCSS
HasText
SpaceAfter
InsertNewObject
SpaceBefore
InsertText
SpaceBetween
LoadFromFile
StyleName
LoadFromString
TOCOutlineLevel
WidthTW
ParCommand
ParStrCommand
ReplaceCharAttr
ReplaceText
SaveToString
SetChar
SetCharAttr
SetParType
SetProp
SetPtr
SetText
TabAdd
TabClear
TabDelete
Low Level Move
Methods (Select..)
287
288
4.5.1.1
4.5.1.1 A) Alignment
Applies to
IWPParInterface
Declaration
int Alignment;
Description
The alignment (WPAT_Alignment) used by this paragraph or style:
0 : Left aligned
1 : Centered
2 : Right aligned
3 : Justified Text
4.5.1.1 B) AlignmentVert
Applies to
IWPParInterface
Declaration
int AlignmentVert;
Description
Vertical alignment (WPAT_VertAlignment) - only possible in cells:
0 : top aligned
1 : centered vertically
2 : bottom aligned
4.5.1.1 C) Borders
Applies to
IWPParInterface
Declaration
int Borders;
Description
Borders (WPAT_BorderFlags) used by this paragraph (styles do not yet use borders).
Bits:
1 : Left border
2 : Top border
4 : Right border
8 : Bottom border
15: all 4 borders.
4.5.1.1 D) CellCommand
Applies to
2006-2009 by WPCubed GmbH, Munich, Germany
Declaration
string CellCommand;
Description
The formula used by this cell. Used for calculation in tables.
4.5.1.1 E) CellName
Applies to
IWPParInterface
Declaration
string CellName;
Description
The cell name used by this cell. Used for calculation in tables.
4.5.1.1 F) CharCount
Applies to
IWPParInterface
Declaration
int CharCount;
Description
The count of characters in a paragraph.
4.5.1.1 G) IndentFirst
Applies to
IWPParInterface
Declaration
int IndentFirst;
Description
The first indent (WPAT_IndentFirst) as twips value.
4.5.1.1 H) IndentLeft
Applies to
IWPParInterface
Declaration
int IndentLeft;
Description
289
290
The left indent (WPAT_IndentLeft) as twips value. Use IndentFirst=-IndentLeft for hanging
indents.
4.5.1.1 I) IndentRight
Applies to
IWPParInterface
Declaration
int IndentRight;
Description
The right indent (WPAT_IndentRight) as twips value.
4.5.1.1 J) IsColMerge
Applies to
IWPParInterface
Declaration
bool IsColMerge;
Description
When set, this paragraph (must be a cell) is horizontally merged with the previous cell.
Please also see InputRowStart - there we added an VB.NET example which creates a table
using merged cells and paragraph styles.
4.5.1.1 K) IsFooterRow
Applies to
IWPParInterface
Declaration
bool IsFooterRow;
Description
When set this row paragraph (or the parent row if it is a cell) is a footer row. Footer rows are
repeated at the bottom of the page.
Category
Table Support
4.5.1.1 L) IsHeaderRow
Applies to
IWPParInterface
Declaration
bool IsHeaderRow;
Description
2006-2009 by WPCubed GmbH, Munich, Germany
291
When set this row paragraph (or the parent row if it is a cell) is a header row. Header rows are
repeated at the top of the page.
Category
Table Support
4.5.1.1 M) IsHidden
Applies to
IWPParInterface
Declaration
bool IsHidden;
Description
If set this paragraph (must not be a cell) is hidden.
4.5.1.1 N) IsNewPage
Applies to
IWPParInterface
Declaration
bool IsNewPage;
Description
A new page starts before this paragraph. In tables hard pagebreaks are only allowed before
rows, soft page breaks are allowed within cells.
4.5.1.1 O) IsProtected
Applies to
IWPParInterface
Declaration
bool IsProtected;
Description
If set this paragraph is protected.
4.5.1.1 P) IsRowMerge
Applies to
IWPParInterface
Declaration
bool IsRowMerge;
Description
When set, this paragraph (must be a cell) is vertically merged with the previous cell.
Also see property IsColMerge.
Category
Table Support
292
4.5.1.1 Q) LineHeight
Applies to
IWPParInterface
Declaration
int LineHeight;
Description
The line height in percent (WPAT_LineHeight) defined for this paragraph or style.
4.5.1.1 R) NumberLevel
Applies to
IWPParInterface
Declaration
int NumberLevel;
Description
The outline level of this style or paragraph. Possible values are between 0 and 9. 0 disables the
outline mode.
The number level can also be modified using property ID WPAT_NumberLevel.
Example:
IWPTextCursor Cursor = rtF2PDF1.Memo.TextCursor;
IWPParInterface Par = rtF2PDF1.Memo.CurrPar;
IWPNumberStyle NStyle = rtF2PDF1.Memo.GetNumberStyle(0, 0, 1);
NStyle.ASet((int)WPAT.NumberMODE,1); // Arabic
rtF2PDF1.ReleaseInt(NStyle);
Cursor.InputText("This is the first outline");
Cursor.InputParagraph(0,"");
for (int i = 0; i < 10; i++)
{
Cursor.InputText("List Item " + i.ToString());
Par.NumberLevel=1;
Cursor.InputParagraph(0,"");
}
Par.NumberMode = 0;
Cursor.InputText("This is the second outline");
Cursor.InputParagraph(0,"");
for (int i = 0; i < 10; i++)
{
Cursor.InputText("List Item " + i.ToString());
Par.NumberLevel=1;
// The following code makes sure the numbering is restarted
if (i==0)
Par.ParASet((int)WPAT.NumberStart, 1);
Cursor.InputParagraph(0,"");
}
293
Par.NumberMode = 0;
4.5.1.1 S) NumberMode
Applies to
IWPParInterface
Declaration
int NumberMode;
Description
The numbering mode for this paragraph or style. If you assign a value NumberLevel will be
cleared.
Possible values are:
0 : no numbering
1 : bullets
2 : circles (not used)
3 : arabic numbering 1,2,3
4 : captital roman
5 : roman
6 : capital latin
7 : latin
Note, this property is not stored as property with WPAT code "WPAT_NumberMode".
WPAT_NumberMode is not used by paragraph styles or paragraphs, only by numberstyles. To
get a numberstyle the use the ID stored as property WPAT_NumberStyle with GetNumberStyle.
294
}
Par.NumberMode = 0;
Cursor.InputText("This is not numbered text");
4.5.1.1 T) ParColor
Applies to
IWPParInterface
Declaration
int ParColor;
Description
The paragraph shading color as RGB value.
Example:
This VB.NET code creates a paragraph style with blue shading. It uses the ColorToRGB utility.
Memo.SelectStyle("DataRow")
Memo.CurrStyle.ParColor = WpdllInt1.ColorToRGB(Color.Blue)
Memo.CurrStyle.ParShading = 20
4.5.1.1 U) ParCSS
Applies to
IWPParInterface
Declaration
property ParCSS: WideString read Get_ParCSS write Set_ParCSS;
Description
Sets and retrieves paragraph or style attributes in standard CSS Level 2 syntax.
Category
TextDynamic CSS strings
4.5.1.1 V) ParShading
Applies to
IWPParInterface
Declaration
int ParShading;
Description
The paragraph shading as percent value. Also see property ParColor.
4.5.1.1 W) ParWPCSS
Applies to
IWPParInterface
295
Declaration
string ParWPCSS;
Description
Read and write the paragraph attributes in WPCSS format.
Category
TextDynamic CSS strings
4.5.1.1 X) SpaceAfter
Applies to
IWPParInterface
Declaration
int SpaceAfter;
Description
The space after the paragraph as twips value.
4.5.1.1 Y) SpaceBefore
Applies to
IWPParInterface
Declaration
int SpaceBefore;
Description
The space before the paragraph as twips value.
4.5.1.1 Z) SpaceBetween
Applies to
IWPParInterface
Declaration
int SpaceBetween;
Description
The line height as twips value. If positive it will be used as minimum height, if negative it will be
used as absolute height. This property overrules LineHeight.
4.5.1.1 AA) StyleName
Applies to
IWPParInterface
Declaration
296
string StyleName;
Description
The name of the paragraph style used by this paragraph. For paragraph styles, this is the name
of the base style.
You can add a style using Memo.SelectStyle(name)
Example - inside the OnEnumParOrStyle event create and apply set a certain style
private void wpdllInt1_OnEnumParOrStyle(object Sender,
bool IsControlPar, int StartPos, int Count,
WPDynamic.IWPParInterface ParText,
WPDynamic.IWPAttrInterface ParAttr,
int EventParam, ref bool Abort)
{
wpdllInt1.Memo.SelectStyle( new_style_name );
wpdllInt1.Memo.CurrStyleAttr.SetFontSize( size_for_style );
ParText.ClearCharAttr();
ParText.StyleName = s;
Abort = false;
}
Please note that the attributes in a style are only used, if they are not overridden by the
paragraph or character attributes. Here we use ClearCharAttr to make sure, the characters do
not have their own attributes.
For a more selective control apply the style using ParStrCommand( 9, x, name ). If bit 1 is set
in X, the character attributes, which are used by the selected style, are cleared, if bit 2 is set,
the paragraph attributes are cleared.
Also see: "Paragraph Styles".
You need to call Memo.ReformatAll(true, true) after you have applied styles!
Category
Paragraphstyle Support
4.5.1.1 AB) TOCOutlineLevel
Applies to
IWPParInterface
Declaration
int TOCOutlineLevel;
Description
Outline level used in table of contents. When creationg a TOC all paragraphs which use a
value>0 will be collected. (Internally for TOCs the attribute with the ID WPAT_ParIsOutline is
used)
4.5.1.1 AC) WidthTW
Applies to
IWPParInterface
297
Declaration
int WidthTW;
Description
The current formatted width of this paragraph. This value can be used to measure cells, it is
readonly.
Not e : There are some commands available to read and set the current row height using the
method ParCommand.
4.5.1.2 Methods to manage attributes
4.5.1.2 A) IWPParInterface.ParASet
Applies to
IWPParInterface
Declaration
procedure ParASet(WPAT_Code: Integer; Value: Integer);
Description
Sets an attribute.
The property is selected by the WPAT code.
Note: Internally the properties are stored in an array, not in specific variables. Only if a
property is defined, an entry is added to this array. This does not only save resources, but it
allows all properties to have an undefined state. This feature is important for a clean support of
paragraph styles.
4.5.1.2 B) IWPParInterface.ParAInc
Applies to
IWPParInterface
Declaration
procedure ParAInc(WPAT_Code: Integer; Offset: Integer; MinValue: Integer);
Description
Increments attribute. The last parameter is the minimum allowed value.
4.5.1.2 C) IWPParInterface.ParAGet
Applies to
IWPParInterface
Declaration
function ParAGet(WPAT_Code: Integer; var Value: Integer): WordBool;
298
Description
Retrieve value of attribute. Retruns true if attribute is defined, otherwise false.
Also see "convert utility functions".
4.5.1.2 D) IWPParInterface.ParADelBits
Applies to
IWPParInterface
Declaration
procedure ParADelBits(WPAT_Code: Integer; Bits: Integer);
Description
Performs "AND NOT value" operation with specified value to delete bits.
4.5.1.2 E) IWPParInterface.ParADel
Applies to
IWPParInterface
Declaration
procedure ParADel(WPAT_Code: Integer);
Description
Deletes a certain attribute. This makes this attribute undefined.
Also see Convert utility for Fontface & Color Values.
4.5.1.2 F) IWPParInterface.ParAClear
Applies to
IWPParInterface
Declaration
procedure ParAClear(Mode: Integer);
Description
Deletes all attributes stored in this paragraph or style.
If bit 1 is set in parameter mode the character attribute in a paragraph are also cleared. (In
contrast to ClearCharAttr this does not change children paragraphs!)
299
4.5.1.2 G) IWPParInterface.ParAAddBits
Applies to
IWPParInterface
Declaration
procedure ParAAddBits(WPAT_Code: Integer; Bits: Integer);
Description
Perform "OR value" operation with specified attribute value to add bits.
You can use this method to set the character styles. Here you need to set the mask and the
on/off flag:
Memo.CurrPar.ParAAddBits((int)WPAT.CharStyleON, 1+4);
Memo.CurrPar.ParAAddBits((int)WPAT.CharStyleMask, 1+4);
4.5.1.2 H) IWPParInterface.SetCharAttr
Applies to
IWPParInterface
Declaration
procedure SetCharAttr(Index: Integer; CharAttr: Integer);
Description
This methods sets the character attribute index of one character in the paragraph.
This example use EnumParagraphs to set one character attribute (Courier New, 10.5 pt, Green)
to the complete text.
300
help.Clear();
help.SetFontface("Courier New");
help.SetColor(wpdllInt1.ToRGB(Color.Green));
help.SetFontSize(10.5F);
// Trigger OnEnumParOrStyle
wpdllInt1.CurrMemo.EnumParagraphs(true,help.CharAttrIndex);
wpdllInt1.CurrMemo.ReformatAll(true,true);
301
4.5.1.2 M) IWPParInterface.GetCharColorAt
This function can be used to read character attributes of text within the paragraph. We added
this method as easier alternative to the use of CharAttr.
The method GetCharFontAt reads the text color as RGB value at a given position.
4.5.1.2 N) IWPParInterface.GetCharBGColorAt
This function can be used to read character attributes of text within the paragraph. We added
this method as easier alternative to the use of CharAttr.
The method GetCharFontAt reads the text background color as RGB value at a given position.
302
4.5.1.2 O) IWPParInterface.GetCharAttr
Applies to
IWPParInterface
Declaration
function GetCharAttr(Index: Integer): Integer;
Description
This method ready the attribute index at a certain position in the paragraph.
Category
Character Attributes
4.5.1.2 P) IWPParInterface.ClearCharAttr
Applies to
IWPParInterface
Declaration
procedure ClearCharAttr;
Description
Sets the CharAttr ids of all the contained text and all children is set to to NEUTRAL. Also See
ParAClear().
4.5.1.2 Q) IWPParInterface.CharAttr
The IWPAttrInterface to modify one character attribute in a paragraph.
Applies to
IWPParInterface
Declaration
function CharAttr(Index: Integer): IWPAttrInterface;
Description
This method returns an IWPAttrInterface reference which can be used to directly manipulate
the attributes of one character in the paragraph. Please note that this interface is only valid
until CharAttr is used the next time.
Example:
This code assigns the color red to all text which follows the comment signs "//". This example
used the method EnumParagraphs which triggers the event OnEnumParOrStyle for all paragraphs
in the text.
303
int Count,
WPDynamic.IWPParInterface ParText,
WPDynamic.IWPAttrInterface ParAttr,
int EventParam,
ref bool Abort)
{
for ( int i = 0; i < ParText.CharCount; i++)
if (((char)ParText.GetChar(i)=='/')&&
((char)ParText.GetChar(i+1)=='/'))
{
while(i<ParText.CharCount)
{
ParText.CharAttr(i++).SetColor(
wpdllInt1.ToRGB(Color.Red));
}
}
}
Note: If you need to apply a certain attribute to more text it is better to calculate an character
attribute index (using AttrHelper) and then use SetCharAttr to apply it.
Also see:
IWPParInterface.GetCharFontAt
IWPParInterface.GetCharSizeAt
IWPParInterface.GetCharStyleAt
IWPParInterface.GetCharColorAt
IWPParInterface.GetCharBGColorAt
Category
Character Attributes
4.5.1.3 Methods to manage tab stops
4.5.1.3 A) IWPParInterface.TabstopDelete
Applies to
IWPParInterface
Declaration
void TabstopDelete(int Twips);
Description
Delete the tabstop at the specified position (twips value).
4.5.1.3 B) IWPParInterface.TabstopClear
Applies to
IWPParInterface
Declaration
procedure TabstopClear;
Description
304
Declaration
void TabAdd(int Twips, int Kind, int Fill, int ColorNr);
Description
Add (define) a tabstop in a paragraph.
To insert a paragraph at the current position use TextCursor.InputTabStop.
Also see: Tabstop Category
Parameters
Twips
Kind
Fill
ColorNr
0 or the color index. (Predefined index values are: 1=red, 2=green, 3=blue,
4=yellow, you can also use the convert method)
Declaration
procedure TabstopMove(OldValue, NewValue: Integer);
Moves a tabstop with a given twip value to a different position
4.5.1.3 E) IWPParInterface.TabGetNext
Applies to
IWPParInterface
Declaration
in TabGetNext(int AfterValue, int UntilValue);
305
306
This method returns the total count of tabstops defined in this paragraph.
VB6 - Example, reads all tabstops one after the other
Dim c, i, pos, Align, Farbe, Leader
c = Ctl.CurrPar.TabCount
If c < 1 Then Exit Sub
For i = 0 To c - 1
'get Tabs
If Ctl.CurrPar.TabGet(i, pos, Align, Farbe, Leader) = 0 And pos > 0 Then
....
End If
End If
Next
4.5.1.4
4.5.1.4 A) IWPParInterface.SetText
Applies to
IWPParInterface
Declaration
procedure SetText(const NewText: WideString; CharAttr: Integer);
Description
Assigns the text of a paragraph
Parameters
Text
CharAttr
CharAttr is the index of the character attribute record to be used for the inserted
data.
Special values:
0: use the attribute of the preceding text or the current attribute in case the
paragraph is empty.
-1: use the attribute of the preceding text or the paragraph default attribute if at
first position in paragraph.
-2: use current writing mode (CurrAttr).
-3: use the document default attribute
-4: don't assign an attribute (CharAttr=0)
-5: use the paragraphs default char attributes
4.5.1.4 B) IWPParInterface.AppendText
Applies to
IWPParInterface
Declaration
procedure AppendText(const NewText: WideString; CharAttr: Integer);
Description
This method appends text to the end of this paragraph. CharAttr can be usually passed as 0.
2006-2009 by WPCubed GmbH, Munich, Germany
307
Parameters
Text
Unicode string
CharAttr is the index of the character attribute record to be used for the inserted
data.
Special values:
0:Use the attribute of the preceding text or the current attribute in case the
CharAttr
paragraph is empty.
-1:Use the attribute of the preceding text or the paragraph default attribute if at
first position in paragraph.
-2: use current writing mode (CurrAttr).
-3: use the document default attribute -4: don't assign an attribute (CharAttr=0)
C# Example:
Memo.CurrAttr.Clear();
Memo.CurrAttr.SetFontface("Arial");
Memo.CurrAttr.SetFontSize(11);
Memo.CurrAttr.IncludeStyles(2); // Italic!
// append text using the current writing mode
Memo.CurrPar.AppendText("Some bold text", -2);
4.5.1.4 C) IWPParInterface.InsertText
Applies to
IWPParInterface
Declaration
procedure InsertText(Index: Integer; const NewText: WideString; CharAttr:
Integer);
Description
Inserts text at a certain position in the paragraph
Parameters
Index
Text
Unicode string
CharAttr
4.5.1.4 D) IWPParInterface.SetChar
Applies to
IWPParInterface
308
Declaration
procedure SetChar(Index: Integer; Character: Word);
Description
Modify one character in the paragraph. If the index is not valid this method will do nothing.
4.5.1.4 E) IWPParInterface.SaveToString
Applies to
IWPParInterface
Declaration
function SaveToString(const Format: WideString; OnlyChildren: WordBool):
WideString;
Description
Saves the contents of zthe paragraph to a string. Also see LoadFromString.
Category
Load and Save
4.5.1.4 F) IWPParInterface.ReplaceText
Applies to
IWPParInterface
Declaration
procedure ReplaceText(PosInPar: Integer; Len: Integer; const NewText:
WideString);
Description
Replaces a subtext with a different text.
4.5.1.4 G) IWPParInterface.LoadFromString
Applies to
IWPParInterface
Declaration
procedure LoadFromString(const Data: WideString; const Format: WideString; Mode:
Integer);
Description
Loads the contents of this paragraph from a string. This can be very useful in table cells.
Parameters
Data
Text to be loaded
Format
Mode
Mode bits:
1: clear indents of loaded text
2: clear shading of loaded text
4: Load using current writing mode
8: Load text as children paragraphs (for table cells!)
Category
Load and Save
2006-2009 by WPCubed GmbH, Munich, Germany
309
4.5.1.4 H) IWPParInterface.LoadFromFile
Applies to
IWPParInterface
Declaration
procedure LoadFromFile(const filename: WideString; const Format: WideString;
Mode: Integer);
Description
Loads the contents of this paragraph from a file. This can be very useful in table cells.
Parameters
Filename
Format
Mode
Mode bits:
1: clear indents of loaded text
2: clear shading of loaded text
4: Load using current writing mode
8: Load text as children paragraphs (for table
cells!)
Category
Load and Save
4.5.1.4 I) IWPParInterface.InsertNewObject
Applies to
IWPParInterface
Declaration
function InsertNewObject(Index: Integer; ObjType: Integer; HasClosing: WordBool;
ClosingOfPtr: Integer; CharAttrIndex: Integer; const Name: WideString; const
Command: WideString): Integer;
Description
This method creates a new object in the paragraph. The result is the ID of the object, it is != 0
if the insertion was successful. This method can also be used to create paired objects, such as
hyperlinks, bookmarks or merge fields. You can use the result value in a subsequent call to this
function as value for parameter ClosingOfPtr.
This procedure can be useful to create links and bookmarks in an event, such as
OnEnumParOrStyle without having to change the cursor position. It can also be used to insert
images.
Note: You can use GetCharObj to acquire an interface to manipulate the object.
Parameters
Index
ObjType
HasClosing
ClosingOfPtr
CharAttrIndex
310
Name
Command
Category
Image Support
InsertNewObject Example
This event handler creates an image object in all paragraphs and loads an image file.
private void wpdllInt1_OnEnumParOrStyle(
object Sender,
bool IsControlPar,
int StartPos,
int Count,
WPDynamic.IWPParInterface ParText,
WPDynamic.IWPAttrInterface ParAttr,
int EventParam,
ref bool Abort)
{
// Make sure there is an image place holder at the start of the paragraph
WPDynamic.IWPTextObj obj = ParText.CharObj(0);
if ((obj==null)|| (obj.ObjType!=WPDynamic.TextObjTypes.wpobjImage))
{
if(ParText.InsertNewObject(0,(int)WPDynamic.TextObjTypes.wpobjImage,false,
0, 0, "", "")==0) obj=null;
else obj = ParText.CharObj(0);
}
// Now update the image placeholder by loading a PNG file
if(obj!=null)
{
obj.LoadFromFile("c:\\Test.PNG");
obj.Width = obj.Contents_Width();
obj.Height = obj.Contents_Height();
}
}
The test is updated with
wpdllInt1.Memo.EnumParagraphs(false,1);
wpdllInt1.Memo.ReformatAll(true,true);
Please note that you could clone the images if you have a global integer variable to hold the ID
of the first image data object:
// Now update the image placeholder by loading a PNG file
if(obj!=null)
{
if (objid==0)
{
obj.LoadFromFile("c:\\Test.PNG");
objid = obj.GetContentsID();
}
else obj.SetContentsID(objid);
obj.Width = obj.Contents_Width();
obj.Height = obj.Contents_Height();
}
311
312
Declaration
function GetAllText(AlsoNumbers: WordBool): WideString;
Description
This function returns the text of this paragraph and all the children. If the parameter
AlsoNumbers has been set to true the numbering of numbered paragraphs will be added, too.
4.5.1.4 O) IWPParInterface.DeleteChar
Applies to
IWPParInterface
Declaration
procedure DeleteChar(Index: Integer; Count: Integer);
Description
Delete N characters at a certain position.
4.5.1.4 P) IWPParInterface.CharObj
Applies to
IWPParInterface
Declaration
function CharObj(Index: Integer): IWPTextObj;
Description
This function provides a IWPTextObj interface to manipulate the object at a certain position in
the paragraph. The result value is null if there is no object at that position.
4.5.1.5
313
314
4.5.1.5 C) IWPParInterface.SwapWithNextPar
Exchanges two paragraphs in the list of paragraphs.
4.5.1.5 D) IWPParInterface.SetPtr
Applies to
IWPParInterface
Declaration
bool SetPtr(int Paragraph);
Description
Makes the paragraph with the specified ID the 'current' paragraph. See method AppendChild for
an example.
Instead of IDs the following constants can be used:
1: Select current cell. This is useful to select the cell a child paragraph is located within.
2: Select parent row.
3: Select parent table - for example to change the properties of a table directly.
4: Select parent cell, the cell which owns a nested table.
5: Select the Parent-Parent Table, the table which owns the parent Cell
If the selected object was not found, false is returned.
Please also see low "level move methods" which make it easy to move through a document
without changing the cursor position!
Category
Lowlevel Paragraph IDs
4.5.1.5 E) IWPParInterface.SetParType
Applies to
IWPParInterface
Declaration
procedure SetParType(ParType: Integer);
Description
Modify the paragraph type. Currently You can use the values:
0 : Standard paragraph
6 : Table parent - holds rows
7 : Table row - holds cells
The .NET assembly defines the enum "ParagraphType".
Category
Table Support
4.5.1.5 F) IWPParInterface.SelectLastPar
This method jumps to the last paragraph in the layer.
4.5.1.5 G) IWPParInterface.SelectFirstParGlobal
Makes the IWPParagraphInterface work with the first paragraph in the document. This can be
used to create loop all paragraphs using SelectNextGlobalPar. (see Low level move Methods )
315
4.5.1.5 H) IWPParInterface.SelectFirstPar
Makes the IWPParagraphInterface work with the first paragraph in this layer. This can be used
to create loop all paragraphs using SelectNextPar. (see Low level move Methods )
4.5.1.5 I) IWPParInterface.GetPtrPrev
Applies to
IWPParInterface
Declaration
function GetPtrPrev: Integer;
Description
This is the ID of the previous sibling of the paragraph.
Category
Lowlevel Paragraph IDs
4.5.1.5 J) IWPParInterface.GetPtrParent
Applies to
IWPParInterface
Declaration
function GetPtrParent: Integer;
Description
This is the ID of the parent of the paragraph. You can use this value with SetPtr.
Category
Lowlevel Paragraph IDs
4.5.1.5 K) IWPParInterface.GetPtrNext
Applies to
IWPParInterface
Declaration
function GetPtrNext: Integer;
Description
This is the ID of the next sibling of the paragraph.
Category
Lowlevel Paragraph IDs
4.5.1.5 L) IWPParInterface.GetPtrChild
Applies to
IWPParInterface
Declaration
function GetPtrChild: Integer;
Description
This is the ID of the first child of this paragraph.
Category
2006-2009 by WPCubed GmbH, Munich, Germany
316
4.5.1.5 P) IWPParInterface.Duplicate
Applies to
IWPParInterface
317
Declaration
procedure Duplicate;
Description
This method duplicates this paragraph and all its text and children. It makes the new paragraph
the current.
4.5.1.5 Q) IWPParInterface.DeleteParEnd
Applies to
IWPParInterface
Declaration
procedure DeleteParEnd;
Description
This method delets the end of the paragraph. This in fact combines the paragraph with the
following paragraph. If the next paragraph cannot be appended (it is is a table) the function
does nothing.
4.5.1.5 R) IWPParInterface.DeleteParagraph
Applies to
IWPParInterface
Declaration
procedure DeleteParagraph;
Description
This method deletes this paragraph and all children. It makes the next paragraph the current.
4.5.1.5 S) IWPParInterface.AppendNext
Applies to
IWPParInterface
Declaration
function AppendNext: Integer;
Description
This procedure appends a new paragraph after the current and makes it the current. If the
current paragraph is a cell and you need to create a second paragraph inside the same cell
please use AppendChild.
4.5.1.5 T) IWPParInterface.AppendChild
Applies to
IWPParInterface
Declaration
function AppendChild: Integer;
318
Description
This procedure creates a new child paragraph. If the current paragraph is a table paragraph the
child will be a table row, if it is a table row, the child will be a cell. The result value is the ID of
the new paragraph. It can be used in SetPtr to be manipulated by the IWPParInterface
instance.
Example: Low level table creation:
IWPParInterface par= wpdllInt1.CurrPar;
int tbl=par.AppendNext();
par.SetParType((int)ParagraphType.Table);
for (int r= 0; r < 10; r++)
{
par.SetPtr(par.AppendChild()); // row=current
for (int c = 0; c < 5; c++)
{
if (c==0) par.SetPtr(par.AppendChild()); // First Cell
else par.AppendNext(); // Other cells
par.AppendText((r*10+c).ToString(),-1);
par.Borders = 15;
}
par.SetPtr(tbl); // table=current
}
par.AppendNext();
par.AppendText("Text after Table",-1);
wpdllInt1.Reformat();
Category
Table Support
4.5.1.6 Other methods
4.5.1.6 A) Convert Utility function
The following methods can be used to create number values for the method ParASet or to
convert the result of ParAGet.
a) Functions to work with font names
int ConvertFontnameToIndex(string fontface)
string ConvertIndexToFontname(int value)
used with this property ids:
WPAT_CharFont = 1
WPAT_NumberFONT = 40
b) Functions to work with color values
int ConvertColorToIndex(int RGB_Value)
string ConvertIndexToText(int value)
used with this property ids:
WPAT_CharColor = 8
WPAT_CharBGColor = 9
WPAT_UnderlineColor = 14
WPAT_NumberFONTCOLOR = 42
2006-2009 by WPCubed GmbH, Munich, Germany
4.5.1.6 B) IWPParInterface.WidthTwips
This function returns the calculated width of this paragraphs in twips.
4.5.1.6 C) IWPParInterface.StartCPOffset
This function calculates the offset from the start of the text.
The result can be used in TextCursor.CPPosition.
To assign the offset to move the "CurrPar" interface use ParCommand with ComID=5.
319
320
4.5.1.6 D) IWPParInterface.SetProp
Applies to
IWPParInterface
Declaration
void SetProp(int ID, int Value);
Description
ID=1:
If You use Memo.CurrPar usually only the current paragraph, the paragraph the cursor
is in, will be modified. Certain methods can also modify all selected paragraphs.
To use this feature You first need to call SetProp with ID=1 and Parameter=1 to
initialize the list of selected paragraphs. When done please don't forget to call SetProp
with ID=1 and Value=0 to clear the list. If not text was selected, at least the current
paragraph will be added to the internal list.
We highlighted the methods which work on a paragraph list with this symbol:
ID=2:
Add the current paragraph to the internal paragraph list (value is ignored). You need to call
SetProp(1,0) to switch the "paragraph list" mode off.
4.5.1.6 E) IWPParInterface.GetProp
Applies to
IWPParInterface
Declaration
int GetProp(int ID);
Description
ID=1
Returns 1 if the interface is currently working on a paragraph list.
4.5.1.6 F) IWPParInterface.ParStrCommand
Applies to
IWPParInterface
Declaration
function ParStrCommand(ComID: Integer; param: Integer; const StrParam:
WideString): Integer;
Description
The following command IDs are currently used:
1: Convert a font name into a font index, use it with the code WPAT.CharFont and method
ParASet. (Better use convert utility)
321
2: Convert a string into a number, use it with the code WPAT_NumberTEXTB and
WPAT_NumberTEXTA. (Better use convert utility)
3: Convert a color string into a number, use it with the code WPAT_CharColor. (Better use
convert utility)
4: Assigns the name of this paragraph
5: Assigns the "cell name" to the parent cell of this paragraph. Returns -1 if not in a table.
(same as property CellName)
6: Assigns the "cell command" to the parent cell of this paragraph. Returns -1 if not in a table.
7: Assigns the name to the parent table of this paragraph. Returns -1 if not in a table. The
table name can be used in MoveToTable.
8: Assigns a name to this paragraph.
Also see: IWPTextCursor.GetParName and SetParName.
9: A paragraph style can be set using property StyleName. For a more control apply the style
using ParStrCommand( 9, param, name ) to set and apply a style. If bit 1 is set in "param", the
character attributes, which are used by the selected style, are cleared, if bit 2 is set, the
paragraph attributes are cleared. The style does not have to exist. The function returns its
number if successful. (
Also see: "Paragraph Styles".
Category
Attribute IDs
4.5.1.6 G) IWPParInterface.ParCommand
Applies to
IWPParInterface
Declaration
322
512:
1024:
2048:
4096:
reserved
footnotes
images
horizontal line
323
ComID = 6: (trim)
Trim function - removes whitespace from start and end of this paragraph / cell.
ComID = 7: (find attributes)
Search in current paragraph for certain character attributes.
Starts to search from position Param2 and returns -1 if nothing was found, or the position is
stored in the high word and the length in the low word of the result text. (This restricts
paragraphs not to exceed 64K characters)
Param selects the attribute in the high byte of the 32 bit parameter. (Actually You can use the
first 16 WPAT codes here)
The low 3 bytes are the parameter.
The following values are useful in the highest byte:
1: The Font Nr
3: The font size * 100
7: The character style. The low byte selects the style.
8: The color nr.
Use the same values as in IWPAttrInterface.IncludeStyles and IWPAttrInterface.ExcludeStyles:
0 : Bold text. (C# wrapper defines enum element WPWRT.BOLD)
1 : Italic text. (C# wrapper defines enum element WPWRT.ITALIC)
2 : Underlined text. (C# wrapper defines enum element WPWRT.UNDERLINE)
3 : Strikeout text. (C# wrapper defines enum element WPWRT.STRIKEOUT)
4 : Text in super-script (C# wrapper defines enum element WPWRT.SUPERSCRIPT)
5 : Text in sub-script (C# wrapper defines enum element WPWRT.SUBSCRIPT)
6 : Hidden text, (C# wrapper: WPWRT.HIDDEN)
7 : Uppercase text. (C# wrapper: WPWRT.UPPERCASE)
8 : reserved.
9 : Lowercase text. (C# wrapper: WPWRT.LOWERCASE)
10 : Text which should be excluded from spellcheck (WPWRT.NOPROOF)
11 : Double strikeout (WPWRT.DBLSTRIKEOUT)
12 : reserved.
13 : protected text (WPWRT.PROTECTED)
The lower 3 bytes are the desired value. They have to match exactly, except for the character
style comparison. In this case the given bits have to be set.
This method can also be used to search special flags. In this case "Param" may have this values
16+1: - locates hyphen marker for manual hyphenation
16+2: - locates text which was spell checked already
16+3: - locates text which was marked to misspelled by the spell-as-you-go feature
16+4: - the alternative misspell marker (green)
16+5: - reserved
16+6: - reserved
16+7: - highlighted text (on the fly highlights, not background color)
16+8: - marked for deletion
ComID = 8: (set attributes)
Assigns new attributes to part of the text. This is the counter part to the search command 7.
Param2 is the position and the length, high/low word.
2006-2009 by WPCubed GmbH, Munich, Germany
324
The Font Nr
The font size * 100
Adds a character style like IWPAttrInterface.IncludeStyles
Removes a character styles like IWPAttrInterface.ExcludeStyles.
325
Calculate the line number of the character at the position param. If param2<>0 it will favors the
end of a line, otherwise the start.
ComID = 11
This Function returns the start offset of the line with number param (range 0..).
ComID = 12
This Function returns the length of the line with number param.
4.5.1.6 H) IWPParInterface.HeightTwips
This function returns the calculated height of this paragraphs in twips.
4.5.2
IWPDataBlock
326
Properties
ID
Methods
AppendParagraph
IsEmpty
Clear
Kind
Delete
Name
GetParPtrFirst
Range
GetParPtrLast
Readonly
SelectFirstPar
SectionID
Text
WorkOnText
CurrPar
CurrParAttr
4.5.2.1
Properties
4.5.2.1 A) ID
Applies to
IWPDataBlock
Declaration
int ID;
Description
This is the ID of the data block. IDs are used to select certain data blocks in event
OnGetSpecialText.
4.5.2.1 B) IsEmpty
Applies to
IWPDataBlock
Declaration
bool IsEmpty;
Description
This property is true if the data block is completely empty.
4.5.2.1 C) Kind
Applies to
IWPDataBlock
Declaration
DataBlockKind Kind;
Description
327
This event handler selects the "custom" header for page number 2 only.
private void wpdllInt1_OnGetSpecialText(
object Sender,
int Editor,
int PageNr,
WPDynamic.DataBlockKind Kind,
ref int SelectedID)
{
if((Kind==DataBlockKind.wpIsHeader)&&(PageNr==2))
{
SelectedID=wpdllInt1.Memo.FindHeader(
(int)DataBlockRange.wpraNamed,
"CUSTOM" // name to find
);
}
}
328
4.5.2.1 E) Range
Applies to
IWPDataBlock
Declaration
DataBlockRange Range;
Description
The "range" is used by header or footer texts. Possible values are
wpraOnAllPages =0; // use on all pages
wpraOnOddPages =1; // use on odd pages (1,3,5,...)
wpraOnEvenPages=2; // use on even pages (2,4,6,...)
wpraOnFirstPage=3; // print on first page only
wpraOnLastPage=4; // print on last page only
wpraNotOnFirstAndLastPages=5; // Not on first or last pages
wpraNotOnLastPage=6; // on all but not on last page
wpraNamed=7; // never used. Use event OnGetSpecialText to select it
wpraIgnored=8; // Dont used
wpraNotOnFirstPage=9; // On all but not on first page
Notes:
Only the first 4 options are standard in RTF format.
Footnotes will use wpraOnAllPages and text boxes will use wpraNamed.
4.5.2.1 F) Readonly
Applies to
IWPDataBlock
Declaration
bool Readonly;
Description
If this property is true the layer cannot be edited.
4.5.2.1 G) SectionID
Applies to
IWPDataBlock
Declaration
int SectionID;
Description
This id is used to select a header or footer for a certain section in the text.
4.5.2.1 H) Text
Applies to
IWPDataBlock
Declaration
string Text;
329
Description
The property Text can be used to assign new text. Example see property name.
This property is write - only!
Category
Load and Save
4.5.2.1 I) WorkOnText
Applies to
IWPDataBlock
Declaration
bool WorkOnText;
Description
If this property is true the cursor (the insertion marker) is located within this layer. This
property can be read and written.
4.5.2.1 J) CurrPar
Applies to
IWPDataBlock
Declaration
IWPParInterface ParAttr
Description
This interface let you modify the current paragraph. The current paragraph is the paragraph
which was appended last using the function AppendParagraph. The method SelectFirstPar will
make the first paragraph the "current".
Note: Please don't forget to call ReleaseInt() with the returned interface at the end of your
code.
4.5.2.1 K) CurrParAttr
Applies to
IWPDataBlock
Declaration
IWPAttrInterface ParAttr
Description
This interface let you modify the current paragraph. The current paragraph is the paragraph
which was appended last using the function AppendParagraph. The method SelectFirstPar will
make the first paragraph the "current".
Note: Please don't forget to call ReleaseInt() with the returned interface at the end of your
code.
330
4.5.2.2
4.5.2.2 A) IWPDataBlock.AppendParagraph
Applies to
IWPDataBlock
Declaration
IWPParInterface AppendParagraph();
Description
This method appends a new paragraph to this text block and returns an IWPParInterface
reference which can be used to manipulate this new paragraph. While it is easier to use the
TextCursor methods to create a new header or footer, this method can be ideal to on the fly
modify the text in header or footer since the cursor position does not have to be changed.
par.SetPtr(row);
par.SetPtr(par.AppendChild());
par.AppendText("Cell A2",-1);
par.SetPtr(row);
par.SetPtr(par.AppendChild());
par.AppendText("Cell A3",-1);
// Tip: to create a second row use
// par.SetPtr(tbl); and then create another row and cells
Please note that it is not possible to change the text in custom paint events.
Category
Table Support
4.5.2.2 B) IWPDataBlock.Clear
Applies to
IWPDataBlock
Declaration
void Clear();
Description
This procedure clears the text in this block.
4.5.2.2 C) IWPDataBlock.Delete
Applies to
IWPDataBlock
Declaration
void Delete();
Description
To delete the entire block use the procedure Delete.
4.5.2.2 D) IWPDataBlock.GetParPtrFirst
Applies to
IWPDataBlock
Declaration
int GetParPtrFirst()
Description
This is the ID of the first paragraph in this text block.
4.5.2.2 E) IWPDataBlock.GetParPtrLast
Applies to
IWPDataBlock
Declaration
int GetParPtrFirst()
331
332
Description
This is the ID of the last paragraph in this text block.
4.5.2.2 F) IWPDataBlock.SelectFirstPar
Applies to
IWPDataBlock
Declaration
bool SelectFirstPar()
Description
This method selects the the first paragraph in this text block to be the "current". You can then
use CurrPar and CurrParAttr to manipulate this paragraph. To move to a different paragraph
use, for example, CurrPar.SelectNextPar().
If the text block is empty the function will return false. You can use AppendParagraph to create
a new paragraph.
4.5.3
IWPTextObj
Properties
4.5.3.1 A) Command
Applies to
IWPTextObj
Declaration
string Command;
Description
This is the command property of this object. It has different meanings, hyperlinks store the
URL, merge fields an optional formula.
4.5.3.1 B) Contents_Filename
Applies to
IWPTextObj
Declaration
string Contents_Filename;
333
Description
This is the file name of the image object linked to this object.
4.5.3.1 C) EmbeddedText
Applies to
IWPTextObj
Declaration
string EmbeddedText;
Description
This is the text which is wrapped by this object and its sibling end object. This only works with
paired objects, such as hyperlinks, merge fields and bookmarks.
Note: You may read and modify this property!
4.5.3.1 D) Frame
Applies to
IWPTextObj
Declaration
int Frame;
Description
If the object is an image you can specify a frame:
0 : no frame
1 : single frame
2 : think frame
4.5.3.1 E) Height
Applies to
IWPTextObj
Declaration
int Height;
Description
This is the height of the object in twips (=1/1440 inch). It is only used by image and TextBox
objects.
4.5.3.1 F) IntParam
Applies to
IWPTextObj
Declaration
int IntParam;
Description
Integer property can be used for custom parameters.
334
4.5.3.1 G) Mode
Applies to
IWPTextObj
Declaration
int Mode;
Description
This are the Mode bits for this object. The Value 2 marks edit fields to be editable. The other
bits are only used by movable image objects:
4 : Lock position
8 : Allows sizing only "aspect ratio"
16: Disable size changes
32: Position at right side of page
64: Center object horizontally
128: Position in Margin.
4.5.3.1 H) Name
Applies to
IWPTextObj
Declaration
string Name;
Description
This is the name of the objects, for example the fieldname of a mailmerge field.
4.5.3.1 I) ObjType
Applies to
IWPTextObj
Declaration
TextObjTypes ObjType;
Description
The type of the object. The property is readonly, You can use _SetObjType to change the
type.
0=text object,
1=merge field,
2=hyperlink,
3=bookmark,
7=text object,
8=page reference,
11=footnote,
12=image or text box and
13 for horizontal lines.
Please note: "Bookmarks" are NOT the kind of bookmarks used by PDF. This are invisible marks
which can be used to locate certain text in a document. They are implemented as object pairs
(like hyperlinks and merge fields) and so can contain text. To mark text to be exported as a PDF
bookmark use the WPAT code ParIsOutline.
335
4.5.3.1 J) Params
Applies to
IWPTextObj
Declaration
string Params;
Description
This is the default text displayed by a textobject field.
4.5.3.1 K) PositionMode
Applies to
IWPTextObj
Declaration
int PositionMode;
Description
Image objects can be positioned relatively to a character (0), to the paragraph (1) and to the
current page (2).
With the modes 1 and 2 the properties RelX and RelY are used to move the image using twips
offset values.
4.5.3.1 L) RelX
Applies to
IWPTextObj
Declaration
int RelX;
Description
Used to position a movable image (PositionMode =1 or 2). It is the horizontal offset in twips.
4.5.3.1 M) RelY
Applies to
IWPTextObj
Declaration
int RelY;
Description
Used to position a movable image (PositionMode =1 or 2). It is the vertical offset in twips.
4.5.3.1 N) StyleName
Applies to
IWPTextObj
Declaration
336
string StyleName;
Description
Some paired objects (SPAN and Hyperlink) can use an attached patragraph style to format the
embedded text. This property contains the name of this style.
Category
Paragraphstyle Support
4.5.3.1 O) Width
Applies to
IWPTextObj
Declaration
int Width;
Description
This is the width of the object in twips (1/1440 inch). It is only used by images.
4.5.3.1 P) wpcss
Applies to
IWPTextObj
Declaration
string wpcss;
Description
Read and write the properties as WPCSS string.
4.5.3.1 Q) Format
Applies to
IWPTextWriter
Declaration
string Format;
Description
The format options used when saving the file
4.5.3.1 R) Wrap
Applies to
IWPTextObj
Declaration
int Wrap;
Description
Used to control the text wrap around a movable image (PositionMode =1 or 2).
0 : automatic, wrap on the wider side
1 : wrap on left side
2 : wrap on right side
3 : do not wrap at all - object is painted over text.
337
4.5.3.2 B) IWPTextObj.Clear
Applies to
IWPTextObj
Declaration
procedure Clear;
Description
This method clears the text of mergefields, hyperlinks and bookmarks. It also clears the
contents of footnotes and textboxes (premium edition).
4.5.3.2 C) IWPTextObj.Contents_Edit
Applies to
IWPTextObj
2006-2009 by WPCubed GmbH, Munich, Germany
338
Declaration
function Contents_Edit: WordBool;
Description
This method selects the edit mode for footnotes and text boxes.
4.5.3.2 D) IWPTextObj.Contents_Height
Applies to
IWPTextObj
Declaration
function Contents_Height: Integer;
Description
This is the physical height of the loaded image.
4.5.3.2 E) IWPTextObj.Contents_LoadFromFile
Applies to
IWPTextObj
Declaration
bool Contents_LoadFromFile( string filename);
This method can be only used with image objects which have been already created. It will
update the image from the provided image file.
4.5.3.2 F) IWPTextObj.Contents_SaveToFile
Applies to
IWPTextObj
Declaration
function Contents_SaveToFile(const filename: WideString): WideString;
Description
This method can be used to save an image to file. It returns the name of the file which was
actually written.
4.5.3.2 G) IWPTextObj.Contents_Width
Applies to
IWPTextObj
Declaration
function Contents_Width: Integer;
Description
This is the physical width of the loaded image.
4.5.3.2 H) IWPTextObj.DeleteObj
Applies to
2006-2009 by WPCubed GmbH, Munich, Germany
339
IWPTextObj
Declaration
procedure DeleteObj;
4.5.3.2 I) IWPTextObj.GetContentsID
Applies to
IWPTextObj
Declaration
function GetContentsID: Integer;
Description
Retrieves the ID of the image object which is attached to the object placeholder. If no image is
attached the ID will be 0.
You can use SetContentsID to assign the object also to another placeholder which clones the
image.
4.5.3.2 J) IWPTextObj.GetEmbText
Applies to
IWPTextObj
Declaration
procedure GetEmbText(const Format: WideString; var Data: WideString);
Description
This property can be used to retrieve the contents as formatted text. It is usually used with
merge fields.
4.5.3.2 K) IWPTextObj.GetFieldProp
Applies to
IWPTextObj
Declaration
function GetFieldProp(ID: Integer; var Value: WideString): WordBool;
4.5.3.2 L) IWPTextObj.GetParentParPos
Applies to
IWPTextObj
Declaration
function GetParentParPos: Integer;
Description
This is the position of the object inside the parent paragraph.
4.5.3.2 M) IWPTextObj.GetParentParPtr
Applies to
IWPTextObj
2006-2009 by WPCubed GmbH, Munich, Germany
340
Declaration
function GetParentParPtr: Integer;
Description
This function retrieves a low level reference to the paragraph this object is located within.
4.5.3.2 N) IWPTextObj.GetProp
Applies to
IWPTextObj
Declaration
function GetProp(ID: Integer): WideString;
Description
This method is used to set the properties set by SetProp.
4.5.3.2 O) IWPTextObj.GetPtr
Applies to
IWPTextObj
Declaration
function GetPtr: Integer;
Description
This method retrieves a low level pointer to this object. This pointer can be carefully(!) used
with other methods which work with "Ptr" values, such as MakeEndTag.
4.5.3.2 P) IWPTextObj.LoadFromFile
Applies to
IWPTextObj
Declaration
function LoadFromFile(const filename: WideString): WordBool;
Description
This method loads the contents of this object from a file.
Parameters
Filename
Note: When working with a placeholder object which embeds data into a PDF file (See
InputEmbeddedData) this method updates the embedded data, not the image! In this case the
file may be in RTF, C# and various other formats!
Category
Load and Save
Image Support
4.5.3.2 Q) IWPTextObj.LoadFromStream
Applies to
IWPTextObj
341
Declaration
function LoadFromStream(const FileExt: WideString; const Stream: IUnknown):
WordBool;
Description
This method loads the contents of this object from a IStream or IWPStream. This is method is
used to load image data into image objects. .NET: The stream converter Stream2WPStream
must be re-created for each load and save operation!
Example:
System.IO.Stream str = new System.IO.MemoryStream();
// ... load data into "str" ... and then load it into the object
wpdllint1.Memo.CurrObj.LoadFromStream("PNG", new WPDynamic.Stream2WPStream(str));
Parameters
FileExt
Stream
Note: When working with a placeholder object which embeds data into a PDF file (See
InputEmbeddedData) this method updates the embedded data, not the image! In this case the
file may be in RTF, C# and various other formats!
Category
Load and Save
4.5.3.2 R) IWPTextObj.MakeEndTag
Applies to
IWPTextObj
Declaration
function MakeEndTag(PtrOfStartTag: Integer): WordBool;
Description
This method can be used to create object pairs, such a merge fields and hyperlinks. Usually you
will not have to use this method, rather use high level functions such as InputHyperlink.
To create an object pair call Obj.MakeEndTag( PtrOfStartTag ). PtrOfStartTag must have been
retrieved using a call to Obj.GetPtr with a different IWPTextObj interface.
4.5.3.2 S) IWPTextObj.MoveCursor
Applies to
IWPTextObj
Declaration
procedure MoveCursor(Mode: Integer);
Description
This method moves the cursor near the
Parameters
2006-2009 by WPCubed GmbH, Munich, Germany
342
Mode
4.5.3.2 T) IWPTextObj.MoveToPage
Applies to
IWPTextObj
Declaration
function MoveToPage(PageNr: Integer; X: Integer; Y: Integer): WordBool;
Description
not used yet.
4.5.3.2 U) IWPTextObj.ObjCommand
Applies to
IWPTextObj
Declaration
bool ObjCommand( int ID, int param,string StrParam);
Currently this commands are defined:
0 : Move cursor to this object
1 : Move cursor to the start tag
2 : Move Cursor to end tag
The Result is TRUE if the operation was successful.
4.5.3.2 V) IWPTextObj.ScaleSize
Applies to
IWPTextObj
Declaration
void ScaleSize(int BestWidth, int BestHeight, int Percent);
Description
This method can be used scale an image object.
Parameters
BestWidth
BestHeight
Percent
343
4.5.3.2 W) IWPTextObj.Select
Applies to
IWPTextObj
Declaration
void Select(int Mode);
Description
This methods selects the object.
Parameters
Select
4.5.3.2 X) IWPTextObj.SetContentsID
Used for image cloning
Applies to
IWPTextObj
Declaration
function SetContentsID(ID: Integer): WordBool;
Description
GetContentsID retrieves the ID of the image object which is attached to the object
placeholder. If no image is attached the ID will be 0.
You can use SetContentsID(id) to assign the object also to another placeholder which clones
the image.
Parameters
ID
Returns
True if assignment was ok, false if ID is not valid.
Category
Image Support
4.5.3.2 Y) IWPTextObj.SetEmbText
Applies to
IWPTextObj
Declaration
procedure SetEmbText(const Data: WideString; const Format: WideString);
Description
This method replaces the embedded text with formatted text. Unlike property EmbeddedText
also HTML and RTF code can be used!
4.5.3.2 Z) IWPTextObj.SetFieldProp
Applies to
IWPTextObj
344
Declaration
procedure SetFieldProp(Id: Integer; const Text: WideString);
4.5.3.2 AA) IWPTextObj.SetProp
Applies to
IWPTextObj
Declaration
procedure SetProp(ID: Integer; const Value: WideString);
Description
With ID<=0 custom string properties can be set in this object.
-ID is used as ID of the specific custom string. Please use adjacent numbers.
Alternatively these flags can be set:
id = 1 : Set the mode [wpobjDrawAsRect]
2 : Set the mode [wpobjDrawAsText]
3 : Set the mode [wpobjWithinEditable]
4 : Set the mode [wpobjWithinProtected]
5 : Set the mode [wpobjPositionAtRight]
6 : Set the mode [wpobjPositionAtCenter]
7 : Set the mode [wpobjPositionInMargin]
8 : Set the mode [wpobjLockedPos]
9 : Set the mode [wpobjDisableAutoSize]
10 : Set the mode [wpobjSizingDisabled]
11 : Set the mode [wpobjSizingAspectRatio]
12 : Set the mode [wpobjObjectUnderText]
13 : Set the mode [wpobjReadSourceFromEmbeddedText]
14 : Set the mode [wpobjUseForMailmerge]
To set the flag use the value "1", to clear it use the value "0".
32: Set the value of the internal property "CParam"
33: Set the value of the internal property "IParam" and expect an integer value
34: Set the value of the internal property "IParam" and expect a color value. (You can set the
color of a horizontal line)
345
4.5.4
IWPNumberStyle
346
par.SetText("Level A",0);
// Optional
// par.IndentLeft = 720;
// par.IndentFirst= -720;
4.5.4.1
par.SetText("not
numbered",0);
par.NumberLevel = 0;
par.SetText("Level A"
,0);
par.NumberLevel = 1;
// Reformat an paint
memo.ReformatAll(
false,true);
Properties
4.5.4.1 A) Color
Applies to
IWPNumberStyle
Declaration
int Color;
Description
The color for the number text (or bullets) as RGB value.
4.5.4.1 B) Font
Applies to
IWPNumberStyle
Declaration
string Font;
Description
The font for numbering or bullets. If empty use the paragraph phont.
4.5.4.1 C) Group
Applies to
IWPNumberStyle
Declaration
int Group;
Description
The outline group, 0 or 1.
If the value is 0 this number style is not part of a group, if it is 1 this is an outline style. Up to
9 levels can be defined in an outline style group.
4.5.4.1 D) ID
Applies to
IWPNumberStyle
Declaration
int ID;
Description
The ID used for the paragraph property WPAT_NumberStyle.
4.5.4.1 E) Indent
Applies to
IWPNumberStyle
Declaration
int Indent;
Description
The width reserved for the number or the bullet.
4.5.4.1 F) LegalNumbering
Applies to
IWPNumberStyle
Declaration
bool LegalNumbering;
Description
If true use legal numbering: 1.1.1
4.5.4.1 G) Level
Applies to
IWPNumberStyle
Declaration
int Level;
Description
0 or the level in an outline group between 1 and 9.
4.5.4.1 H) Mode
Applies to
IWPNumberStyle
Declaration
int Mode;
Description
The numbering mode:
0 : no numbering
1 : bullets
2 : circles
3 : arabic numbering 1,2,3
4 : captital roman
347
348
5 : roman
6 : capital latin
7 : latin
4.5.4.1 I) Size
Applies to
IWPNumberStyle
Declaration
float Size;
Description
The font size for the numbering, 0 to use paragraph attribute.
4.5.4.1 J) TextA
Applies to
IWPNumberStyle
Declaration
string TextA;
Description
The text after the number.
4.5.4.1 K) TextB
Applies to
IWPNumberStyle
Declaration
string TextB;
Description
The text before the number. You can use it to define the bullet symbol. For bullets also
change Font.
4.5.4.1 L) WPCSS
Applies to
IWPNumberStyle
Declaration
string WPCSS;
Description
Get and set the properies as WPCSS string.
4.5.4.2
Methods
4.5.4.2 A) IWPNumberStyle.ADel
Applies to
IWPNumberStyle
Declaration
procedure ADel(WPAT_Code: Integer);
Description
Low level method to delete a property referenced by a WPAT id.
4.5.4.2 B) IWPNumberStyle.AGet
Applies to
IWPNumberStyle
Declaration
function AGet(WPAT_Code: Integer; var Value: Integer): WordBool;
Description
Low level method to read a property referenced by a WPAT id.
4.5.4.2 C) IWPNumberStyle.ASet
Applies to
IWPNumberStyle
Declaration
procedure ASet(WPAT_Code: Integer; Value: Integer);
Description
Low level method to modify a property referenced by a WPAT id.
4.5.4.2 D) IWPNumberStyle.Command
Applies to
IWPNumberStyle
Declaration
function Command(ID: Integer; Param: Integer): Integer;
Description
ID=1: Change locked state of style.
bit 1: Clear does not delete this style.
bit 2: Load will not overwrite this style.
bit 3: Always saved in WPT format, even if not used in document.
4.5.4.2 E) IWPNumberStyle.DeleteStyle
Applies to
IWPNumberStyle
Declaration
procedure DeleteStyle;
Description
Delete this style. The interface must not be used afterwards.
We recommend to use GetNumberStyle(ID,-1000,level) to delete styles.
349
350
4.5.4.2 F) IWPNumberStyle.SelectStyle
Applies to
IWPNumberStyle
Declaration
procedure SelectStyle;
Description
Make the style the current style referenced by CurrStyle.
4.6
4.6.1
IWPPageSize
Methods
GetProp
SetPageWH
LeftMargin
MarginFooter
MarginHeader
MarginMirror
PageHeight
PageWidth
RightMargin
TopMargin
SetProp
4.6.1.1
Properties
4.6.1.1 A) BottomMargin
Applies to
IWPPageSize
Declaration
int BottomMargin;
Description
The margin area at the bottom of the page.
4.6.1.1 B) Landscape
Applies to
IWPPageSize
Declaration
bool Landscape;
Description
The orientaion of the page.
4.6.1.1 C) LeftMargin
Applies to
IWPPageSize
Declaration
int LeftMargin;
Description
The margin area at the left side of the page.
4.6.1.1 D) MarginFooter
Applies to
IWPPageSize
2006-2009 by WPCubed GmbH, Munich, Germany
351
352
Declaration
int MarginFooter;
Description
This is the margin between the border of the page and the footer text.
4.6.1.1 E) MarginHeader
Applies to
IWPPageSize
Declaration
int MarginHeader;
Description
This is the margin between the border of the page and the header text.
4.6.1.1 F) MarginMirror
Applies to
IWPPageSize
Declaration
bool MarginMirror;
Description
If this property is true the left and right margin will be swapped on every otrher page.
4.6.1.1 G) PageHeight
Applies to
IWPPageSize
Declaration
int PageHeight;
Description
The page height measured in twips.
4.6.1.1 H) PageWidth
Applies to
IWPPageSize
Declaration
int PageWidth;
Description
The page width measured in twips.
4.6.1.1 I) RightMargin
Applies to
353
IWPPageSize
Declaration
int RightMargin;
Description
The margin area at the right side of the page.
4.6.1.1 J) TopMargin
Applies to
IWPPageSize
Declaration
int TopMargin;
Description
The margin area at the top of the page.
4.6.1.2
Methods
4.6.1.2 A) IWPPageSize.GetProp
Applies to
IWPPageSize
Declaration
int GetProp(int ID);
Description
354
Use ID=1 to set a bitfield which tells the editor which properties are controlled (selected) by
this section object.
1 : PageSize (Landscape, PageWidth and PageHeight),
2 : Margins
4 : Tab Default
8: Page Mirror
16: Page Numbering Mode (reserved)
32: Select Header and footer
64: Reset numbers of Outline
128: Reset Page number
Note: The bits 1-4 are automatically set when the respective property is changed!
4.6.1.2 C) IWPPageSize.SetPageWH
Applies to
IWPPageSize
Declaration
function SetPageWH(WidthTW: Integer; HeightTW: Integer; MargL: Integer; MargR:
Integer; MargT: Integer; MargB: Integer): Boolean;
Description
This method can be used to set width, height and margins in one line of code. For properties
which should not be updated pass -1.
4.6.1.2 D) IWPPageSize.MakeDefault
Call this method to make this page definition the default. It will be applied, when the editor is
cleared.
4.6.1.2 E) IWPPageSize.ReadDefault
Call this method to initialize the page definition with the default values.
4.6.2
IWPPageSizeList
You can use this property to install different page sizes for each page.
For Example If you need the first page to be extra lager. In this case just create 1
entry for the first page and another for all subsequent pages.
You can use the method Clear to remove all page size elements.
Use Add(int Width, int Height) or AddEx(int Width, int Height, int MargLeft, int
MargRight, int MargTop, int MargBottom) to append a new entry.
Unless LastPageMaxHeight is set to true, all pages after the last definition will use the
properties of the last definition.
Tip: To retrieve a page as meta file use GetPageAsMetafile.
Please see this demo. This interface is used by PageSizeList.
355
Properties
4.6.2.1 A) AsString
Applies to
IWPPageSizeList
Declaration
string AsString;
Description
Set and retrieve the page sizes (but not the resolution) as string. This can be useful to cache
the rectangle sizes.
4.6.2.1 B) Count
Applies to
IWPPageSizeList
Declaration
int Count;
Description
The count of defined page sizes - readonly.
4.6.2.1 C) LastPageHeight
Applies to
IWPPageSizeList
Declaration
int LastPageHeight;
Description
The text height of the last page - readonly.
4.6.2.1 D) LastPageMaxHeight
Applies to
IWPPageSizeList
Declaration
bool LastPageMaxHeight;
Description
If true (default=false) the last page uses a very large height and the width of the previous
page.
This way the last page will hold all text which did not fit into the previous pages.
Please use this property with care. It should not be used when the pagelayout mode was
selected.
356
4.6.2.1 E) Resolution
Applies to
IWPPageSizeList
Declaration
int Resolution;
Description
This is the resolution for the values provided to Add and AddEx.
4.6.2.1 F) Active
Applies to
IWPPageSizeList
Declaration
bool Active;
Description
Activates and deactivates the defined page sizes. When it is active (and Count>0) the page
sizes defined in the document are overridden and the event OnMeasurePage is not been
triggered.
4.6.2.2
Methods
4.6.3
IWPPrintParameter
4.6.3.1
Properties
4.6.3.1 A) AllPagePaperSource
Applies to
IWPPrintParameter
Declaration
int AllPagePaperSource;
Description
The paper tray ID used for all pages.
4.6.3.1 B) DontUpdateDEVMode
Applies to
IWPPrintParameter
Declaration
bool DontUpdateDEVMode;
Description
357
358
359
Description
Page list as string, i.e "1-5,8,10"
4.6.3.1 G) PageSides
Applies to
IWPPrintParameter
Declaration
int PageSides;
Description
0=print all, 1=print even, 2=print odd pages only
4.6.3.1 H) Title
Applies to
IWPPrintParameter
Declaration
string Title;
Description
Title for the printer job.
4.6.3.2
Methods
4.6.3.2 A) IWPPrintParameter.SetExtraProp
Applies to
IWPPrintParameter
Declaration
procedure SetExtraProp(ID: Integer; Value: Integer);
4.6.4
IWPMeasurePageParam
Properties
MarginLeft
ColCount
MarginRight
Height
MarginTop
MarginBottom
PageNr
Width
360
4.6.4.1
4.6.4.1 A) Changed
Applies to
IWPMeasurePageParam
Declaration
bool Changed;
Description
Assign true to activated the changes.
4.6.4.1 B) ColCount
Applies to
IWPMeasurePageParam
Declaration
int ColCount;
Description
Reserved.
4.6.4.1 C) Height
Applies to
IWPMeasurePageParam
Declaration
int Height;
Description
Height of the page in twips (inch/1440)
4.6.4.1 D) MarginBottom
Applies to
IWPMeasurePageParam
Declaration
int MarginBottom;
Description
Bottom margin in twips (inch/1440)
4.6.4.1 E) MarginLeft
Applies to
IWPMeasurePageParam
Declaration
int MarginLeft;
Description
2006-2009 by WPCubed GmbH, Munich, Germany
361
4.8
Mailmerge
"Mail merge" makes it possible to update fields which were embedded in the text with
external data. Due to it versatility it is one of the most popular features offered by
TextDynamic.
Example:
This is the name field: NAME
2006-2009 by WPCubed GmbH, Munich, Germany
362
4.8.1
363
To insert a field use the method InputField. It expects the name of the field and the
initial text. The boolean parameter controls if the cursor should be placed inside (true)
or after the new field (false). Using the true you can insert multiple paragraphs or an
image inside of the field.
VB:
TextCursor.InputField "NAME", "Name-Field", False
C#:
TextCursor.InputField("NAME","Name-Field",false);
b) Load RTF code which contains fields:
TextDynamic uses standard RTF tags to load and save fields so merge fields inserted
in Word are usually available in TextDynamic as well (without the extended
attributes).
c) Load RTF text which contains tokens and let the tokens convert into fields:
You can inserted the tags using escape text, i.e. <name> and use either
- the method IWPTextCursor.FieldsFromTokens(StartText,EndText,FieldPreText)
(=ReplaceTokens)
- or TextCommandStr(17) "Token To Template Conversion". The latter can ignore
start codes which are used inside the text.
You can use TextCommandStr(16) activate syntax highlighting to display the tokens
as bold red text.
Note: Fields are displayed as and . Memo.ShowFields = true to display field names
instead and WPDLLInt1.SpecialTextAttr(SpecialTextSel.wpInsertpoints).Hidden = true to hide
fields.
4.8.2
Insert Data
After the method MergeText was called the event OnFieldGetText will be triggered for
each field.
Please use this event to prvide the field data.
This event receives the following parameters:
Editor, the number of the editor, usually 1
FieldName, the fieldname,
Contents, the interface IWPFieldContents to change the contents.
The interface IWPFieldContents has many options, but usually you will only need to
modify the property StringValue:
VB:
Private
ByVal
ByVal
ByVal
Sub WPDLLInt1_OnFieldGetText(
Editor As Long,
FieldName As String,
Contents As WPToolsInt.IWPFieldContents)
364
If FieldName="NAME" Then
Contents.StringValue = 'Julian Ziersch'
End If
End Sub
C#
Private void wpdllInt1_OnFieldGetText(
Object Sender,
int Editor,
String FieldName,
WPDynamic.IWPFieldContents Contents)
{
If (FieldName.Equals("NAME"))
Contents.StringValue = "Julian Ziersch";
}
In the event OnFieldGetText you can access a database, calculate text or use fixed
strings. The inserted text can be standard non formatted text, and it can be also RTF
or HTML text.
Insert an image
You can insert a picture. If you use the OCX you can use any IPicture reference.
When using .NET convert an "Image" using the Image2Picture class:
Contents.LoadPicture(
new WPDynamic.Image2Picture(
pictureBox1.Image ),0,0 );
Change font attributes
The interface Contents.FieldAttr allows it to change the attributes of the inserted text,
i.e. you can use it, for example, to make negative numbers red.
To start the mail merge use the method MergeText
4.8.2.1
4.8.2.2
365
If the parameter Cont e nt s is not accessible as interface IWPFieldContents you can also load
the text using Memo.SelText. The TextCursor methods can also be used inside this event and
the field text is selected while the event is active.
In Visual FoxPRO this can be helpful:
ThisContents=GETINTERFACE(Contents, "IWPFieldContents", "WPTDynInt.ocx")
Tip: In case You cannot use the event, You can can enumerate the fields using TextCursor.
CPMoveNextObject.
4.8.3
Highlight/HideFields
To highlight the fields in the text you can use this code:
VB
WPDLLInt1.SpecialTextAttr(wpInsertpoints).Hidden = True
C#
WPDLLInt1.SpecialTextAttr(SpecialTextSel.wpInsertpoints).Hidden = true;
4.8.4
Append to Editor #2
You can use both editors to create a list or multiple copies of the form letter in editor 1
Use method SetEditorMode to initialize the "double editor" mode.
To create the list execute Memo.MergeText for each record and append the mrged text to the
editor #2 using Memo2.AppendOtherText(0);
In case you want to append to an invisible alternative text buffer use the API Memo.
RTFDataAppendTo like it is showed in the label demo.
366
4.8.5
Now TextDynamic has an exciting new feature. It can display the current document as labels on
a label sheet. The label sheet can be configured using the interface LabelDef. You can set the
width and height of the sheet, the count of columns and rows, the margins on each side of the
sheet and the margin between labels, horizontally and vertically.
The properties of the IWPLabelDef interface as graphic:
Floating point properties such as "SheetHeight" and "SheetWidth" are measured in centimeter,
the can be also set as inch if the property UnitIsInch = true.
The property "Caption" makes it easy to provide a return address. When this string is not empty
1/2 cm will be reserved on the label for the text and a line will be drawn. You can get a similar
effect with standard, repeated text on the label text, but since the caption is not part of the
text the user cannot delete it. This makes it easier to edit the created labels in the preview
2006-2009 by WPCubed GmbH, Munich, Germany
367
before they are printed. (Yes, you can edit in the "Preview"!)
It is also possible to start with a certain label on the first page - in case the label sheet is not
empty (StartNr).
The property AsText makes it easy to save the label definition as a string together with its
name - you can use it to save a set of predefined labels in a simple string list.
To display the label sheet you only have to set the property Active = true. This will override
the page setup in the editor and the OnMeasurePage event. Since the label definition is part of
a "RTFData" element (see demo Simulated MDI) make sure you change it after a call to
RTFDataSelect. You can simply use RTFDataSelect("@@FIRST@@") when you are finished with
label printing to return to the mailing template.
4.8.5.1 C# Code
This C# code uses a loop instead of a database and the event OnFieldGetText is not defined.
// Initialize
IWPMemo memo;
IWPTextCursor cursor;
memo = wpdllInt1.Memo;
cursor = memo.TextCursor;
memo.Clear(false, true);
IWPCharAttr CurrAttr = memo.CurrAttr;
// Create mailing fields
CurrAttr.Clear();
CurrAttr.SetFontSize(10);
cursor.InputField("NAME","Name",false);
cursor.InputString("\r",0);
cursor.InputField("ADR1","Adr1",false);
cursor.InputString("\r",0);
cursor.InputField("ADR2","Adr2",false);
cursor.InputString("\r\r",0);
CurrAttr.IncludeStyles(1); // bold
cursor.InputField("ZIP","00000",false);
cursor.InputString(" ",0);
cursor.InputField("CITY","City",false);
//
//
//
//
368
4.8.5.2
VB Code
369
label.Active = True
4.8.5.3
The resulting label sheet is displayed in the editor and can be printed and edited (!)
4.8.6
interface IWPFieldContents
370
The reporting engine will also trigger the event OnFieldGetText to evaluate fields which
were used in band conditions such as ?fieldname=null and ?fieldname#null. In this
case the property IsMergefield =false. In this case use ExecStrCommand to modify
the state property.
Properties
Description
Methods
AddTable
FieldCommand
ContinueOptions
FieldName
CurrentBand
FloatValue
CurrentGroup
Format
DeleteField
IsMergefield
EmbeddedObject
StringValue
ExecStrCommand
Title
FieldAttr
FieldObject
InputHyperlink
LoadImage
LoadPicture
LoadText
SetValue
4.8.6.1
Properties
4.8.6.1 A) Description
Applies to
IWPFieldContents
Declaration
string Description;
Description
Only used during report creation to red predefined value.
4.8.6.1 B) FieldCommand
Applies to
IWPFieldContents
Declaration
string FieldCommand;
Description
The property gives access to the "command" property of the field.
371
4.8.6.1 C) FieldName
Applies to
IWPFieldContents
Declaration
string FieldName;
Description
The property gives access to the name of the field.
4.8.6.1 D) FloatValue
Applies to
IWPFieldContents
Declaration
double FloatValue;
4.8.6.1 E) Format
Applies to
IWPFieldContents
Declaration
string Format;
Description
Only used during report creation to red predefined value.
4.8.6.1 F) IsMergefield
Applies to
IWPFieldContents
Declaration
bool IsMergefield;
Description
The reporting engine will also trigger the event OnFieldGetText to evaluate fields which were
used in band conditions such as ?fieldname=null and ?fieldname#null. In this case the property
IsMergefield =false;
4.8.6.1 G) StringValue
Applies to
IWPFieldContents
Declaration
string StringValue;
Description
This property is used to assign a string to this value to replace the contents of the field. You
372
can also read the field to retrieve the current data. An instance of the interface
IWPFieldContents is passed to the event OnFieldGetText after the method MergeText was
called.
You can also assign a string in RTF or WPT format. HTML will be auto detected if the text starts
with <html>.
Example:
StringValue = "<html><b>Super</b> mail merge</html>"
This code will insert the text: Super mail merge
If you need to create a hyperlink use the method InputHyperlink und set the link text using this
property.
Note
If you cannot use the IWPFieldContents interface because of a limitation of the developing
language, you can insert text using the method LoadFromString. The input methods of the
IWPTextCursor can also be used, only the cursor position or selection may not be changed. In
MS-Access please define a global variable to hold a IWPFieldContents interface reference. In
the event OnFieldGetText assign the "Contents" parameter to that variable.
Category
Mailmerge
4.8.6.1 H) Title
Applies to
IWPFieldContents
Declaration
string Title;
Description
Only used during report creation to red predefined value.
4.8.6.2
Methods
4.8.6.2 A) IWPFieldContents.AddTable
Applies to
IWPFieldContents
Declaration
procedure AddTable(ColCount: Integer; RowCount: Integer; Border: WordBool;
EventParam: Integer; CreateHeader: WordBool; CreateFooter: WordBool);
Description
This is a powerful and versatile method. It creates a table inside the merge field inside the
mailmerge process. The callback OnCreateNewCell is triggered if EventParam was passed with a
value != 0. So you can add the data and properties is a very efficient way.
Note
If you do not need to merge the template again we recommend to use DeleteFields. This makes
sure there are no extra empty lines before and after the table which are required to host the
field markers.
373
Parameters
ColCount
RowCount
Border
EventParam
CreateHeader
CreateFooter
Category
Callback Functions
Table Support
4.8.6.2 B) IWPFieldContents.ContinueOptions
Applies to
IWPFieldContents
Declaration
void ContinueOptions(int OptionBits);
Description
This method is used to add flags which change the way the inserted text (or the insertion
itself) is performed for this field.
You can use the following bit values:
1: The paragraph attributes of the inserted text will be overridden with the attributes of the
paragraph the field is located within.
2: The character attributes of the inserted text will be overridden with the character attributes
of the field object.
4: Do not load font information from the inserted RTF text.
8: Do not load font size information from the inserted RTF text.
16: Do not load font style information (bold, italic, underline) from the inserted RTF text.
32: Do not load tabs - use current tabs.
64: Do not load paragraph styles - use current style.
Usually the loaded text will use the current paragraph attributes for its first paragraph.
The following bits change this behaviour:
128: Overwrite current paragraph attributes with attributes from first loaded paragraph.
256: If merge field is at start of paragraph overwrite current paragraph attributes with
attributes from the first new paragraph.
This bits refine the copying of the properties:
374
512: Also use the borders of loaded text (overwrites table cell borders)
1024: Do not use the loaded tab positions
2048: Do not use the loaded paragraph style
When inserting text the fields (start/end marker) stay intact.
Only if this bit is set, the field will be deleted:
4096: Delete This Field
Note
This method will add flags but will not remove flags which have been set before. The flags are
only used for the current field and then set to 0.
Category
Mailmerge
4.8.6.2 C) IWPFieldContents.CurrentBand
Applies to
IWPFieldContents
Declaration
function CurrentBand: IWPReportBand;
4.8.6.2 D) IWPFieldContents.CurrentGroup
Applies to
IWPFieldContents
Declaration
function CurrentGroup: IWPReportBand;
4.8.6.2 E) IWPFieldContents.DeleteField
Applies to
IWPFieldContents
Declaration
procedure DeleteField;
Description
Use this method if you need to delete the field markers. If you delete the fields you cannot use
the template for merging again. But if the inserted text contained fields those can be merged in
a second round. If you insert a table (AddTable) DeleteField is required to avoid otherwise blank
paragraphs which host the field markers.
Note: The markers are not deleted when you call this function but later when the field is
processed and the data specified using StringValue is inserted.
4.8.6.2 F) IWPFieldContents.EmbeddedObject
Applies to
IWPFieldContents
375
Declaration
function EmbeddedObject: IWPTextObj;
Description
This reference allows it to manipulate the first object, probably an image, inside the merge field.
If no object is within the field, EmbeddedObject will be null.
4.8.6.2 G) IWPFieldContents.ExecStrCommand
Applies to
IWPFieldContents
Declaration
procedure ExecStrCommand(CommandID: Integer; param: Integer; const StrParam:
WideString);
CommandID = 1:
Set the state of the field using the parameter 'param' inside the event OnFieldGetText. The
State is used for band conditions of the integrated reporting.
0: Default value
1: Field is not known (default if checking field and band conditions, i.e. ?field=null )
2: Field is defined and NULL
3: Field is defined and ZERO
4: Field is defined (set this value unless it is null or zero)
Example - Simulate certain conditions:
private void wpdllInt2_OnFieldGetText(object Sender,
int Editor, string FieldName, IWPFieldContents Contents)
{
// test the conditions
if (!Contents.IsMergefield)
{
if (FieldName == "ISNULL")
Contents.ExecStrCommand(1, 2, "");
else if (FieldName == "ISZERO")
Contents.ExecStrCommand(1, 3, "");
else if (FieldName == "ISUNDEF")
Contents.ExecStrCommand(1, 1, "");
else
{
Contents.ExecStrCommand(1, 4, ""); // Known
Contents.StringValue = "123";
}
} else
....
}
This conditions can be used inside band tokens like in this simplified sample (See Token
to Template Conversion):
2006-2009 by WPCubed GmbH, Munich, Germany
376
Other CommandIDs:
This method can be extended for custom manipulations of the inserted text - if you have a wish
please let us know.
4.8.6.2 H) IWPFieldContents.FieldAttr
Applies to
IWPFieldContents
Declaration
function FieldAttr: IWPAttrInterface;
Description
This interface allows it to change the attributes of the inserted text. You can use it, for
example, to make negative numbers red.
Category
Character Attributes
4.8.6.2 I) IWPFieldContents.FieldObject
Applies to
IWPFieldContents
Declaration
function FieldObject: IWPTextObj;
Description
This interface provides access to the field marker itself. You can use this interface to change
the name and command properties. To delete a field use DeleteFields.
4.8.6.2 J) IWPFieldContents.InputHyperlink
Applies to
IWPFieldContents
Declaration
procedure InputHyperlink(const URL: WideString; const LinkName: WideString);
Description
Use this method to create a hyperlink within the field. The link text has to be set using property
StringValue. This makes it possible to place formatted text or images inside the link.
2006-2009 by WPCubed GmbH, Munich, Germany
377
The first parameter is the URL, the second is reserved (link caption).
Category
Hyperlinks and Bookmarks
4.8.6.2 K) IWPFieldContents.LoadImage
Applies to
IWPFieldContents
Declaration
procedure LoadImage(const filename: WideString; w: Integer; h: Integer);
Description
You can load an image into this field. If the field alreaday contains an image object the existing
object will be reused.
4.8.6.2 L) IWPFieldContents.LoadPicture
Applies to
IWPFieldContents
Declaration
procedure LoadPicture(const Picture: IUnknown; w: Integer; h: Integer);
Description
You can insert a picture. If you use the OCX you can use any IPicture reference.
When using .NET convert an "Image" using the Image2Picture class:
Contents.LoadPicture(new WPDynamic.Image2Picture(
pictureBox1.Image ),0,0 );
4.8.6.2 M) IWPFieldContents.LoadText
Applies to
IWPFieldContents
Declaration
procedure LoadText(const filename: WideString);
Description
This method can be used to load a file which will be inserted.
Category
Load and Save
4.8.6.2 N) IWPFieldContents.SetValue
Applies to
IWPFieldContents
Declaration
procedure SetValue(Value: OleVariant);
378
4.9
Reporting
4.9.1
Introduction
In contrast to the the plenty reporting applications and tools available already, our reporting
engine is based on a word processor. This means the reporting template is just a text
document, so is the output.
This makes the output completely editable after the creation. It is exceptionally useful to edit
the output after the creation but prior to the print to quickly check the accuracy of the text,
for example if names are written correctly.
Using the new "token to template conversion" You can use a document as input, simply add a
few tags (<<..>>) and you can create an invoice or a list at once. This makes it very easy to
convert existing reports into reporting templates. It is not required to explore the more
advanced reporting features of TextDynamic to do so, just add 2 evens and you are done. One
event is responsible to select the data sets (build queries) and advance the dataset cursor, the
other event is responsible to retrieve the field data. Usually a few lines of code will do.
Only this two events needs to be used:
OnFieldGetText
OnReportState
379
RT F 2PDF / T e xt Dy na m ic Se rv e r now also comes as reporting edition which can work with the
same templates.
4.9.1.1
380
Price
10.00
30.00
40.00
4.9.2
If you use the t oke n t o t e m pla t e c onv e rsion you can edit the reporting template with an editor
such as MS Word.
381
The template is loaded into TextDynamic. In this control the template can be further edited
with the additional convenience of syntax highlighting and on demand converted into a "true"
reporting template. (The latter uses nested paragraphs to represent groups and special
paragraph types for bands. Fields are not text based but use objects instead.).
Edit ing is not possible in t he non v isua l RT F 2PDF T e xt Dy na m ic Se rv e r - w e inc lude a n e xt e rna l
a pplic a t ion w hic h offe rs t he sy nt a x highlight ing.
If you used the mail merge feature before and have documents with embedded merge fields
those can be easily used a reporting templates as well! It is also possible to convert an existing
report into a template.
Start the Syntax Highlighter
Memo.TextCommandStr ID 16 - Syntax Highlighting
Start the Token to Template conversion:
Use Report.ConvertTokens or
Memo.TextCommandStr ID 17 - Token To Template Conversion
Note: The codes <<, >>, : and # can be customized in the above two methods!
Overview:
General Syntax - Fields, Bands, Groups
Parameters for Fields, Parameters for Bands and Groups
Example Template
4.9.2.1 General Syntax - Fields
The token to template conversion uses special character combinations to separate the
commands from the text. Fields have to be embedded into the characters << and >>.
(This codes <<, >>, : and # can be customized in Memo.TextCommandStr)
Note:
The parser expects that after the << and before the >> characters no whitespace characters
are typed. Otherwise the characters will be interpreted as text.
Example for fields:
<<name>>
The name of a field may contain space characters.
Optionally the closing '/' character can be printed:
<<name/>>
Using such fields mail merge documents can be created. Such merge documents only require
fields to be filled with data. Using mail merge does not require the reporting extension so we
decided to make the syntax highlighting and token to template conversion available in the basis
edition.
If you need repeated data rows in a document you need groups and bands. Bands mark certain
text to be the header and footer of a document or group while groups are used to loop certain
parts of the template as long as data to fill in the fields is available. Groups can also be used to
382
disable certain parts of the template. While bands are not nested, groups can be nested and so
consist of a start and end token.
Note: The name of a field will be passed to the event OnFieldGetText while merging the text or
creating a report. This event can retrieve the text which should be inserted inside the field.
TextDynamic includes a syntax highlighter for XML and also for the syntax described in this
chapter - please see Memo.TextCommandStr(16) - Syntax Highlighting
4.9.2.2 Bands
Bands are identified by a colon (':') after the opening << characters.
Example for header bands:
<<:HEADER>>
This starts a group header or, if used outside of any group a document header text. In the
latter case the following variations are possible:
HEADERF = header on first page only
HEADERO = header on odd pages
HEADERE = header on even pages
HEADER_OFF = this header is disabled.
Please note that bands are not implemented using opening and closing tokens ("i.e. <<..>>...
<</...>>") so optionally the closing '/' character can be typed: <<:HEADER/>>
Example for footer bands:
<<:FOOTER>>
This starts a group footer or, if used outside of any group a document footer text. In the latter
case the following variations are possible:
FOOTERF = footer on first page only
FOOTERO = footer on odd pages
FOOTERE = footer on even pages
FOOTER_OFF = this footer is disabled.
Inside header and footer bands fields, images and text is possible. A header and footer band
ends where either a different header or footer band starts or a data band:
<<:DATA/>>
Bands must be the first non white space (white space= space or tab characters) in a
paragraph. All text after the band token will be ignored and can be used to write comments.
4.9.2.3
Groups
Groups are identified by a double cross ('#') after the opening << characters. While bands
<<:.../>> are not nested, groups can be nested and so are embedded into a tag pairs <<#...
>> <<#/....>.
Unlike header and footer bands the name of the group tags are not fixed. Practically any name
can be used if it does not contain spaces. However the opening token must match the closing
token. For practical reasons the names should match the database which is referenced inside of
the group.
383
Example:
<<#CUSTOMERS>> comment: we list all customers in this group
<<Customers.Name/>>
<<Customers.Address/>>
Ordered Items:
<<#ORDERS>> comment: we list all items ordered by the current customer
<<Orders.Name/>>
<<#/ORDERS>>
<<#/CUSTOMERS>>
Note: The name of a group will be passed to the event OnReportState while creating a report.
This event has to decide if a group should be processed (again) or not. It can create a sql
query and calculate sub totals.
4.9.2.4
5. Condition ?...=...
?fieldname=null - use this field if the specified field was null
?fieldname#null - use this field if the specified field is not null
?fieldname=zero - use this field if the specified field was zero
?fieldname#zero - use this field if the specified field is not zero
Use IWPFieldContents.ExecStrCommand to tell the engine that a field is null or zero.
384
4.9.2.5
Example Template
<<:HEADERF "my header"/>> -- any text after the group will be ignored as comment
This is the header on the first page
<<:HEADER "my header"/>> -- HEADERF, HEADERO, HEADERE, HEADER
This is the header on all pages
<<:TEXT>> -- start the regular text
Dear Developer,
This letter documents and demonstrates the reporting feature which is based on a
template written in regular formatted text with additional tags:
The "<<#" signs are expected as first non-space signs in a paragraph. Any text after the
closing >> signs is ignored and can be used as comment. Fields are inserted between the
signs << and >>. It is important that after the '<<' no white space or punctuation is
written.
Headers in groups are written using single, not open/closing tags. They cannot be nested
anyway. The / before the closing >> signs should be added but is not required.
Only groups are nestable. Groups are started using the code <<#. The name after the #
sign will be the group name, so a database name can be used. An optional alias can be
specified. It is possible to set up a list of possible group names.
Now our list starts:
<<#GROUP1 ?name#null "Invoice">> -- the table will be given the display name "invoice",
the logical names remains "GROUP1". After the optional name a condition is expected.
<<:HEADER/>> -- this header will be displayed at the start of the group
Group Header. Fields are possible: <<fieldname +spc/>>
<<:DATA ?"has orders"=null/>> -- this is the data row.
Some data here - under condition that there are no orders. (Note that a field name may
used spaces. In this case use " in the field name part as well.)
<<:DATA ?hasorders#null/>> -- this is the data row.
Some data here - under condition there are orders.
<<:FOOTER/>> -- this footer will be displayed at the end of the group
Group Footer. Fields are possible: <<fieldname/>>
<<#/GROUP1>> -- close the group.
This text comes after the group.
When viewed with activated the syntax highlighting the document will look like
385
386
Note: The syntax highlighter does not make any modifications to the attributes of the text. All
highlighting is done just visual and is updated while the text is edited.
After the conversion to the internal reporting template structure the document looks like this:
4.9.3
387
OnReportState
OnFieldGetText
OnReadFormulaVar
To outline the idea of the events we use some simple C# code:
OnReportState:
This event is triggered before and after a group is started. You use it to move to the next data
record or initalize a query. Here we simply use the Count property to abort after 10 rows.
private void wpdllInt1_OnReportState(
object Sender, string Name,
int State, WPDynamic.IWPReportBand Band,
ref bool Abort)
{
if (State==WPDynamic.commands.REP_BeforeProcessGroup)
Abort = Band.Count>10;
else Abort = false;
}
OnFieldGetText:
This event is triggered to fill in field data. It is the same as the one for the regular mail merge.
Here we simply print an incremented number.
static int a;
private void wpdllInt1_OnFieldGetText(object Sender, int Editor,
string FieldName, WPDynamic.IWPFieldContents Contents)
{
Contents.StringValue = Convert.ToString(a++);
}
The image shows the result
OnReadFormulaVar
It is triggered to read the value of a variable which is used in a formula. Please don't mix up
with group variables used by the reporting engine, those group variables contain the formulas
which itself contain the variables which trigger this event. In fact any unknown name inside a
2006-2009 by WPCubed GmbH, Munich, Germany
388
4.9.4
In this chapter we develop a simple program which can be used to explore the possibilities of
the TextDynamic reporting.
Basis
File Menu
Use conditions for bands
View Menu - (Hide/ShowTemplate)
4.9.4.1
Basis
389
390
391
{
if(State==0) //REP_BeforeProcessGroup
{
// Take Name to open a data base query. Move to first
Record
// and set Abort to TRUE if the query is empty!
// Here also Set total variables to 0.
Abort = Band.Count>10;
}
}
Please see "OnReportState" for a complete C# template.
Now some code to fill in data for our fields is missing. To do so the event OnFieldGetText is
used. Here we would usually read out a dataset, but for simplicity we here just insert a random
value:
Random rnd = new Random();
private void wpdllInt2_OnFieldGetText(object Sender,
int Editor, string FieldName, IWPFieldContents Contents)
{
Contents.StringValue = Convert.ToString(rnd.NextDouble());
}
b) Second page
top editor = template in internal format
2006-2009 by WPCubed GmbH, Munich, Germany
392
4.9.4.2
File Menu
393
TextDynamic allows simple conditions for bands. This makes it possible to use some parts of the
text depending on the value of a certain field. Of course the field name can be virtual, not
existing in the database but known by your code.
To use a condition in a band use the option:
?fieldname=yyy
To evaluate the specified fieldname the event OnFieldGetText is called. There the property
Contents.IsMergeField will be false. Use ExecStrCommand the special states (null, zero, defined)
of a field can be specified.
4.9.4.4
We want to create a menu to show and hide the template and the created report.
394
This is the code for the 3 menu items. It uses the property Memo.Hidden.
private void templateAndReportToolStripMenuItem_Click(object sender,
EventArgs e)
{
wpdllInt2.Memo2.Hidden = false;
wpdllInt2.Memo.Hidden = false;
templateAndReportToolStripMenuItem.Checked = true;
reportToolStripMenuItem.Checked = false;
templateToolStripMenuItem.Checked = false;
}
private void reportToolStripMenuItem_Click(object sender, EventArgs e)
{
wpdllInt2.Memo2.Hidden = false;
wpdllInt2.Memo.Hidden = true;
templateAndReportToolStripMenuItem.Checked = false;
reportToolStripMenuItem.Checked = true;
templateToolStripMenuItem.Checked = false;
}
private void templateToolStripMenuItem_Click(object sender, EventArgs e)
{
wpdllInt2.Memo.Hidden = false;
wpdllInt2.Memo2.Hidden = true;
templateAndReportToolStripMenuItem.Checked = false;
reportToolStripMenuItem.Checked = false;
templateToolStripMenuItem.Checked = true;
}
4.9.5
The principle is very similar when using our product the RTF2PDF TextDynamic Server.
Here this feature is used best with the token conversion or complete and tested templates. You
can use TextDynamic to create and edit such templates.
using wPDF;
using WPDynamic;
private void ConvertTest_Click(object sender, System.EventArgs e)
{
// Set License with Reportion Option
rtF2PDF2.SetLicense( "---", "---", 0);
// Load a File
rtF2PDF2.Memo.LoadFromFile(@"c:\Template_With_Tokens.RTF", false, "");
// Use the Token To Template Conversion
rtF2PDF2.Memo.TextCommandStr(17,0, "");
395
4.9.6
When speaking of "reporting" we mean the process that data which comes from a database or
has been calculated is merged with the text and layout objects stored in a report template to
create a new document. Already the basis version of TextDynamic has a powerful method to
mix text and data, called mail merge. In contrast to this easy to use method the "reporting" we
talk about here allows that areas of the report template can be looped for each row in the input
data which is typically the result of a database query.
Using the "Token to Template Conversion" it is possible to create powerful templates which can
be used to create complicated documents. But since it is based on simple text it does not offer,
apart from syntax highlighting, much possibilities to detect errors in a template (for example a
data field defined by a sub query is used outside of the group which enumerates the records in
this query).
To be able to detect such errors it is required for the editor to know the underlying database
structure. Since TextDynamic does not implement database access (except for DAO) the
structure must be made known using a special description, the "DB-Description".
To make it possible
Of course the looping allows recursion to work with relationally organized data.
Example of a customer organization application:
We need a database with two tables, one table contains the names and addresses of the
customers of a company. Each customer has a unique number: "CUST_ID".
The second table contains all orders received by the sales department. To identify that a
certain order was placed by a certain customer the (lookup-)field CUST_ID receives the value
of the field CUST_ID found in the first table, the customer table.
396
In a real application we would need additional tables to group orders by dates, to store
received payments, to cancel orders and so on. But we want to keep things simple, only show
the basic concepts.
Creating the data input form for the two tables would be fairly simple, but the code which
creates and prints the invoice can be tricky.
TextDynamic simplifies this problem for you by separating the necessary tasks into several
steps.
(a) DB-Description (XML)
Collect the required fields from the involved tables and add into virtual groups.
What is done here is basically the creation of a XML structure which represents the graphic
above. In this step you also add group variables which are used to sum up values to create
totals.
The XML DB-Description can be edited as text and loaded into TextDynamic or you can use a
special API to build the template. We added a feature to auto create such a template from DAO
compatible databases, such as MS Access. (See Example)
The DB-Description is maintained by the IWPReporter interface.
(b) Template (RTF with extensions)
From the XML structure created in (a) TextDynamic can create and maintain a raw reporting
template.
The devloper can now format this template, add or remove fields and text.
You can also enable the end users to adjust the reporting template to their needs.
An external application is not required for this, all is done with TextDynamic.
(c) Events used to retrieve and locate data
Create the necessary programming logic to provide the data for the groups. Usually you will
create SQL queries for the inner groups each time one row of the outer group is processed.
(Alt hough SQL a llow s t he GROUPBY m ode in t he SELECT m e t hod, w e re c om m e nd t o e xe c ut e
m ult iple SQL st a t e m e nt s for t he inne r groups. So y ou ha v e m ore c ont rol ov e r t he orde ring of
t he row s a nd de e pe r ne st ing le v e ls a re no proble m )
4.9.7
MS Access Example
In this topic we
1) show how to use the events to control the creating of a report in MS Access
2006-2009 by WPCubed GmbH, Munich, Germany
397
2) Show how to use the DAO Interface to read and convert a MS Access Database
automatically
4.9.7.1 MS Access code
In this chapter we show some real word MS Access code to handle the reporting events.
Event to control how often a group is processed
' This event is used to control how often a group will be processed
' The most important values of parameter 'State' are:
' 0=BeforeProcessGroup - check if we are at EOF
' 8=AfterProcessGroup - move to next record
Private Sub WPDLLInt1_OnReportState(ByVal NAME As String, ByVal State As Long, ByVal Band
As Object, Abort As Boolean)
If State = 0 Then
Abort = RepRS.EOF
End If
If State = 8 Then
RepRS.MoveNext
Abort = RepRS.EOF
End If
End Sub
398
4.9.7.2
To start simple we only create a list from items in table "Orders". This would be already
sufficient to create an invoice for a certain customer.
We create nested groups for each of the tables. Inside each group we add the possible fields.
The field names can be usually read easily from the table object. After the structure was
created it is used to create a reporting template. The user can modify the template and add
fields which are listed in the "repository".
Example written in MS Access:
2006-2009 by WPCubed GmbH, Munich, Germany
399
Procedure which takes one database table and creates a simple template to list all fields except
for "ID"
Private Sub Recreate_Template_Click()
Dim td As WPDLLInt
Dim Report As IWPReport
Dim db As DAO.Database
Dim tdf As DAO.Recordset
Dim i As Integer
Dim mode As Integer
Dim tblNameToLoop As String
Dim fieldName As String
Dim fieldCount As Integer
Set db = CurrentDb() 'pointer to current database
Set td = WPDLLInt1.Object
Set Report = td.Report
' the next line fails if reporting as not been activated in Form_Load()
Report.Clear
' Create a table of all fields in table 'CUSTOMERS'
tblNameToLoop = "ORDERS"
Report.AddGroup tblNameToLoop, "", tblNameToLoop, "*", 0, ""
Set tdf = db.OpenRecordset(tblNameToLoop, dbOpenSnapshot, dbSeeChanges)
fieldCount = tdf.Fields.Count
For i = 0 To fieldCount - 1
fieldName = tdf.Fields(i).NAME
' we can deselect some of the fields which are used for the table relation
If InStr(fieldName, "ID") > 0 Then
mode = 2 ' Deselected but visible.
Else
mode = 0 ' Standard: Visible and Selected
End If
Report.AddField tblNameToLoop + "." + fieldName, fieldName, "", _
"*", "", "", "", 0, mode, 0
Next
tdf.Close
' Add group variables here (if required)
' ...
' We need bands, otherwise the group is empty!
Report.AddBand "*", "Header", 1, 0, "", "", 0, 0
Report.AddBand "*", "Data", 0, 0, "", "", 0, 0
Report.AddBand "*", "Footer", 2, 0, "", "", 0, 0
db.Close
2006-2009 by WPCubed GmbH, Munich, Germany
400
If you need calculation, for example to create an invoice you can add group variables.
' Group Variable to calculate the price in each row
Report.AddVar "ORDER_PRICE", "Sub Total", "Price * Amount", "*", _
"=0", "CUR=$", "", 0, "=ORDERS.AMOUNT*ORDERS.PRICE", 0
' Group Variable to calculate the total price, note the '+=' and mode=2
' This variable should be use in the footer
Report.AddVar "TOTAL_PRICE", "Total", "Sum of all ORDER_PRICE", "*", _
"=0", "CUR=$", "", 2, "+=ORDERS.AMOUNT*ORDERS.PRICE", 0
Group variables are processed before each time the group is used. The StartFormula is only
executed before the first time. By default a variable has the value 0 (the formula "=0" is
redundant). In the LoopFormula use += to sum up values.
References to table values are possible in formulas, for example "ORDERS.AMOUNT". Since
TextDynamic does not access the database directly, the value must be provided using the
event OnReadFormulaVar.
Note: If in a report template a field uses the name of a variable, that variable is assigned.
To show the report editor without recreation of the template use this code:
Private Sub Edit_Template_Click()
Dim td As WPDLLInt
Set td = WPDLLInt1.Object
td.Report.InitTemplate "@Field and Bands", 6
End Sub
4.9.8
401
API
Interfaces
IWPReport
Methods
WPDLLInt.CreateReport
IWPReportBand
WPDLLInt.Report
IWPReportVar
Events
OnFieldGetText
IWPTextCursor.ReportConvertTable
OnReadFormulaVar
IWPTextCursor.ReportInputGroup
IWPTextCursor.ReportConvertText
IWPTextCursor.ReportInputBand
OnReportState
4.9.8.1
IWPReport
Description
This interface can be accessed through the property Report. It allows the preparation
of a reporting template definition with obligatory and optional groups, bands and
fields.
Please don't forget to activate the double editor and the reporting support:
SetEditorMode(
EditorMode.wpmodDoubleEditor,
EditorXMode.wpmodexReporting|...)
The second editor can be hidden using: wpdllInt1.Memo2.Hidden = true;
Manage report template and reporting.
Please note the new token to template conversion. It allows it to convert simple text
into a reporting template and is suitable to solve most of the reporting problems.
2006-2009 by WPCubed GmbH, Munich, Germany
402
Here we discuss the more advanced techniques. Please first read the chapter "
Reporting".
In this case you will only need this methods:
IWPReport.CreateReport
IWPReport.Command
Please also see the description of this events:
OnFieldGetText
OnReportState
Overview
a) This interface has basic functions to initialize the template editor and start
reporting.
b) The property RecordSet makes it easy to create a list in MS Access by using a
DAO RecordSet interface.
c)
This interface manages an internal XML DB-Description. This DB-Description is
used to create a reporting template from all groups, bands and fields which are
marked to be obligatory. Optional groups and bands can be selected by the user.
A dialog box will show the available elements in this DB-Description as drag&drop
repository. Internally the template is managed as XML file - it can also be saved
and loaded in this format.
Please see the introduction "Reporting".
The DB-Description is internally managed as a XML structure, it can be loaded from
XML and saved to XML. When the XML structure is used to create a reporting
template, a copy of the XML data is attached to the template.
Report.InitTemplate(Filename,Mode)
By simply calling the method InitTemplate the template is prepared in the upper
editor. The user can then add optional fields, adjust text attributes or type in some
text.
InitTemplate function parameters:
Filename: This is an optional filename. If specified the template (NOT the xml data!)
will be loaded from this file. This can be usefull to load the initial paragraph
style list. If starting with "@", this parameter is used to set the caption for
the DB-Description form.
Mode: If bit 1 is set, the template in the editor #1 will be initialized using the XML
data (which was loaded or created). Otherwise, in case a file name was
specified, only the report template will be loaded. In this case it is
recommended to also set bit 2 to avoid out of sync XML data.
If bit 2 is set, the engine will load the XML from the report template and
overwrite the information stored in the report object.
If bit 3 is set, the DB-Description form (also called repository) will be
displayed. Once this form was displayed the methods ShowTemplate and
ShowResult will automatically show and hide this form.
Examples:
Load a DB-Description and create a raw report template
Report.LoadFromFile("c:\\groups_and_fields.xml");
2006-2009 by WPCubed GmbH, Munich, Germany
403
Properties
AsXML
BandCount
Database
Methods
AddBand
AddField
AddGroup
404
RecordSet
RepositoryCaption
ShowRepository
TemplateEditorStyle
AddSection
AddText
AddVar
Band
Clear
Command
CreateReport
DefinePageSize
FindGroup
GetError
GetErrorCount
InitGroup
InitTemplate
LoadFromFile
ModifyXML
SaveToFile
SelectSection
SetAutomatic
SetProp
ShowResult
ShowTemplate
405
Format="CUR=$"/>
<var Name="TOTAL_PRICE"
Title="Total"
Description="Sum of all ORDER_PRICE"
StartFormula="=0"
LoopFormula="+=ORDERS.AMOUNT*ORDERS.PRICE"
Format="CUR=$"
Mode="2"/>
<header Title="Header"/>
<data Title="Data"/>
<footer Title="Footer"/>
</group>
</main>
In the XML structure the possible group nesting is outlined. Also fields which are available are
defined. Optionally calculated fields ("var") to create totals can be also added. The XML
structure also contains information for the creation of a default reporting template. Here the
obligatory groups and bands are created (Mode). Text can be filled in using HTML code. The
captions use the 'Titel' defined for a field. (So changing just one element will update all
references)
The XML structure can be created using program code. At best by reading the structure of a
database connection and reusing the "Titel" and information of the field. To do so the Reporter
interface has several procedures to add groups, fields and bands. It is also possible to add
bands and fields to an existing template.
Once the default template has been created it can still be edited in the regular text editor.
4.9.8.1 B) What are groups
Groups are used in reports to mark areas of the text which is used as long as there is data to
export. The event OnReportState is used to check for the end condition.
4.9.8.1 C) What are bands
Bands can be data bands, header or footer bands.
Headers are used to mark text parts (usually a table row) which should be written before the
group data and, optionally, at the top of each page.
Footers are used to mark text parts (usually a table row) which should be written after the
group data and, optionally, at the bottom of of each page. The latter is a feature unique to
TextDynamic.
Databands mark the part of the group which is used for each data row.
406
Fields can also be defined by a formula. Here the OnFieldGetText event is not beeing triggered,
instead the formula is evaluated. (see more below)
4.9.8.1 E) What are group variables
Group variables are used to calculate values while the report is beeing processed. The variables
can also be inserted into the report template, usually the footer row, to retrieve the stored
value.
Variables are always inserted as text-objects, not as merge variables in the text.
Variables marked as hidden (mode=16) cannot be inserted in the report. They can only be
referenced by fields which read out the value or use it to create a chart.
4.9.8.1 F) What are formulas
Formulas are used to calculate totals. TextDynamic only allows numeric formulas. If you need to
combine string fields you need to create a new field name which represents the combined value
of two physical fields.
Inside formulas variables are allowed, i.e. "VARA+VARB". Here the event OnReadFormulaVar is
used to retrieve the value which should be inserted instead of VARA and VARB.
Some special formulas are allowed at certain places:
If a group variable uses the LoopFormula "add(field(fieldname),formula)" first the event
OnFieldGetText will be triggered for "fieldname" and then the formula will be evaluated. The
result and the text retrieved for the field will be added to the element list of the variable. This
list can used later to create a chart. The formula can be also written as add(fieldname,formula).
"formula" must be a string constant.
Fields can also read out the value of a group variable of a previous, higher level group. To do so
specify the name of the group variable in the formula using "var(varname)".
4.9.8.1 G) Properties
? AsXML
Applies to
IWPReport
Declaration
string AsXML;
Description
The DB-Description data as XML string.
? BandCount
Applies to
IWPReport
Declaration
int BandCount;
Description
Count of bands in the highest level in the report template (this is in editor 1, it is not the XML
data!). To get access to a band or group use GetBand.
407
408
? ShowRepository
Applies to
IWPReport
Declaration
bool ShowRepository;
Description
Display the repository.
? TemplateEditorStyle
Applies to
IWPReport
Declaration
int TemplateEditorStyle;
Description
Currently not used - must be 0.
4.9.8.1 H) Methods
? IWPReport.ConvertTokens
Converts the document in the editor into a reporting template
See: Token To Template Conversion
? IWPReport.CreateReport
Applies to
IWPReport
Declaration
int CreateReport();
Description
This method Starts the report process.
The second editor is cleared and the page size is copied from the the first editor which holds
the template.
More features are available through Command(1 - 3).
? IWPReport.Command
Applies to
IWPReport
Declaration
int Command(int ID);
Description
409
Command ID =1:
Start the report, works like CreateReport.
Command ID =2:
Start the report like CreateReport but first copies the header and footer for first/odd and even
pages to the destination. The body is cleared.
Command ID =3:
Start the report like CreateReport but does not clear the destination. The text is simply
appended.
? IWPReport.AddBand
Create a band definition in the DB-Description.
Applies to
IWPReport
Declaration
procedure AddBand(const Group: WideString; const Title: WideString; BandType:
Integer; ColumnCount: Integer; const FieldList: WideString; const ParStyle:
WideString; RadioGroup: Integer; Mode: Integer);
Description
You can use AddBand to build a DB-Description (which can be saved and loaded in XML format).
The use of DB-Descriptions makes it easier for the end user to manage the report template
since the technical details are hidden.
Parameters
Group
Title
BandType
410
BANDTYP_HEADER_ALL
= 1;
BANDTYP_FOOTER_ALL
= 2;
BANDTYP_HEADER_FIRST = BANDTYP_HEADER_ALL + 16;
BANDTYP_FOOTER_FIRST = BANDTYP_FOOTER_ALL + 16;
BANDTYP_FOOTER_LAST = BANDTYP_FOOTER_ALL + 32;
BANDTYP_OVERFLOW_HEADER = BANDTYP_HEADER_ALL + 4
BANDTYP_OVERFLOW_FOOTER = BANDTYP_FOOTER_ALL + 4
Note
When the DB-Description is saved to XML the
bits 3 and 4 are converted into bit 1 and 2 of
parameter "Usage". The bits 5 to 8 are
converted into bit 1 to 4 of the parameter
"Visibility"
ColumnCount
FieldList
ParStyle
RadioGroup
Mode
411
template.
bit 1: In the repository the user cannot
change the selected state.
bit 2: The band is not selected.
bit 3: Do not create default columns when the
the ColumnCount value is 0. Unless a field list
has been specified, the "default columns" are
created for all selected fields and variables in
the same group.
bit 4: Use the field text as HTML source. If this
bit is set you can specify text and fields for
each column.
Example:
"<field name="Product"/>,<field name="Amount"/>,<
bit 5: The band is hidden in the repository. It
can still be selected to create a band in the
report template.
? IWPReport.AddField
Applies to
IWPReport
Declaration
procedure AddField(const Name: WideString; const Title: WideString; const
Description: WideString; const Group: WideString; const Formula: WideString;
const Format: WideString; const ParStyle: WideString; FieldType: Integer; Mode:
Integer; WidthTW: Integer);
Description
This method is used to create a new field in the XML description.
Parameters
Name
Title
Description
Group
Formula
Format
ParStyle
FieldType
Mode
WidthTW
? IWPReport.AddGroup
Applies to
IWPReport
Declaration
procedure AddGroup(const Name: WideString; const Alias: WideString; const Title:
WideString; const Group: WideString; Mode: Integer; const DBParams: WideString);
412
Description
This menthod is used to start a new group. Groups contain bands, fields, variables and can also
contain other groups. During the report creation a group is processed over and over again - as
long as data is there to export.
Parameters
Name
Alias
Title
Group
Mode
DBParams
? IWPReport.AddSection
Applies to
IWPReport
Declaration
procedure AddSection(const Name: WideString; const Title: WideString; const
PrintText: WideString; const ParStyle: WideString; const PageSize: WideString;
Mode: Integer);
Description
Use this method to start a new section. Currently only one section is allowed.
? IWPReport.AddText
Applies to
IWPReport
Declaration
procedure AddText(const PrintText: WideString; const ParStyle: WideString);
Description
Creates an entry in the DB-Description to create a regular paragraph. Usually you will not have
to use AddText - it is better to use the AddGroup, AddBand, AddField to create the logical
structure of a report (can be saved as XML XML), then use InitTemplate to create a reporting
template from the XML data. Now you can edit the reporting template using the TextDynamic
editor and save it for later use.
Parameters
PrintText
413
? IWPReport.AddVar
Applies to
IWPReport
Declaration
procedure AddVar(const Name: WideString; const Title: WideString; const
Description: WideString; const Group: WideString; const StartFormula:
WideString; const Format: WideString; const ParStyle: WideString; Mode:
Integer; const LoopFormula: WideString; const GetTextForumula: WideString;
WidthTW: Integer);
Description
This method adds a variable which can be added to the report template, just like a field. In
contrast to a field a variable can only represent a number value. It is designed to keep the
value between different loops of the same report group - therefore it can be used to create
totals. Its value is modified by the assigned formulas "StartFormula" and "LoopFormula". The
first formula is evaluated when the group the field is owned by is used first, the second formula
is before each time (including the first) the group is used. This means that when the text of a
group is evaluated the variables are already processed. Both the "StartFormula" and
"LoopFormula" should be written as assignment to modify the value. (Exception function "add
()").
Example: LoopFormula = "+=ORDERS.AMOUNT*ORDERS.PRICE".
Parameters
Name
Title
Description
Group
StartFormula
Format
ParStyle
Mode
LoopFormula
GetTextFormula
WidthTW
? IWPReport.Band
Applies to
IWPReport
Declaration
414
415
Declaration
function FindGroup(const Name: WideString): IWPReportBand;
Description
Finds a group anywhere in the template (editor one).
? IWPReport.GetError
Applies to
IWPReport
Declaration
function GetError(Index: Integer): WideString;
Description
Retrieve an error message.
? IWPReport.GetErrorCount
Applies to
IWPReport
Declaration
function GetErrorCount: Integer;
Description
How many errors happend during reporting.
? IWPReport.InitGroup
Applies to
IWPReport
Declaration
procedure InitGroup(const GroupName: WideString; const AfterGroup: WideString);
? IWPReport.InitTemplate
Applies to
IWPReport
Declaration
procedure InitTemplate(const filename: WideString; Mode: Integer);
Description
This is an optional filename. If specified the template (NOT the xml data!) will be loaded from
this file. This can be usefull to load the initial paragraph style list. If starting with "@", this
parameter is used to set the caption for the DB-Description form.
Parameters
Filename
Mode
416
? IWPReport.LoadFromFile
Applies to
IWPReport
Declaration
function LoadFromFile(const filename: WideString): WordBool;
? IWPReport.ModifyXML
Applies to
IWPReport
Declaration
procedure ModifyXML(const Path: WideString; const Name: WideString; const param:
WideString; const ParamValue: WideString);
Description
Reserved
? IWPReport.SaveToFile
Applies to
IWPReport
Declaration
procedure SaveToFile(const filename: WideString);
Description
Saves the XML data to a file.
? IWPReport.SelectSection
Applies to
IWPReport
Declaration
procedure SelectSection(const Name: WideString);
Description
Makes a certain section the current.
417
? IWPReport.SetAutomatic
Applies to
IWPReport
Declaration
function SetAutomatic(Mode: Integer; const Param: WideString): WordBool;
Description
Activate automatic mode. If that was not possible FALSE is returned. See propery RecordSet.
? IWPReport.SetProp
Applies to
IWPReport
Declaration
procedure SetProp(ID: Integer; const Value: WideString);
Description
Reserved
? IWPReport.ShowResult
Applies to
IWPReport
Declaration
procedure ShowResult;
Description
Displays the editor which holds the result of the reporting process.
? IWPReport.ShowTemplate
Applies to
IWPReport
Declaration
procedure ShowTemplate;
Description
Displays the editor which holds the template for the reporting process.
4.9.8.2
IWPReportBand
Methods
AddBand
BandCount
AddTable
418
Count
Band
DBParams
CheckSyntax
Depth
Clear
DisplayName
FindVar
GroupRadioNr
GetParPtr
GroupSiblingNr
GetProp
Mode
GetVar
Name
ParentGroup
Options
SetParPtr
ParAttr
SetProp
ParentGroupCount
VarCount
ParentGroupName
ParentParentGroup
ParentParentGroupCount
RecordSet
Selected
State
Typ
Visibility
4.9.8.2 A) Properties
? Alias
Applies to
IWPReportBand
Declaration
string Alias;
Description
This parameter can be used for an alternative alias name.
? BandCount
Applies to
IWPReportBand
Declaration
int BandCount;
Description
Count of sub bands and groups. For sample code please see Report.Band(). The property is
readonly.
? Count
Applies to
IWPReportBand
Declaration
419
int Count;
Description
This value is used during reporting. The current loop counter for each group is assigned to this
property. The property is readonly.
? DBParams
Applies to
IWPReportBand
Declaration
property DBParams: WideString read Get_DBParams write Set_DBParams;
Description
This string parameter can be used freely, i.e. to store the SQL statement used for a sub query.
? Depth
Applies to
IWPReportBand
Declaration
int Depth;
Description
The nesting level of this band. The property is readonly.
? DisplayName
Applies to
IWPReportBand
Declaration
string DisplayName;
Description
This name should be displayed in the editor.
? GroupRadioNr
Applies to
IWPReportBand
Declaration
int GroupRadioNr;
Description
This property is used to create group of bands. They can be on different levels inside the
report. When selection one of this band all other bands with same id will deselected - unless
they use the same GroupSiblingNr as this band.
420
? GroupSiblingNr
Applies to
IWPReportBand
Declaration
int GroupSiblingNr;
Description
This property is used to create group of bands. If a band is selected all other bands which use
the same GroupSiblingNr will be also selected.
? Mode
Applies to
IWPReportBand
Declaration
int Mode;
Description
Reserved Property.
? Name
Applies to
IWPReportBand
Declaration
string Name;
Description
The name of this group or band. Usually only group have names.
? Options
Applies to
IWPReportBand
Declaration
int Options;
Description
The following option bits are possible: Bit 1: Stretchable (reserved)
Bit 2: KeepControl (reserved)
Bit 3: NewPageAfter - create a new page after a group
Bit 4: NewPageBefore - create a new page before the group
Bit 5: DontContinueTable - do not continue a table which was started in a previous or nested
group.
? ParAttr
Applies to
IWPReportBand
421
Declaration
IWPAttrInterface ParAttr;
Description
Currently not used.
? ParentGroupCount
Applies to
IWPReportBand
Declaration
int ParentGroupCount;
Description
This property contains the run count of the parent group of this band. It is only used during
reporting. If undefined it is -1.
? ParentGroupName
Applies to
IWPReportBand
Declaration
string ParentGroupName;
Description
This is the name of the parent group.
? ParentParentGroup
Applies to
IWPReportBand
Declaration
string ParentParentGroup;
Description
This is the name of the parent group of the parent group.
? ParentParentGroupCount
Applies to
IWPReportBand
Declaration
int ParentParentGroupCount;
Description
This property contains the run count of the parent group of the parent group of this band. It is
only used during reporting. If undefined it is -1.
422
? RecordSet
Applies to
IWPReportBand
Declaration
IUnknown RecordSet;
Description
You may assign an interface reference to access it inside the reporting events. This makes it
easier to create multi level sub queries. TextDynamic will not use this interface.
? Selected
Applies to
IWPReportBand
Declaration
bool Selected;
Description
This property is used to change the selected state. If the Visibility bit 5 (=16) is set, a band
will only be used if selected. Using the properties GroupRadioNr and GroupSiblingNr bands on
different levels can be combined to logical groups.
? State
Applies to
IWPReportBand
Declaration
int State;
? Typ
Applies to
IWPReportBand
Declaration
int Typ;
? Visibility
Applies to
IWPReportBand
Declaration
int Visibility;
Description
For header and footer in first level (not children of a group) this property controls on which
pages a page header or page footer should be created:
0=All pages, 1=Odd, 2=Even, 3=First, 4=AllNotFirst, 5=OddNotFirst, 6=Hide.
423
For group header and footer this value controls the usage of this band. The following bit are
used: Bit 1: dont use at start or end of group. Bit 2: also use between data groups. Bit 5(=16):
Only use if selected.
4.9.8.2 B) Methods
? IWPReportBand.AddBand
Applies to
IWPReportBand
Declaration
function AddBand(Typ: Integer; Visibility: Integer): Integer;
Description
If this is a group paragraph, AddPar will add a new child band. If this is a data, header or footer
band the new band will be added after the text of this band.
Parameters
Typ
Visibility
Returns
If no band was created 0 is returned, otherwise the ParPtr value of the created band
paragraph.
? IWPReportBand.AddTable
Applies to
IWPReportBand
Declaration
procedure AddTable(ColCount: Integer; RowCount: Integer; Border: WordBool;
EventParam: Integer);
Description
This method creates a table inside group bands or after header, footer or data bands. If there
is already a table all rows will be removed and the table will be recreated.
If the parameter EventParam is not 0 the event OnCreateNewCell will be triggerd for each new
cell. You can use the event to create text and fields in the new cells.
Category
Table Support
424
? IWPReportBand.Band
Applies to
IWPReportBand
Declaration
function Band(Index: Integer): IWPReportBand;
Description
Retrieve sub bands. For sample code please see Report.Band().
? IWPReportBand.CheckSyntax
Applies to
IWPReportBand
Declaration
function CheckSyntax: Integer;
Description
This method is not used.
? IWPReportBand.Clear
Applies to
IWPReportBand
Declaration
procedure Clear(GroupsToo: WordBool);
Description
The methods delets the contents of this band. Groups will not be deleted unless the parameter
GroupsToo was passed as true.
? IWPReportBand.FindVar
Applies to
IWPReportBand
Declaration
function FindVar(const Name: WideString): IWPReportVar;
Description
This function locates a group variable and returns null or the a reference to the interface
IWPReportVar.
You can also use this function to add a variable, place in front of the name a '+' sign. The
variable will be only added if it was not found. To delete a variable place in front the character
'-'.
? IWPReportBand.GetParPtr
Applies to
IWPReportBand
425
Declaration
function GetParPtr: Integer;
Description
Get the ParPtr id of the paragraph which represents this band. You can use this id to move the
cursor to this band.
? IWPReportBand.GetProp
Applies to
IWPReportBand
Declaration
function GetProp(Item: Integer): WideString;
Description
Reserved.
? IWPReportBand.GetVar
Applies to
IWPReportBand
Declaration
function GetVar(Index: Integer): IWPReportVar;
Description
This function returns an interface to read and modify a certain group variable. You can check
all variables in a loop by using VarCount.
? IWPReportBand.ParentGroup
Applies to
IWPReportBand
Declaration
function ParentGroup: IWPReportBand;
Description
This functions returns either null or a reference of the parent group of this band.
? IWPReportBand.SetParPtr
Applies to
IWPReportBand
Declaration
procedure SetParPtr(Paragraph: Integer);
Description
This method may not be used.
426
? IWPReportBand.SetProp
Applies to
IWPReportBand
Declaration
procedure SetProp(Item: Integer; const Value: WideString);
Description
Reserved
? IWPReportBand.VarCount
Applies to
IWPReportBand
Declaration
function VarCount: Integer;
Description
This function returns the count of variables of a group.
4.9.8.3
IWPReportVar
Methods
ElementsAdd
Format
ElementsClear
GetTextFormula
ElementsCount
LoopFormula
ElementsGet
Mode
Name
ParStyle
StartFormula
Text
Title
Value
WidthTW
4.9.8.3 A) Properties
? Description
Applies to
IWPReportVar
Declaration
427
string Description;
Description
This is the description for this variable.
? Format
Applies to
IWPReportVar
Declaration
string Format;
Description
This is the format string. "CUR=$" will format as currency.
? GetTextFormula
Applies to
IWPReportVar
Declaration
string GetTextFormula;
? LoopFormula
Applies to
IWPReportVar
Declaration
string LoopFormula;
Description
This is the formula which will be evaluated before each time the group is processed. Use the
string "=" to assign, or "+=", "-=", "*=" or "/=" in front of the formula to manipulate the current
value.
In formulas you can refer to number data base fields by simply specify a name, i.e. ORDERS.
PRICE. The event OnReadFormulaVar will be triggered to read the value. If the variable was not
found the value will be always 0.
? Mode
Applies to
IWPReportVar
Declaration
int Mode;
? Name
Applies to
IWPReportVar
Declaration
2006-2009 by WPCubed GmbH, Munich, Germany
428
string Name;
? ParStyle
Applies to
IWPReportVar
Declaration
string ParStyle;
? StartFormula
Applies to
IWPReportVar
Declaration
string StartFormula;
Description
This formula will be evaluated before the first time the parent group is used. You can use "=" in
front of the formula to assign a value, othewise the value will be 0. Usuall you only have to use
LoopFormula.
? Text
Applies to
IWPReportVar
Declaration
string Text;
Description
This is the value as text.
? Title
Applies to
IWPReportVar
Declaration
string Title;
Description
The title of this variable.
? Value
Applies to
IWPReportVar
Declaration
double Value;
Description
2006-2009 by WPCubed GmbH, Munich, Germany
429
430
? IWPReportVar.ElementsGet
Applies to
IWPReportVar
Declaration
function ElementsGet(Index: Integer; var Value: Double; var Color: Integer):
WideString;
Description
Retrieve a certain element.
4.11
4.11.1 IWPPdfCreator
Interface to start and configure PDF creation
Description
The integrated PDF engine is based on the powerful wPDF V3 library which is widely
accepted by the industry.
It also is able to create PDF files which meet the PDF/A specification.
The PDF exporter is now now also able to attach data - see example.
Properties:
CIDFontMode
Methods:
BeginDoc
Compression
EndDoc
FontMode
GetProperty
OwnerPW
PDFAMode
Print / Export
("Print" does not work in VB6)
PDFFile
PrintSecond
Protection
SetProp
Security
SetProperty
UserWP
4.11.1.1 Properties
4.11.1.1 A) CIDFontMode
Applies to
IWPPdfCreator
Declaration
int CIDFontMode;
Description
This property enables the support for text written used by Character Identifiers. Here in the
PDF text numbers are written which are mapped to certain glyphs in an embedded font. A
special additional mapping table makes sure that the text can be extracted as unicode text.
When the CID feature is used this means the fonts are embedded as subsets in a highly
efficient way. PDF files become smaller this way. Since it works with character ids and not with
2006-2009 by WPCubed GmbH, Munich, Germany
431
charsets the export for say, Russian text, also works without having specified the charset
explicitly. wPDF uses as character IDs the UNICODE values of each character - it can have
used any number but we wanted to preserve the most information of the source text in the PDF
as possible. Please note that the support for asian languages does NOT use the CID feature.
Asian languages use special, perdefined fonts and mapping tables and require the charyset to
be known to be propperly exported.
CidFontMode Values:
0 - CID feature is not used. The property FontMode rules font embedding
1 - all fonts are embedded. Unicode values will be used as character ids
2 - only symbol fonts will be embedded
4.11.1.1 B) Compression
Applies to
IWPPdfCreator
Declaration
int Compression;
Description
Bit 1:
0: no compression
1: deflate compression for text
Bit 2-8:
0: no jpeg
1-100: JPEG compression for images
4.11.1.1 C) FontMode
Applies to
IWPPdfCreator
Declaration
int FontMode;
Description
Fontmode:
0 : UseTrueTypeFonts
1 : EmbedTrueTypeFonts
2 : EmbedSymbolTrueTypeFonts
3 : UseBase14Type1Fonts
4 : EmbedSubsetTrueType_Charsets
5 : EmbedSubsetTrueType_UsedChar
4.11.1.1 D) OwnerPW
Applies to
IWPPdfCreator
Declaration
string OwnerPW;
432
Description
The owner password for the PDF file. Also see UserPW.
4.11.1.1 E) PDFAMode
Applies to
IWPPdfCreator
Declaration
int PDFAMode;
Description
This property enables PDF/A support.
Values: 0=off or 1=enabled
PDF/A is a new norm which based on PDF 1.4 - it was created to provide a guildline for the
creation of document files which stay readable for the time to come. So the major demand for
PDF/A complient files is that the used font files are embedded. Security measures are forbidden
in PDF/A complient files as are links to external files. But there is more to PDF/A. We have
checked the component carefully against the final documentation of PDF/A.
When you use TextDynamic additional (invisible) tags will be added to the PDF data. This tags
make it possible to identify layout elements (such as header or footer texts) on a page. They
can be also used by a PDF reader to convert the PDF data into text paragraphs, something
which is otherwise at least difficult and impossible if a paragraph spans a page. The wPDF
engine will also create tags to mark table cells. wPDF3 will also add the document information
as XMP data to the PDF file.
4.11.1.1 F) PDFFile
Applies to
IWPPdfCreator
Declaration
string PDFFile;
Description
Default filename for the created PDF file. Unless you have licensed the TextDynamic server a
file save dialog will be always displayed.
4.11.1.1 G) Protection
Applies to
IWPPdfCreator
Declaration
int Protection;
Description
PDF protection: bit 1: Enable protection
bit 2: Enable Printing
bit 3: Enable Changing
bit 4: Enable Copying
bit 5: Low Quality PrintOnly
2006-2009 by WPCubed GmbH, Munich, Germany
433
434
4.11.1.2 C) IWPPdfCreator.GetProperty
Applies to
IWPPdfCreator
Declaration
function GetProperty(const Name: WideString): WideString;
Description
Read a PDF document property, such as "Author", "Keywords", "Subject".
4.11.1.2 D) IWPPdfCreator.Print, Export
Applies to
IWPPdfCreator
Declaration
function Print: WordBool;
function Export: WordBool;
Description
Export the text in editor #1.
VB6 Note:
If you are using VB6 you cannot use this method since Visual basic overrides this name with
special functionality.
In TextDynamic we added the method "Export" to avoid this complication.
In wRTF2PDF You can use the command 1313 instead of PDFCreator.Print:
VB6 Example: wRTF2PDF:
Dim Memo As IWPEditor ' TextDynamic uses IWPMemo.
Dim PDFCreator As IWPPdfCreator
' TODO: Modify license codes
PDFControl1.StartEngine "wPDFControlDemo.dll", "lic", "lic", 0
Set Memo = PDFControl1.Memo
Set PDFCreator = PDFControl1.PDFCreator
Memo.LoadFromFile "sometext.rtf", False, "AUTO"
PDFCreator.PDFFile = "new.PDF"
' PDFCreator.Print - this cannot be used due to VB "bug"
' Use command instead
PDFControl1.ExecIntCommand 1313, 0
Category
Load and Save
Printing
4.11.1.2 E) IWPPdfCreator.PreparePDFAttachment
Applies to
IWPPdfCreator
Declaration
int PreparePDFAttachment(string filename; int Editor; int Modes): Integer;
Description
2006-2009 by WPCubed GmbH, Munich, Germany
4.11.1.2 F) IWPPdfCreator.PrintSecond
Applies to
IWPPdfCreator
Declaration
function PrintSecond: WordBool;
Description
Export the text in editor #2.
4.11.1.2 G) IWPPdfCreator.SetProp
Applies to
IWPPdfCreator
Declaration
procedure SetProp(ID: Integer; const Value: WideString);
Description
Reserved
4.11.1.2 H) IWPPdfCreator.SetProperty
Applies to
IWPPdfCreator
Declaration
procedure SetProperty(const Name: WideString; const Value: WideString);
Description
Write a PDF document property, such as "Author", "Keywords", "Subject".
435
436
4.12
Helpers
4.12.1 IWPTextWriter
Access writing properties
Description
This interface is used by the event OnLoadExtImage. It provides access to few saving
parameters: Format, SaveName and SavePath.
Properties
Format
Methods
WriteData
SaveName
WriteString
SavePath
4.12.1.1 Properties
4.12.1.1 A) SaveName
Applies to
IWPTextWriter
Declaration
string SaveName;
Description
The name of the file which is beeing written.
4.12.1.1 B) SavePath
Applies to
IWPTextWriter
Declaration
string SavePath;
Description
The path of the file which is being written.
4.12.1.2 Methods
4.12.1.2 A) IWPTextWriter.WriteData
Applies to
IWPTextWriter
Declaration
procedure WriteData(Data: LongWord; DataLen: Integer);
Description
Write data from a buffer.
437
4.12.1.2 B) IWPTextWriter.WriteString
Applies to
IWPTextWriter
Declaration
procedure WriteString(const Text: WideString);
Description
Write a string to the output stream or file.
4.12.2 IWPPicture
.NET Image2Picture utility class
Description
This interface is used to allow the TextDynamic DLL to read data from a .NET image
object. To use this interface simply create an instance of the class Image2Picture
and pass it as Picture parameter to any of the methods which expects an IPicture
interface.
Example:
WPDLLInt1.TextCursor.InputPicture(new WPDynamic.Image2Picture
(pictureBox1.Image),0,0);
438
4.13
WPAT_codes
TextDynamic stores paragraph and paragraph style attribute values (such as indents and
spacing) using a value and an ID. The ID is the "WPAT code".
List of WPAT codes:
Character Attributes
Predefined Color Index Values
Paragraph Attributes
Numbering Attributes
Border Attributes
Table Size and Position
Technical Note:
Internally an array of 32bit values is used:
This makes it possible to not only store the value of a property but also to know that the
property is not defined at all - but does not use memory for undefined properties.
The IDs are specified as WPAT_ constants. The first 16 are used for character attributes (and
also used by the CharAttr records). The names of the procedures which work with this kind of
attributes start with "A".
"WPAT" codes are used by low level methods to set and retrieve paragraph and style
attributes.
You can use this properties whenever you manipulate paragraph, table cell or table row
properties directly.
The Attributes do only use 3 bytes, so the maximum value is $8FFFFF.
The .NET assembly defines the enum WPAT, so you need to write (int)WPAT.CharFontSize to
set the size of the text in pt*100.
Interface to use WPAT codes:
IWPParInterface.ParAAddBits
IWPParInterface.ParAClear
IWPParInterface.ParADel
IWPParInterface.ParADelBits
IWPParInterface.ParAGet
IWPParInterface.ParAInc
IWPParInterface.ParASet
IWPParInterface.ParStrCommand
439
WPAT_CharColor = 8; // The text color (as index in palette - see Convert Utility)
Using ParStrC ommand(3, color_string, 0) it is possible to convert a color name into an index value.
WPAT_CharBGColor = 9; // The text background color (as index in palette - see Convert Utility
)
WPAT_CharSpacing = 10; // "Letter-Spacing" in twips, 0..$8000 = EXPAND, $8001- $FFFF =
COMPRESS
WPAT_CharLevel = 11; // Move Character up or down - in half points (RTF: \up \dn }
// 0..$8000 = UP, $8001- $FFFF = down
WPAT_CharHighlight = 12; // {reserved} Highlight mode (different styles and colors)
2006-2009 by WPCubed GmbH, Munich, Germany
440
9=Aqua
10=Teal
11=Navy
12=White
13=Light Gray
14=Gray
15=Black
441
442
The following constants are used as values for the 'Type' attribute
{*}WPBRD_SINGLE = 0; // \brdrs Single-thickness border. (=Default)
{*}WPBRD_NONE = 1; // \brdrnil \brdrtbl No Border
{*}WPBRD_DOUBLEW = 2; // \brdrth Double-thickness border.
{*}WPBRD_SHADOW = 3; // \brdrsh Shadowed border.
{*}WPBRD_DOUBLE = 4; // \brdrdb Double border.
{*}WPBRD_DOTTED = 5; // \brdrdot Dotted border.
{*}WPBRD_DASHED = 6; // \brdrdash
Dashed border.
{*}WPBRD_HAIRLINE = 7; // \brdrhair
Hairline border.
{*}WPBRD_INSET = 8; // \brdrinset
Inset border.
{*}WPBRD_DASHEDS = 9; // \brdrdashsm
Dashed border (small).
{*}WPBRD_DOTDASH = 10; // \brdrdashd
Dot-dashed border.
{*}WPBRD_DOTDOTDASH = 11; // \brdrdashdd
Dot-dot-dashed border.
{*}WPBRD_OUTSET = 12; // \brdroutset
Outset border.
{*}WPBRD_TRIPPLE = 13; // \brdrtriple Triple border.
{*}WPBRD_THIKTHINS = 14; // \brdrtnthsg Thick-thin border (small).
{*}WPBRD_THINTHICKS = 15; // \brdrthtnsg
Thin-thick border (small).
{*}WPBRD_THINTHICKTHINS = 16; // \brdrtnthtnsg
Thin-thick thin border (small).
{*}WPBRD_THICKTHIN = 17; // \brdrtnthmg Thick-thin border (medium).
{*}WPBRD_THINTHIK = 18; // \brdrthtnmg Thin-thick border (medium).
{*}WPBRD_THINTHICKTHIN = 19; // \brdrtnthtnmg Thin-thick thin border (medium).
{*}WPBRD_THICKTHINL = 20; // \brdrtnthlg
Thick-thin border (large).
{*}WPBRD_THINTHICKL = 21; // \brdrthtnlg
Thin-thick border (large).
{*}WPBRD_THINTHICKTHINL = 22; // \brdrtnthtnlg
Thin-thick-thin border (large).
{*}WPBRD_WAVY = 23; // \brdrwavy Wavy border.
{*}WPBRD_DBLWAVY = 24; // \brdrwavydb Double wavy border.
{*}WPBRD_STRIPED = 25; // \brdrdashdotstr
Striped border.
{*}WPBRD_EMBOSSED = 26; // \brdremboss Embossed border. (CSS=ridge)
{*}WPBRD_ENGRAVE = 27; // \brdrengrave Engraved border. (CSS=groove)
{*}WPBRD_FRAME = 28; // \brdrframe
Border resembles a "Frame."
443
444
If the values of all borders are the same, these codes can be used as a shortcut to set the
value for a whole group:
// Shortcut - set width and color of ALL lines. - Use Flags to switch on/off
WPAT_BorderType = 87; // Border Mode ALL LINES AROUND BOX
WPAT_BorderWidth = 88; // Thickness ALL LINES
WPAT_BorderColor = 89; // Color ALL LINES - this is an index value. You need to use the
Convert function
This is the most important code. By setting a single bit a border is switched on.
// Border Flags - switch borders on/off
WPAT_BorderFlags = 90;
{The following flags switch on certain borders. The type can be defined or inherited}
{*}WPBRD_DRAW_Left = 1; // Left Border (Default = Single Line = Mode 0) = BlLeft
{*}WPBRD_DRAW_Top = 2; // Top Border
{*}WPBRD_DRAW_Right = 4; // Right Border
{*}WPBRD_DRAW_Bottom = 8; // Bottom Border
{*}WPBRD_DRAW_All4
= 15; // left + Top+ Right + Bottom
{*}WPBRD_DRAW_DiagLB = 16; // Cells: Diagonal Top-Left -> Bottom-Right
{*}WPBRD_DRAW_DiagRB = 32; // Cells: Diagonal Top-Right-> Bottom-Left
{*}WPBRD_DRAW_Bar = 64; // Border outside (right side of odd-numbered pages,
// left side of even-numbered pages)
{*}WPBRD_DRAW_InsideV = 128; // Rows: Inside Vertical
{*}WPBRD_DRAW_InsideH = 256; // Rows: Inside Horizontal
{*}WPBRD_DRAW_Box = 512; // Draw Box around paragraph
{*}WPBRD_DRAW_Finish = 1024; // Draw bottom border here, even if next paragraph has same
border properties
445
10%).
WPAT_ColWidth has priority over WPAT_ColWidth_PC. You will need to delete the
WPAT_ColWidth flag if you need to set the width in percent.
CurrPar.ParADel(WPAT_ColWidth)
CurrPar.ParASet(WPAT_ColWidth_PC, 1000); // 10%
You can read the current width of a cell using the method cell.IsWidthTW. The text must be
formatted. Once the user resizes columns in a table all widths which are defined by a percent
value will be converted into exact WPAT_ColWidth values. You can force this conversion for the
complete text using the function WPRichText.TableFixAllCellWidths. This method can also round
the width values suing a 'snap value'. The method TableAdjustCellWidth can be used to
recalculate the width of all columns to keep them visible.
The property WPAT_BoxMinHeight can be used with table rows to set the minimum height of a
table row.
WPAT_BoxMaxHeight is used to set the maximum width. Both properties will be ignored in cells
which are merged vertically. They can be used together when using WPT format, in RTF only
the minimum value can be preserved if both are used.
Not e : There are some commands available to read and set the current row height using the
method ParCommand.
RTF2PDF in ASP.NET
1) In your ASP.NET C# project please first add a reference to the wPDF3.DLL. (Note that
there are two versions, one for .NET 1.1, the other for wPDF 2)
2) In the file module you want to use RTF2PDF add a link to wPDF:
using wPDF;
using WPDynamic;
3) Within the Page_Load event you create and instance of RTF2PDF - at the end don't forget
Dispose()!
RTF2PDF wpdllint1 = new RTF2PDF();
try
{
// insert the following code here
}
finally
{
wpdllint1.Dispose();
}
4) Please set the license code. In ASP project please load the license from an encrypted file this avoids that the keys become public in case the asp code is displayed by the server in case
of an error. You can use "Demo.EXE" to create such an encrypted file. We place the license file
outside of wwwroot, so it is not possible to access it.
wpdllint1.SetLicense("@FILE@mysecretpassword", "C:\\Windows\\rtflic.dat",0);
2006-2009 by WPCubed GmbH, Munich, Germany
446
5) You can use code to load data, or to create text. Here we simply create a table.
wpdllint1.Memo.Clear(false,false);
wpdllint1.TextCursor.AddTable("",2,30,true,0,true,true);
6) When the document was created you can send it as response either as HTML or as PDF:
a) as HTML:
Response.Write( wpdllint1.Memo.SaveToString(false, "HTML") );
b) as PDF:
// Create PDF in memory
wpdllint1.PdfCreator.PDFFile = "memory";
wpdllint1.PdfCreator.FontMode = 0;
wpdllint1.Memo.ReformatAll(false,false);
wpdllint1.Print();
// Set ASP result
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("Content-Disposition","inline;filename=PortableDocument.pdf");
Response.BinaryWrite(wpdllint1.ResultBuffer);
Tip: In our demos we use this code to either create PDF or HTML output:
if (Request.QueryString.Get("pdf")!="true")
// method a)
else
// method b)
5.2
If you create the PDF in memory (as described here) your web service can be
negatively affected in case the web user simply clicks the reload button several times.
We created a download class which handles this case better. It first creates a
temporary file and then writes small chunks of this file to the Response - until it
detects that the client is not connected anymore or all data has been sent.
As advantage over TransmitFile() we here have the possibility to react on an aborted
transmission and delete the temporary file when it is not needed anymore. Also see
2006-2009 by WPCubed GmbH, Munich, Germany
447
448
449
TempFileSend = "";
ok = false;
}
else
{
Response.Clear();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Type", "application/pdf");
Response.AddHeader("Content-Disposition","inline;filename="
+ filename + ".pdf");
}
}
// Unknown format
else
{
TempFileSend = "";
ok = false;
}
// --------- now send and while doing so check IsClientConnected ---------if (TempFileSend!="")
{
const int PartSize = 8192;
byte[] buffer = new byte[PartSize];
System.IO.FileStream Stream =
new System.IO.FileStream(TempFileSend, System.IO.FileMode.Open);
using(Stream)
{
int l;
long len = Stream.Length;
while ((len>0)&& Response.IsClientConnected)
{
l = Stream.Read(buffer, 0, PartSize);
Response.OutputStream.Write(buffer, 0, l);
Response.Flush();
len -= l;
}
}
Response.Close();
}
return ok;
}
}
You can call this method at the end of your PageLoad handler.
This demo simply takes a file (must be in directory c:\doc) and converts to PDF:
RTF2PDF wpdllint1 = new RTF2PDF();
try
{
string path = Server.MapPath(".") + "\\";
wpdllint1.SetLicense("@FILE@"+password, "C:\\Windows\\rtflic.dat",0);
WPDynamic.IWPEditor Memo = wpdllint1.Memo;
WPDynamic.IWPTextCursor TextCursor = Memo.TextCursor;
//------------------------------------------------------------------------string afile = System.IO.Path.GetFileName(Request.QueryString.Get("file"));
string afilepath = "c:\\doc\\" + afile;
450
5.3
Interface "Memo" includes methods for loading and saving data quietly:
bool LoadFromFile(string filename, bool Insert, string FormatStr);
bool SaveToFile(string filename, bool OnlySelection, string FormatStr);
bool LoadFromStream(object Stream, bool Insert, string FormatStr);
bool SaveToStream(object Stream, bool OnlySelection,string FormatStr);
bool LoadFromString(string Data, bool Insert, string FormatStr);
string SaveToString(bool OnlySelection, string FormatStr);
If the parameter "Insert" is true the text will be inserted at the current cursor position.
If the parameter "OnlySelection" is true only the selected text will be saved.
The parameter FormatStr controls the format to create or load.
Possible values are "AUTO" (default), "RTF", "ANSI", "HTML", "XML", "XMLTAGS" and
"UNICODE".
When reading text the format is detected automatically if an empty string or "AUTO"
2006-2009 by WPCubed GmbH, Munich, Germany
451
was specified.
"RTF" selects the RTF reader and writer. RTF is a text format standard which is widely
understood.
"HTML" selects the HTML/CSS reader or writer
"XML" writes simplified HTML code. You can use "XML-useptag,-ignorefonts" to only
write <p>, <b>, <i>, <u> and <a> tags. Paragraphs may use styles which are
written as class="".
"XMLTAGS" is used to select a special XML reader which creates tag objects. (see:
SetXMLSchema )
"ANSI" writes standard ANSI text. You can use "ANSI-codepageXXX" to write text for
a certain code page
"UNICODE" reads and writes unicode (2 byte) data
Additional parameters are possible, such as "RTF-onlybody". (See formatstrings.htm)
The "Stream" parameter for LoadFromStream is an IStream or IWPStream interface.
An IWPStream interface is provided by the utility class Stream2WPStream which is
implemented by the c# wrapper.
This example loads from a file stream - the format is automatically detected.
IWPMemo Memo = WPDLLInt1.Memo;
FileStream textstream = new FileStream("C:\\1.htm",FileMode.
Open);
Memo.LoadFromStream(
new WPDynamic.Stream2WPStream(textstream),
false, "" );
textstream.Close();
This example creates HTML code in a new file stream:
IWPMemo Memo = WPDLLInt1.Memo;
FileStream textstream = new FileStream("C:\\new.htm",FileMode.
Create);
Memo.SaveToStream(
new WPDynamic.Stream2WPStream(textstream),
false, "HTML" );
textstream.Close();
5.4
We want to show all the wpa actions nicely formatted in the editor.
To the event handler of a newly created button we add this code to create a table in
2006-2009 by WPCubed GmbH, Munich, Germany
452
the editor.
// Now clear the text
WPDLLInt1.Clear();
// We need these interfaces for text creation
IWPMemo Memo = WPDLLInt1.Memo;
IWPTextCursor TextCursor = Memo.TextCursor;
IWPAttrInterface AttrHelper = WPDLLInt1.AttrHelper;
IWPParInterface CurrPar = Memo.CurrPar;
// set all margins, do not change page size
Memo.PageSize.SetPageWH(-1,-1,360,360,360,360);
// We want to use 2 different character styles
AttrHelper.Clear();
AttrHelper.SetFontface("Verdana");
AttrHelper.SetFontSize(11);
AttrHelper.IncludeStyles(1); // bold
int headerchars = AttrHelper.CharAttrIndex;
AttrHelper.Clear();
AttrHelper.SetFontface("Verdana");
AttrHelper.SetFontSize(8);
int bodychars = AttrHelper.CharAttrIndex;
// and add a one row table
TextCursor.AddTable("WPA",3,1,true,0,false,false);
// Now add one row after the other
string n = "",c ="",h ="";
for(int i=0; i<1000;i++)
{
if (!WPDLLInt1.Memo.wpaGetCaption(i,ref n, ref c, ref h)) break;
TextCursor.CPMoveNextRow(true); // down and create
TextCursor.CPTableColNr = 0;
CurrPar.SetText(n, bodychars);
TextCursor.CPTableColNr = 1;
CurrPar.SetText(c, bodychars);
TextCursor.CPTableColNr = 2;
CurrPar.SetText(h, bodychars);
}
// add text to the header row
TextCursor.CPTableRowNr = 0;
TextCursor.CPTableColNr = 0;
CurrPar.SetText("Name", headerchars);
CurrPar.Alignment = 1;
CurrPar.ParShading = 30;
TextCursor.CPTableColNr = 1;
CurrPar.SetText("Caption", headerchars);
CurrPar.Alignment = 1;
CurrPar.ParShading = 30;
TextCursor.CPTableColNr = 2;
CurrPar.SetText("Hint", headerchars);
2006-2009 by WPCubed GmbH, Munich, Germany
453
CurrPar.Alignment = 1;
CurrPar.ParShading = 30;
// and reformat
Memo.Reformat();
This is the created table:
5.5
This C# code generates a new header, a right tabstop and page numbering:
IWPMemo memo = WPDLLInt1.Memo;
IWPDataBlock header = memo.BlockAdd(DataBlockKind.wpIsHeader,
DataBlockRange.wpraOnAllPages, "", 0);
if (header!=null)
{
header.Clear();
header.WorkOnText = true;
IWPTextCursor cursor = memo.TextCursor;
memo.CurrAttr.IncludeStyles((int)(WPSTY.BOLD|WPSTY.UNDERLINE));
cursor.InputText(" Page ");
cursor.InputTabstop(false,
memo.PageSize.PageWidthmemo.PageSize.LeftMarginmemo.PageSize.RightMargin,
1 , 0);
cursor.InputObject(TextObjTypes.wpobjTextObject,"PAGE","",0);
cursor.InputText(" of ");
cursor.InputObject(TextObjTypes.wpobjTextObject,"NUMPAGES","",0);
cursor.InputText(" ");
}
Result:
454
5.6
455
wpdllInt1.ReleaseInt(Memo);
wpdllInt1.ReleaseInt(TextCursor);
wpdllInt1.ReleaseInt(par);
5.7
5.7.1
Technical Information
wRTF2PDF / TextDynamic Server can load and save HTML formatted files. It supports
many HTML tags and also cascading style sheets (internally it uses a style class which
mimics CSS style information). As a word processing engine it supports page layouts
(header area, text area, footer area), a feature which is important for high quality
printing of the documents, and can split table rows on several pages. Both features
require a formatting routine which is different to the one used by a web browser. So
usually websites will look differently when loaded into wRTF2PDF / TextDynamic
Server than they looked in a web browser. Frames are not supported.
HTML documents which are designed to be "printable" will usually look perfect in
wRTF2PDF / TextDynamic Server.
With Memo.SetBProp ist is possible to select a special HTML format mode!
wpViewOptionsEx (Webpage Mode)
If you want to display a split editor with the HTML source (HTML code) and
formatted text you can use TextCommandStr(5, ..) .
With an additional license it is now possible to load a http access DLL to
automatically retrieve JPEG and PNG images referenced by HTML files.
This DLL is loaded by Memo.TextCommandStr(6,1, dll_key )
Notes:
a) Please see ActivateSyntaxHighlighter for XML and HTML syntax highlighting.
b) also see SetXMLSchema to work with XML tags
b) The format string "XML" writes simplified HTML code.
You can use "XML-useptag,-ignorefonts" to only write <p>, <b>, <i>, <u> and <a>
tags. Paragraphs may use styles which are written as <p class="">.
5.7.2
Create HTML
You can create a HTML file by simply use the Memo.SaveToFile method. By default
embedded images will be recreated using the naming
filename_000x.png or filename_000x.jpeg
This also happens when the save dialog is used. (Save or SaveAs action)
When the same file is saved another time in the same session the existing image file
will be reused. The component will automatically compress bitmap (BMP) to PNG
format if the color depth is <= 8 bit and otherwise JPEG format. The compressed
image data will replace the embedded, non compressed image data.
In place of metafiles (EMF, WMF) a 200 dpi PNG image will be created. The PNG
2006-2009 by WPCubed GmbH, Munich, Germany
456
information will be only used to save the image, the embedded data will not be
replaced.
If you use the format string HTML-imgpath:"" embedded images will not be exported.
(This behaviour used to be the default setting)
If you want to save the images to a different directory use the format string
HTML-imgpath:"c:\attach\img"
Then the files
c:\attach\img_000x.png or c:\attach\img_000x.jpeg
will be created.
If you need to create HTML as string use the method SaveToString. Here the creation
of image files must be explicitly activated using a format string like HTML-imgpath:"c:
\attach\img".
Note: The double quotes are required for the -imgpath: format option!
5.7.3
Format Options
Using the format strings used by the IO methods the HTML reader and writer can be
customized. The format strings are passed to the IO method as second or third
parameter.
To select the HTML writer or writer use the format string
"HTML"
TextDynamic will usually detect HTML input correctly if the format string is empty or
"AUTO" is used.
Options can be appended to the format string, the following options are useful for
HTML:
For HTML writer:
-imgpath:"imagepath_and_filename"
This will tell the writer to create a copy of all images in the mentioned path. The
filename part will be used to build the name for the image file.
-csspath:"http://www.wpcubed.com/docstyle.css"
Write a link to the give CSS file.
Examples:
"\"
create name save using the path and name of the HTML file plus the number.
(Does not work for SaveToStream and SaveToString)
"\testimages\" create files in sub directory testim ages and use name _000x.
""
Do not create files. Only create IMG tags for linked images.
Default
2006-2009 by WPCubed GmbH, Munich, Germany
457
For images which are not linked create image files using the name of the
created HTML file + _000x.
-onlybody
Do not save the <html> and <body> tags to make it possible to use the output as
text block in a website.
-writebasefont
Write a basefont tag using the information of the default attributes of the document.
-writespan
Write <span> objects instead of <font>
For HTML reader:
-csspath:"c:\docstyle.css" Opens the local file "c:\docstyle.css" instead of the linked
one.
-onlyinbodytag
-nospanobjects
-ignorehtml do not use HTML formatting tags. this is useful in combination with useBBCodes.
-useBBCodes
Interpret the "bulletin board" tags [b], [i], [u], [s], [color], [size],
[align], [center], [left], [right], [justify], [list], [url], [email]
-usecr
-codepageXXXX
5.7.4
Emails contain plain text, possible HTML text with images and further attachments.
The creation and collection of all this data is not an easy task. If a document contains
embedded images, first image files have to be created so the HTML part of the e-mail
can link to them.
The TextDynamic interface IWPMAPI makes it easy to prepare the e-mail data. You
are then free to either use the MapiSendMail function to send it (call Send) or you can
read the properties and send the e-mail using a different tool. In this case you only
2006-2009 by WPCubed GmbH, Munich, Germany
458
5.7.5
The integrated MIME writer class can be used to create MIME formatted data:
If you use the method SaveToString with the format name "MIME" it will create
2006-2009 by WPCubed GmbH, Munich, Germany
459
multipart MIME e-mail data with the HTML code and all images embedded without a
single temporary file being created!
A MIME message will be also written when the document is saved to a *.MSG file.
Example MIME Ouput Data:
From: [email protected]
To: [email protected]
Subject: Test me
Date: Fri, 17 Nov 2006 09:00:29 +0100
CC: "Julian"<[email protected]>
MIME-Version: 1.0 (produced by Synapse)
X-mailer: WPTools/TextDynamic
Content-type: Multipart/mixed;
boundary="00010001_1855D7EE_MIME_Boundary"
Content-Description: Multipart message
--00010001_1855D7EE_MIME_Boundary
Content-type: text/html; charset=UTF-8
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline
Content-Description: Message text
=EF=BB=BF<html>
<head></head><body>
<div><font face=3D"Arial">Some Text</font></div>
<div><font face=3D"Arial">and an image: <img
src=3D"CID000100000001" style=
=3D"width:0.23in;height:0.17in;"/></font></div>
</body></html>
--00010001_1855D7EE_MIME_Boundary
--00010001_1855D7EE_MIME_Boundary
Content-type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: Quoted-printable
Content-Disposition: inline
Content-Description: Message text
Some Text
and an image: [image1.JPEG]
--00010001_1855D7EE_MIME_Boundary
Content-type: image/JPEG; name="image1.JPEG"
Content-Transfer-Encoding: Base64
Content-ID: CID000100000001
Content-Disposition: inline; FileName="image1.JPEG"
Content-Description: Included file: image1.JPEG
/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQgFBQQEBQoHB
wYIDAoM
DAsKCwsNDhIQDQ4RDgsLEBYQERMUFRUVDA8XGBYUGBIUFRT/2wBDAQMEBAUEBQkFB
QkUDQsN
FBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUFBQUF
BT/wAAR
CAAUABsDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/
2006-2009 by WPCubed GmbH, Munich, Germany
460
8QAtRAA
AgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM
2JyggkK
FhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4e
XqDhIWG
h4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2
uHi4+Tl
5ufo6erx8vP09fb3
+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREA
AgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVY
nLRChYk
NOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3e
Hl6goOE
hYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2
Nna4uPk
5ebn6Onq8vP09fb3
+Pn6/9oADAMBAAIRAxEAPwDA+PfxTn8MeHxZ6PNfKz+TbhWj8uHczSZe
NwrEtjgjHQD1rzdfFHxJWGaC71S5uLeaTDrLPKmCCd2wlSF6dOM+lXviV8QYdcu9E
0+JZolt
riaYSMzFVwAoO0eucZ9q7y6/an1K00jzZ/ConuHuFURxXW0AfNycg8/
LnHvXk11ONnBHs4WW
Gkpe1lZnyvqukaff65c6f5U1ssRM6b0EbyyOcks2B+HHPNLa6DJYwJBJJtdOCJ13O
Pqe9dnq
et6Rr2sFJZWRkId2hOWjGTnkAE88dO1ePa4b2DWLtDFc4WQhcmfle3f0xXXGTa97c
8SpyKXu
6nvvijT4rnxddyuPmYlMKAoABJA4HufzrC1DU2fQ7i+MMXnWsqwouCVIc7SWBPJAH
HpRRWb2
FLdGPrF0ugW1q9jbwwzXhaFpgDujAzynOAfcg16NpXhOK7sUml1DUGkZnJPn4z8x9
qKKjodF
JK7P/9k=
--00010001_1855D7EE_MIME_Boundary-The following format options can be used:
-noplain : Do not include the plain text
-nohtml : Do not include the text as HTML code. Embedded images will be still
appended to the mail data.
In the plain text always placeholders for the images will be inserted, see the text "
[image1.JPEG]" in the MIME example above.
Example:
html_mail = SaveToString(false, "MIME-noplain,")
The e-mail properties
Form, To, Subject, and CC will be set to the values assigned to the property MAPI!
5.8
461
In case You do not want to use .NET or the OCX Interface there is a third possibility to
integrate TextDynamic in your application.
We call it the "Popup Editor Mode".
You can either create an editor dialog window, or place the editor inside one of your windows.
In the latter case this will look like an embedded OCX, only that no COM is involved. You can
still load and save the text.
Please read more here: TextDynamic as Popup Editor (method wptextCreateDialog)
462
463
464
This component was created to view PDF files which were created using the wPDF engine,
but it is also capable of viewing PDF files created with other windows based engines which
utilize TrueType(tm) fonts. In contrast to many competing solutions WPViewPDF is very
fast. You can also use WPViewPDF to convert PDF to EMF and to convert PDF to JPEG.
As "PLUS" edition WPViewPDF is a component which allows you to view, merge, stamp
and print PDF files.
New in WPViewPDF V2:
optionally integrates font rendering engine to display and print Type 1 fonts (simply add
2 DLLs)
support for TrueType subset fonts.
improved support for CMYK images.
new auto scroll mode activated with middle mouse button.
display bookmarks of PDF file.
text selection and copy to clipboard.
optimized load and render methods to open and display PDF files with thousands of pages
instantly.
WPViewPDF used in Visual Studio 2005:
465
WPViewPDF PLUS
With the PLUS license you can save the PDF information from WPViewPDF which makes it a
versatile pdf conversion software. This means you can load in multiple PDF files and save
all pages into a new PDF file (=pdf merge, edit pdf).
Certain pages can be marked to be deleted, they will not be displayed by WPViewPDF.
When you save the PDF file this pages will be removed. It is also possible to set new
security properties (apply, remove encryption) and set property strings int this pdf
conversion tool. The WPViewPDF Demo has the PLUS features enabled, but when a new file
is created a red cube will be printed on all pages.
With the "PLUS" version it is now possible to add text and vector graphics to certain pages
of a PDF file (pdf stamping). Any text will be converted to vectors - this allows it to use
special fonts. The graphics will be already visible in the viewer before the PDF data has
been updated!