Mohammed AL Sarraj Claude Sonnet 4.6 commited on
Commit
42bfd2a
Β·
1 Parent(s): 6030f8d

fix: replace html2pdf with window.print for text-based ATS-readable PDF export

Browse files

Remove html2pdf.js CDN (canvas-image renderer); replace with window.print()
and per-tool @media print visibility CSS. Rename button to 'Save as PDF'.
Tools updated: changelog_ai, schema_detective

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

app/tools/changelog_ai/templates/changelog_ai/index.html CHANGED
@@ -1,6 +1,17 @@
1
  {% extends "base.html" %}
2
  {% block title %}Changelog.ai β€” AI Release Notes Generator{% endblock %}
3
 
 
 
 
 
 
 
 
 
 
 
 
4
  {% block content %}
5
  <!-- Top Nav -->
6
  <header class="flex justify-between items-center px-6 w-full sticky top-0 z-50 bg-white/80 backdrop-blur-md h-16 border-b border-slate-200/60">
@@ -18,9 +29,10 @@
18
  </div>
19
  <div class="flex items-center gap-3">
20
  <button id="btn-download-pdf"
 
21
  class="hidden bg-white border border-slate-200 hover:border-slate-300 text-on-surface px-4 py-2 rounded-lg text-sm font-medium transition-all shadow-sm flex items-center gap-2">
22
  <span class="material-symbols-outlined text-sm" style="font-size:16px">picture_as_pdf</span>
23
- Download PDF
24
  </button>
25
  <button id="btn-copy-md"
26
  class="bg-primary hover:bg-primary-dim text-on-primary px-4 py-2 rounded-lg text-sm font-medium transition-all shadow-sm flex items-center gap-2">
@@ -197,7 +209,6 @@ refactor: clean up legacy charting utility"></textarea>
197
  {% endblock %}
198
 
199
  {% block extra_scripts %}
200
- <script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
201
  <script>
202
  (function () {
203
  const CSRF = document.querySelector('meta[name="csrf-token"]').content;
@@ -263,8 +274,6 @@ refactor: clean up legacy charting utility"></textarea>
263
  const RTL_LANGS = new Set(['ar']);
264
  function isRtl() { return RTL_LANGS.has(langSelect.value); }
265
 
266
- // html2pdf screenshots the DOM, so all languages/scripts render correctly.
267
-
268
  // ── Audience sync ─────────────────────────────────────────────────────────
269
  function setAudience(aud) {
270
  selectedAudience = aud;
@@ -440,22 +449,7 @@ refactor: clean up legacy charting utility"></textarea>
440
 
441
  function downloadPDF() {
442
  if (!lastResult) return;
443
- btnDownloadPdf.disabled = true;
444
- btnDownloadPdf.textContent = 'Generating…';
445
- const el = document.getElementById('results-state');
446
- const ver = versionInput.value.trim();
447
- const fname = (ver ? ver.replace(/\s+/g, '-') : 'changelog') + '-release-notes.pdf';
448
- html2pdf().set({
449
- margin: 10,
450
- filename: fname,
451
- image: { type: 'jpeg', quality: 0.98 },
452
- html2canvas: { scale: 2, useCORS: true, logging: false, backgroundColor: '#f8fafc' },
453
- jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
454
- pagebreak: { mode: ['avoid-all', 'css'] },
455
- }).from(el).save().then(() => {
456
- btnDownloadPdf.disabled = false;
457
- btnDownloadPdf.textContent = 'Download PDF';
458
- });
459
  }
460
  /* legacy jsPDF body
461
  function downloadPDF_legacy() {
 
1
  {% extends "base.html" %}
2
  {% block title %}Changelog.ai β€” AI Release Notes Generator{% endblock %}
3
 
4
+ {% block extra_head %}
5
+ <style>
6
+ @media print {
7
+ body * { visibility: hidden !important; }
8
+ #results-state, #results-state * { visibility: visible !important; }
9
+ #results-state { position: absolute; top: 0; left: 0; width: 100%; height: auto; }
10
+ body { height: auto !important; overflow: visible !important; }
11
+ }
12
+ </style>
13
+ {% endblock %}
14
+
15
  {% block content %}
16
  <!-- Top Nav -->
17
  <header class="flex justify-between items-center px-6 w-full sticky top-0 z-50 bg-white/80 backdrop-blur-md h-16 border-b border-slate-200/60">
 
29
  </div>
30
  <div class="flex items-center gap-3">
31
  <button id="btn-download-pdf"
32
+ title="Opens print dialog β€” choose Save as PDF for a text-based, ATS-readable file"
33
  class="hidden bg-white border border-slate-200 hover:border-slate-300 text-on-surface px-4 py-2 rounded-lg text-sm font-medium transition-all shadow-sm flex items-center gap-2">
34
  <span class="material-symbols-outlined text-sm" style="font-size:16px">picture_as_pdf</span>
35
+ Save as PDF
36
  </button>
37
  <button id="btn-copy-md"
38
  class="bg-primary hover:bg-primary-dim text-on-primary px-4 py-2 rounded-lg text-sm font-medium transition-all shadow-sm flex items-center gap-2">
 
209
  {% endblock %}
210
 
211
  {% block extra_scripts %}
 
212
  <script>
213
  (function () {
214
  const CSRF = document.querySelector('meta[name="csrf-token"]').content;
 
274
  const RTL_LANGS = new Set(['ar']);
275
  function isRtl() { return RTL_LANGS.has(langSelect.value); }
276
 
 
 
277
  // ── Audience sync ─────────────────────────────────────────────────────────
278
  function setAudience(aud) {
279
  selectedAudience = aud;
 
449
 
450
  function downloadPDF() {
451
  if (!lastResult) return;
452
+ window.print();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
453
  }
454
  /* legacy jsPDF body
455
  function downloadPDF_legacy() {
app/tools/schema_detective/templates/schema_detective/index.html CHANGED
@@ -1,6 +1,17 @@
1
  {% extends "base.html" %}
2
  {% block title %}Schema Detective β€” Database Schema Auditor{% endblock %}
3
 
 
 
 
 
 
 
 
 
 
 
 
4
  {% block content %}
5
  <!-- Top Nav -->
6
  <header class="flex justify-between items-center w-full px-6 py-3 h-16 bg-slate-50 sticky top-0 z-50 border-b border-slate-200 shrink-0">
@@ -14,9 +25,9 @@
14
  <button id="btn-clear" class="px-4 py-2 text-sm font-medium text-on-surface-variant hover:bg-surface-container rounded-lg transition-colors">
15
  Clear
16
  </button>
17
- <button id="btn-download-pdf" class="hidden items-center gap-2 px-4 py-2 bg-white border border-slate-200 hover:border-slate-300 rounded-lg text-sm font-medium text-on-surface shadow-sm transition-all">
18
  <span class="material-symbols-outlined" style="font-size:16px">picture_as_pdf</span>
19
- Download PDF
20
  </button>
21
  <button id="btn-audit" class="px-4 py-2 text-sm font-medium bg-primary text-on-primary rounded-lg shadow-sm hover:bg-primary-dim transition-colors">
22
  Run Audit
@@ -507,22 +518,8 @@ CREATE TABLE prescriptions (
507
  });
508
 
509
  btnDownloadPdf.addEventListener('click', () => {
510
- const el = document.getElementById('results-state');
511
- btnDownloadPdf.disabled = true;
512
- btnDownloadPdf.textContent = 'Generating...';
513
- html2pdf().set({
514
- margin: 8,
515
- filename: 'schema-audit.pdf',
516
- image: { type: 'jpeg', quality: 0.98 },
517
- html2canvas: { scale: 2, useCORS: true, logging: false, backgroundColor: '#ffffff' },
518
- jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
519
- pagebreak: { mode: ['avoid-all', 'css'] },
520
- }).from(el).save().then(() => {
521
- btnDownloadPdf.disabled = false;
522
- btnDownloadPdf.textContent = 'Download PDF';
523
- });
524
  });
525
  })();
526
  </script>
527
- <script src="https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js"></script>
528
  {% endblock %}
 
1
  {% extends "base.html" %}
2
  {% block title %}Schema Detective β€” Database Schema Auditor{% endblock %}
3
 
4
+ {% block extra_head %}
5
+ <style>
6
+ @media print {
7
+ body * { visibility: hidden !important; }
8
+ #results-state, #results-state * { visibility: visible !important; }
9
+ #results-state { position: absolute; top: 0; left: 0; width: 100%; height: auto; }
10
+ body { height: auto !important; overflow: visible !important; }
11
+ }
12
+ </style>
13
+ {% endblock %}
14
+
15
  {% block content %}
16
  <!-- Top Nav -->
17
  <header class="flex justify-between items-center w-full px-6 py-3 h-16 bg-slate-50 sticky top-0 z-50 border-b border-slate-200 shrink-0">
 
25
  <button id="btn-clear" class="px-4 py-2 text-sm font-medium text-on-surface-variant hover:bg-surface-container rounded-lg transition-colors">
26
  Clear
27
  </button>
28
+ <button id="btn-download-pdf" title="Opens print dialog β€” choose Save as PDF for a text-based, ATS-readable file" class="hidden items-center gap-2 px-4 py-2 bg-white border border-slate-200 hover:border-slate-300 rounded-lg text-sm font-medium text-on-surface shadow-sm transition-all">
29
  <span class="material-symbols-outlined" style="font-size:16px">picture_as_pdf</span>
30
+ Save as PDF
31
  </button>
32
  <button id="btn-audit" class="px-4 py-2 text-sm font-medium bg-primary text-on-primary rounded-lg shadow-sm hover:bg-primary-dim transition-colors">
33
  Run Audit
 
518
  });
519
 
520
  btnDownloadPdf.addEventListener('click', () => {
521
+ window.print();
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  });
523
  })();
524
  </script>
 
525
  {% endblock %}