Do you own a Debenu Quick PDF Library 12/11/10/9/8/7? Upgrade to Debenu Quick PDF Library 13!

Foxit Quick PDF Library

Frequently Asked Question:

Return to FAQ Index

How can I highlight text in an existing pdf?

Question

How can I highlight text in an existing pdf? I can get coordinates of the required text by GetPageText(4) but do not know what methods can take those coordinates and highlight the text? Please advise...

Answer

I figured out how to highlight. Before, I looked a way to add a highlight annotation, but highlighting can be done by adding a background layout and a colored rectangle to it. See the following snippet:

QuickPDFAX0718.PDFLibrary qp = new QuickPDFAX0718.PDFLibrary();
qp.UnlockKey(LicenseKey);

if (qp.LoadFromFile(input_pdf) == 0)
{
    message("Could not load file " + input_pdf);
    return;
}

qp.SelectPage(1);
int l = qp.NewLayer();
if (qp.MoveLayer(l, 1) == 0 
    || qp.SelectLayer(1) == 0
    || qp.SetFillColor(1, 0, 0) == 0
    || qp.DrawBox(229.92, 679, 169, 27, 1) == 0
    )
{
    message("Could not highlight text");
    return;
}

if (qp.SaveToFile(output_pdf) == 0)
{
    message("Could not save file " + output_pdf);
    return;
}

© 2015 Debenu & Foxit. All rights reserved. AboutBuyContactBlogNewsletterSupportFAQProduct UpdatesForum