yashgori20 commited on
Commit
5bd6119
Β·
1 Parent(s): 9b4ad2b
Files changed (2) hide show
  1. app.py +1 -36
  2. templates/report.html +32 -3
app.py CHANGED
@@ -290,42 +290,7 @@ def download_html(report_id):
290
 
291
  return send_file(temp_path, as_attachment=True, download_name=filename, mimetype='text/html')
292
 
293
- @app.route('/download-pdf/<report_id>')
294
- def download_pdf(report_id):
295
- if report_id not in reports_store:
296
- return jsonify({'error': 'Report not found'}), 404
297
-
298
- try:
299
- report_data = reports_store[report_id]
300
-
301
- # Check if PDF generator is available
302
- if not pdf_gen.available:
303
- return jsonify({
304
- 'error': 'PDF generation not available. Install reportlab: pip install reportlab',
305
- 'alternative': 'Use browser print-to-PDF: Ctrl+P β†’ Save as PDF'
306
- }), 500
307
-
308
- pdf_data = pdf_gen.generate_pdf(report_data['html'])
309
-
310
- with tempfile.NamedTemporaryFile(suffix='.pdf', delete=False) as f:
311
- f.write(pdf_data)
312
- temp_path = f.name
313
-
314
- filename = f"seo_report_{report_data['url'].replace('https://', '').replace('http://', '').replace('/', '_')}.pdf"
315
-
316
- return send_file(temp_path, as_attachment=True, download_name=filename, mimetype='application/pdf')
317
-
318
- except ImportError as e:
319
- return jsonify({
320
- 'error': 'PDF generation requires additional libraries',
321
- 'solution': 'Run: pip install reportlab',
322
- 'alternative': 'Use browser print-to-PDF: Ctrl+P β†’ Save as PDF'
323
- }), 500
324
- except Exception as e:
325
- return jsonify({
326
- 'error': f'PDF generation failed: {str(e)}',
327
- 'alternative': 'Use browser print-to-PDF: Ctrl+P β†’ Save as PDF'
328
- }), 500
329
 
330
  def _analyze_with_gsc(url: str, competitor_domains: List[str]):
331
  """Analyze keywords using GSC as primary source"""
 
290
 
291
  return send_file(temp_path, as_attachment=True, download_name=filename, mimetype='text/html')
292
 
293
+ # PDF Download removed - now using browser print functionality
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
 
295
  def _analyze_with_gsc(url: str, competitor_domains: List[str]):
296
  """Analyze keywords using GSC as primary source"""
templates/report.html CHANGED
@@ -61,6 +61,8 @@
61
  display: flex;
62
  align-items: center;
63
  gap: 6px;
 
 
64
  }
65
 
66
  .action-btn:hover {
@@ -68,6 +70,33 @@
68
  font-size: 15px;
69
  }
70
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  .report-container {
72
  max-width: 1200px;
73
  margin: 0 auto;
@@ -147,9 +176,9 @@
147
  </div>
148
 
149
  <div class="action-buttons">
150
- <a href="/download-pdf/{{ report_id }}" class="action-btn primary">
151
- πŸ“‘ Download PDF
152
- </a>
153
  </div>
154
  </div>
155
  </div>
 
61
  display: flex;
62
  align-items: center;
63
  gap: 6px;
64
+ cursor: pointer;
65
+ font-family: inherit;
66
  }
67
 
68
  .action-btn:hover {
 
70
  font-size: 15px;
71
  }
72
 
73
+ /* Print-friendly styles */
74
+ @media print {
75
+ .header,
76
+ .action-buttons,
77
+ .action-btn {
78
+ display: none !important;
79
+ }
80
+
81
+ body {
82
+ background: white !important;
83
+ color: black !important;
84
+ }
85
+
86
+ .report-container {
87
+ background: white !important;
88
+ color: black !important;
89
+ box-shadow: none !important;
90
+ padding: 0 !important;
91
+ margin-top: 0 !important;
92
+ }
93
+
94
+ .section {
95
+ break-inside: avoid;
96
+ page-break-inside: avoid;
97
+ }
98
+ }
99
+
100
  .report-container {
101
  max-width: 1200px;
102
  margin: 0 auto;
 
176
  </div>
177
 
178
  <div class="action-buttons">
179
+ <button onclick="window.print()" class="action-btn primary">
180
+ πŸ“‘ Print to PDF
181
+ </button>
182
  </div>
183
  </div>
184
  </div>