React Native Requires Chilkat v11.7.0+
React Native
Tile a Watermark Across a PDF Page
See more PDF Watermark Examples
Demonstrates a tiled watermark, which repeats the stamp over the whole page instead of placing it once. Tiling overrides position.align; tile.spacingX and spacingY set the gaps, and tile.stagger offsets alternate rows by half a tile so the pattern does not line up in columns. A faint tiled stamp carrying the name or address is the usual way to mark a document so that a leaked copy can be traced back, and zOrder back keeps it behind the text where it does not hinder reading.Chilkat React Native Downloads
import { JsonObject, Pdf } from '@chilkat/react-native'
function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// The PDF used in this example is available at long_report.pdf
const pdf = new Pdf();
try {
pdf.loadFile('qa_data/pdf/long_report.pdf');
} catch {
console.log(pdf.lastErrorText);
return;
}
const json = new JsonObject();
json.updateString('type', 'text');
// {date:FORMAT} is replaced per page when the watermark is added. The other placeholders are
// {page}, {pages} and {filename}; {{ gives a literal brace.
json.updateString('text', 'jdoe@example.com {date:yyyy-MM-dd}');
json.updateString('id', 'trace');
json.updateString('zOrder', 'back');
json.updateNumber('font.size', '14');
json.updateNumber('opacity', '0.15');
json.updateNumber('rotation', '30');
json.updateBool('tile.enabled', true);
json.updateNumber('tile.spacingX', '60');
json.updateNumber('tile.spacingY', '80');
json.updateBool('tile.stagger', true);
const jsonOut = new JsonObject();
try {
pdf.watermark('add', json, jsonOut);
} catch {
console.log(pdf.lastErrorText);
return;
}
console.log(`id: ${jsonOut.stringOf('id')} pages: ${jsonOut.stringOf('pages')}`);
try {
pdf.writeFile('qa_output/report_traced.pdf');
} catch {
console.log(pdf.lastErrorText);
return;
}
// Sample output:
// id: trace pages: 1-3
}