# Generate HTML/PDF reports from the cmd-line

**URL:** <https://forums.toadworld.com/t/generate-html-pdf-reports-from-the-cmd-line/32494>\
**Category:** Toad Data Modeler\
**Created:** [February 2, 2015, 3:54pm UTC](https://forums.toadworld.com/t/generate-html-pdf-reports-from-the-cmd-line/32494 "2015-02-02T15:54:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bcalmac](https://avatars.discourse-cdn.com/v4/letter/b/6a8cbe/32.png) [@bcalmac](https://forums.toadworld.com/u/bcalmac)\
**Post date:** [February 2, 2015, 3:54pm UTC](https://forums.toadworld.com/t/generate-html-pdf-reports-from-the-cmd-line/32494/1 "2015-02-02T15:54:53Z")

</div>

I’m trying to integrate DataModeler with the build system and I would like to generate the reports (PDF/HTML) unattended, from the cmd-line. How can that be done?

---

<div class="post-metadata">

**Author:** ![Lukas.Knapek](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/lukas.knapek/32/269_2.png) [@Lukas.Knapek](https://forums.toadworld.com/u/Lukas.Knapek)\
**Post date:** [February 3, 2015, 5:37am UTC](https://forums.toadworld.com/t/generate-html-pdf-reports-from-the-cmd-line/32494/2 "2015-02-03T05:37:05Z")

</div>

Hello there,

You cannot generate reports from command line, BUT you can create an **external .js script** which generates reports and launch it from command line.

First, create a new empty text file and save it as a **.js file**. Now you have to actually write the script itself.

For example, an **HTML report** is generated like this (taken from **Help** | **Projects and Models** | **Scripting and Customizatio** n | **Automation** ):

* * *

function HTMLReport(Model, System, OutputPath)  
{

var ReportRegistrar = System.CreateObject(‘ReportRegistrar’);  
ReportRegistrar.DataSource = Model;  
var Report = ReportRegistrar.CreateReport(‘BasicHTMLPERReport’+Model.ModelDef.Abbrev, 1 , Model); **//1 - HTML**

ReportRegistrar.RegisterLayoutClasses(1);

Report.Path = OutputPath;  
Report.FileName = ‘Report’;  
Report.Language = ‘ENU’;  
Report.Kind = ‘HTML’;  
Report.Layout = ReportRegistrar.GetLayoutClass(0);  
Report.CSS = Report.Layout.CSSList.GetObject(0);  
Report.GenerateInfo = false;

Report.Generate();

}  
//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

var App;  
App = new ActiveXObject(“TDM.App”);  
var Model = App.OpenModelFromFile(“C:\Models\Videorental.txp”); **//Change path**  
HTMLReport(Model, App.System, ‘C:\Reports\’ ); **// Change path**

* * *

A script to generate **PDF report** is a bit different:

* * *

function PDFReport(Model, System, OutputPath)  
{

var ReportRegistrar = System.CreateObject(‘ReportRegistrar’);

ReportRegistrar.DataSource = Model;

var Report = ReportRegistrar.CreateReport(‘BasicRTFPERReport’+Model.ModelDef.Abbrev, 2, Model); **//2 - RTF,PDF**  
Report.Path = OutputPath;  
Report.FileName = ‘Report’;  
Report.Language = ‘ENU’;  
Report.Kind = ‘PDF’;  
Report.Frames = true;  
Report.Shadow = true;  
Report.UseWatermark = false;  
Report.Extension = ‘pdf’;  
Report.Generate();

}  
//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

var App;  
App = new ActiveXObject(“TDM.App”);  
var Model = App.OpenModelFromFile(“C:\Users\lknapek\Documents\Models\Videorental.txp”); **//Change path**  
PDFReport(Model, App.System, ‘C:\Users\lknapek\Documents\Reports’ ); **//Change path**

* * *

If you want, you can look into **Reference Guide** ( **Expert Mode Menu** | **Reference Guide** ) to learn how to configure more report properties via script.

Once your script is complete, you can launch it from command line using the following command:

**Cscript.exe "C:\Path\YourScript.js"**

I hope this functionality satisfies your needs.

Regards,

Lukas

---

<div class="post-metadata">

**Author:** ![Andre](https://avatars.discourse-cdn.com/v4/letter/a/6de8d8/32.png) [@Andre](https://forums.toadworld.com/u/Andre)\
**Post date:** [January 28, 2022, 8:47am UTC](https://forums.toadworld.com/t/generate-html-pdf-reports-from-the-cmd-line/32494/3 "2022-01-28T08:47:57Z")

</div>

I have a question related to this.

I created a custom package where I am able to modify the HTML report that will be generated.  
The Metamodel of the package also includes additional properties.

If I run from inside the Application, I can access the properties in my custom package.  
If I run from the command line (using the above example), I get an error that the properties is unknown. It shows the exact line in my custom package script, so the package itself is available.

Is there something I need to do related to the custom packages if I run from the command line?
