electron / electron/typescript-definitions

[Bug]: [Electron.d.ts][gn-typescript-definitions][Invalid type annotations] Electron.PrintToPDFOptions > Margins

Open
#276 3 comments 2 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
131
Forks
37
Avg merge
6h
Merged PRs (30d)
2

Description

### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.

### Electron Version

28.1.2

### What operating system are you using?

Windows

### Operating System Version

all

### What arch are you using?

x64

### Last Known Working Electron version

~28.1.2~

### Expected Behavior

Electron.PrintToPDFOptions > Margins

`web-contents.md`, `webview-tag.md` file
```md
#### `contents.print([options], [callback])`
### `.print([options])`
* `options` Object (optional)
* `margins` Object (optional)
* `marginType` string (optional) - Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen, you will also need to specify `top`, `bottom`, `left`, and `right`.
* `top` number (optional) - The top margin of the printed web page, in pixels.
* `bottom` number (optional) - The bottom margin of the printed web page, in pixels.
* `left` number (optional) - The left margin of the printed web page, in pixels.
* `right` number (optional) - The right margin of the printed web page, in pixels.
```
```md
#### `contents.printToPDF(options)`
### `.printToPDF(options)`
* `options` Object
* `marginsToPDF` Object (optional)
* `top` number (optional) - Top margin in inches. Defaults to 1cm (~0.4 inches).
* `bottom` number (optional) - Bottom margin in inches. Defaults to 1cm (~0.4 inches).
* `left` number (optional) - Left margin in inches. Defaults to 1cm (~0.4 inches).
* `right` number (optional) - Right margin in inches. Defaults to 1cm (~0.4 inches).
```

### Actual Behavior

The docs are different, the `gn-typescript-definitions` script only creates one 'Margins'.

```ts
interface WebContentsPrintOptions {
...
margins?: Margins;
...
}
interface PrintToPDFOptions {
...
margins?: Margins;
...
}
interface WebviewTagPrintOptions {
...
margins?: Margins;
...
}

interface Margins {
/**
* Can be `default`, `none`, `printableArea`, or `custom`. If `custom` is chosen,
* you will also need to specify `top`, `bottom`, `left`, and `right`.
*/
marginType?: ('default' | 'none' | 'printableArea' | 'custom');
/**
* The top margin of the printed web page, in pixels.
*/
top?: number;
/**
* The bottom margin of the printed web page, in pixels.
*/
bottom?: number;
/**
* The left margin of the printed web page, in pixels.
*/
left?: number;
/**
* The right margin of the printed web page, in pixels.
*/
right?: number;
}
```

### Testcase Gist URL

_No response_

### Additional Information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.