eDocEngine VCL
Create documents and reports in 18 formats
Compatibility
Delphi C++Builder

Export From TRichView and ScaleRichView To PDF And Other Formats

Interactive and programmatic export of rich text format files using Gnostice eDocEngine VCL.
By V. Subhash

eDocEngine comes with several "report-export interface components" for providing multiple output format support for Delphi reporting tools. For TRichView, eDocEngine has the TgtRichViewInterface interface component. For ScaleRichView, eDocEngine provides the TgtScaleRichViewInterface component.

On an application built with TRichView, an instance of the interface component needs to be paired up with an eDocEngine document-creation engine component. For example, to output RTF documents to PDF, a TgtRichViewInterface instance needs to be paired with a TgtPDFEngine instance on the same form as TRichView instance.

eDocEngine offers at least three ways to export from TRichView. In this article, we shall see them one by one.

Export After TRVPrint.Print()

  1. Open the IDE and create a VCL Forms Application project.
  2. Drop the following components on the form.
    • TRVReportHelper
    • TRVStyle
    • TRVPrint
    • TgtPDFEngine
    • TgtRichViewInterface
    • TButton
  3. Set TRVReportHelper.RichView.Style property to TRVStyle to the component.
  4. Set TgtRichViewInterface.Engine property to the TgtPDFEngine instance.
  5. Add this "click" event handler for the button.
    procedure TForm6.Button2Click(Sender: TObject);
    begin
      // Set output PDF file name for the engine
      gtPDFEngine1.FileName := 'edocengine_richview_demo2.pdf';
      // Load a RTF document with a report helper component
      RVReportHelper1.RichView.LoadRTF('edocengine_richview_demo.rtf');
      // Set loaded document that needs to be printer
      RVPrint1.AssignSource(RVReportHelper1.RichView);
      // Create the print output
      RVPrint1.Print('My eDocEngine App', 1, false);
      // Render PDF using the print output
      gtRichViewInterface1.RenderDocument(RVReportHelper1);
      // Free memory
      RVPrint1.Clear;
    end;
    
  6. Run the project and click the button.

Export Without TRVPrint

  1. Open the IDE and create a VCL forms project.
  2. Drop the following components on the form.
    • TRVReportHelper
    • TRVStyle
    • TgtPDFEngine
    • TgtRichViewInterface
    • TButton
  3. Set TRVReportHelper.RichView.Style property to the TRVStyle instance.
  4. Set TgtRichViewInterface.Engine property to the TgtPDFEngine instance.
    procedure TForm6.Button1Click(Sender: TObject);
    begin
      // Load a RTF document
      RVReportHelper1.RichView.LoadRTF('edocengine_richview_demo.rtf');
      // Format the document
      RVReportHelper1.RichView.Format;
      // Set output PDF file name
      gtPDFEngine1.FileName := 'edocengine_richview_demo.pdf';
      // Render RTF document as PDF
      gtRichViewInterface1.RenderDocument(RVReportHelper1);
      // Free memory
      RVReportHelper1.Clear;
    end;
    

Export Using A .RVF File

Where is the code snippet, you ask? Well, we had covered this in an older article titled "Exporting TRichView (.RVF) Files to PDF Using eDocEngine VCL." Please try that.

Export From ScaleRichView To PDF

  1. Open the IDE and create a VCL forms application.
  2. Drop the following components on the
    1. TSRichViewEdit
    2. TgtPDFEngine (or any other document-creation component)
    3. TgtScaleRichViewInterface
    4. TEdit
    5. TOpenDialog
    6. TButton (2 nos.)
  3. Set the Engine property of the TgtScaleRichViewInterface control to the TgtPDFEngine control.
  4. Double click the buttons and add these event handlers.
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      if OpenDialog1.Execute() then begin
        Edit1.Text := OpenDialog1.FileName;
        SRichViewEdit1.Clear;
        SRichViewEdit1.RichViewEdit.LoadRTF(Edit1.Text);
        SRichViewEdit1.Format;
      end;
    end;
    
    procedure TForm1.Button2Click(Sender: TObject);
    begin
      gtPDFEngine1.FileName := OpenDialog1.FileName + '.pdf';
      gtScaleRichViewInterface1.RenderDocument(SRichViewEdit1);
    end;
    
  5. Run the application.
  6. Click the first button and select an RTF document to get it displayed in the ScaleRichView control.
  7. Click the second button to convert the displayed document to PDF.

---o0O0o---

Our Developer Tools
eDocEngine VCL

A Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools.

PDFtoolkit VCL

A Delphi/C++Builder component suite to edit, enhance, view, print, merge, split, encrypt, annotate, and bookmark PDF documents.

XtremePDFConverter VCL

A Delphi/C++Builder component to intelligently convert PDF to user-friendly Word RTF documents.

PDFOne .NET

A .NET PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, and bookmark PDF documents in .NET applications.

XtremeDocumentStudio .NET

Multi-format document-processing component suite for .NET developers

PDFOne (for Java™)

A Java™ PDF component suite to create, edit, view, print, reorganize, encrypt, annotate, bookmark PDF documents in Java™ applications.

XtremeFontEngine (for Java)

Java font engine to render glyphs from Type 1, Type 2 (CFF), and TrueType fonts

Our Office Productivity Applications
Free PDF Reader

A free, fast, and portable application for viewing, printing and converting PDF documents.

Privacy | Legal | Feedback | Newsletter | Resellers © 2002-2013 Gnostice Information Technologies Private Limited. All rights reserved.

This site is best viewed on a screen with minimum resolution of 1152 x 864 pixels. Windows XP users are advised to use Microsoft ClearType Tuning for optimal experience. Also, please use the latest version of a standards-compliant browser such as Firefox, Opera, or Dragon (Chromium).