code: func (f *Fpdf) Close() {
  	if f.err == nil {
  		if f.clipNest > 0 {
  			f.err = fmt.Errorf("clip procedure must be explicitly ended")
  		} else if f.transformNest > 0 {
  			f.err = fmt.Errorf("transformation procedure must be explicitly ended")
  		}
  	}
  	if f.err != nil {
  		return
  	}
  	if f.state == 3 {
  		return
  	}
  	if f.page == 0 {
  		f.AddPage()
  		if f.err != nil {
  			return
  		}
  	}
  	// Page footer
  	f.inFooter = true
  	if f.footerFnc != nil {
  		f.footerFnc()
  	} else if f.footerFncLpi != nil {
  		f.footerFncLpi(true)
  	}
  	f.inFooter = false
  
  	// Close page
  	f.endpage()
  	// Close document
  	f.enddoc()
  	return
  }
docs: // Close terminates the PDF document. It is not necessary to call this method
  // explicitly because Output(), OutputAndClose() and OutputFileAndClose() do it
  // automatically. If the document contains no page, AddPage() is called to
  // prevent the generation of an invalid document.