# NGDesktop Utils (ref)

(part of package '[NGDesktop Utils](https://docs.servoy.com/reference/servoyextensions/packages/browser-plugin-packages/ngdesktop-utils)')

You can access it in code via: **plugins.ngdesktoputils**

## API

### executeCommand(program,args)

Executes a command async, the server side call will not block on this call.

**Parameters:**

> * {[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)} program
> * {[Array\<Object>](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)} args

***

### executeCommandSync(program,args)

This executes a command and returns the result of the stdout This will also call reject when a error happens so the call will error out. (will not return correct) Try to use the async executeCommand so nothing will be blocking.

**Parameters:**

> * {[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)} program The command to be executed
> * {[Array\<Object>](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/object)} args The command arguments

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) The result from standard output.

***

### exit()

This will close the NGDesktop main application.\
Be sure you will call this and after this call application.exit() to close also the client directly itself.

***

### getClipboardContent()

Get clipboard text.

**Returns:** [String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string) The clipboard text.

***

### getDefaultPrinter()

Returns default printer on local machine.

**Returns:** [CustomType\<ngdesktoputils.printer>](#printer) The default printer object.

***

### getPrinters()

Returns installed printers on local machine.

**Returns:** [Array\<CustomType\<ngdesktoputils.printer>>](#printer) An array of printer objects.

***

### getSystemInformation()

Retrieve information from the ngdesktop client

**@return** {CustomType\<ngdesktoputils.sysinfo>}

```
an object containing the client's system information:

    ngDesktopVersion    - string: ngdesktop version
    osPlatform          - string: can be 'darwin', 'linux', 'freebsd', 'openbsd' and 'win32'
    osRelease           - string: kernel release number
    osTotalMem          - long: total system's memory
    osFreeMem           - long: total available memory
```

**Returns:** [CustomType\<ngdesktoputils.sysinfo>](#sysinfo) `an object containing the client's system information:ngDesktopVersion - string: ngdesktop versionosPlatform - string: can be 'darwin', 'linux', 'freebsd', 'openbsd' and 'win32'osRelease - string: kernel release numberosTotalMem - long: total system's memoryosFreeMem - long: total available memory`

***

### isNGDesktop()

Whether application is running as NGDesktop.

**Returns:** [Boolean](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/boolean) True if app running inside NGDesktop, false otherwise.

***

### printPDF(path,options )

Prints a pdf document specified by path. Optionally, specify printer or unix print options (lp command) or windows print options see: <https://github.com/Servoy/pdf-to-printer>

**Parameters:**

> * {[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)} path
> * {[CustomType\<ngdesktoputils.printoptions>](#printoptions)} \[options]

***

### setClipboardContent(text)

Set clipboard text.

**Parameters:**

> * {[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)} text To be set in clipboard

***

### showExternal(url)

Manage URLs using their default applications

**Parameters:**

> * {[String](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)} url The URL to be opened.

***

## Types

## printer

Contains printer information. scripting type: CustomType\<ngdesktoputils.printer>

* deviceId
  * The device identifier for the printer.
  * **Type**: [string](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)
* name
  * The name of the printer.
  * **Type**: [string](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)
* paperSizes
  * An array of supported paper sizes.
  * **Type**: [string\[\]](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

## printoptions

Contains print options for different platforms. scripting type: CustomType\<ngdesktoputils.printoptions>

* printer
  * The printer identifier or name to use.
  * **Type**: [string](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)
* unix
  * An array of Unix-specific printing options.
  * **Type**: [string\[\]](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)
* win32
  * An array of Windows-specific printing options.
  * **Type**: [string\[\]](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)

## sysinfo

Contains system information from the NGDesktop client. scripting type: CustomType\<ngdesktoputils.sysinfo>

* electronVersion
  * The version of Electron used by NGDesktop.
  * **Type**: [string](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)
* ngDesktopVersion
  * The NGDesktop version.
  * **Type**: [string](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)
* osFreeMem
  * The available (free) system memory in bytes.
  * **Type**: [long](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)
* osPlatform
  * The operating system platform (e.g. 'darwin', 'win32', etc.).
  * **Type**: [string](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)
* osRelease
  * The operating system release version.
  * **Type**: [string](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/string)
* osTotalMem
  * The total system memory in bytes.
  * **Type**: [long](https://docs.servoy.com/reference/servoycore/dev-api/js-lib/number)

***
