You can apply while you are still in Canada. In most cases, the application must be sent to the Portuguese Embassy or Consulate in the country in which the applicant resides.