



Collapse All
Syntax| HRESULT ShowTextParagraph ( FLOAT x, FLOAT y, ParagraphAlign pAlign, FLOAT interval, FLOAT marginLeft, FLOAT marginTop, FLOAT marginRight, FLOAT marginBottom, BSTR text ) |
RemarksThe method will automatically split the paragraph text to the lines to fit the page bounds, align text lines as needed and add a new PDF page if the text does not fit to the rest of the current PDF page.
This method respects all text settings such as text direction, text font and font size, word spacing, character spacing and e.t.c.
Example{ PDF object is supposed to be created }
{*** prepare PDF for e-reader size}
PDF.PageResolution := 166;
W := 584;
H := 754;
PDF.PageWidth := W;
PDF.PageHeight := H;
margin := 10;
{*** draw title and author}
fnt := PDF.AddFont('Some Font Family Name', false, false, false, false, fcDefault);
PDF.UseFont(fnt, 14.0);
PDF.SetColorFill(0.0, 0.0, 0.0, 0.0);
PDF.ShowUnicodeTextAligned(mLeft, margin, W - margin, margin + 40, taCenter, vaTop, 'Alice''s Adventures in Wonderland');
PDF.UseFont(fnt, 12.0);
PDF.SetColorFill(0.3, 0.3, 0.3, 0.0);
PDF.ShowUnicodeTextAligned(mLeft, margin + 40, W - margin, margin + 80, taCenter, vaTop, '(by Lewis Carroll)');
{*** now we'll read the text file (to an array of lines) and draw paragraphs}
PDF.SetColorFill(0.0, 0.0, 0.0, 0.0);
PDF.UseFont(fnt, 11.0);
{your method readTextLines returns an array of text lines}
txt := readTextLines('Alice.txt');
{your method getNumOfLines returns a total number of text lines in the array}
totalLines := getNumOfLines(txt);
for i := 0 to totalLines do
begin
y := PDF.GetCurrentTextY();
if i = 0 then
y := y + 60.0;
else
y := y + 34.0;
PDF.ShowUnicodeTextParagraph(mLeft + 20, y, 3, -1, margin, margin, margin, margin, txt[i]);
end;
{*** save to file}
PDF.SaveToFile('Alice.pdf', true);
// PDF object is supposed to be created
//*** prepare PDF for e-reader size
PDF->PageResolution = 166;
int W = 584;
int H = 754;
PDF->PageWidth = W;
PDF->PageHeight = H;
float margin = 10.0f;
//*** draw title and author
int fnt = PDF->AddFont("Some Font Family Name", false, false, false, false, fcDefault);
PDF->UseFont(fnt, 14.0f);
PDF->SetColorFill(0.0f, 0.0f, 0.0f, 0.0f);
PDF->ShowUnicodeTextAligned(mLeft, margin, W - margin, margin + 40, taCenter, vaTop, "Alice's Adventures in Wonderland");
PDF->UseFont(fnt, 12.0f);
PDF->SetColorFill(0.3f, 0.3f, 0.3f, 0.0f);
PDF->ShowUnicodeTextAligned(mLeft, margin + 40, W - margin, margin + 80, taCenter, vaTop, "(by Lewis Carroll)");
//*** now we'll read the text file (to an array of lines) and draw paragraphs
PDF->SetColorFill(0.0f, 0.0f, 0.0f, 0.0f);
PDF->UseFont(fnt, 11.0f);
//your method readTextLines returns an array of text lines
TCHAR** text = readTextLines("Alice.txt");
//your method getNumOfLines returns a total number of text lines in the array
int totalLines = getNumOfLines(text);
for(int i = 0; i < totalLines; i++)
{
float y = PDF->GetCurrentTextY();
if(i = 0)
y += 60.0f;
else
y += 34.0f;
CComBSTR txtLine = text[i];
PDF->ShowUnicodeTextParagraph(mLeft + 20, y, 3, -1, margin, margin, margin, margin, txtLine);
}
//*** save to file
PDF->SaveToFile("Alice.pdf", TRUE);
// PDF object is supposed to be created
//*** prepare PDF for e-reader size
PDF.PageResolution = 166;
int W = 584;
int H = 754;
PDF.PageWidth = W;
PDF.PageHeight = H;
float margin = 10.0f;
//*** draw title and author
int fnt = PDF.AddFont("Some Font Family Name", false, false, false, false, FontCharset.fcDefault);
PDF.UseFont(fnt, 14.0f);
PDF.SetColorFill(0.0f, 0.0f, 0.0f, 0.0f);
PDF.ShowUnicodeTextAligned(mLeft, margin, W - margin, margin + 40, TextAlign.taCenter, VerticalAlign.vaTop, "Alice's Adventures in Wonderland");
PDF.UseFont(fnt, 12.0f);
PDF.SetColorFill(0.3f, 0.3f, 0.3f, 0.0f);
PDF.ShowUnicodeTextAligned(mLeft, margin + 40, W - margin, margin + 80, TextAlign.taCenter, VerticalAlign.vaTop, "(by Lewis Carroll)");
//*** now we'll read the text file (to an array of lines) and draw paragraphs
PDF.SetColorFill(0.0f, 0.0f, 0.0f, 0.0f);
PDF.UseFont(fnt, 11.0f);
//your method readTextLines returns an array of text lines
string[] text = readTextLines("Alice.txt");
//your method getNumOfLines returns a total number of text lines in the array
int totalLines = getNumOfLines(text);
for(int i = 0; i < totalLines; i++)
{
float y = PDF.GetCurrentTextY();
if(i = 0)
y += 60.0f;
else
y += 34.0f;
PDF.ShowUnicodeTextParagraph(mLeft + 20, y, 3, -1, margin, margin, margin, margin, text[i]);
}
//*** save to file
PDF.SaveToFile("Alice.pdf", true);
' PDF object is supposed to be created
'*** prepare PDF for e-reader size
PDF.PageResolution = 166
W = 584
H = 754
PDF.PageWidth = W
PDF.PageHeight = H
margin = 10
taCenter = 1
vaTop = 0
fcDefault = 1
'*** draw title and author
fnt = PDF.AddFont("Some Font Family Name", false, false, false, false, fcDefault)
PDF.UseFont fnt, 14
PDF.SetColorFill 0, 0, 0, 0
PDF.ShowUnicodeTextAligned mLeft, margin, W - margin, margin + 40, taCenter, vaTop, "Alice's Adventures in Wonderland"
PDF.UseFont fnt, 12
PDF.SetColorFill 0.3, 0.3, 0.3, 0
PDF.ShowUnicodeTextAligned mLeft, margin + 40, W - margin, margin + 80, taCenter, vaTop, "(by Lewis Carroll)"
'*** now we'll read the text file (to an array of lines) and draw paragraphs
PDF.SetColorFill 0, 0, 0, 0
PDF.UseFont fnt, 11
'your method readTextLines returns an array of text lines
text = readTextLines("Alice.txt")
'your method getNumOfLines returns a total number of text lines in the array
totalLines = getNumOfLines(text)
For i = 0 To totalLines
y = PDF.GetCurrentTextY()
if i = 0 then
y = y + 60
else
y = y + 34
end if
PDF.ShowUnicodeTextParagraph mLeft + 20, y, 3, -1, margin, margin, margin, margin, text(i)
Next
'*** save to file
PDF.SaveToFile "Alice.pdf", true
See Also