Using a tool like PlayWright, how can I interact with annotations after they're created on the pdf?

Hi mirsean99,

We actually use Playwright to test WebViewer in our development process. For testing highlights and other annotations, we use the mouse, like so:

  const textInTheFirstPage = 'PDF Text to select';

  const rect1 = await getTextPosition(textInTheFirstPage);
  await page.mouse.move(rect1.x1, rect1.y1);
  await page.mouse.down();
  await page.mouse.move(rect1.x2, rect1.y2);
  await page.mouse.up();

This is some code for testing text selection, if you just change the tool to the Highlight tool it will work as well.

Let me know if this works for you.

Best regards,
Tyler

2 Likes