Developer Tools
|
Office Productivity Applications
|
Platform-Agnostic APIs
|
Home | Online Demos | Downloads | Buy Now | Support | About Us | News | Working Together | Contact Us
If you are familiar with XML and XSLT, then you also know that transformed XML documents can be displayed inside a web browser just like a web page.
Well, it does not stop with transformed XML. A lot of people have been asking us about exporting XML to PDF and other formats. And, here is our solution.
Our solution uses an old Delphi component called THTMLViewer. THTMLViewer is no longer under development by its original authors. The last update from them was for Delphi 2006. However, the authors had made the project open source. There is a Delphi 2009 update for the component from the good folks at www.songbeamer.com/delphi/.
Before you try our solution, you need to install the new THTMLViewer and then recompile eDocEngine's export interface component for THTMLViewer - TgtHtmlViewInterface. The test XML and XSL files used in our example code are named gnostice_nl.xsl
and placed in the project folder. (You can use any XML and XSL file so long as the THTMLViewer can display it without problem.) Here are the steps for creating the Delphi application.
procedure TForm1.Button1Click(Sender: TObject); var XMLDocument1: TXMLDocument; XSLPageProducer1: TXSLPageProducer; begin XMLDocument1 := TXMLDocument.Create(self); XSLPageProducer1 := TXSLPageProducer.Create(self); try // Transform XML and place HTML in memo XMLDocument1.Active := False; XSLPageProducer1.FileName := 'Input_Docs\gnostice_nl.xsl'; XMLDocument1.FileName := 'Input_Docs\gnostice_nl.xml'; XSLPageProducer1.XMLData := XMLDocument1; XMLDocument1.Active := True; Memo1.Text := XSLPageProducer1.Content; XMLDocument1.Active := False; // Display HTML from memo HTMLViewer1.LoadFromString(Memo1.Text); // Export displayed HTML to PDF gtHtmlViewInterface1.Engine := gtPDFEngine1; gtPDFEngine1.Preferences.ShowSetupDialog := false; gtPDFEngine1.FileName := 'Output_Docs\gnostice_nl.pdf'; gtHtmlViewInterface1.RenderDocument(HTMLViewer1); except on E: Exception do Memo1.Text := E.Message end; end;
Here is the final output.
---o0O0o---
Our .NET Developer Tools | |
---|---|
![]() Gnostice Document Studio .NETMulti-format document-processing component suite for .NET developers. |
![]() PDFOne .NETA .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 DelphiMulti-format document-processing component suite for Delphi/C++Builder developers, covering both VCL and FireMonkey platforms. |
![]() eDocEngine VCLA Delphi/C++Builder component suite for creating documents in over 20 formats and also export reports from popular Delphi reporting tools. |
![]() PDFtoolkit VCLA 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 JavaMulti-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 | |
---|---|
![]() StarDocsCloud-hosted and On-Premises REST-based document-processing and document-viewing APIs |
Privacy | Legal | Feedback | Newsletter | Blog | Resellers | © 2002-2025 Gnostice Information Technologies Private Limited. All rights reserved. |