watermark code cleanup
This commit is contained in:
parent
63e511e28f
commit
c9c895676a
@ -158,39 +158,16 @@ export class WatermarkScreenComponent implements OnInit {
|
||||
}
|
||||
|
||||
private async _drawWatermark() {
|
||||
console.log('draw WV');
|
||||
|
||||
const PDFNet = this._instance.PDFNet;
|
||||
|
||||
const document = await this._instance.docViewer.getDocument().getPDFDoc();
|
||||
const doc = document;
|
||||
await this._instance.PDFNet.runWithCleanup(
|
||||
|
||||
await PDFNet.runWithCleanup(
|
||||
async () => {
|
||||
//const s = await PDFNet.Stamper.create(PDFNet.Stamper.SizeType.e_relative_scale, 0.5, 0.5);
|
||||
|
||||
// Specifies if the stamp is to be stamped as an annotation.
|
||||
// note that stamps created with this setting do not work with SetAsBackground, HasStamps, and DeleteStamps, if annotation is true.
|
||||
//s.setAsAnnotation(true);
|
||||
|
||||
// await s.setAlignment(PDFNet.Stamper.HorizontalAlignment.e_horizontal_center, PDFNet.Stamper.VerticalAlignment.e_vertical_top);
|
||||
// const font = await PDFNet.Font.create(doc, PDFNet.Font.StandardType1Font.e_courier);
|
||||
// await s.setFont(font);
|
||||
// const redColorPt = await PDFNet.ColorPt.init(1, 0, 0, 0);
|
||||
// await s.setFontColor(redColorPt);
|
||||
// await s.setTextAlignment(PDFNet.Stamper.TextAlignment.e_align_right);
|
||||
// await s.setAsBackground(false);
|
||||
// const pgSet = await PDFNet.PageSet.createRange(1, 2);
|
||||
// await s.stampText(doc, 'This is a title!', pgSet);
|
||||
//
|
||||
// s.setAsBackground(false);
|
||||
// const pgSetImage = await PDFNet.PageSet.createRange(1, 1);
|
||||
// await s.setAlignment(PDFNet.Stamper.HorizontalAlignment.e_horizontal_right, PDFNet.Stamper.VerticalAlignment.e_vertical_bottom);
|
||||
|
||||
await document.lock();
|
||||
|
||||
const pageSet = await this._instance.PDFNet.PageSet.createSinglePage(1);
|
||||
const pageSet = await PDFNet.PageSet.createSinglePage(1);
|
||||
|
||||
await this._instance.PDFNet.Stamper.deleteStamps(document, pageSet);
|
||||
await PDFNet.Stamper.deleteStamps(document, pageSet);
|
||||
|
||||
const text = this.configForm.get('text').value || '';
|
||||
const fontSize = this.configForm.get('fontSize').value;
|
||||
@ -201,8 +178,8 @@ export class WatermarkScreenComponent implements OnInit {
|
||||
|
||||
const rgbColor = hexToRgb(color);
|
||||
|
||||
const stamper = await this._instance.PDFNet.Stamper.create(3, fontSize, 0);
|
||||
await stamper.setFontColor(await this._instance.PDFNet.ColorPt.init(rgbColor.r / 255, rgbColor.g / 255, rgbColor.b / 255));
|
||||
const stamper = await PDFNet.Stamper.create(3, fontSize, 0);
|
||||
await stamper.setFontColor(await PDFNet.ColorPt.init(rgbColor.r / 255, rgbColor.g / 255, rgbColor.b / 255));
|
||||
await stamper.setOpacity(opacity / 100);
|
||||
|
||||
switch (orientation) {
|
||||
@ -218,7 +195,7 @@ export class WatermarkScreenComponent implements OnInit {
|
||||
await stamper.setRotation(-45);
|
||||
}
|
||||
|
||||
const font = await this._instance.PDFNet.Font.createAndEmbed(document, this._convertFont(fontType));
|
||||
const font = await PDFNet.Font.createAndEmbed(document, this._convertFont(fontType));
|
||||
await stamper.setFont(font);
|
||||
await stamper.setTextAlignment(0);
|
||||
await stamper.stampText(document, text, pageSet);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user