Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/reporting/getting-started.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ image:reporting/images/share-button.png["Reporting Button",link="share-button.pn
.. If you're on Visualize or Dashboard:
... Select *PDF Reports*

... Choose to enable *Optimize for printing* layout mode. For an explanation of the different layout modes, see <<pdf-layout-modes, PDF Layout Modes>>.
... Dashboard only: Choose to enable *Optimize for printing* layout mode. For an explanation of the different layout modes, see <<pdf-layout-modes, PDF Layout Modes>>.

... Click the *Generate PDF* button.

Expand Down
4 changes: 3 additions & 1 deletion docs/reporting/pdf-layout-modes.asciidoc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[[pdf-layout-modes]]
== PDF Layout Modes

When creating a PDF report, there are two layout modes *Optimize PDF for printing* and *Preserve existing layout in PDF*
When creating a PDF report of a dashboard, there are two layout modes: *Optimize PDF for printing* and *Preserve existing layout in PDF*

--
[role="screenshot"]
Expand All @@ -27,3 +27,5 @@ This will create a PDF preserving the existing layout and size of the Visualizat
[role="screenshot"]
image:reporting/images/preserve-layout.png["Preserve existing layout in PDF",link="preserve-layout.png"]
--

When creating a PNG or a PDF report of a visualization, the "Optimize for printing" option will automatically be used.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@ interface Props {
}

interface State {
isPreserveLayoutSupported: boolean;
usePrintLayout: boolean;
}

export class ScreenCapturePanelContent extends Component<Props, State> {
constructor(props: Props) {
super(props);

const isPreserveLayoutSupported =
props.reportType !== 'png' && props.objectType !== 'visualization';
this.state = {
isPreserveLayoutSupported,
usePrintLayout: false,
};
}
Expand All @@ -47,13 +51,7 @@ export class ScreenCapturePanelContent extends Component<Props, State> {
}

private renderOptions = () => {
if (this.props.reportType === 'png') {
return (
<Fragment>
<EuiSpacer size="s" />
</Fragment>
);
} else {
if (this.state.isPreserveLayoutSupported) {
return (
<Fragment>
<EuiSwitch
Expand All @@ -71,6 +69,12 @@ export class ScreenCapturePanelContent extends Component<Props, State> {
</Fragment>
);
}

return (
<Fragment>
<EuiSpacer size="s" />
</Fragment>
);
};

private handlePrintLayoutChange = (evt: any) => {
Expand All @@ -85,22 +89,13 @@ export class ScreenCapturePanelContent extends Component<Props, State> {
const el = document.querySelector('[data-shared-items-container]');
const bounds = el ? el.getBoundingClientRect() : { height: 768, width: 1024 };

if (this.props.reportType === 'png') {
return {
dimensions: {
height: bounds.height,
width: bounds.width,
},
};
} else {
return {
id: 'preserve_layout',
dimensions: {
height: bounds.height,
width: bounds.width,
},
};
}
return {
id: this.props.reportType === 'png' ? 'png' : 'preserve_layout',

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: the previous code would have an undefined id field when the export type was PNG. This changes it to have an id: 'png' value. There doesn't seem to be any functional change from this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, good catch. At least it's less ambiguous now.

dimensions: {
height: bounds.height,
width: bounds.width,
},
};
};

private getJobParams = () => {
Expand Down