MCPcopy Create free account
hub / github.com/Rello/analytics / convertPDF

Function convertPDF

js/panorama.js:1243–1420  ·  view source on GitHub ↗
(path, download = false)

Source from the content-addressed store, hash-verified

1241 },
1242
1243 async convertPDF(path, download = false) {
1244 const filterState = OCA.Analytics.PanoramaFilters.state;
1245 if (filterState?.renders.size || filterState?.errors.size) {
1246 OCA.Analytics.Notification.notification('error', t('analytics', 'Wait for all reports to load successfully before exporting.'));
1247 return;
1248 }
1249 OCA.Analytics.Notification.htmlDialogInitiate(
1250 t('analytics', 'Export as PDF'),
1251 OCA.Analytics.Notification.dialogClose
1252 );
1253
1254 // Keep the captured page below the title/subtitle and above the branding.
1255 const headerHeight = 60;
1256 const footerHeight = 45;
1257 const pages = document.querySelectorAll('.flex-container');
1258 const pdf = new jspdf.jsPDF({
1259 orientation: 'landscape',
1260 unit: 'pt',
1261 });
1262
1263 OCA.Analytics.Notification.htmlDialogUpdate(
1264 document.createElement('div'),
1265 t('analytics', 'Starting PDF export')
1266 );
1267
1268 let headerText = document.getElementById('panoramaHeader').textContent;
1269
1270 const restorePdfLightTheme = OCA.Analytics.Panorama.applyPdfLightTheme();
1271
1272 // hide the subheaders. will only take the text later
1273 const elements = document.querySelectorAll('.panoramaSubHeaderRow');
1274 elements.forEach(element => {
1275 element.classList.add('analyticsFullscreen');
1276 });
1277
1278 // getting "by analytics"
1279 let byAnalyticsImg = document.querySelector('#analytics-content-panorama #byAnalyticsImg');
1280 let byAnalyticsElement = document.querySelector('#analytics-content-panorama #byAnalytics');
1281 let byAnalyticsClass = byAnalyticsElement.classList.contains('analyticsFullscreen');
1282 const byAnalyticsStyles = {
1283 width: byAnalyticsImg.style.width,
1284 height: byAnalyticsImg.style.height,
1285 transform: byAnalyticsImg.style.transform,
1286 };
1287
1288 try {
1289 if (!byAnalyticsClass) {
1290 byAnalyticsElement.classList.add('analyticsFullscreen');
1291 }
1292
1293 // Temporarily reset styles for the branding image capture.
1294 byAnalyticsImg.style.width = byAnalyticsImg.naturalWidth + 'px';
1295 byAnalyticsImg.style.height = byAnalyticsImg.naturalHeight + 'px';
1296 byAnalyticsImg.style.transform = 'none';
1297
1298 let byAnalyticsCanvas = await html2canvas(byAnalyticsImg, {scale: 1});
1299 let byAnalyticsRawData = byAnalyticsCanvas.toDataURL('image/png');
1300

Callers

nothing calls this directly

Calls 10

containsMethod · 0.80
toDataURLMethod · 0.80
setPropertiesMethod · 0.80
setFontSizeMethod · 0.80
addImageMethod · 0.80
saveMethod · 0.80
tFunction · 0.50
addMethod · 0.45
textMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected