Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Jun 22, 2022 8:03 am

Hi,

I am very new to Spire PDF.

I want to be able to take a PDF of a techincal drawing and ask the user to enter some Quality Assurance Checks and to help I want to highlight a relevant area on the PDF.
Once done, I want to remove the highlighted area and then create another for the next question.

Is this possible with Spire PDF or do we need an extra piece of software.

Many thanks

Andrew

adrury2305
 
Posts: 2
Joined: Wed Jun 22, 2022 7:57 am

Wed Jun 22, 2022 10:19 am

Hi,

Thanks for your inquiry.
I need to further confirm with you about your requirement. What you want is to find keywords, highlight keywords and remove highlight in PDF document, right? If so, our Spire.PDF can achieve it by PdfTextMarkupAnnotation, please refer to the code below. If there is any misunderstanding, please provide detailed information for further investigation.
Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("test.pdf");
PdfPageBase page = doc.Pages[0];
//find keyword
PdfTextFind[] finds = page.FindText("keyword", Spire.Pdf.General.Find.TextFindParameter.IgnoreCase).Finds;
//draw PdfTextMarkupAnnotation according keyword bound
foreach (PdfTextFind find in finds)
{
    RectangleF rect = find.TextBounds[0];
    PdfTextMarkupAnnotation annotation1 = new PdfTextMarkupAnnotation("", "",rect);
    annotation1.Border = new PdfAnnotationBorder(0.75f);
    //highlight
    annotation1.TextMarkupColor = Color.Yellow;
    find.SearchPage.AnnotationsWidget.Add(annotation1);
}

//remove TextMarkupAnnotation
for (int i = 0; i < page.AnnotationsWidget.Count; i++)
{
    if (page.AnnotationsWidget[i] is PdfTextMarkupAnnotation)
    {
        page.AnnotationsWidget.Remove(page.AnnotationsWidget[i]);
        i--;
    }
}
doc.SaveToFile("result.pdf",FileFormat.PDF);

Sincerely,
Kylie
E-iceblue support
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Wed Jun 22, 2022 12:20 pm

Hi,

Appreciate you reply.

I am not searching for words I will know the precise size of box required and a position, So will want to use the preset variables, an x and y coordinate and a height and width.

I also only want to open the document once and not have to keep saving and re-loading.

Is this possible if we had the pdf viewer package also.

Regards

Andy

adrury2305
 
Posts: 2
Joined: Wed Jun 22, 2022 7:57 am

Thu Jun 23, 2022 10:00 am

Hello,

Thanks for your feedback.
According to my understanding, what you want is to use the Spire.PDFViewer to view PDF document and allow your users to drag a rectangle and highlight it. Actually, combining features of Spire.PDFViewer and Spire.PDF can achieve your needs. The realization principle is that the Spire.PDF adds annotation with highlighting according the dragged rectangle, saves the PDF to stream and then use Spire.PDFViewer to view the stream again. In this case, it is impossible to open the document once and not have to keep saving and re-loading.

If there is any misunderstanding, please provide more information, like your input PDF and expected effect to help us better investigate your problem. You can attach your document here or send it to us via email (support@e-iceblue.com). Thank you in advance.

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Mon Oct 10, 2022 2:59 am

Hi,

Greetings from E-iceblue.
How is your issue going? Could you please give us some feedback at your convenience? Thanks in advance.

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Return to Spire.PDF