canvas {
border: 2px dashed #a5b4fc; /* Light indigo border for canvas */
max-width: 100%;
height: auto;
}
.gradient-bg {
background: linear-gradient(135deg, #333333, #131b28); /* Purple to blue gradient */
}
const pdfInput = document.getElementById(“pdfInput”);
const pdfPassword = document.getElementById(“pdfPassword”);
const pdfCanvas = document.getElementById(“pdfCanvas”);
const loadBtn = document.getElementById(“loadBtn”);
const cropBtn = document.getElementById(“cropBtn”);
const downloadPngBtn = document.getElementById(“downloadPngBtn”);
const downloadJpgBtn = document.getElementById(“downloadJpgBtn”);
const printBtn = document.getElementById(“printBtn”);
const ctx = pdfCanvas.getContext(“2d”);
let pdfDoc = null;
let selectedFile = null;
// Enable Load button when a file is selected
pdfInput.addEventListener(“change”, (e) => {
const file = e.target.files[0];
if (file && file.type === “application/pdf”) {
selectedFile = file;
loadBtn.disabled = false;
}
});
// Load PDF when Load button is clicked
loadBtn.addEventListener(“click”, async () => {
if (selectedFile) {
const arrayBuffer = await selectedFile.arrayBuffer();
const password = pdfPassword.value || null;
try {
pdfDoc = await pdfjsLib.getDocument({ data: arrayBuffer, password })
.promise;
renderPage(1); // Render first page
cropBtn.disabled = false;
} catch (error) {
alert(“Error loading PDF: ” + error.message);
}
}
});
// Render PDF page on canvas with high resolution
async function renderPage(pageNum) {
const page = await pdfDoc.getPage(pageNum);
const scale = 3; // High resolution scale
const viewport = page.getViewport({ scale });
pdfCanvas.width = viewport.width;
pdfCanvas.height = viewport.height;
await page.render({
canvasContext: ctx,
viewport: viewport,
}).promise;
}
// Crop Aadhaar card from the bottom with high resolution
cropBtn.addEventListener(“click”, () => {
const croppedCanvas = document.createElement(“canvas”);
const croppedCtx = croppedCanvas.getContext(“2d”);
// Aadhaar card standard aspect ratio
const aadhaarAspectRatio = 3.54 / 1.44;
// Define cropping width dynamically (use 90% width for better cropping)
const cropWidth = pdfCanvas.width * 0.9;
const cropHeight = cropWidth / aadhaarAspectRatio;
// Crop from bottom
const startX = (pdfCanvas.width – cropWidth) / 2;
const startY = pdfCanvas.height – cropHeight – 20; // Moves crop area up
// Set canvas size to cropped Aadhaar size
croppedCanvas.width = cropWidth;
croppedCanvas.height = cropHeight;
// Draw cropped Aadhaar card
croppedCtx.drawImage(
pdfCanvas,
startX,
startY,
cropWidth,
cropHeight,
0,
0,
cropWidth,
cropHeight
);
// Replace original canvas content with cropped one
pdfCanvas.width = cropWidth;
pdfCanvas.height = cropHeight;
ctx.drawImage(croppedCanvas, 0, 0);
// Enable download and print buttons
downloadPngBtn.disabled = false;
downloadJpgBtn.disabled = false;
printBtn.disabled = false;
});
// Download as PNG (High Quality)
downloadPngBtn.addEventListener(“click”, () => {
const link = document.createElement(“a”);
link.download = “aadhaar_card.png”;
link.href = pdfCanvas.toDataURL(“image/png”, 1.0); // Maximum quality
link.click();
});
// Download as JPG (High Quality)
downloadJpgBtn.addEventListener(“click”, () => {
const link = document.createElement(“a”);
link.download = “aadhaar_card.jpg”;
link.href = pdfCanvas.toDataURL(“image/jpeg”, 1.0); // Maximum quality
link.click();
});
// Print (High Quality)
printBtn.addEventListener(“click”, () => {
const printWindow = window.open(“”);
const imgData = pdfCanvas.toDataURL(“image/png”, 1.0); // Maximum quality
printWindow.document.write(
`
`
);
printWindow.document.close();
printWindow.print();
});
Welcome to Crop and Print PAN Card PDF, your ultimate tool for effortlessly cropping and printing PAN cards from PDF files. We know how vital a PAN card is for financial and identity purposes, and we’re here to simplify the process of preparing it with precision and ease. Learn more about PAN card crop and print.
At Crop and Print PAN Card PDF, we’ve built a fast, reliable, and intuitive solution to help you extract perfectly sized PAN card images from any PDF—password-protected or not. Upload your file, crop it to the exact dimensions, and choose your preferred output: download as PNG or JPG, or print it instantly. Our sleek, responsive design ensures a smooth experience whether you’re on a phone, tablet, or desktop.
Our goal is to save you time and eliminate the hassle of manual editing. Whether you’re an individual preparing your PAN card for personal use or a professional managing multiple documents, Crop and Print PAN Card PDF delivers consistent, high-quality results with just a few clicks. Let us help you handle your PAN card needs efficiently—try it now and experience the difference!
Key Elements Included:
- Purpose: Focuses on cropping and printing PAN cards from PDFs.
- Features: Highlights support for PDFs (including password-protected ones), cropping accuracy, and output options (PNG, JPG, print).
- Benefits: Emphasizes speed, simplicity, and quality.
- Design: Notes the modern, responsive interface.
- Audience: Appeals to both individuals and professionals.
Popular Tools | TextFixerOnline
.tool-card:hover {
transform: translateY(-4px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}
Popular Tools | TextFixerOnline
.tool-card:hover {
transform: translateY(-4px);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}
My Name is Sourav Mukherjee. I am a Website Developer and SEO Expart. AllBestTool.com is a browser-based collection of free online utilities — everything from PDF converters and text tools to SEO helpers and calculators. The idea is pretty simple: make a bunch of useful web tools available in one place without requiring users to sign up.
Latest posts by allbesttool.com
(see all)