Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
Watermark text in PDF using Quick PDF libary |
Post Reply ![]() |
Author | |
ssivasankaran ![]() Beginner ![]() Joined: 28 Jun 16 Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() Posted: 09 Dec 19 at 6:52AM |
Hi,
I want to create watermark text in pdf using quick pdf library. Could you give me a sample program to insert watermark text in pdf? If the code is in C# then it will be helpful for me.
Regards Santhanaraman.S
|
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
Hi, i think you've didn't read/search in the online reference 'till now? ;-) Here's a C#-sample from the kb: https://www.debenu.com/kb/programmatically-add-watermark-stamp-pdf/ Cheers and welcome here, Ingo |
|
Cheers,
Ingo |
|
![]() |
|
ssivasankaran ![]() Beginner ![]() Joined: 28 Jun 16 Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
Hi, Thanks for your response. I have converted the code into c# mentioned in the following link. ******************************************************************************* string printFile = fileName; int transp = 10; //The transparency as a percent value int drewin = 35; //Angle of rotation... try with values over and below zero... not more than -45 to 45 string ausr; if (_objPdfLibrary.Unlocked() == 1) { try { string waterMarkText = "Uncontrolled Copy"; if (waterMarkText.Trim().Length > 40) //The text should have max. 40 characters waterMarkText = waterMarkText.Substring(1, 40); _objPdfLibrary.LoadFromFile(fileName, ""); _objPdfLibrary.SetOrigin(1); _objPdfLibrary.SetMeasurementUnits(0); //means pixel for(int i = 1 ; i<= _objPdfLibrary.PageCount();i++) { int ts, tl, th; ts = tl = 0; _objPdfLibrary.SelectPage(i); int sc1 = i / 2; int sc2 = i * 2; if (_objPdfLibrary.PageWidth() < 250) ts = 8; if ((_objPdfLibrary.PageWidth() > 249) && (_objPdfLibrary.PageWidth() < 400)) ts = 12; if ((_objPdfLibrary.PageWidth() > 399) && (_objPdfLibrary.PageWidth() < 650) ) ts = 18; if ((_objPdfLibrary.PageWidth() > 649) && (_objPdfLibrary.PageWidth() < 1500)) ts = 22; if ((_objPdfLibrary.PageWidth() > 1499) && (_objPdfLibrary.PageWidth() < 2500)) ts = 30; if(_objPdfLibrary.PageWidth() > 2499) ts = 38; _objPdfLibrary.SetTextSize(ts); int tw = tl * ts; //Textwidth is the sum from length * size... tw = tw / 2; tw = tw + drewin; th = (tw * drewin) / 45; _objPdfLibrary.SetTransparency(transp); if (ausr == 'lo') _objPdfLibrary.DrawRotatedText(ts, th, drewin, waterMarkText); // left - top - width - height if (ausr == 'lu') _objPdfLibrary.DrawRotatedText(ts, _objPdfLibrary.PageHeight() - th, drewin, waterMarkText); // left - top - width - height if (ausr == 'ro') _objPdfLibrary.DrawRotatedText(_objPdfLibrary.PageWidth() - tw, ts, drewin, waterMarkText); // left - top - width - height if (ausr == 'ru') _objPdfLibrary.DrawRotatedText(_objPdfLibrary.PageWidth() - tw, _objPdfLibrary.PageHeight() - tl, drewin, waterMarkText); // left - top - width - height _objPdfLibrary.CompressContent(); } _objPdfLibrary.SaveToFile(fileName); } catch (Exception ex) { } } ************************************************************************** But unable to convert the following code. I can't understand. if cbausr.Text = 'Links oben' then ausr := 'lo'; //top left if cbausr.Text = 'Links unten' then ausr := 'lu'; //bottom left if cbausr.Text = 'Rechts oben' then ausr := 'ro'; //top right if cbausr.Text = 'Rechts unten' then ausr := 'ru'; //bottom right Could you explain the above? Thanks and Regards Santhanaraman.S
Edited by ssivasankaran - 09 Dec 19 at 12:06PM |
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
cbausr.Text means the selected content of a combobox.
If you choose "Links unten" variable ausr will set to "lu". "lu" means left, bottom and has to do with a simple alignment of the watermark. |
|
Cheers,
Ingo |
|
![]() |
|
ssivasankaran ![]() Beginner ![]() Joined: 28 Jun 16 Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
Thank you so much. It's working for me.
Thanks and Regards Santhanaraman.S
|
|
![]() |
|
Ingo ![]() Moderator Group ![]() ![]() Joined: 29 Oct 05 Status: Offline Points: 3529 |
![]() ![]() ![]() ![]() ![]() |
a NormalizePage before the stamp is always a good option...
Edited by Ingo - 10 Dec 19 at 10:52PM |
|
Cheers,
Ingo |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store