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

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

有没有办法可以手动或通过第三方组件将数据发送到我的 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/

相关文章:

multithreading - 如何在多线程模式下实现Delphi Tserversocket

delphi - 在导入表中找不到 SHGetStockIconInfo

delphi - Hook TNotifyEvent/寻找使用方法和过程指针的正确方法

java - 我可以在 Android 和 IOS 应用程序中使用由 inspector recorder 生成的相同代码吗?

pdf-generation - Flying Saucer : Chinese character rendered as a box in PDF

delphi - 当迭代表单上的控件时,如何识别特定按钮?

.net - NAnt 或 MSBuild,该选择哪一个以及何时选择?

c# - 使用 C# 在分解后删除 AutoCAD 绘图对象

ruby-on-rails - 我正在尝试使用 Prawn 创建 PDF,但我得到:Prawn::Errors::UnrecognizedTableContent

linux - 帮助使用 PDFKit 和 Rails 应用程序