Shipping labels are a small problem that shows up every day for online sellers. Marketplaces like Meesho, Flipkart and Amazon give sellers a full A4 PDF where the actual label is just one part of the page. Sellers who use thermal printers need only that 4x6 inch part.
Many online tools solve this by uploading your PDF to a server. That is a privacy problem, because a label contains a customer's name, phone number and address. A better approach is to process the file entirely in the browser. This post shows how that works.
Why client-side processing?
Privacy: the file never leaves the user's device.
Speed: no upload or download wait for large batches.
Cost: no server storage or processing bill.
Offline use: it can work as a PWA with no connection.
The basic idea
Read the file the user selected, using the File API.
Load it into a PDF library running in the browser.
Change the visible area of each page (the crop box).
Save the result and let the user download it.
A minimal example with pdf-lib
pdf-lib is a popular JavaScript library for editing PDFs in the browser.
javascript
import { PDFDocument } from 'pdf-lib';
async function cropLabels(file) {
const bytes = await file.arrayBuffer();
const pdf = await PDFDocument.load(bytes);
for (const page of pdf.getPages()) {
// Example coordinates only. Real label positions
// differ for each marketplace and must be measured.
const x = 20;
const y = 400;
const width = 288; // 4 inch = 288 pt
const height = 432; // 6 inch = 432 pt
page.setCropBox(x, y, width, height); }
const output = await pdf.save();
return new Blob([output], { type: 'application/pdf' });
}
Then trigger a download:
javascript
const blob = await cropLabels(selectedFile);
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'labels-cropped.pdf';
a.click();
URL.revokeObjectURL(url);
The hard part: finding the label
The code above uses fixed numbers, but in real life the label position changes between marketplaces, couriers and even PDF versions. To make it reliable you need to:
Extract text positions (for example with PDF.js) and look for markers like "Ship to" or a barcode area.
Detect the label box and calculate the crop area automatically.
Handle multi-page PDFs and pages with more than one label.
Test with real sample files from each marketplace.
Extra features that sellers actually use
Sorting labels by SKU, so packing is faster
A picklist page with the total quantity per SKU
Printing SKU, quantity or date on each label
Choosing the output size: 4x6, 4x4, 3x5 or A4
Privacy checklist for any tool that handles personal data
Open the browser DevTools Network tab and confirm no file is uploaded.
Read the privacy policy.
Check whether the app works offline.
See it in action
If you want to see this kind of workflow without writing code, SellerLabel is a free tool that crops labels in the browser. It has a dedicated page for Meesho label crop as well.
Takeaway
For anything involving personal documents, client-side processing is usually the better default. Modern browser APIs and libraries like pdf-lib make it practical. If you have built something similar, share your approach in the comments.
