class_docstr: Manages grafting text-only PDFs onto regular PDFs.
class_docstr_tok: ["Manages","grafting","text-only","PDFs","onto","regular","PDFs","."]
docstr: Save and reload the Pdf.
  
  This will keep a lid on our memory usage for very large files. Attach
  the font to page 1 even if page 1 doesn't use it, so we have a way to get it
  back.
docstr_tok: ["Save","and","reload","the","Pdf",".","This","will","keep","a","lid","on","our","memory","usage","for","very","large","files",".","Attach","the","font","to","page","1","even","if","page","1","does","n't","use","it",",","so","we","have","a","way","to","get","it","back","."]
code: def save_and_reload(self) -> None:
      """Save and reload the Pdf.
  
      This will keep a lid on our memory usage for very large files. Attach
      the font to page 1 even if page 1 doesn't use it, so we have a way to get it
      back.
      """
      page0 = self.pdf_base.pages[0]
      _update_resources(
          obj=page0.obj, font=self.font, font_key=self.font_key
      )
  
      # We cannot read and write the same file, that will corrupt it
      # but we don't to keep more copies than we need to. Delete intermediates.
      # {interim_count} is the opened file we were updating
      # {interim_count - 1} can be deleted
      # {interim_count + 1} is the new file will produce and open
      old_file = self.output_file.with_suffix(
          f".working{self.interim_count - 1}.pdf"
      )
      if not self.context.options.keep_temporary_files:
          with suppress(FileNotFoundError):
              old_file.unlink()
  
      next_file = self.output_file.with_suffix(
          f".working{self.interim_count + 1}.pdf"
      )
      self.pdf_base.save(next_file)
      self.pdf_base.close()
  
      self.pdf_base = Pdf.open(next_file)
      self.font, self.font_key = (
          None,
          None,
      )  # Ensure we reacquire this information
      self.interim_count += 1
  
file_path: OCRmyPDF/src/ocrmypdf/_graft.py
imports: from __future__ import annotations
  import logging
  from contextlib import suppress
  from enum import Enum
  from pathlib import Path
  from pikepdf import Dictionary, Matrix, Name, Operator, Page, Pdf, PdfError, Stream, parse_content_stream, unparse_content_stream
  from ocrmypdf._jobcontext import PdfContext
label_desc: Use image node_id 3 for calling the OcrGrafter obj's underlying member method code with example usage: obj.save_and_reload() without return types