Hello, how can I can export the data shown on a DBgrid to a pdf file?
Well, data being shown in a DBGrid is provided by the dataset attached to that dbgrid, so exporting data in DBGrid to PDF means exporting data in your dataset to PDF.
The easiest option is to use a Reporting tool. There are many different reporting tools available for Delphi e.g. Rave Report, FastReport, Report Builder, QuickReport, and so on.
Such tools let you to design a printing report from your data, and let you to either print the report or export it to formats like HTML, DOC, PDF, and so on. Rave Report is shipped with Delphi and you can use it for free. I personally like FastReport and use it in my applications.
Another option is that, if you have a virtual PDF printer installed on the target system, you can select it as your printer and use Delphi's TPrinter class to write directly on printer canvas, and your virtual PDF printer will make a PDF file for you rather than printing your data on paper.
A third option is to use third-party components which are specifically built for PDF manipulation and let you to create or edit PDF files in your application.
Regards
try EMS Advanced Data Export VCL
http://sqlmanager.net/en/products/tools/advancedexport
- Data (Datasets) export into 17 most popular formats: MS Access, MS Excel, MS Word, Open XML Format, Open Document Format (ODF), RTF, HTML, XML, PDF, TXT, DBF, CSV, SYLK, DIF, LaTeX, SQL and Windows Clipboard
- Borland Delphi 5-7, 2005, 2006, CodeGear Delphi 2007, 2009 and Borland C++ Builder 5-6, CodeGear C++ Builder 2007, 2009 support
- Export of Unicode data. Manually preset text encoding for exported data (UTF-8, UTF-16/UCS-2, UTF-32/UCS-4, Latin1, Latin2, Latin5, Latin7 and more)
- Saving data for future viewing, modification, printing or web publication
- Easy-to-use wizard allows your end-users to export data quickly
- Powerful export options for each data format
- 100% native Delphi code
- No additional libraries or software required to operate
- Detailed help system and demo application
- Powerful components and properties editors
- Setting the user formats for each field separately
- Multilanguage support
You may iterate through the data yourself and use excellent exporting VCL eDocEngine from Gnostice. It also connects to reporting tools, and other components.
The Scalabium Export suite for Delphi (including 2009) supports many export formats, including PDF and other office formats with and without OLE. The export components can be used with TDBGrid and TDataSet descendants.
It can be used non-visual but also offers configurable export wizards. We successfully use it in a application suite migration from Delphi 7 to 2009.