With SetaPDF from Setasign, when importing a page from a document and trying to paint a line of text to that page the text shows up upside down, as if it was reflected on the x axis.
I tried drawing the text vía SetaPDF_Core_Text_Block() and also with the canvas text() helper
$reader = new \SetaPDF_Core_Reader_File($original);
$tempWriter = new\SetaPDF_Core_Writer_File(Routes::DOCUMENT_UPLOAD.'test.pdf');
$document = \SetaPDF_Core_Document::load($reader, $tempWriter);
$portada = $document->getCatalog()->getPages()->getPage(1);
$canvas = $portada->getCanvas();
$font = \SetaPDF_Core_Font_Standard_HelveticaBold::create($document);
$text = new \SetaPDF_Core_Text_Block($font, 24);
$text->setText('ABCDEF');
$text->setAlign(\SetaPDF_Core_Text::ALIGN_LEFT);
$text->setBackgroundColor('#FFFFFF');
$text->draw($canvas, 0 ,0);
The result in this image:
Setasign support provided the page in manuals to understand this issue:
https://manuals.setasign.com/setapdf-core-manual/canvas/#index-2-1
TLDR; I was working with a PDF that was previously rotated (didn't know) so when working with existing pages you have to use:
$pageImported = $document->getCatalog()->getPages()->getPage(1);
$pageImported ->getStreamProxy()->encapsulateExistingContentInGraphicState();
$canvas = $portada->getCanvas();
So you encapsulate the content and do not work with the page original graphic state.