什么库(Debenu,Gnostic,其他?)允许我从数据库nad读取文本然后将其插入pdf文件,但是有分页?例如,我在数据库中有1000行,但是一个A4页面仅适用于250行,所以我需要4页,而不是一个小字体...
在将文本发送到pdf之前是否可以测量文本的高度?
答案 0 :(得分:0)
如果您使用的是Gnostice eDocEngine,则可以使用PDF引擎的AutoPaginate属性自动创建额外的页面。您使用常规Delphi类从数据库中读取记录,然后开始写入PDFEngine中的页面,当您开始耗尽页面空间时,PDFEngine将自动生成新页面并适应您的文本输出。您可以选择任何页面大小。
此示例直接来自帮助文件。
{
This example illustrates autopagination and the use of
built-in and custom placeholders.
Drag a button component and a PDF engine component
on a form. Double-click the button and use the
following code for the click-event procedure.
}
procedure TForm3.Button1Click(Sender: TObject);
var
i: Integer;
begin
with gtPDFEngine1 do begin
FileName := 'autopagination_placeholders_demo.pdf';
Font.Size := 16;
Font.Name := 'Times New Roman';
TextFormatting.LineSpacing := 2;
// Enable autopagination
AutoPaginate := true;
// Ensure all text placeholders are replaced at run-time
Preferences.CalculateVariables := true;
// Render pages after processing all instructions
Preferences.ProcessAfterEachPage // Required for generating values
:= false; // for built-in placeholders
// Specify event handler for placeholder substitution events
OnCalcVariables := gtPDFEngine1CalcVariablesEventHandler;
BeginDoc;
for i := 1 to 50 do begin
// Render paragraph containing built-in and custom placeholders
BeginPara;
Textout('Hello, world! - on page #' +
CphPageNo + ' of ' + CphTotalPages +
' - Random #<%my_random_number_placeholder%>');
EndPara;
end;
EndDoc;
end;
Close;
end;
// Event handler that gets called whenever a placeholder is substituted.
procedure TForm3.gtPDFEngine1CalcVariablesEventHandler(
Sender: TgtCustomDocumentEngine;
Variable: String;
var Value: String);
begin
// Provide a value for the custom placeholder
if Variable = 'my_random_number_placeholder' then begin
Value := FloatToStr(Random);
end;
end;