code: def _read_bti_header_pdf(pdf_fname):
      """Read header from pdf file."""
      with _bti_open(pdf_fname, "rb") as fid:
          fid.seek(-8, 2)
          start = fid.tell()
          header_position = read_int64(fid)
          check_value = header_position & BTI.FILE_MASK
  
          if (start + BTI.FILE_CURPOS - check_value) <= BTI.FILE_MASK:
              header_position = check_value
  
          # Check header position for alignment issues
          if (header_position % 8) != 0:
              header_position += 8 - (header_position % 8)
  
          fid.seek(header_position, 0)
  
          # actual header starts here
          info = {
              "version": read_int16(fid),
              "file_type": read_str(fid, 5),
              "hdr_size": start
              - header_position,  # add for convenience
              "start": start,
          }
  
          fid.seek(1, 1)
  
          info.update(
              {
                  "data_format": read_int16(fid),
                  "acq_mode": read_int16(fid),
                  "total_epochs": read_int32(fid),
                  "input_epochs": read_int32(fid),
                  "total_events": read_int32(fid),
                  "total_fixed_events": read_int32(fid),
                  "sample_period": read_float(fid),
                  "xaxis_label": read_str(fid, 16),
                  "total_processes": read_int32(fid),
                  "total_chans": read_int16(fid),
              }
          )
  
          fid.seek(2, 1)
          info.update(
              {
                  "checksum": read_int32(fid),
                  "total_ed_classes": read_int32(fid),
                  "total_associated_files": read_int16(fid),
                  "last_file_index": read_int16(fid),
                  "timestamp": read_int32(fid),
              }
          )
  
          fid.seek(20, 1)
          _correct_offset(fid)
  
          # actual header ends here, so dar seems ok.
  
          info["epochs"] = [
              _read_epoch(fid) for epoch in range(info["total_epochs"])
          ]
  
          info["chs"] = [
              _read_channel(fid) for ch in range(info["total_chans"])
          ]
  
          info["events"] = [
              _read_event(fid) for event in range(info["total_events"])
          ]
  
          info["processes"] = [
              _read_process(fid)
              for process in range(info["total_processes"])
          ]
  
          info["assocfiles"] = [
              _read_assoc_file(fid)
              for af in range(info["total_associated_files"])
          ]
  
          info["edclasses"] = [
              _read_pfid_ed(fid)
              for ed_class in range(info["total_ed_classes"])
          ]
  
          info["extra_data"] = fid.read(start - fid.tell())
          info["pdf"] = pdf_fname
  
      info["total_slices"] = sum(
          e["pts_in_epoch"] for e in info["epochs"]
      )
  
      info["dtype"] = DTYPES[info["data_format"]]
      bps = info["dtype"].itemsize * info["total_chans"]
      info["bytes_per_slice"] = bps
      return info
  
imports: import functools
  import os.path
  from io import BytesIO
  from itertools import count
  import numpy
  from ..._fiff._digitization import _make_bti_dig_points
  from ..._fiff.constants import FIFF
  from ..._fiff.meas_info import _empty_info
  from ..._fiff.tag import _coil_trans_to_loc, _loc_to_coil_trans
  from ..._fiff.utils import _mult_cal_one, read_str
  from ...transforms import Transform, combine_transforms, invert_transform
  from ...utils import _stamp_to_dt, _validate_type, logger, path_like, verbose
  from ..base import BaseRaw
  from .constants import BTI
  from .read import read_char, read_dev_header, read_double, read_double_matrix, read_float, read_float_matrix, read_int16, read_int16_matrix, read_int32, read_int64, read_transform, read_uint16, read_uint32
label_desc: Use image node_id 18 for calling a global function with example usage: _read_bti_header_pdf(pdf_fname) and returns: info