-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint-without-black.html
More file actions
401 lines (343 loc) · 18.4 KB
/
print-without-black.html
File metadata and controls
401 lines (343 loc) · 18.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/svg+xml" href="favicon.svg">
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32x32.png">
<link rel="apple-touch-icon" sizes="180x180" href="apple-touch-icon.png">
<title>Print Without Black Ink — Free PDF Color Converter | tools.treble.dev</title>
<meta name="description" content="Out of black ink? Convert your PDF so it prints using only color ink cartridges. Choose deep blue, green, or violet as your substitute. 100% free, browser-based — no uploads, no accounts.">
<meta name="keywords" content="print without black ink, convert pdf to color, out of black ink print, empty black cartridge, print pdf without black, pdf color converter free">
<link rel="canonical" href="https://tools.treble.dev/print-without-black.html">
<!-- Open Graph -->
<meta property="og:type" content="website">
<meta property="og:site_name" content="tools.treble.dev">
<meta property="og:title" content="Print Without Black Ink — Free PDF Color Converter">
<meta property="og:description" content="Out of black ink? Convert your PDF to print using only color cartridges — free, private, no uploads. Everything runs in your browser.">
<meta property="og:url" content="https://tools.treble.dev/print-without-black.html">
<!-- Twitter Card -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:title" content="Print Without Black Ink — Free PDF Color Converter">
<meta name="twitter:description" content="Out of black ink? Convert your PDF to print using only color cartridges — free, private, no uploads. Everything runs in your browser.">
<meta name="twitter:image" content="https://tools.treble.dev/og-image.png">
<!-- Open Graph image -->
<meta property="og:image" content="https://tools.treble.dev/og-image.png">
<meta property="og:image:width" content="1200">
<meta property="og:image:height" content="630">
<meta property="og:image:alt" content="tools.treble.dev — Free. Private. Browser-Based.">
<!-- PWA / theme -->
<link rel="manifest" href="manifest.json">
<meta name="theme-color" content="#004aad">
<script src="vendor/pdfjs/pdf.min.js"></script>
<script src="vendor/jspdf/jspdf.umd.min.js"></script>
<!-- Structured data: SoftwareApplication -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "SoftwareApplication",
"name": "Print Without Black Ink — PDF Color Converter",
"description": "Convert your PDF to print using only color ink cartridges when your black ink is empty. All processing happens locally in your browser — no uploads, no accounts, completely free.",
"applicationCategory": "UtilitiesApplication",
"operatingSystem": "Web Browser",
"url": "https://tools.treble.dev/print-without-black.html",
"offers": {
"@type": "Offer",
"price": "0",
"priceCurrency": "USD"
},
"featureList": [
"Convert black PDF content to a printable color substitute",
"Choose from deep indigo, forest green, maroon, or deep violet",
"Force monochrome mode or smart-mode to preserve existing colors",
"Multi-page PDF support with side-by-side preview",
"Adjustable render scale and JPEG compression",
"100% browser-based — no uploads, no accounts"
]
}
</script>
<script type="application/ld+json">
{
"@context": "https://schema.org/",
"@type": "HowTo",
"name": "How to print a PDF when you are out of black ink",
"step": [
{
"@type": "HowToStep",
"position": 1,
"name": "Open your PDF",
"text": "Select your black and white PDF using the file picker. The file is loaded entirely in your browser — nothing is uploaded."
},
{
"@type": "HowToStep",
"position": 2,
"name": "Choose a replacement color",
"text": "Select a dark blue or dark grey color to replace the black ink channel."
},
{
"@type": "HowToStep",
"position": 3,
"name": "Download and print",
"text": "Download the processed PDF and print using the 'Color' setting on your printer."
}
]
}
</script>
<link rel="stylesheet" href="common.css">
<link rel="stylesheet" href="print-without-black/style.css">
</head>
<body>
<div class="container">
<header class="tool-header">
<a href="index.html" class="back-link">← All Tools</a>
<h1>🖨️ Print Without Black</h1>
<p class="hero-text">
Printer refusing to print because black ink is empty?<br>
Convert black-heavy PDF output to color-friendly ink combinations in your browser.
</p>
<div class="badge-container">
<span class="badge">100% Private</span>
<span class="badge">No Uploads</span>
<span class="badge">Free Forever</span>
</div>
</header>
<div class="controls-grid">
<div>
<label for="pdfInput">1. Select your PDF Document</label>
<input type="file" id="pdfInput" accept="application/pdf">
<div class="checkbox-group">
<input type="checkbox" id="forceGrayscale" checked>
<label for="forceGrayscale" style="margin:0; font-weight: normal;">
Force Monochrome (Convert entire document to target color)
</label>
</div>
<p class="help-text" style="margin-top:4px;">Uncheck this if your PDF has colors you want to keep, and you *only* want to change the black text.</p>
</div>
<div>
<label for="colorSelect">2. Choose Replacement Color</label>
<select id="colorSelect">
<option value="10,10,100">Deep Indigo (Best overall, uses Cyan + Magenta)</option>
<option value="0,100,0">Forest Green (Use if Magenta is empty)</option>
<option value="150,0,0">Maroon (Use if Cyan is empty)</option>
<option value="100,0,150">Deep Violet (Use if Yellow is empty)</option>
</select>
<details>
<summary>⚙️ Advanced Quality Settings</summary>
<div class="advanced-settings">
<div>
<label for="pdfScale">Render Scale: <span id="scaleVal">2.0</span>x</label>
<input type="range" id="pdfScale" value="2.0" min="1.0" max="4.0" step="0.5" style="width:100%;">
<p class="help-text">Higher scale = sharper text but much larger file sizes.</p>
<p class="warning-text">Warning: Setting this above 3.0 may cause the browser to freeze on long documents.</p>
</div>
<div>
<label for="pdfQuality">JPEG Compression: <span id="qualityVal">90</span>%</label>
<input type="range" id="pdfQuality" value="0.90" min="0.5" max="1.0" step="0.05" style="width:100%;">
<p class="help-text">Lower quality reduces file size but may introduce visual artifacts around text.</p>
</div>
</div>
</details>
</div>
</div>
<div class="btn-group">
<button class="btn btn-primary" id="previewBtn">Load & Preview</button>
<button class="btn btn-success" id="downloadBtn" disabled>Download Ready PDF</button>
</div>
<div id="status"></div>
<div class="workspace" id="workspace">
<div class="pagination">
<button class="btn btn-secondary" id="prevPageBtn" disabled>◀ Previous</button>
<span id="pageIndicator"><strong>Page 1 of ?</strong></span>
<button class="btn btn-secondary" id="nextPageBtn">Next ▶</button>
</div>
<div class="preview-panels">
<div class="panel">
<h3>Original</h3>
<canvas id="originalCanvas"></canvas>
</div>
<div class="panel">
<h3>Converted</h3>
<canvas id="previewCanvas"></canvas>
</div>
</div>
</div>
<!-- How to Use Section -->
<section class="how-to-section" aria-labelledby="how-to-heading">
<h2 id="how-to-heading">How to Print a PDF When You Are Out of Black Ink</h2>
<ol class="how-to-list">
<li><strong>Select your PDF</strong> — click the file input and choose the PDF you want to print. The file is loaded entirely in your browser; nothing is uploaded.</li>
<li><strong>Choose a replacement color</strong> — pick the color that matches the ink cartridges you have. Deep Indigo works well for most documents and uses cyan and magenta. If one color cartridge is also low, pick the option that avoids it.</li>
<li><strong>Preview the result</strong> — click "Load & Preview" to see the original and converted page side by side. Use the page navigation to check any page.</li>
<li><strong>Download and print</strong> — click "Download Ready PDF" to save the converted file. Open it and print using your printer's <em>Color</em> setting (not grayscale).</li>
</ol>
<p class="how-to-note">The "Force Monochrome" option converts the entire document to your chosen color. Uncheck it if your PDF has existing colors you want to keep — only dark gray and black pixels will be changed.</p>
<p class="how-to-note">All processing happens entirely in your browser. Your PDF is never sent to any server.</p>
</section>
</div>
<script>
// Initialize PDF.js
pdfjsLib.GlobalWorkerOptions.workerSrc = 'vendor/pdfjs/pdf.worker.min.js';
let loadedPdf = null;
let originalFileName = "document";
let currentPage = 1;
// UI Listeners for Advanced Settings
document.getElementById('pdfScale').addEventListener('input', (e) => {
document.getElementById('scaleVal').innerText = parseFloat(e.target.value).toFixed(1);
});
document.getElementById('pdfQuality').addEventListener('input', (e) => {
document.getElementById('qualityVal').innerText = Math.round(parseFloat(e.target.value) * 100);
});
// Color Tinting Logic
function applyColorTint(ctx, width, height, targetRGB, forceMonochrome) {
const imgData = ctx.getImageData(0, 0, width, height);
const data = imgData.data;
const [targetR, targetG, targetB] = targetRGB.split(',').map(Number);
for (let i = 0; i < data.length; i += 4) {
let r = data[i], g = data[i+1], b = data[i+2];
let gray = (r * 0.299 + g * 0.587 + b * 0.114);
if (forceMonochrome) {
// Map all grays to the target color gradient
data[i] = targetR + (255 - targetR) * (gray / 255);
data[i+1] = targetG + (255 - targetG) * (gray / 255);
data[i+2] = targetB + (255 - targetB) * (gray / 255);
} else {
// Smart mode: Only change dark/grayscale pixels. Preserve vibrant colors.
// Calculate saturation (how different the max and min RGB values are)
let max = Math.max(r, g, b);
let min = Math.min(r, g, b);
let saturation = max === 0 ? 0 : (max - min) / max;
// If it's desaturated (grayish) AND darkish, tint it
if (saturation < 0.25 && gray < 200) {
data[i] = targetR + (255 - targetR) * (gray / 255);
data[i+1] = targetG + (255 - targetG) * (gray / 255);
data[i+2] = targetB + (255 - targetB) * (gray / 255);
}
}
}
ctx.putImageData(imgData, 0, 0);
}
// Render a specific page to the UI
async function renderPageToUI(pageNum) {
if (!loadedPdf) return;
const statusDiv = document.getElementById('status');
const targetColor = document.getElementById('colorSelect').value;
const forceMonochrome = document.getElementById('forceGrayscale').checked;
try {
const page = await loadedPdf.getPage(pageNum);
const viewport = page.getViewport({ scale: 1.5 }); // Fixed scale for screen preview
// Setup Original Canvas
const origCanvas = document.getElementById('originalCanvas');
const origCtx = origCanvas.getContext('2d');
origCanvas.width = viewport.width;
origCanvas.height = viewport.height;
await page.render({ canvasContext: origCtx, viewport: viewport }).promise;
// Setup Converted Canvas
const prevCanvas = document.getElementById('previewCanvas');
const prevCtx = prevCanvas.getContext('2d', { willReadFrequently: true });
prevCanvas.width = viewport.width;
prevCanvas.height = viewport.height;
// Draw original onto preview canvas, then apply tint
prevCtx.drawImage(origCanvas, 0, 0);
applyColorTint(prevCtx, prevCanvas.width, prevCanvas.height, targetColor, forceMonochrome);
// Update Pagination UI
document.getElementById('pageIndicator').innerText = `Page ${pageNum} of ${loadedPdf.numPages}`;
document.getElementById('prevPageBtn').disabled = pageNum <= 1;
document.getElementById('nextPageBtn').disabled = pageNum >= loadedPdf.numPages;
} catch (err) {
console.error(err);
statusDiv.innerText = "Error rendering page.";
}
}
// Load PDF and initialize preview
document.getElementById('previewBtn').addEventListener('click', async () => {
const fileInput = document.getElementById('pdfInput');
const statusDiv = document.getElementById('status');
if (!fileInput.files.length) {
statusDiv.innerText = "Please select a PDF file first.";
return;
}
const file = fileInput.files[0];
originalFileName = file.name.replace('.pdf', '');
statusDiv.innerText = "Loading PDF...";
const fileReader = new FileReader();
fileReader.onload = async function() {
try {
const typedarray = new Uint8Array(this.result);
loadedPdf = await pdfjsLib.getDocument({ data: typedarray }).promise;
currentPage = 1;
await renderPageToUI(currentPage);
document.getElementById('workspace').style.display = 'block';
document.getElementById('downloadBtn').disabled = false;
statusDiv.innerText = "Preview generated! Adjust settings or download.";
} catch (error) {
console.error(error);
statusDiv.innerText = "Error loading PDF.";
}
};
fileReader.readAsArrayBuffer(file);
});
// Pagination Controls
document.getElementById('prevPageBtn').addEventListener('click', () => {
if (currentPage > 1) {
currentPage--;
renderPageToUI(currentPage);
}
});
document.getElementById('nextPageBtn').addEventListener('click', () => {
if (currentPage < loadedPdf.numPages) {
currentPage++;
renderPageToUI(currentPage);
}
});
// Download Full PDF
document.getElementById('downloadBtn').addEventListener('click', async () => {
if (!loadedPdf) return;
const statusDiv = document.getElementById('status');
const targetColor = document.getElementById('colorSelect').value;
const forceMonochrome = document.getElementById('forceGrayscale').checked;
const scale = parseFloat(document.getElementById('pdfScale').value);
const quality = parseFloat(document.getElementById('pdfQuality').value);
const { jsPDF } = window.jspdf;
document.getElementById('downloadBtn').disabled = true;
document.getElementById('previewBtn').disabled = true;
try {
let newPdf = null;
for (let pageNum = 1; pageNum <= loadedPdf.numPages; pageNum++) {
statusDiv.innerText = `Processing page ${pageNum} of ${loadedPdf.numPages}... (High Quality)`;
const page = await loadedPdf.getPage(pageNum);
const viewport = page.getViewport({ scale: scale });
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d', { willReadFrequently: true });
canvas.width = viewport.width;
canvas.height = viewport.height;
await page.render({ canvasContext: ctx, viewport: viewport }).promise;
applyColorTint(ctx, canvas.width, canvas.height, targetColor, forceMonochrome);
const pdfWidth = viewport.width / scale;
const pdfHeight = viewport.height / scale;
if (pageNum === 1) {
newPdf = new jsPDF({
orientation: pdfWidth > pdfHeight ? 'landscape' : 'portrait',
unit: 'pt',
format: [pdfWidth, pdfHeight]
});
} else {
newPdf.addPage([pdfWidth, pdfHeight], pdfWidth > pdfHeight ? 'landscape' : 'portrait');
}
const imgDataUrl = canvas.toDataURL('image/jpeg', quality);
newPdf.addImage(imgDataUrl, 'JPEG', 0, 0, pdfWidth, pdfHeight);
}
statusDiv.innerText = "Done! Check your downloads folder.";
const colorSelect = document.getElementById('colorSelect');
const colorName = colorSelect.options[colorSelect.selectedIndex].text.split(' ')[1];
newPdf.save(`${originalFileName}_${colorName}_Printable.pdf`);
} catch (error) {
console.error(error);
statusDiv.innerText = "An error occurred during download.";
} finally {
document.getElementById('downloadBtn').disabled = false;
document.getElementById('previewBtn').disabled = false;
}
});
</script>
</body>
</html>