Unique AddTextWatermark

PDF-XChange Drivers API (only) V4/V5
This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - VERSION 4 & 5 - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Tracker Supp-Stefan

Post Reply
oskpm
User
Posts: 41
Joined: Tue Aug 31, 2010 8:44 am

Unique AddTextWatermark

Post by oskpm »

Hi,

I'm using AddTextWatermark to add a single Watermarktext on all pdf-pages with the following steps:
- Create Printer
- Call AddTextWatermark(...) with Text 1 (same sName-Parameter)
- Print Doc
- call AddTextWatermark(...) with Text 2 ( same sName-Parameter)
- Print Doc
- ...
- Destroy Printer

The first Parameter 'sName' is always the same.
The result is Doc1 has Text 1, Doc2 has Text 1 + Text 2, Doc3 would have Text 1 + Text 2 + Text 3 and son on.

From the documenation "If there is already a watermark with the same name - it will be overwritten!".
That does not seem to work?

Perhaps there is a way to remove a specific watermark or simple all?

The Code to set the Watermarktext:

Code: Select all

HRESULT hr = m_Printer->AddTextWatermark
			(
						L"DB",
						strWatermarkText.AllocSysString(),
						L"Arial",
						400,	//[in] long dwFontWeight,
						0,		//[in] long bItalic,
						0,		//[in] long bOutline,
						45,		//[in] long nFontSize,
						0,		//[in] long nLineWidth,
						1,		//[in] long nTextcolor,
						1+16,	//[in] long dwAlign,
						0,		//[in] long xOffset,
						0,		//[in] long yOffset,
						45,		//[in] long nAngle,
						25,		//[in] long dwOpacity,
						2+4+8+16,	 //[in] long dwFlags,
						0,			//[in] long dwPlaceType,
						L"1-"			//[in] BSTR sRange);
			);
		
		m_Printer->Option[L"Watermarks.Enabled"]  = "Yes";
		m_Printer->Option[L"Watermarks.Watermarks"]  = "DB";
		m_Printer->ApplyOptions(0);
In this sample code only strWatermarkText changes.


Edit: My current solution is a call from m_Printer->ResetDefaults(); before m_Printer->AddTextWatermark

Thanks
Peter
Nico - Tracker Supp
User
Posts: 205
Joined: Fri May 18, 2012 8:41 pm

Re: Unique AddTextWatermark

Post by Nico - Tracker Supp »

Hi oskpm,

Thank you for your post.
Please let me ask you are you trying to print a different watermark on every page or you are trying to print the same water mark in all pages?
If the latter is true, you need to specify AddTextWatermark only once with the dwPlaceType parameter set to 0.
If the former is true, you need to use sRange for the page number where you want to add the watermark, set dwPlaceType to 5, and add a separate AddTextWatermark for every different watermark.
Thanks.

Sincerely,
oskpm
User
Posts: 41
Joined: Tue Aug 31, 2010 8:44 am

Re: Unique AddTextWatermark

Post by oskpm »

Hello Nico,

thanks for your reply.

I'm printing multiple docs one after another. Some with a watermark (text1) on all pages, some with another watermark (on all pages) and some without a watermark at all.

Attached a pdf created with 2 calls of AddTextWatermark directly on after another with the same sName-Parameter.
First Text was 1234567890__________ and the 2nd was__________1234567890. The result in the pdf is 12345678901234567890. It seems that the internal sName is not replaced.

Regards,
Peter
Attachments
1.pdf
(4.31 KiB) Downloaded 266 times
Nico - Tracker Supp
User
Posts: 205
Joined: Fri May 18, 2012 8:41 pm

Re: Unique AddTextWatermark

Post by Nico - Tracker Supp »

Hi oskpm,

Thank you for your post.
Please could you send me a simple project with your code which I can run and see?
Also, please state clearly in your code with comments what you are trying to do.
You can send it to support@pdf-xchange.com.
Thanks.

Sincerely,
Walter-Tracker Supp
User
Posts: 381
Joined: Mon Jun 13, 2011 5:10 pm

Re: Unique AddTextWatermark

Post by Walter-Tracker Supp »

Hi Peter,

As Nico said, getting a code sample from you would be useful, while we investigate this. It looks like you have found a workaround; you could also (obviously) try something like this:

1. Create watermarks as needed during document processing, and give each unique one a unique name ("Watermark1", "Watermark2", ...)

2. Set the Watermarks property to only include those named watermarks that you wish to be printed in each document.

Code: Select all

e.g. in psuedo code:

watermarkname = "Watermark1";
PDFPrinter.AddTextWatermark(watermarkname, watermarkText, ...); 
PDFPrinter.Option["Watermarks.Watermarks"] = watermarkname;
print file

watermarkname = "Watermark2";
PDFPrinter.AddTextWatermark(watermarkname, watermarkText, ...);
PDFPrinter.Option["WaterMarks.Watermarks"] = watermarkname;
print file
...
Thanks for your patience while we look into this.

-Walter
oskpm
User
Posts: 41
Joined: Tue Aug 31, 2010 8:44 am

Re: Unique AddTextWatermark

Post by oskpm »

@Nico
I modified your sample-project to reproduce the behaviour. See attached zip-archive.
The modified code (here as c#)

Code: Select all

 private void bPrint_Click(object sender, EventArgs e)
        {
            PDFPrinter.SetAsDefaultPrinter();
            bPXCPrinterDefault = true;

            PrintDocument printDoc = new PrintDocument();
            printDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage); 

            PDFPrinter.AddTextWatermark(
                "ANAME",
                "Hello______",
                "Arial",
                  400,   //[in] long dwFontWeight,
                  0,      //[in] long bItalic,
                  0,      //[in] long bOutline,
                  45,      //[in] long nFontSize,
                  0,      //[in] long nLineWidth,
                  1,      //[in] long nTextcolor,
                  1+16,   //[in] long dwAlign,
                  0,      //[in] long xOffset,
                  0,      //[in] long yOffset,
                  45,      //[in] long nAngle,
                  25,      //[in] long dwOpacity,
                  2+4+8+16,    //[in] long dwFlags,
                  0,         //[in] long dwPlaceType,
                  "1-"         //[in] BSTR sRange);
            );


            PDFPrinter.AddTextWatermark(
                    "ANAME",
                    "______World",
                    "Arial",
                      400,   //[in] long dwFontWeight,
                      0,      //[in] long bItalic,
                      0,      //[in] long bOutline,
                      45,      //[in] long nFontSize,
                      0,      //[in] long nLineWidth,
                      1,      //[in] long nTextcolor,
                      1 + 16,   //[in] long dwAlign,
                      0,      //[in] long xOffset,
                      0,      //[in] long yOffset,
                      45,      //[in] long nAngle,
                      25,      //[in] long dwOpacity,
                      2 + 4 + 8 + 16,    //[in] long dwFlags,
                      0,         //[in] long dwPlaceType,
                      "1-"         //[in] BSTR sRange);
                );

            PDFPrinter.set_Option("Watermarks.Enabled", "Yes");
            PDFPrinter.set_Option("Watermarks.Watermarks", "ANAME");
            PDFPrinter.ApplyOptions(0);

            printDoc.Print();
            
        }

@Walter
Thanks for your workaround. I think this would function too.


A very importend fact I did not mention. I still use version 0199. Unfortunaley I'm not able to upgrade a the moment.


Edit: I reproduced this issue with the current version. Both texts were concatenated. (and font size is much more smaller than in version 0199?)

Regards,
Peter
Attachments
PDFdriverAPI.zip
(65.06 KiB) Downloaded 244 times
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17948
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Unique AddTextWatermark

Post by Tracker Supp-Stefan »

Hi Peter,

Yes Walter's suggestion should work, and I have also created a ticket in our internal system:
#1618: Drivers API: Unique AddTextWatermark
So that we can track and fix this as soon as possible.

Please note that any fix will be in a future build - so you will need to update our libraries in your project to get that fix.

Best,
Stefan
oskpm
User
Posts: 41
Joined: Tue Aug 31, 2010 8:44 am

Re: Unique AddTextWatermark

Post by oskpm »

Thanks a lot :D
User avatar
Tracker Supp-Stefan
Site Admin
Posts: 17948
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: Unique AddTextWatermark

Post by Tracker Supp-Stefan »

:)
Post Reply