I have File With Page Rotated by 90 Degree.
I want to add WM Annotation On Top Of Page. With Smal FullName it works perfect. but with large fullName it shifted in Middle. I want to know and understand how to set rectangle as I tried alot with no chance.
I want to add header in left, center, and right of top Page
And When Set Text to arabic Word, text doesnt render correct.
Test.pdf (143.3 KB)
code.jpg (191.4 KB)
Arabic.PNG (7.1 KB)
@NourKhashan
Please attach the code you are using in a text message. (To indicate the code in the message, use ~~~С# at the beginning of the block and ~~~ at the end).
@sergei.shibanov Code
var page = pdfDocument.Pages[1];
var fullName = "Admin TestingAdmin TestingAdmin TestingAdmin Testing";//Admin Testing//اهلا وسهلا
var textS = GetTextSize(18, $"Full Name: {fullName}");
var sizeCenter = page.GetPageRect(true);
var w = sizeCenter.Width;
var h = sizeCenter.Height;
double x = w - textS.Width;
double y = w - textS.Width;
double ux = w;
double uy = w;
var rec = new Aspose.Pdf.Rectangle(x, y, ux, uy);
WatermarkAnnotation wa = new WatermarkAnnotation(page, rec);
wa.Characteristics.Rotate = Rotation.on90;
TextState ts = new TextState();
ts.ForegroundColor = Aspose.Pdf.Color.Purple;
ts.Font = FontRepository.FindFont("Arial");
ts.FontSize = 18;
wa.SetTextAndState(new string[] { $"Full Name: {fullName}", "Title: Title 01" }, ts);
page.Annotations.Add(wa, true);
@NourKhashan
Please clarify using the attached images - how would you like to place the text. As in variant 1, 2 or some other way?
Variant_1.png (4.1 KB)
Variant_2.png (4.5 KB)
Do you mean that the result is an incorrect inscription - as in the picture?
ArabicNotSupport.png (18.1 KB)
@sergei.shibanov
how would you like to place the text. As in variant 1, 2 or some other way?
As variant 1
Do you mean that the result is an incorrect inscription - as in the picture?
Yes this is issue in arabic
and I have another question why there is no rotation (ex. 45,130) in WatermarkAnnotation
like as rotation in TextStamp - I need to use WatermarkAnnotation-?
@NourKhashan
It seems that rotation (or combination of several rotations) for WatermarkAnnotation does not work properly. I will create an investigative task for the development team about this.
The code that works for a document without rotation does not work in any variations for a rotated page.
var pdfDocument = new Document(dataDir + "Test.pdf");
var page = pdfDocument.Pages[1];
var fullName = "Admin TestingAdmin TestingAdmin TestingAdmin Testing";//Admin Testing//اهلا وسهلا
short usedFontSize = 18;
Aspose.Pdf.Text.Font usedFont = FontRepository.FindFont("Arial");
string addedStr1 = $"Full Name: {fullName}";
string addedStr2 = "Title: Title 01";
var textFragment1 = new TextFragment(addedStr1);
textFragment1.TextState.Font = usedFont;
textFragment1.TextState.FontSize = usedFontSize;
double width1 = textFragment1.Rectangle.Width;
double height1 = textFragment1.Rectangle.Height;
var textFragment2 = new TextFragment(addedStr1);
textFragment2.TextState.Font = usedFont;
textFragment2.TextState.FontSize = usedFontSize;
double width2 = textFragment2.Rectangle.Width;
double height2 = textFragment2.Rectangle.Height;
double width = Math.Max(width1, width2);
double height = 1.1*height1 + 1.1*height2;
// For place in left upper corner.
var rect = new Aspose.Pdf.Rectangle(page.MediaBox.LLX, page.MediaBox.URY - height, page.MediaBox.LLX + width, page.MediaBox.URY);
//var rect = new Aspose.Pdf.Rectangle(page.MediaBox.LLY, page.MediaBox.URX - height, page.MediaBox.LLY + width, page.MediaBox.URX);
var wa = new WatermarkAnnotation(page, rect);
wa.Characteristics.Rotate = Rotation.on90;
var ts = new TextState();
ts.ForegroundColor = Aspose.Pdf.Color.Purple;
ts.Font = usedFont;
ts.FontSize = usedFontSize;
wa.SetTextAndState(new string[] { $"Full Name: {fullName}", "Title: Title 01" }, ts);
page.Annotations.Add(wa, true);
//page.Annotations.Add(wa);
pdfDocument.Save(dataDir + "Test-out.pdf");
I’ll write about the other questions a little later.
@NourKhashan
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-58616
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@sergei.shibanov
Thanks. but I want to make sure u open for 3 issuses(Position in Rotated, Arabic and Add WM Annotation with Rotation)?
I have another Q.
How to add SVG to Watermark annotation as When I add Large png it pixled.
@NourKhashan
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): PDFNET-58617
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.
@NourKhashan
I am attaching screenshots of the tasks created by the development team.
58616.png (46.7 KB)
58617.png (37.1 KB)
The pdf specification states that this angle must be a multiple of 90 degrees. I have seen implementations with arbitrary angles. However, since this is not standardized, one cannot be sure that it will be accepted by all viewers. Therefore, this option is not available.
You should make this in a separate topic so that there are not many Different questions in one topic (even though they all concern WatermarkAnnotation).
Thanks. and I added another ticket for SVG.