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!

Debenu Quick PDF Library - PDF SDK Community Forum Homepage
Forum Home Forum Home > For Users of the Library > I need help - I can help
  New Posts New Posts RSS Feed - Watermark text in PDF using Quick PDF libary
  FAQ FAQ  Forum Search   Register Register  Login Login

Watermark text in PDF using Quick PDF libary

 Post Reply Post Reply
Author
Message
ssivasankaran View Drop Down
Beginner
Beginner


Joined: 28 Jun 16
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote ssivasankaran Quote  Post ReplyReply Direct Link To This Post Topic: Watermark text in PDF using Quick PDF libary
    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
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3151
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 09 Dec 19 at 8:36AM
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

Back to Top
ssivasankaran View Drop Down
Beginner
Beginner


Joined: 28 Jun 16
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote ssivasankaran Quote  Post ReplyReply Direct Link To This Post Posted: 09 Dec 19 at 8:58AM
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
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3151
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 09 Dec 19 at 6:51PM
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

Back to Top
ssivasankaran View Drop Down
Beginner
Beginner


Joined: 28 Jun 16
Status: Offline
Points: 8
Post Options Post Options   Thanks (0) Thanks(0)   Quote ssivasankaran Quote  Post ReplyReply Direct Link To This Post Posted: 10 Dec 19 at 4:35AM
Thank you so much. It's working for me.

Thanks and Regards
Santhanaraman.S
Back to Top
Ingo View Drop Down
Moderator Group
Moderator Group
Avatar

Joined: 29 Oct 05
Status: Offline
Points: 3151
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ingo Quote  Post ReplyReply Direct Link To This Post Posted: 10 Dec 19 at 10:52PM
a NormalizePage before the stamp is always a good option...



Edited by Ingo - 10 Dec 19 at 10:52PM
Cheers,
Ingo

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.01
Copyright ©2001-2014 Web Wiz Ltd.

Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. AboutContactBlogSupportOnline Store