XtremeDocumentStudio Delphi
Next-generation multi-format document-processing component suite for Delphi/C++Builder developers
Compatibility
VCL - FireMonkey - Delphi - C++Builder

A multi-format FireMonkey document viewer for iOS, Android, Mac OS X & Windows Desktop

Getting started with XtremeDocumentStudio's FireMonkey viewer component.

XtremeDocumentStudio Delphi is the next-generation multi-format document-processing framework for Delphi/C++Builder developers. Initially, it was released with viewing, printing and conversion functions. Later, we added creation and editing functions as a preview feature (part of the "Ultimate" edition).

One of the most requested feature from our customers and visitors to our Delphi-Tage booth was a FireMonkey version of the document viewer. In October this year, we released a multi-format FireMonkey document viewer component as a preview. In iOS, Mac OS X and Windows, the FireMonkey viewer supports PDF and image formats. In Android, only images are supported. Optionally, DOCX and PDF can be supported on all platforms when the backend is plugged with Gnostice StarDocs Document Server, our REST-based document-processing solution. This StarDocs integration requires just a StarDocs-specific unit and no further changes to your code.

In this article, you will learn to create a simple a multi-format multi-platform viewer using the FMX document viewer component. The viewer will allow an end-user to select a file and display it in the viewer on Windows and Mac. In IOS, it will open a document embedded in the app.

Here are the steps you need to follow:

  1. Start your Delphi IDE.
  2. From the menu, choose to create a new "Multi-Device Project" and select the "Blank Application" project template.
  3. Drop the following components on the form:
    • FMX.StdControls.TButton
    • FMX.Dialogs.TOpenDialog
    • fmx.gtxDocumentViewer.TgtDocumentViewer
  4. Add a PDF document as a project resource.
  5. Name the resource as "sampledoc".
  6. Double-click the button and set its "OnClick" event handler to the following:
    procedure TForm5.Button1Click(Sender: TObject);
    var
      oStream: TResourceStream;
    begin
    {$IFDEF IOS}
      try
       begin
         oStream := TResourceStream.Create(HInstance, 'sampledoc', RT_RCDATA);
         // Load document from internal resource stream
         gtDocumentViewer1.LoadFromStream(oStream);
    
       end;
      except
       on Err:Exception do begin
         ShowMessage('Error: ' + Err.Message);
       end;
      end;
    {$ELSE}
      // Set file open dialog filter
      OpenDialog1.Filter :=
        'Supported formats|*.docx;*.pdf;*.bmpg;*.png;*.jpg;*.jpeg|'+
        'Word DOCX files|*.docx|Acrobat PDF files|*.pdf|'+
        'Images|*.bmp;*.png;*.jpg;*.jpeg|All files|*.*';
      // Display the dialog
      If (OpenDialog1.Execute) then begin
        try
         begin
           // Load document selected by user
           gtDocumentViewer1.LoadFromFile(OpenDialog1.FileName);
           Caption := OpenDialog1.FileName;
         end;
        except
         on Err:Exception do begin
           ShowMessage('Error: ' + Err.Message);
         end;
        end;
      end;
    {$ENDIF}
    end;
    
  7. Compile the project, fix any errors and run it.
  8. When the form is shown in the default Windows target, click the button and test it with some DOCX or PDF files.
  9. When you are finished with the Windows test, close the application.
  10. Add an additional target for Mac OS in the project.
  11. Run the project and check the targeted Mac system.
  12. Open a supported document in the Mac.
  13. When are done with the Mac test, add a IOS target to the project.
  14. Run the project in the IOS device or simulator.
  15. Click the button to open the embedded document.

---o0O0o---

Our .NET Developer Tools
XtremeDocumentStudio .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
XtremeDocumentStudio 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
XtremeDocumentStudio (for 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-2017 Gnostice Information Technologies Private Limited. All rights reserved.