3

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

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

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

谢谢 :)

4

1 回答 1

2

我猜您希望您的应用程序从用户界面字段创建一些 PDF 内容。

您可以从代码中轻松完成此操作,使用代码中的报告生成器,然后使用PDF 引擎

我们为此提出了一个开源解决方案,从 Delphi 6 到 XE。

这是从一个演示中提取的代码,它使用一些用户界面字段作为源(例如 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 文件,则此库将不起作用。

您应该使用一些闭源库,例如VeryPdfQuickPdf谷歌是你的朋友

于 2011-01-31T14:42:53.753 回答