我猜您希望您的应用程序从用户界面字段创建一些 PDF 内容。
您可以通过代码轻松完成此操作,使用代码中的报告生成器,然后使用 PDF engine。
我们建议Open Source solution just for doing this,从 Delphi 6 到 XE。
这是一个code extract from one demo,它使用一些用户界面字段作为源(例如 edt1.Text 或 mmo1.Text)创建报告:
procedure TForm1.btn1Click(Sender: TObject);
(...)
with TGDIPages.Create(self) do
try
// the name of the report is taken from main Window's caption
Caption := self.Caption;
// now we add some content to the report
BeginDoc;
(...)
// main content (automaticaly split on next pages)
NewHalfLine;
TextAlign := taJustified;
s := 'This is some big text which must be justified on multiple lines. ';
DrawText(s+s+s+s);
NewLine;
TextAlign := taLeft;
DrawTitle(edt1.Text,true);
for i := 1 to 10 do
DrawText('This is some text '+IntToStr(i));
NewLine;
DrawBMP(Bmp,maxInt,50,'Some bitmap in the report');
AddBookMark('bookmarkname');
WordWrapLeftCols := true;
AddColumns([10,20,50]);
AddColumnHeaders(['#','Two','Three'],true,true);
for i := 1 to 100 do
DrawTextAcrossCols([IntToStr(i),'Column '+IntToStr(i),'Some text here. '+s]);
NewLine;
DrawBMP(Bmp,maxInt,50,'Some bitmap in the report (twice)');
DrawTitle('This is your text',false,0,'','bookmarkname');
DrawText(mmo1.Text);
EndDoc;
// set optional PDF export options
// ExportPDFForceJPEGCompression := 80;
// ExportPDFEmbeddedTTF := true;
// ExportPDFUseUniscribe := true;
// ExportPDFA1 := true;
// show a preview form, and allow basic actions via the right click menu
// ShowPreviewForm;
// export as PDF
ExportPDF('test.pdf',false);
finally
Free;
end;
还有其他解决方案,但这个是开源的,你甚至可以在报告中绘制任何你想要的东西(使用“标准”TCanvas 属性 - 你甚至可以使用 PaintTo 方法直接任何图形组件),而不是只有专用的报告生成方法,如 DrawTitle() 或 DrawText()。
编辑:
如果您的问题是关于使用表单创建 PDF 文件,则此库将不起作用。
您应该使用一些闭源库,例如 VeryPdf 或 QuickPdf。 Google is your friend.