Posting the document was very helpful. For additional protection of your identity, I would suggest that you also blank out your name and the serial number at the top of the document.
The document says:
ESTE DOCUMENTO PERMITE A SU TITULAR LA SALIDA Y EL POSTERIOR REGRESO A ESPAÑA, ÚNICAMENTE POR PUESTOS FRONTERIZOS ESPAÑOLES, SIN NECESIDAD DE VISADO, HASTA EL 04 DE JULIO DE 2019. NO VÁLIDO PARA CIRCULAR POR ESTADOS SCHENGEN.
[my translation] THIS DOCUMENT ALLOWS ITS HOLDER TO EXIT AND SUBSEQUENTLY RETURN TO SPAIN, ONLY BY SPANISH BORDER POSTS, WITHOUT NEED OF VISA, UNTIL 4 JULY 2019. NOT VALID FOR TRAVELING THROUGH SCHENGEN STATES.
The rule stated on the document is clear: You cannot use it to travel through any other Schengen countries, such as Germany. You must use the document to return to Spain via its own border control, meaning a direct entry to Spain from a non-Schengen country. Various flights from Canada to Spain pass through other non-Schengen countries (such as the US, UK, or Ireland); however, those countries have their own visa requirements for citizens of Iran, even for transit. Therefore, the clear solution is to get a nonstop flight from Canada to Spain.
Lufthansa has a codesharing arrangement with Air Canada, so you might be able to change your existing ticket to a nonstop flight, rather than having to buy a whole new ticket.
EDIT: I notice the document has its own translation of the above rule into English, saying "This paper allows to its holder the entry and the later return to Spain, only through spanish crossing borders, no need for visa, from 04 07 2019 No longer valid for roaming the Schengen territory." This unclear English might lead you to think it was valid for all of Schengen before 4 July, but it is simply a poor translation. The rule in Spanish and the translation in French are clear that the document is never valid for other travel in Schengen.