2011-01-31 46 views
3

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

我该如何实现这个目标,如果它需要一些第三方组件,这是最好的,价格是多少?

我们的开发IDE是德尔福2010/2011德尔福XE

谢谢:)

+3

什么是“发送数据到PDF”?你想生成PDF还是填写现有PDF文档的表单?请编辑您的问题并指定详细信息。 – 2011-01-31 11:22:15

+0

我同意尤金 - 这个问题非常模糊,需要澄清。 – 2011-01-31 14:13:57

回答

2

我想你想你的应用程序来创建用户界面领域的一些PDF内容。

您可以通过代码轻松完成此操作,使用代码报告生成器,然后使用PDF engine

我们建议从Delphi 6到XE的Open Source solution just for doing this

这里是一个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