RTF Data Exporter lazarus / 16-Databases ---------------------------------------------------------------------- InfoMan · 2012-04-30 23:50 Good Evening! Lazarus 1.1 (04/21/2012) with FPC 2.6.1 and Windows 7 (32 Bit) I am trying to export a database to a dbf file RTF (RichText) using the component DBExporter. Gero's report but no information appears there. What is happening? Where can I find information on how to use this component (TRTFExporter)? Have export to CSV without problems but is not working. The report is generated but no data is displayed. Thanks to all who respond. ---------------------------------------------------------------------- BigChimp · 2012-05-01 05:11 Ciao Infoman, You're trying to export to RTF... that is not DBF format though... Are you saying an RTF file is generated but no information appears? And that you are using the CSV exporter and it works? Or are you using a different methot to export CSV? IIRC, for the graphical export components, you must specify which fields you want to export. See the demos in the Lazarus source directory: \components\dbexport\demo The source code for the exporter non-visual code is in \packages\fcl-db\src\export You can find a non-GUI sample that shows how to export to DBF (using a similar approach as RTF export): http://bugs.freepascal.org/view.php?id=20163 ---------------------------------------------------------------------- InfoMan · 2012-05-01 14:55 Let me explain. Use a component TDbf to access the data you need to export. I also use various componetes CSV Exporter to export to CSV from the data read from the DBF. This works perfectly. I tried the same thing using the component RTF Exporter to generate an RTF file, using basically the same code used to generate the CSV. In both cases (and CSVExporter RTFExporter) I specified all the fields you want to export the same way. The CSV file is generated correctly, and when opened in Excel or Calc it shows the data correctly. The same does not happen with RTF. If the report for example, gives 03 pages it generates three blank pages but no data of any record appears. Have we looked at the suggested but did not help me much. Where am I wrong? Thank you for your attention. ---------------------------------------------------------------------- BigChimp · 2012-05-01 16:03 Ok, sounds like you're doing things the way they should be done. If you can write a simple application (perhaps based on one of the demos) that shows the problem with exporting to RTF, perhaps somebody can help... or it can go to the bug tracker as an issue to be fixed... ---------------------------------------------------------------------- InfoMan · 2012-05-01 19:46 No need to develop a project. Compile the project which is in simpledata lazarus demos and generate the executable from it. Attached are the results generated for export to CSV and RTF files from this demo on my computer with Lazarus 1.1 (04.26.2012), FPC 2.6.1 and Windows 7 (32 Bit). I also added the file and the file testdata.dbf MDX (index it) so they can reproduce the test. Take the quiz and see. Open the file and send testdata.dbf export to CSV. Open the file in Excel or Calc and see the data exported correctly there. Now repeat the process, but have to export to RTF. Open the file and you will see that the data were not exported. I thought it was something wrong with my version of Lazarus but whether it works with the CSV export should work also for export to RTF, right? The problem occurs with any use which DBF files. Tested multiple files and in all cases was the same result. How do I fix this? Thank you. ---------------------------------------------------------------------- maurog · 2025-09-08 14:31 Hi, The problem still persists. The RTF file is generated, and while AbiWord can open it without any issues, LibreOffice loads the file without any error messages but only displays blank pages. The screenshot I am posting now shows Infoman’s attachment in AbiWord. Regards, Maurog. ---------------------------------------------------------------------- Thaddy · 2025-09-08 15:15 Use a font that is actually on your machine or embed the font as a resource. This has been solved 13 years ago, so why would itt give you problems now? No font, no display. Obviously. ---------------------------------------------------------------------- wp · 2025-09-08 16:30 I can confirm that, on Windows, LibreOffice displays a blank page for the InfoMan's file. When I load it in Word there is only a narrow stripe of characters at the left side. This gives the idea to look at the column widths, and I can see that there is no column width info in the file. Following http://www.pindari.com/rtf3.html I added \cellxNUMBER instructions (where NUMBER is the start of a column in twips, 1/20pt), and now the file is displayed correctly in both LibreOffice and Word (well... Word does not display the cell borders, maybe a different story) Code: Text  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {\rtf1{\fonttbl{\f0\fswiss Helvetica{\*\falt Arial};}{\f1\fmodern Courier{\*\falt Courier New};}{\f2\froman Times{\*\falt Times New Roman};}}{\stylesheet{\s1\li0\fi0\ql\sb240\sa60\keepn\f2\b\fs32 Section Title;}{\s2\ql\sb30\sa30\keepn\b0\i0\scaps1\f1\fs28 Table Title;}{\s3\li0\fi0\qc\sb240\sa60\keepn\f2\b\scaps1\fs28 Listing Title;}{\s4\li30\fi30\ql\f2\fs24 Listing Contents;}{\s5\li0\fi0\ql\sb240\sa60\keepn\f2\b\fs40 Chapter;}{\s6\li0\fi0\ql\sb240\sa60\keepn\f2\b\fs32 Section;}{\s7\li0\fi0\ql\sb240\sa60\keepn\f2\b\fs28 Subsection;}{\s8\li0\fi0\ql\sb240\sa60\keepn\f2\b\fs24 Subsubsection;}{\s9\li30\fi10\ql\sb60\keepn\f2\fs24 Description titles;}{\s10\li30\fi30\ql\fs24 Description;}{\s11\li0\fi0\ql\fs24 Source Example;}}\par{{\b\trowd\trbrdrh\brdrs\trbrdrv\brdrs\cellx1200\ cellx2400\cellx3600\cellx4800\cellx6000\cellx7200\cellx8400\cellx9600\ pard\intbl TRACKID\cell\pard\intbl PERSONID\cell\pard\intbl FIRSTNAME\cell\pard\intbl LASTNAME\cell\pard\intbl DAYOFWEEK\cell\pard\intbl DATE\cell\pard\intbl TIMEIN\cell\pard\intbl TIMEOUT\cell\row}}} Is there a "default colwidth" command in rtf? ---------------------------------------------------------------------- wp · 2025-09-08 22:16 Spent some more time with this issue: Installed WordPad in Win11 (they got rid of it some time ago...), it opens the test file without any issues (it does not fit nicely on the page, though). Installed KControls and checked TKMemo - the kmemoeditor_demo displays the test file also, here with relative column widths. I think the inability of Libreoffice Writer and Word to display the file correctly is an issue of these applications (or intentional - who knows?). I would not spent much time in fixing around the issues of other programs. Is is absolutely necessary that you export to rtf? You could try to export to Excel (xls, xlsx) or LibreOffice Calc (ods) by using the fpspreadsheet library which you can install from OPM. There is also a dedicated exporter to spreadsheets, similar to the rtf exporter (https://wiki.lazarus.freepascal.org/FPSpreadsheet#Dataset_export)- ---------------------------------------------------------------------- Thaddy · 2025-09-09 04:38 If you are on windows, you can still use the converters that belong to the RICHEDIT2 (or 5) control and also the Text Object Model (TOM) COM interfaces from the richedit. (Not the lazarus control, but the winapi RICHEDIT2 or higher) I wrote Delphi converters around 2004-5 for KOL. See if I can find them. ---------------------------------------------------------------------- maurog · 2025-09-09 06:34 Hi, I personally do not need the RTF export myself. At the moment I am trying to revive TurboBird (a Firebird admin tool), (https://github.com/mdadali/TurboBird) and a user from the Firebird forum asked me about the RTF export. It would be nice if the dbExport library could be fixed directly, instead of relying on workarounds or post-processing the generated RTF files. Modifying the library locally would not be a clean solution, since the change would only exist on my machine. Regards,  Maurog