gpt4 book ai didi

delphi - 使用 Delphi 将数据发送到 PDF

转载 作者:行者123 更新时间:2023-12-03 15:57:29 24 4
gpt4 key购买 nike

有没有办法可以手动或通过第三方组件将数据发送到我的 PDF 文件(填写字段/空白),PDF 文件具有可由用户输入数字来修改的某些字段。 .复选框等

我怎样才能实现这个目标,是否需要一些第三方组件,哪个是最好的,价格是多少?

我们的开发IDE是delphi 2010/Delphi 2011 XE

谢谢:)

最佳答案

我猜您希望您的应用程序从用户界面字段创建一些 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 文件,则此库将不起作用。

您应该使用一些闭源库,例如 VeryPdfQuickPdfGoogle is your friend .

关于delphi - 使用 Delphi 将数据发送到 PDF,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4850207/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com