'Searching buffer string using Nodejs

I have an Revit .rvt file (which is a .7z file under the hood), which I know contains a specific phrase within the first 30,000 bytes. I've attempted to use Nodejs to read it to a buffer, convert it to a string, and then search for the index of the phrase, but it always returns -1. If I print the string to the console, I see the words I'm looking for.

What am I missing?

Example Function:

async function findPhraseIndex(path){
    const fileHandle = await open(path, 'r');

    const read = await fileHandle.read(Buffer.alloc(30000), 0, 30000);
    await fileHandle.close()

    const bufferString = read.buffer.toString('utf8');

    const index = bufferString.indexOf('Format');

    return index;
}

Example Data:

�P�Ԧ��♀��↕lkH)��R,8�♣0�EJ�→�)�PWԀ^Q¶�7At;♂o�(����↕v�&y�|���Z�♥��xa6���@K�∟Iɟ���A�<��ޛ0��☻Y�Ҫ��@.��oG�9�R�
ڃ♫UΧ�40��@���C���→♦�K^�F��r▲p��z���B/O⌂����k�1,�c��x�c�Z��♣��\*]um�t�
[1] a꒷���K;v��68�Ӵ♠�ꭇ�#�▬o�&�3�#�Ƅ��¶↓�⌂�↨Ҙ�}�J�ӤQ����S)��N�T�☼►g\)���n�▲��O^¶�"���►�����Da�♀H/�EZ7�♥�ݠ7ԁs��e��W�觌Z���7ճ-�T↨{�X���u�⌂��{h�⌂���o�▼�▼PK☺☻¶¶ ����W'☻�♣~C
915665c-dc15-4f6d-8dd6-51ebaf9d8c32.project.xmlP♫♦2022↕20210224_1515(x64)mC:\AC\Github\revit-family-property-updater-electron\RevitAddIns\FamilyParameterManager\SampleFiles\sample.rvt♥$00000000-0000-0000-0000-000000000000♥ENU☺$4badad54-ec6a-4af8-be09-5fecedec44dd$4badad54-ec6a-4af8-be09-5fecedec44dd☺1$00000000-
0000-0000-0000-000000000000♫Autodesk Revit►RevitApplication
[1] Worksharing: Not enabled
[1] Username:
[1] Central Model Path:
[1] Format: 2022
[1] Build: 20210224_1515(x64)
[1] Open Workset Default: 3
[1] Project Spark File: 0
[1] Central Model Identity: 00000000-0000-0000-0000-000000000000
[1] Locale when saved: ENU
[1] All Local Changes Saved To Central: 0
[1] Central model's version number corresponding to the last reload latest: 1
[1] Central model's episode GUID corresponding to the last reload latest: 4badad54-ec6a-4af8-be09-5fecedec44dd
[1] Unique Document GUID: 4badad54-ec6a-4af8-be09-5fecedec44dd
[1] Unique Document Increments: 1
[1] Model Identity: 00000000-0000-0000-0000-000000000000
[1] IsSingleUserCloudModel: False
[1] Author: Autodesk Revit
[1] ClientAppName: RevitApplication
[1] t
[1] ClientAppName: RevitAppO♣<?xml version="1.0"?>
[1] <TransmissionData isTransmitted="false" userData="" version="5"><ExternalFileReference><ElementId>117704</ElementId><ExternalFileReferenceType>Keynote Table</ExternalFileReferenceType><LastSavedPath>RevitKeynotes_Imperial_2004.txt</LastSavedPath><LastSavedAbsolutePath>C:\ProgramData\Autodesk\RVT 2022\Templa
tes\English-Imperial\RevitKeynotes_Imperial_2004.txt</LastSavedAbsolutePath><LastSavedPathType>Relative to Library Locations</LastSavedPathType><LastSavedLoadState>Not Found</LastSavedLoadState><DesiredPath>RevitKeynotes_Imperial_2004.txt</DesiredPath><DesiredPathType>Relative to Library Locations</DesiredPathT
ype><DesiredLoadState>Loaded</DesiredLoadState></ExternalFileReference><ExternalFileReference><ElementId>306703</ElementId><ExternalFileReferenceType>Assembly Code Table</ExternalFileReferenceType><LastSavedPath>UniformatClassifications.txt</LastSavedPath><LastSavedAbsolutePath>C:\ProgramData\Autodesk\RVT 2022\
Templates\English-Imperial\UniformatClassifications.txt</LastSavedAbsolutePath><LastSavedPathType>Relative to Library Locations</LastSavedPathType><LastSavedLoadState>Not Found</LastSavedLoadState><DesiredPath>UniformatClassifications.txt</DesiredPath><DesiredPathType>Relative to Library Locations</DesiredPathT
ype><DesiredLoadState>Loaded</DesiredLoadState></ExternalFileReference></TransmissionData>
[1] ☻♦♦♦♦♦♦
[1] b↓"♣→☺☺C☺☺☺☺☻☻♦♦♦♦♦♦
[1] ☻   �!►b↓"♣�▼♂Z�


Solution 1:[1]

Basically, afaik, the RVT file format uses OLE storage, aka COM Structured Storage. Maybe some parts of it are 7z compressed and others are not. The Building Coder shares various examples showing how to extract useful parts of the data from that file format, especially the RVT file version:

Maybe the information you are searching for can be read in a similar manner, and using a slightly less hacky approach than just searching randomly for a given string of bytes.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jeremy Tammik