while highlighting the text in existing pdf using C# platform i am facing issue of highlightion which highlights text vertically.
i have tried in all possible ways could you please anyone help me how to highlight text horizontally for portrait pdf
PdfLoadedDocument document = new PdfLoadedDocument(@"d:\LocalData\z015266\Desktop\OneDrive_1_30-07-2019\Updated\AA30-AC.PDF");
PdfDocument pdfDoc = PdfDocument.Merge(null, document) as PdfDocument;
//Gets the first page from the document
float width = pdfDoc.Pages[0].Size.Width;
float height = pdfDoc.Pages[0].Size.Height;
if (pdfDoc.Pages[0].Rotation == PdfPageRotateAngle.RotateAngle90 ||
pdfDoc.Pages[0].Rotation == PdfPageRotateAngle.RotateAngle270)
{
width = pdfDoc.Pages[0].Size.Height;
height = pdfDoc.Pages[0].Size.Width;
}
if (width > height)
{
pdfDoc.Sections[0].PageSettings.Orientation = PdfPageOrientation.Portrait;
}
else
{
pdfDoc.Sections[0].PageSettings.Orientation = PdfPageOrientation.Landscape;
pdfDoc.Sections[0].PageSettings.Size = new SizeF(width, height);
}
//Add a list to maintain extracted text information
List<TextData> extractedText = new List<TextData>();
//Extract text from first page
pdfDoc.Sections[0].Pages[0].ExtractText(out extractedText);
//for (var yu = 0; yu < arrvalues_smipp.Length; yu++)
//{
foreach (TextData textData in extractedText)
{
if (textData.Text == "F261")
{
PdfGraphics graphics = pdfDoc.Pages[0].Graphics;
Font font = new Font("Calibri", 10, FontStyle.Bold);
PdfFont pdfFont = new PdfTrueTypeFont(font, false);
PdfSolidBrush brush = new PdfSolidBrush(Color.DarkGreen);
PdfPen pen = new PdfPen(PdfBrushes.DarkMagenta, 5f);
float x_coordiante = textData.Bounds.Location.X - 3;
float y_coordinate = textData.Bounds.Location.Y - 10;
float width1 = textData.Bounds.Size.Width;
float height1 = textData.Bounds.Size.Height;
RectangleF rectangle = new RectangleF(x_coordiante, y_coordinate, width1, height1);
PdfTextMarkupAnnotation textmarkup = new PdfTextMarkupAnnotation("", "", textData.Text, new PointF(x_coordiante, y_coordinate), pdfFont);
textmarkup.TextMarkupColor = new PdfColor(Color.LightPink);
textmarkup.TextMarkupAnnotationType = PdfTextMarkupAnnotationType.Highlight;
textmarkup.Rotate = PdfAnnotationRotateAngle.RotateAngle180;
pdfDoc.Sections[0].Pages[0].Annotations.Add(textmarkup);
}
}
pdfDoc.Save("HighlightText.pdf");
pdfDoc.Close(true);
Process.Start("HighlightText.pdf");