Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix: Remove redundant PDF title header and clean up code

LearningCircuit74defd9496f1
diff --git a/src/local_deep_research/web/static/js/services/pdf.js b/src/local_deep_research/web/static/js/services/pdf.js
index 6ced7a397f..fa5228922e 100644
--- a/src/local_deep_research/web/static/js/services/pdf.js
+++ b/src/local_deep_research/web/static/js/services/pdf.js
@@ -20,8 +20,7 @@ async function generatePdf(title, content, metadata = {}) {
throw new Error('PDF generation libraries not loaded (html2canvas missing)');
}
- // Ensure title and content are strings
- title = String(title || 'Research Report');
+ // Ensure content is a string
content = String(content || '');
// Create a temporary container to render the markdown
@@ -126,30 +125,35 @@ async function generatePdf(title, content, metadata = {}) {
font-size: 12px;
color: #666;
}
+ .pdf-content a {
+ color: #0066cc;
+ text-decoration: underline;
+ }
</style>
- <div class="pdf-header">
- <h1>${title}</h1>
- </div>
- <div class="pdf-metadata">
- <p>Generated: ${new Date().toLocaleString()}</p>
- ${metadata.mode ? `<p>Mode: ${metadata.mode}</p>` : ''}
- ${metadata.iterations ? `<p>Search iterations: ${metadata.iterations}</p>` : ''}
- ${metadata.id ? `<p>Research ID: ${metadata.id}</p>` : ''}
- ${metadata.timestamp ? `<p>Research Date: ${new Date(metadata.timestamp).toLocaleString()}</p>` : ''}
- </div>
- <div class="pdf-body">
- ${window.marked ? window.marked.parse(content) : content}
- </div>
- <div class="pdf-footer">
- <p>Generated by Deep Research System</p>
+ <div class="pdf-body" id="pdf-body-content">
+ <!-- Content will be added after marked parsing -->
</div>
`;
// Add to the document body temporarily
document.body.appendChild(tempContainer);
+ // Now parse and add the content
+ const pdfBodyDiv = tempContainer.querySelector('#pdf-body-content');
+ if (pdfBodyDiv) {
+ if (window.marked && typeof window.marked.parse === 'function') {
+ pdfBodyDiv.innerHTML = window.marked.parse(content);
+ } else {
+ // marked.js not available - this is a critical error for PDF generation
+ document.body.removeChild(tempContainer);
+ throw new Error('Markdown parser (marked.js) not loaded. Cannot generate PDF.');
+ }
+ } else {
+ document.body.removeChild(tempContainer);
+ throw new Error('PDF body container not found in template');
+ }
+
try {
- console.log("Starting PDF generation...");
// Use the jsPDF library from the window object
const { jsPDF } = window.jspdf;
@@ -161,29 +165,40 @@ async function generatePdf(title, content, metadata = {}) {
const margin = 40;
const contentWidth = pdfWidth - 2 * margin;
- // Function to add page with header
- const addPageWithHeader = (pageNum) => {
- if (pageNum > 1) {
- pdf.addPage();
- }
+ // Add footer to page
+ const addFooterToCurrentPage = (pageNum) => {
pdf.setFontSize(8);
pdf.setTextColor(100, 100, 100);
- pdf.text(`Deep Research - ${title} - Page ${pageNum}`, margin, pdfHeight - 20);
+ pdf.text(`Page ${pageNum}`, margin, pdfHeight - 20);
};
// Process each element with a more optimized approach
- const contentDiv = tempContainer.querySelector('.pdf-body');
+ const contentDiv = tempContainer.querySelector('#pdf-body-content');
if (!contentDiv) {
throw new Error('PDF body container not found');
}
// Create a more efficient PDF generation approach that keeps text selectable
const elements = Array.from(contentDiv.children);
- let currentY = margin;
+ let currentY = margin; // Start position at margin
let pageNum = 1;
- // Add the first page with header
- addPageWithHeader(pageNum);
+ // Start with the first page
+ // Note: jsPDF starts with one page already, no need to add
+
+ // Add footer to first page
+ addFooterToCurrentPage(pageNum);
+
+ // If no elements found, try to add raw content
+ if (elements.length === 0) {
+ const rawContent = contentDiv.textContent || '';
+ if (rawContent) {
+ pdf.setFont('helvetica', 'normal');
+ pdf.setFontSize(11);
+ const lines = pdf.splitTextToSize(rawContent, contentWidth);
+ pdf.text(lines, margin, currentY);
+ }
+ }
// Process each element
for (const element of elements) {
@@ -194,53 +209,307 @@ async function generatePdf(title, content, metadata = {}) {
// Simple text content - handled directly by jsPDF for better text selection
if ((element.tagName === 'P' || element.tagName === 'DIV' || element.tagName === 'H1' ||
element.tagName === 'H2' || element.tagName === 'H3') &&
- !element.querySelector('img, canvas, svg, table') &&
- !element.innerHTML.includes('<')) {
+ !element.querySelector('img, canvas, svg, table')) {
- pdf.setFont('helvetica', element.tagName.startsWith('H') ? 'bold' : 'normal');
- pdf.setFontSize(element.tagName === 'H1' ? 18 : (element.tagName === 'H2' ? 16 : (element.tagName === 'H3' ? 14 : 11)));
- pdf.setTextColor(0, 0, 0);
+ // Special styling for headers
+ if (element.tagName.startsWith('H')) {
+ pdf.setFont('helvetica', 'bold');
+
+ // Add background for H1 and H2
+ if (element.tagName === 'H1' || element.tagName === 'H2') {
+ // Check if we need a new page for header
+ if (currentY + 30 > pdfHeight - margin) {
+ pageNum++;
+ pdf.addPage();
+ currentY = margin;
+ }
+
+ // Draw background rectangle
+ if (element.tagName === 'H1') {
+ pdf.setFillColor(0, 51, 102); // Dark blue for H1
+ pdf.rect(margin - 10, currentY, contentWidth + 20, 28, 'F');
+ pdf.setTextColor(255, 255, 255); // White text
+ pdf.setFontSize(18);
+ } else {
+ pdf.setFillColor(240, 240, 240); // Light gray for H2
+ pdf.rect(margin - 10, currentY + 2, contentWidth + 20, 22, 'F');
+ pdf.setTextColor(0, 51, 102); // Dark blue text
+ pdf.setFontSize(16);
+ }
+ } else {
+ pdf.setFontSize(14);
+ pdf.setTextColor(0, 51, 102); // Dark blue for H3
+ }
+ } else {
+ pdf.setFont('helvetica', 'normal');
+ pdf.setFontSize(11);
+ pdf.setTextColor(0, 0, 0);
+ }
+
+ // Check if element contains links
+ const links = element.querySelectorAll('a');
+ if (links.length > 0) {
+ // Process element with links
+ let currentX = margin;
+ let currentLine = currentY + 12;
+
+ // Process each child node
+ for (const node of element.childNodes) {
+ if (node.nodeType === Node.TEXT_NODE) {
+ // Regular text
+ const text = node.textContent;
+ if (text.trim()) {
+ const words = text.split(/\s+/);
+ for (const word of words) {
+ const wordWidth = pdf.getTextWidth(word + ' ');
+ if (currentX + wordWidth > pdfWidth - margin && currentX > margin) {
+ currentLine += 14;
+ currentX = margin;
+ if (currentLine > pdfHeight - margin) {
+ pageNum++;
+ pdf.addPage();
+ currentLine = margin;
+ }
+ }
+ pdf.setTextColor(0, 0, 0);
+ pdf.text(word + ' ', currentX, currentLine);
+ currentX += wordWidth;
+ }
+ }
+ } else if (node.tagName === 'A') {
+ // Link element
+ const linkText = node.textContent;
+ const linkUrl = node.href;
+ const linkWidth = pdf.getTextWidth(linkText + ' ');
+
+ if (currentX + linkWidth > pdfWidth - margin && currentX > margin) {
+ currentLine += 14;
+ currentX = margin;
+ if (currentLine > pdfHeight - margin) {
+ pageNum++;
+ pdf.addPage();
+ currentLine = margin;
+ }
+ }
+
+ // Add link with styled blue color
+ pdf.setTextColor(0, 102, 204);
+ pdf.textWithLink(linkText + ' ', currentX, currentLine, { url: linkUrl });
+
+ // Underline
+ pdf.setDrawColor(0, 102, 204);
+ pdf.setLineWidth(0.3);
+ pdf.line(currentX, currentLine + 2, currentX + linkWidth - 5, currentLine + 2);
+
+ currentX += linkWidth;
+ }
+ }
+
+ currentY = currentLine + 2;
+ if (element.tagName === 'P') currentY += 6; // Extra space after paragraphs
+ continue; // Skip the rest of the processing for this element
+ }
+ // No links, process as plain text
const text = element.textContent.trim();
if (!text) continue; // Skip empty text
- const textLines = pdf.splitTextToSize(text, contentWidth);
+ // Special handling for text with citation links like [[ref]](url) or [ref](url) in plain text
+ if ((text.includes('[[') && text.includes('](')) || (text.includes('[') && text.includes(']('))) {
+ // Process text with citation links - handle both [[ref]](url) and [ref](url) formats
+ const citationRegex = /\[?\[([^\]]+)\]\]?\(([^)]+)\)/g;
+ let lastIndex = 0;
+ let currentX = margin;
+ let lineStarted = false;
+
+ const processTextSegment = (segment) => {
+ if (!segment) return;
+
+ const words = segment.split(' ');
+ for (const word of words) {
+ const wordWidth = pdf.getTextWidth(word + ' ');
+
+ // Check if word fits on current line
+ if (currentX + wordWidth > pdfWidth - margin && lineStarted) {
+ currentY += 14;
+ currentX = margin;
+ lineStarted = false;
+
+ // Check for new page
+ if (currentY + 14 > pdfHeight - margin) {
+ pageNum++;
+ pdf.addPage();
+ currentY = margin;
+ }
+ }
+
+ pdf.setTextColor(0, 0, 0);
+ pdf.text(word + ' ', currentX, currentY + 12);
+ currentX += wordWidth;
+ lineStarted = true;
+ }
+ };
- // Check if we need a new page
- if (currentY + (textLines.length * 14) > pdfHeight - margin) {
- pageNum++;
- addPageWithHeader(pageNum);
- currentY = margin;
- }
+ let match;
+ while ((match = citationRegex.exec(text)) !== null) {
+ // Process text before citation
+ if (match.index > lastIndex) {
+ processTextSegment(text.substring(lastIndex, match.index));
+ }
+
+ // Process citation link
+ const citationText = `[${match[1]}]`;
+ const citationUrl = match[2];
+ const citationWidth = pdf.getTextWidth(citationText);
+
+ // Check if citation fits on current line
+ if (currentX + citationWidth > pdfWidth - margin && lineStarted) {
+ currentY += 14;
+ currentX = margin;
+ lineStarted = false;
+
+ if (currentY + 14 > pdfHeight - margin) {
+ pageNum++;
+ pdf.addPage();
+ currentY = margin;
+ }
+ }
+
+ // Add citation as clickable link
+ pdf.setTextColor(0, 102, 204);
+ pdf.textWithLink(citationText, currentX, currentY + 12, { url: citationUrl });
+
+ // Underline
+ pdf.setDrawColor(0, 102, 204);
+ pdf.setLineWidth(0.3);
+ pdf.line(currentX, currentY + 14, currentX + citationWidth, currentY + 14);
+
+ currentX += citationWidth;
+ lineStarted = true;
+ lastIndex = match.index + match[0].length;
+ }
+
+ // Process remaining text
+ if (lastIndex < text.length) {
+ processTextSegment(text.substring(lastIndex));
+ }
- pdf.text(textLines, margin, currentY + 12);
- currentY += (textLines.length * 14) + 10;
+ currentY += 14;
+ if (element.tagName === 'P') currentY += 6; // Extra space after paragraphs
+ } else {
+ // No citation links, process normally
+ const textLines = pdf.splitTextToSize(text, contentWidth);
+
+ // Check if we need a new page
+ if (currentY + (textLines.length * 14) > pdfHeight - margin) {
+ pageNum++;
+ pdf.addPage();
+ currentY = margin;
+ }
+
+ // Adjust text position for headers with background
+ let textY = currentY + 12;
+ if (element.tagName === 'H1') {
+ textY = currentY + 18; // Center text in H1 background
+ } else if (element.tagName === 'H2') {
+ textY = currentY + 16; // Center text in H2 background
+ }
+
+ pdf.text(textLines, margin, textY);
+
+ // Adjust currentY based on element type
+ if (element.tagName === 'H1') {
+ currentY += 36; // Account for background height + spacing
+ } else if (element.tagName === 'H2') {
+ currentY += 32; // Account for background height + spacing
+ } else if (element.tagName === 'H3') {
+ currentY += (textLines.length * 14) + 8; // Extra space after H3
+ } else {
+ currentY += (textLines.length * 14);
+ if (element.tagName === 'P') currentY += 6; // Extra space after paragraphs
+ }
+ }
}
// List elements - handle bullets and numbering
else if (element.tagName === 'UL' || element.tagName === 'OL') {
const listItems = Array.from(element.querySelectorAll('li'));
for (let i = 0; i < listItems.length; i++) {
const item = listItems[i];
- const itemText = item.textContent.trim();
- if (!itemText) continue;
pdf.setFont('helvetica', 'normal');
pdf.setFontSize(11);
pdf.setTextColor(0, 0, 0);
const bulletPoint = element.tagName === 'UL' ? '•' : `${i + 1}.`;
- const textWithBullet = `${bulletPoint} ${itemText}`;
- const textLines = pdf.splitTextToSize(textWithBullet, contentWidth - 10);
+ const indentX = margin + 15; // Indent for list items
// Check if we need a new page
- if (currentY + (textLines.length * 14) > pdfHeight - margin) {
+ if (currentY + 14 > pdfHeight - margin) {
pageNum++;
- addPageWithHeader(pageNum);
+ pdf.addPage();
currentY = margin;
}
- pdf.text(textLines, margin, currentY + 12);
- currentY += (textLines.length * 14) + 5;
+ // Draw bullet/number
+ pdf.text(bulletPoint, margin, currentY + 12);
+
+ // Process list item content (may contain links)
+ const links = item.querySelectorAll('a');
+ if (links.length > 0) {
+ // List item with links
+ let currentX = indentX;
+ let lineY = currentY + 12;
+
+ for (const node of item.childNodes) {
+ if (node.nodeType === Node.TEXT_NODE) {
+ const text = node.textContent.trim();
+ if (text) {
+ const textWidth = pdf.getTextWidth(text + ' ');
+ if (currentX + textWidth > pdfWidth - margin && currentX > indentX) {
+ lineY += 14;
+ currentX = indentX;
+ if (lineY > pdfHeight - margin) {
+ pageNum++;
+ pdf.addPage();
+ lineY = margin + 12;
+ }
+ }
+ pdf.setTextColor(0, 0, 0);
+ pdf.text(text + ' ', currentX, lineY);
+ currentX += textWidth;
+ }
+ } else if (node.tagName === 'A') {
+ const linkText = node.textContent;
+ const linkUrl = node.href;
+ const linkWidth = pdf.getTextWidth(linkText + ' ');
+
+ if (currentX + linkWidth > pdfWidth - margin && currentX > indentX) {
+ lineY += 14;
+ currentX = indentX;
+ if (lineY > pdfHeight - margin) {
+ pageNum++;
+ pdf.addPage();
+ lineY = margin + 12;
+ }
+ }
+
+ pdf.setTextColor(0, 102, 204);
+ pdf.textWithLink(linkText + ' ', currentX, lineY, { url: linkUrl });
+ pdf.setDrawColor(0, 102, 204);
+ pdf.setLineWidth(0.3);
+ pdf.line(currentX, lineY + 2, currentX + linkWidth - 5, lineY + 2);
+ currentX += linkWidth;
+ }
+ }
+ currentY = lineY + 5;
+ } else {
+ // Plain text list item
+ const itemText = item.textContent.trim();
+ const textLines = pdf.splitTextToSize(itemText, contentWidth - 25);
+
+ pdf.text(textLines, indentX, currentY + 12);
+ currentY += (textLines.length * 14) + 5;
+ }
}
currentY += 5; // Add some space after the list
}
@@ -249,10 +518,31 @@ async function generatePdf(title, content, metadata = {}) {
const rows = Array.from(element.querySelectorAll('tr'));
if (rows.length === 0) continue;
- // Get header cells
+ // Check if we need multiple pages for wide tables
const headerCells = Array.from(rows[0].querySelectorAll('th, td'));
const colCount = headerCells.length || 1;
- const colWidth = contentWidth / colCount;
+
+ // For wide tables, use smaller font and narrower columns
+ let fontSize = 10;
+ let cellPadding = 5;
+ if (colCount > 4) {
+ fontSize = 8;
+ cellPadding = 3;
+ }
+
+ // Calculate column widths - make them proportional to content
+ const colWidths = [];
+ let totalWidth = contentWidth;
+
+ // For tables with many columns, allow some overflow
+ if (colCount > 3) {
+ totalWidth = Math.min(contentWidth, pdfWidth - 20);
+ }
+
+ const baseColWidth = totalWidth / colCount;
+ for (let i = 0; i < colCount; i++) {
+ colWidths.push(baseColWidth);
+ }
// Start table at current position
let tableY = currentY;
@@ -260,82 +550,125 @@ async function generatePdf(title, content, metadata = {}) {
// Check if we need a new page
if (tableY + 20 > pdfHeight - margin) {
pageNum++;
- addPageWithHeader(pageNum);
+ pdf.addPage();
tableY = margin;
}
// Draw header background
- pdf.setFillColor(240, 240, 240);
- pdf.rect(margin, tableY, contentWidth, 20, 'F');
+ pdf.setFillColor(0, 51, 102);
+ pdf.rect(margin - 10, tableY, totalWidth + 20, 25, 'F');
// Draw header text
pdf.setFont("helvetica", "bold");
- pdf.setFontSize(10);
- pdf.setTextColor(0, 0, 0);
+ pdf.setFontSize(fontSize);
+ pdf.setTextColor(255, 255, 255);
+ let headerHeight = 25;
headerCells.forEach((cell, index) => {
const text = cell.textContent.trim();
- const x = margin + (index * colWidth) + 5;
- pdf.text(text, x, tableY + 13);
+ let x = margin;
+ for (let i = 0; i < index; i++) {
+ x += colWidths[i];
+ }
+
+ // Wrap text in cells
+ const cellText = pdf.splitTextToSize(text, colWidths[index] - 2 * cellPadding);
+ pdf.text(cellText, x + cellPadding, tableY + 15);
+
+ // Track max height needed
+ const cellHeight = cellText.length * (fontSize + 2) + 10;
+ headerHeight = Math.max(headerHeight, cellHeight);
});
// Draw horizontal line after header
pdf.setDrawColor(200, 200, 200);
pdf.setLineWidth(0.5);
- pdf.line(margin, tableY + 20, margin + contentWidth, tableY + 20);
+ pdf.line(margin - 10, tableY + headerHeight, margin + totalWidth + 10, tableY + headerHeight);
- tableY += 20;
+ tableY += headerHeight;
// Draw table rows
pdf.setFont("helvetica", "normal");
+ pdf.setFontSize(fontSize);
+
for (let i = 1; i < rows.length; i++) {
+ // Get cells for this row
+ const cells = Array.from(rows[i].querySelectorAll('td, th'));
+
+ // Calculate row height based on content
+ let rowHeight = 20;
+ const cellContents = [];
+
+ cells.forEach((cell, index) => {
+ const text = cell.textContent.trim();
+ const wrappedText = pdf.splitTextToSize(text, colWidths[index] - 2 * cellPadding);
+ cellContents.push(wrappedText);
+ const cellHeight = wrappedText.length * (fontSize + 2) + 10;
+ rowHeight = Math.max(rowHeight, cellHeight);
+ });
+
// Check if we need a new page
- if (tableY + 20 > pdfHeight - margin) {
+ if (tableY + rowHeight > pdfHeight - margin) {
pageNum++;
- addPageWithHeader(pageNum);
+ pdf.addPage();
tableY = margin;
// Redraw header on new page
- pdf.setFillColor(240, 240, 240);
- pdf.rect(margin, tableY, contentWidth, 20, 'F');
+ pdf.setFillColor(0, 51, 102);
+ pdf.rect(margin - 10, tableY, totalWidth + 20, 25, 'F');
pdf.setFont("helvetica", "bold");
+ pdf.setTextColor(255, 255, 255);
headerCells.forEach((cell, index) => {
const text = cell.textContent.trim();
- const x = margin + (index * colWidth) + 5;
- pdf.text(text, x, tableY + 13);
+ let x = margin;
+ for (let j = 0; j < index; j++) {
+ x += colWidths[j];
+ }
+ const cellText = pdf.splitTextToSize(text, colWidths[index] - 2 * cellPadding);
+ pdf.text(cellText, x + cellPadding, tableY + 15);
});
- pdf.line(margin, tableY + 20, margin + contentWidth, tableY + 20);
- tableY += 20;
+ pdf.line(margin - 10, tableY + 25, margin + totalWidth + 10, tableY + 25);
+ tableY += 25;
pdf.setFont("helvetica", "normal");
+ pdf.setTextColor(0, 0, 0);
}
- // Get cells for this row
- const cells = Array.from(rows[i].querySelectorAll('td, th'));
+ // Alternate row background
+ if (i % 2 === 0) {
+ pdf.setFillColor(245, 245, 245);
+ pdf.rect(margin - 10, tableY, totalWidth + 20, rowHeight, 'F');
+ }
// Draw cell content
- cells.forEach((cell, index) => {
- const text = cell.textContent.trim();
- if (!text) return;
-
- const x = margin + (index * colWidth) + 5;
- pdf.text(text, x, tableY + 13);
+ pdf.setTextColor(0, 0, 0);
+ cellContents.forEach((content, index) => {
+ let x = margin;
+ for (let j = 0; j < index; j++) {
+ x += colWidths[j];
+ }
+ pdf.text(content, x + cellPadding, tableY + 12);
});
// Draw horizontal line after row
- pdf.line(margin, tableY + 20, margin + contentWidth, tableY + 20);
- tableY += 20;
+ pdf.setDrawColor(220, 220, 220);
+ pdf.line(margin - 10, tableY + rowHeight, margin + totalWidth + 10, tableY + rowHeight);
+ tableY += rowHeight;
}
// Draw vertical lines
+ pdf.setDrawColor(220, 220, 220);
+ let xPos = margin - 10;
for (let i = 0; i <= colCount; i++) {
- const x = margin + (i * colWidth);
- pdf.line(x, currentY, x, tableY);
+ pdf.line(xPos, currentY, xPos, tableY);
+ if (i < colCount) {
+ xPos += colWidths[i];
+ }
}
// Update current position to after the table
- currentY = tableY + 10;
+ currentY = tableY + 15;
}
// Code blocks - render with monospace font and background
else if (element.tagName === 'PRE' || element.querySelector('pre')) {
@@ -364,7 +697,7 @@ async function generatePdf(title, content, metadata = {}) {
// Check if we need a new page
if (currentY + codeHeight > pdfHeight - margin) {
pageNum++;
- addPageWithHeader(pageNum);
+ pdf.addPage();
currentY = margin;
}
@@ -399,7 +732,7 @@ async function generatePdf(title, content, metadata = {}) {
// Check if we need a new page
if (currentY + imgHeight > pdfHeight - margin) {
pageNum++;
- addPageWithHeader(pageNum);
+ pdf.addPage();
currentY = margin;
}
@@ -427,7 +760,7 @@ async function generatePdf(title, content, metadata = {}) {
// Check if we need a new page
if (currentY + (textLines.length * 14) > pdfHeight - margin) {
pageNum++;
- addPageWithHeader(pageNum);
+ pdf.addPage();
currentY = margin;
}
@@ -449,14 +782,13 @@ async function generatePdf(title, content, metadata = {}) {
if (currentY + imgHeight > pdfHeight - margin) {
pageNum++;
- addPageWithHeader(pageNum);
+ pdf.addPage();
currentY = margin;
}
pdf.addImage(imgData, 'PNG', margin, currentY, imgWidth, imgHeight);
currentY += imgHeight + 10;
} catch (canvasError) {
- console.error('Error rendering complex element:', canvasError);
pdf.text("[Content could not be rendered]", margin, currentY + 12);
currentY += 20;
}
@@ -471,7 +803,6 @@ async function generatePdf(title, content, metadata = {}) {
// Generate the PDF blob
const blob = pdf.output('blob');
- console.log("PDF generation completed successfully");
return blob;
} catch (error) {
console.error('Error in PDF generation:', error);
@@ -493,7 +824,6 @@ async function generatePdf(title, content, metadata = {}) {
*/
async function downloadPdf(titleOrData, content, metadata = {}) {
try {
- console.log("Starting PDF download process...");
let title, pdfContent, pdfMetadata;
@@ -503,7 +833,6 @@ async function downloadPdf(titleOrData, content, metadata = {}) {
const researchData = titleOrData;
const researchId = content; // Second parameter is research ID in this case
- console.log("Processing research data object", { researchId });
// Extract title from research data
title = researchData.query || researchData.title || researchData.prompt || `Research ${researchId}`;
@@ -542,10 +871,10 @@ async function downloadPdf(titleOrData, content, metadata = {}) {
.replace(/\n{3,}/g, '\n\n'); // Normalize excessive newlines
} else {
// Last resort: stringify the entire object
- console.warn("Could not find content in research data, using JSON stringification");
pdfContent = JSON.stringify(researchData, null, 2);
}
+
// Extract metadata
pdfMetadata = {
mode: researchData.mode,
@@ -563,7 +892,6 @@ async function downloadPdf(titleOrData, content, metadata = {}) {
// Ensure title is a string
title = String(title || 'Research Report');
- console.log("PDF parameters prepared", { titleLength: title.length, contentLength: pdfContent?.length });
// Show loading indicator
const loadingIndicator = document.createElement('div');
@@ -600,7 +928,6 @@ async function downloadPdf(titleOrData, content, metadata = {}) {
document.body.removeChild(downloadLink);
URL.revokeObjectURL(url);
- console.log("PDF download process completed");
return true;
} catch (error) {
console.error('Error generating PDF:', error);
diff --git a/src/local_deep_research/web/templates/base.html b/src/local_deep_research/web/templates/base.html
index 5f9a694973..f6aa969e1c 100644
--- a/src/local_deep_research/web/templates/base.html
+++ b/src/local_deep_research/web/templates/base.html
@@ -7,7 +7,7 @@
<title>{% block title %}Deep Research System{% endblock %}</title>
<link rel="stylesheet" href="{{ url_for('research.serve_static', path='css/styles.css') }}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" integrity="sha512-Fo3rlrZj/k7ujTnHg4CGR2D7kSs0v4LLanw2qksYuRlEzO+tcaEPQogQ0KaoGN26/zrn20ImR1DfuLWnOo7aBA==" crossorigin="anonymous" referrerpolicy="no-referrer">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/github-dark.min.css" integrity="sha512-nVbtfXz0GkNOIiVnhIb+6rBS3jSkFMsszOl8X0OqhuvWDEQjMVCW7oKV3vyMelCfX3nhuCkDDQSb5kE4qi9JOQ==" crossorigin="anonymous" referrerpolicy="no-referrer">
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/github-dark.min.css" integrity="sha512-rO+olRTkcf304DQBxSWxln8JXCzTHlKnIdnMUwYvQa9/Jd4cQaNkItIUj6Z4nvW1dqK0SKXLbn9h4KwZTNtAyw==" crossorigin="anonymous" referrerpolicy="no-referrer">
{% block extra_head %}{% endblock %}
</head>
<body>
@@ -48,8 +48,8 @@
{% block templates %}{% endblock %}
<!-- Scripts -->
- <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.1/socket.io.min.js" integrity="sha512-s+NedSzEBxfi8oURfZ/h3AUzyj3QYrnMP0euRx5iR52QRnsV/bVexHa/Um/JbLzjWdGTmBZPufHyaEkb0dYUBw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
- <script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/marked.umd.min.js" integrity="sha512-A+vBvS3Pv7mTfH+kyV8uGRi8PGLaWKqQlXytN6pHzTTjWFGL1j+1U8ZlXBNTH9HZlUwWVdF0XjGCu4VCe7EwFA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.1/socket.io.min.js" integrity="sha512-iqRVtNB+t9O+epcgUTIPF+nklypcR23H1yR1NFM9kffn6/iBhZ9bTB6oKLaGMv8JE9UgjcwfBFg/eHC/VMws+g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/marked.umd.min.js" integrity="sha512-P0TPTfSkSA7/I3P0xjPz+qIrXojG8vEAU2EfFkaYFX7tdN1yeMM4ryUfuHHMKOugMpb+0bgYAmDl+2aN7Bogpg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js" integrity="sha512-bgHRAiTjGrzHzLyKOnpFvaEpGzJet3z4tZnXGjpsCcqOnAH6VGUx9frc5bcIhKTVLEiCO6vEhNAgx5jtLUYrfA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js" integrity="sha512-qZvrmS2ekKPF2mSznTQsxqPgnpkI4DNTlrdUmTzrDgektczlKNRRhy5X5AAOnx5S09ydFYWWNSfcEqDTTHgtNA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js" integrity="sha512-BNaRQnYJYiPSqHHDb58B0yaPfCu+Wgds8Gp/gU33kqBtgNS4tSPHuGibyoeqMV/TJlSKda6FXzoEyYGjTe+vXA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>