Skip to content

Commit ea77e24

Browse files
feat(core): Merge pull request #161 from mindfiredigital/dev
release
2 parents 83fadda + 36628c2 commit ea77e24

File tree

3 files changed

+4
-132
lines changed

3 files changed

+4
-132
lines changed

packages/angular/dist/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@mindfiredigital/page-builder-angular",
3-
"version": "4.0.7",
3+
"version": "4.0.8",
44
"private": true,
55
"description": "Angular wrapper for @mindfiredigital/page-builder",
66
"main": "dist/index.js",

packages/core/dist/PageBuilder.js

Lines changed: 3 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -224,134 +224,12 @@ export class PageBuilder {
224224
});
225225
}
226226
}
227-
// public setupExportPDFButton() {
228-
// const exportButton = document.getElementById('export-pdf-btn');
229-
// if (exportButton) {
230-
// exportButton.addEventListener('click', async () => {
231-
// showNotification('Generating PDF for download...');
232-
// await new Promise(resolve => setTimeout(resolve, 1500));
233-
// const tempContainer = document.createElement('div');
234-
// try {
235-
// const worker = html2pdf();
236-
// if (!worker) {
237-
// showNotification('html2pdf library not loaded');
238-
// return;
239-
// }
240-
// const htmlGenerator = new HTMLGenerator(new Canvas());
241-
// const contentHTML = htmlGenerator.generateHTML();
242-
// let css = htmlGenerator.generateCSS();
243-
// const canvasElement = document.getElementById('canvas');
244-
// const sidebarElement = document.getElementById('sidebar');
245-
// if (!canvasElement) return;
246-
// const MARGIN_MM = 4;
247-
// let canvasWidth: number;
248-
// if (PageBuilder.initialCanvasWidth === null) {
249-
// const rect = canvasElement.getBoundingClientRect();
250-
// if (sidebarElement) {
251-
// canvasWidth =
252-
// rect.width + sidebarElement?.getBoundingClientRect().width;
253-
// } else {
254-
// canvasWidth = rect.width;
255-
// }
256-
// PageBuilder.initialCanvasWidth = canvasWidth;
257-
// } else {
258-
// canvasWidth = PageBuilder.initialCanvasWidth;
259-
// }
260-
// css = css.replace(/min-height:\s*100vh/gi, 'min-height: auto');
261-
// const pdfContent = `
262-
// <style>
263-
// ${css}
264-
// * { box-sizing: border-box; }
265-
// html, body, #pdf-wrapper {
266-
// margin: 0; padding: 0;
267-
// overflow: visible !important;
268-
// font-family: Arial, sans-serif !important;
269-
// background-color: white !important;
270-
// }
271-
// /* CRITICAL VERTICAL FIX: Ensure auto height for full expansion */
272-
// #pdf-wrapper {
273-
// width: ${canvasWidth}px !important;
274-
// height: auto !important;
275-
// overflow: visible !important;
276-
// transform: none !important;
277-
// }
278-
// #canvas.home {
279-
// width: ${canvasWidth}px !important;
280-
// height: auto !important;
281-
// min-height: auto !important;
282-
// transform: none !important;
283-
// position: relative !important;
284-
// margin: 0 !important;
285-
// padding: 0 !important;
286-
// overflow: visible !important;
287-
// }
288-
// /* Added for clean page breaking */
289-
// table, #pdf-wrapper, #canvas.home {
290-
// page-break-inside: avoid !important;
291-
// }
292-
// </style>
293-
// <div id="pdf-wrapper">
294-
// ${contentHTML}
295-
// </div>
296-
// `;
297-
// tempContainer.innerHTML = pdfContent;
298-
// tempContainer.style.cssText = `
299-
// position: absolute;
300-
// left: -99999px;
301-
// top: 0;
302-
// width: ${canvasWidth}px;
303-
// height: auto;
304-
// overflow: visible;
305-
// background-color: white;
306-
// `;
307-
// document.body.appendChild(tempContainer);
308-
// // Give a solid, but shorter, wait time.
309-
// await new Promise(resolve => setTimeout(resolve, 1500));
310-
// const sourceElement = tempContainer.querySelector('#pdf-wrapper') as HTMLElement;
311-
// if (!sourceElement) {
312-
// throw new Error("PDF source element (#pdf-wrapper) not found.");
313-
// }
314-
// await worker
315-
// .set({
316-
// filename: 'exported_page_download.pdf',
317-
// image: { type: 'png', quality: 1 },
318-
// html2canvas: {
319-
// scale: 3,
320-
// width: canvasWidth,
321-
// useCORS: true,
322-
// logging: false,
323-
// backgroundColor: null,
324-
// letterRendering: true,
325-
// allowTaint: true,
326-
// },
327-
// jsPDF: {
328-
// unit: 'mm',
329-
// format: 'a4',
330-
// orientation: 'portrait',
331-
// },
332-
// margin: MARGIN_MM,
333-
// })
334-
// .from(sourceElement)
335-
// .save();
336-
// showNotification('PDF downloaded successfully!');
337-
// } catch (error) {
338-
// console.error('PDF generation error:', error);
339-
// showNotification('Error generating PDF. Check console for details.');
340-
// } finally {
341-
// if (document.body.contains(tempContainer)) {
342-
// document.body.removeChild(tempContainer);
343-
// }
344-
// }
345-
// });
346-
// }
347-
// }
348227
setupExportPDFButton() {
349228
const exportButton = document.getElementById('export-pdf-btn');
350229
if (exportButton) {
351230
exportButton.addEventListener('click', () =>
352231
__awaiter(this, void 0, void 0, function* () {
353232
showNotification('Generating PDF for download...');
354-
// Note: Keeping this initial delay for stability
355233
yield new Promise(resolve => setTimeout(resolve, 1500));
356234
const tempContainer = document.createElement('div');
357235
try {
@@ -365,21 +243,16 @@ export class PageBuilder {
365243
let css = htmlGenerator.generateCSS();
366244
const canvasElement = document.getElementById('canvas');
367245
if (!canvasElement) return;
368-
// 1. GET TRUE CONTENT DIMENSIONS (CRUCIAL FIX)
369-
// Use scroll dimensions to get the full size of the content, even if it's off-screen.
370246
const contentWidth = canvasElement.scrollWidth;
371247
const contentHeight = canvasElement.scrollHeight;
372-
// 2. CALCULATE UNIFIED SHRINK FACTOR
373-
const A4_WIDTH_PX = 794; // A4 width at 96 DPI
374-
const A4_HEIGHT_PX = 1123; // A4 height at 96 DPI
375-
const MARGIN_BUFFER_PX = 40; // Small buffer for margins
248+
const A4_WIDTH_PX = 794;
249+
const A4_HEIGHT_PX = 1123;
250+
const MARGIN_BUFFER_PX = 40;
376251
const QUALITY_SCALE = 3;
377-
// Calculate factor needed to shrink content to fit A4 usable area
378252
const widthScaleFactor =
379253
(A4_WIDTH_PX - MARGIN_BUFFER_PX) / contentWidth;
380254
const heightScaleFactor =
381255
(A4_HEIGHT_PX - MARGIN_BUFFER_PX) / contentHeight;
382-
// Use the smallest factor (width or height) to ensure ALL content fits on one page.
383256
const SHRINK_FACTOR = Math.min(
384257
widthScaleFactor,
385258
heightScaleFactor,

packages/core/src/PageBuilder.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ export class PageBuilder {
234234
if (exportButton) {
235235
exportButton.addEventListener('click', async () => {
236236
showNotification('Generating PDF for download...');
237-
// Note: Keeping this initial delay for stability
238237
await new Promise(resolve => setTimeout(resolve, 1500));
239238

240239
const tempContainer = document.createElement('div');

0 commit comments

Comments
 (0)