Search for Text with Regex?

  • Search for Text with Regex?

    Posted by Alex Schectman on February 11, 2025 at 10:43 am

    I’d like to write a script that searches an active/given PDF for strings that match a regular expression. This script should output the sum of all those matches (a count, or tally).

    Neither Revu’s nor Adobe’s respective documentation seem to indicate the presence of a method for traversing or otherwise recognizing text (embedded or otherwise). Which methods carry over from the latter to the former is also unclear without rote testing.

    Liz Larsen’s scripting videos offer otherwise unavailable demonstrations but seem to use methods restricted to specific workflows. Using Acrobat and avoiding Bluebeam entirely is unfortunately not an option. Asking an LLM results in non-functional code that it cannot explain or clarify (in the context of Revu, at least). Official Bluebeam support on this topic — be it documentation or rep contact — is almost nonexistent.

    Any guidance would be appreciated. Thanks

    Isaac Harned replied 1 month ago 4 Members · 15 Replies
  • 15 Replies
  • David Cutler

    Member
    February 11, 2025 at 12:25 pm
    Points: 28,004
    Rank: UC2 Brainery Advanced Brown Belt I UC2 Brainery Advanced Brown Belt I

    Can you provide an example of what you are looking to “find” @aschectman ?

    I’m probably oversimplifying, but if you are looking to find a certain set of characters or values – say “1234” for example you could use a simple text search and then apply a count tool to all the results.

    • Alex Schectman

      Member
      February 11, 2025 at 12:39 pm
      Points: 290
      Rank: UC2 Brainery Newbie UC2 Brainery Newbie Belt Rank
      W\d{2}X\d{2}

      e.g. W21X44

      Script preferred so functionality may be expanded and multiple related/relevant results returned per run. Count tool would be an acceptable stopgap if the Find tool accepted regex (which it seemingly does not).

      • David Cutler

        Member
        February 11, 2025 at 1:16 pm
        Points: 28,004
        Rank: UC2 Brainery Advanced Brown Belt I UC2 Brainery Advanced Brown Belt I

        I created a simple word doc using your sample text and used it to create a PDF with the example text. The search tool seemed to find both fine – see screen shot below.

        Still a manual process, so I’m not sure that is what you are looking for – but the search in Revu appears to be able to find both of your examples…

        • Alex Schectman

          Member
          February 11, 2025 at 1:20 pm
          Points: 290
          Rank: UC2 Brainery Newbie UC2 Brainery Newbie Belt Rank

          Attempts on my end to search PDFs with regex yields nothing. This appears to be the case for others as well: Search Text with Regular Expressions — Bluebeam Community

          Find tool in your screenshot appears to have identified the regex string literal on the PDF.

          • David Cutler

            Member
            February 11, 2025 at 3:57 pm
            Points: 28,004
            Rank: UC2 Brainery Advanced Brown Belt I UC2 Brainery Advanced Brown Belt I

            Yup, that’s what I asked it to find…

            I think I mis-understood your original question – you are looking for a method of finding all of the various sizes of W sections included in the document and counting them, without searching for a specific section each time.

            Best I can offer would be to use multiple runs of the search feature and applying a count markup as you find them. Again, not what you are looking to do, but would get it done.

            Perhaps @lizlarsen will chime in on this one…

            • Troy DeGroot

              Organizer
              February 11, 2025 at 5:14 pm
              Points: 24,547
              Rank: UC2 Brainery Brown Belt IIII UC2 Brainery Brown Belt IIII

              Thanks for tagging @lizlarsen I was about to do the same @DavidCutler .

              Also, @isaac-harned is an excellent resource.

              Welcome to the Brainery Professional Learning Community @aschectman

            • Alex Schectman

              Member
              February 12, 2025 at 7:14 am
              Points: 290
              Rank: UC2 Brainery Newbie UC2 Brainery Newbie Belt Rank

              Appreciate you tagging them for me, but what I seek to do in Revu doesn’t seem to be possible. Please see my most recent reply to the main post for details and reference.

  • Alex Schectman

    Member
    February 12, 2025 at 7:12 am
    Points: 290
    Rank: UC2 Brainery Newbie UC2 Brainery Newbie Belt Rank

    Evidently, what I seek to accomplish is not currently possible. See Bluebeam staff’s reply to the same request on their forum: https://community.bluebeam.com/bluebeam-community/discussion/comment/3030#Comment_3030:~:text=Revu%20doesn%27t%20expose%20functionality%20to%20programmatically%20access%20the%20text%20of%20a%20PDF%20document%2C

    • David Cutler

      Member
      February 12, 2025 at 8:18 am
      Points: 28,004
      Rank: UC2 Brainery Advanced Brown Belt I UC2 Brainery Advanced Brown Belt I

      Peter Noyes, who responded to your post on the “other” forum, is one of (if not “the”) lead programmers at Bluebeam. If he says it cannot be done there’s a 99.99% chance that it’s true. Not to say folks such as @lizlarsen and @isaac-harned couldn’t figure it out, but you’d be hard pressed to find someone who knows the product better than Peter.

      BTW, as @troy-degroot mentioned, welcome to the Brainery! 🙂

      • Troy DeGroot

        Organizer
        February 12, 2025 at 1:15 pm
        Points: 24,547
        Rank: UC2 Brainery Brown Belt IIII UC2 Brainery Brown Belt IIII

        Peter has been with Bluebeam from the beginning: a super smart programmer and a really cool guy.

  • Alex Schectman

    Member
    February 13, 2025 at 2:24 pm
    Points: 290
    Rank: UC2 Brainery Newbie UC2 Brainery Newbie Belt Rank

    Desired functionality is available in a free alternative that seems to support the JS API more thoroughly: https://forum.pdf-xchange.com/viewtopic.php?p=190291#p190291:~:text=the%20length%20for.-,something%20like%3A,-Code%3A

    • David Cutler

      Member
      February 14, 2025 at 7:57 am
      Points: 28,004
      Rank: UC2 Brainery Advanced Brown Belt I UC2 Brainery Advanced Brown Belt I

      That’s great that you found a solution @aschectman !

      Out of curiosity, what is the work flow that you are needing this functionality for? As an estimator I’d expect that in addition to a count of each piece, W21x44 per your example, I’d also need the length of the piece so I’d be able to calculate the tonnage of steel to purchase.

      • Alex Schectman

        Member
        February 17, 2025 at 7:30 am
        Points: 290
        Rank: UC2 Brainery Newbie UC2 Brainery Newbie Belt Rank

        Reading member lengths would be great for our estimator and is among my goals. I’m a detailing manager, so our roles overlap at the fringes of BIM.

        My particular workflow is for calculating the ETA of a given estimodel (via Tekla). Script-read/-reported quantities will provide units against which tracked time (via ManicTime) may be compared. More accurate predictions of time-to-completion may then be offered when a job comes across my desk, which will help my supervisor and coworkers decide whether to proceed or simply estimate by hand.

    • Troy DeGroot

      Organizer
      February 14, 2025 at 8:58 am
      Points: 24,547
      Rank: UC2 Brainery Brown Belt IIII UC2 Brainery Brown Belt IIII

      Thank you for supporting the community by posting the solution. I appreciate you @aschectman

  • Isaac Harned

    Member
    February 21, 2025 at 5:55 pm
    Points: 8,204
    Rank: UC2 Brainery Purple Belt III UC2 Brainery Purple Belt III

    Wow, looks like I missed the party on this one, lol I think my notifications are broken. Very sorry to see there is no functionality on this. Haven’t had any use quite yet myself, but would help as I start to get more into Commissioning. They have definitely been talking of Javascript enhancements for a while, so I am hopeful that its just around the corner, may be a focus of the conference if I’m reading the room right.

Log in to reply.