Pregunta

I am drawing a document in cocoa, and it is 90 degrees rotated so the print job is sent correctly to a thermal label printer. It works fine, since the document is rotated 90 degrees correctly according to the label printer layout. But I want to display the document for the user in PDFView correctly, how can I rotate the whole document 90 degrees as it is inserted using "setDocument"? Thanks.

¿Fue útil?

Solución

Create a PDF first. In PDF you can create rotated pages in 2 ways: set page size to 8.5*11in and set the Rotate page attribute to 90, or simply set the page size to 11*8.5in. Visually there is no difference. The problem with Preview (and I assume also PDFKit behind it) is that when you set the rotation to 90, it does not simply set the Rotate attribute to 90, but it switches the page width and height and applies a transformation on the page content stream so that the page content appears rotated. Because the [PDFPage rotation] and CGPDFPageGetRotationAngle return the value of the Rotate attribute, they will always return 0 on pages rotated with Preview and PDFKit.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top