使用 Delphi 将数据发送到 PDF

发布于 2024-10-14 23:52:20 字数 189 浏览 11 评论 0原文

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

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

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

谢谢:)

Is there a way I can send data to my PDF file, (fill in the fields/blanks), either manually or by a third party component, the PDF files have certain fields that can be modified by user, entering numbers.. checkboxes etc etc

how can I achieve this goal, an if it will require some third party component, which is the best, and what are the prices?

our Development IDE is delphi 2010 / Delphi 2011 XE

thanks :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

转身以后 2024-10-21 23:52:21

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

您应该使用一些闭源库,例如 VeryPdfQuickPdfGoogle 是您的朋友

I guess you want your application to create some PDF content from User Interface field.

You can do this easily from code, using a report generator from code, then a PDF engine.

We propose an Open Source solution just for doing this, from Delphi 6 up to XE.

Here is a code extract from one demo, which create a reports, using some User Interface fields as source (e.g. edt1.Text or 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;

There are other solutions around, but this one is Open Source, and you can even draw whatever you want to the report (using a "standard" TCanvas property - you can even directly any graphical component using the PaintTo method), not only dedicated report generated methods like DrawTitle() or DrawText().

EDIT:

If your question was about creating PDF files with forms, this library won't work.

You should use some closed-source libraries like VeryPdf or QuickPdf. Google is your friend.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文