I am evaluating Aspose.Pdf product for my company. Requirement was to overlay text at specific location on page. I end up using RedactionAnnotation. But now when code is in dev environment and we are progressing to finalize the use of Aspose.Pdf. I came across with orientation problem on Landscape page. Attached is the sample. Note:- Pdf is in sample file is random pdf from the internet. Pdf is in landscape page orientation.
I will appreciate any help. Thanks
string sourceFile = "landscape.pdf";
string outputFile = System.IO.Path.GetRandomFileName() + ".pdf";
var lines = 5;
var lineWidth = 80;
var lineSpacing = 15; ;
var x = 42;
var y = 80;
var width = 350;
var yy = y + lineSpacing;
Document pdfDocument = new Document(sourceFile);
List<string> lineList = new List<string>();
lineList.Add("This is the replacement of text under Graduate Program Title. ");
lineList.Add("");
lineList.Add("This is the replacement of text under Graduate Program Title. ");
lineList.Add("This is the replacement of text under Graduate Program Title. ");
lineList.Add("This is the replacement of text under Graduate Program Title. ");
lineList.Add("This is the replacement of text under Graduate Program Title. ");
lineList.Add("This is the replacement of text under Graduate Program Title. ");
RedactionAnnotation annot = null;
for (int i = 0; i < lineList.Count & i < lines; i++)
{
annot = new RedactionAnnotation(pdfDocument.Pages[1], new Aspose.Pdf.Rectangle(x, y, width, yy));
annot.FillColor = Aspose.Pdf.Color.Yellow;
annot.BorderColor = Aspose.Pdf.Color.Black;
annot.Color = Aspose.Pdf.Color.Black;
annot.OverlayText = lineList[i];
annot.RichText = "What is the richtext";
annot.TextAlignment = Aspose.Pdf.HorizontalAlignment.Justify;
annot.Repeat = false;
pdfDocument.Pages[1].Annotations.Add(annot);
annot.Redact();
y = y + lineSpacing;
yy = yy + lineSpacing;
}
pdfDocument.Save(outputFile);
source file is also attached.
lsq01al2.uca.pdf (147.3 KB)original_issue.pdf (110.7 KB)