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 .NET Developer Tools
Gnostice Document Studio .NET

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

PDFOne .NET

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

Our Delphi/C++Builder developer tools
Gnostice Document Studio Delphi

Multi-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms.

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.

Our Java developer tools
Gnostice Document Studio Java

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

PDFOne (for Java)

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

Our Platform-Agnostic Cloud and On-Premises APIs
StarDocs

Cloud-hosted and On-Premises REST-based document-processing and document-viewing APIs

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