【问题标题】:Send data to PDF with Delphi使用 Delphi 将数据发送到 PDF
【发布时间】:2011-01-31 11:12:43
【问题描述】:

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

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

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

谢谢:)

【问题讨论】:

  • 什么是“发送数据到 PDF”?您要生成 PDF 还是填写现有 PDF 文档的表格?请编辑您的问题并指定详细信息。
  • 我同意尤金的观点——这个问题非常模糊,需要澄清。
  • 哦,对不起,是的,我的意思是在 PDF 文件中填写表格

标签: delphi automation pdf-generation delphi-2010 delphi-xe


【解决方案1】:

我猜您希望您的应用程序从用户界面字段创建一些 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.

【讨论】:

  • 这个在我可能需要免费 PDF 生成器的其他项目中很有用,但是我正在寻找一种修改现有 PDF 文件的方法,即像在锁定的 Word 文档,您可以拥有可以修改的某些字段,并且文件的其余部分保持只读状态...您将字符串发送到这些空白处
  • @Plastkort 所以你需要一个 PDF 查看器。您可以将 Acrobat Reader 嵌入为 ActiveX。要么使用像wpcubed.com/products/pdfviewer/index.htm 这样的纯德尔福解决方案,但据我所知,没有开源解决方案。 :(
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-04
  • 2018-03-03
  • 1970-01-01
  • 2015-08-31
  • 1970-01-01
相关资源
最近更新 更多