[Tex/LaTex] How to change the PDFBookmark titles (hyperref)

bookmarkshyperref

I am looking to change the title which displays in the PDF bookmark tabs to match the format of how I have my chapters listed.

\documentclass[]{report}
\usepackage[hidelinks]{hyperref} %to add hyperlinks throughout document
\usepackage{titlesec} %reformatting the chapter headings
\titleformat{\chapter}[block]
    {\normalfont\LARGE\bfseries\centering}{CHAPTER \thechapter}{0em}{:\hspace{2mm}}
\begin{document}

\chapter{THE BEGINNING}
Hello.

\chapter{THE END}
Goodbye.
\end{document}

What i currently have is:

title format

with the option of creating bookmarks of:

bad bookmarks1
bad bookmarks2

What I want my bookmarks to look like is identical to how the chapter title is formatted:

good bookmark

I have found that I can input \pdfbookmark[0]{THE BEGINNING}{name1}, but I would need to remove the bookmarks created by hyperref (which would not be ideal if I have multiple chapters, sections, subsections, etc., and have to input them all manually using this method.)

Will I have to work with changing \chapter{THE BEGINNING} to \chapter{CHAPTER \thechapter: THE BEGINNING}, then worry about removing the chapter number from 'CHAPTER 1: THE BEGINNING' from the title and ToC?

UPDATE:

The best option I found is:
How to remove chapter numbering without removing it from tableofcontents

I can use the code

\newcommand{\mychapter}[2]{
    \setcounter{chapter}{#1}
    \setcounter{section}{0}
    \chapter*{#2}
    \addcontentsline{toc}{chapter}{#2}}

I use TeXMaker, and I like the structure is provides for opening/organizing subfiles (i.e. using \input{...}). To keep this as organized as possible, I resorted to the following:

  1. Create .tex file titled Chapter.1.THEBEGINNING

  2. This subfile will include \mychapter{1}{CHAPTER \thechapter: THE BEGINNING}

  3. My main document will include \input{Chapter.1.THEBEGINNING}

This works well enough…although still looking for better options.

Best Answer

This example provides a small modification of Werner's solution. Instead of patching the internal \Hy@writebookmark the redefinition of \numberline is done in the bookmark hook addtohook of package bookmark:

\documentclass{report}

\usepackage{hyperref}
\usepackage{bookmark}
\bookmarksetup{numbered}

\usepackage{titlesec} %reformatting the chapter headings
\titleformat{\chapter}[block]
  {\normalfont\LARGE\bfseries\centering}
  {CHAPTER\thechapter: }{0em}{}

\makeatletter
\bookmarksetup{%
  addtohook={%
    \ifnum\toclevel@chapter=\bookmarkget{level}\relax
      \renewcommand*{\numberline}[1]{CHAPTER #1: }%
    \fi
  },
}
\makeatother

\begin{document}

\tableofcontents

\chapter{THE BEGINNING}
Hello.
\section{A section}

\chapter{THE END}
Goodbye.
\end{document}

Result