Platforms to show: All Mac Windows Linux Cross-Platform
FAQ.How to rotate a PDF page with CoreGraphics?
// Rotate a PDF page// our filesdim sourcefile as FolderItem = SpecialFolder.Desktop.Child("test.pdf")dim destfile as FolderItem = SpecialFolder.Desktop.Child("rotated.pdf")// open PDFdim pdf as CGPDFDocumentMBS = sourcefile.OpenAsCGPDFDocumentMBS// query media size of first pagedim r as CGRectMBS = pdf.MediaBox(1)// create new PDFdim c as CGContextMBS = destfile.NewCGPDFDocumentMBS(r,"title","Author","Creator")// create rotated rectangledim nr as new CGRectMBS(0,0,r.Height,r.Width)// create new pagec.BeginPage nrc.SaveGStateconst pi = 3.14159265// rotate by 90°c.RotateCTM pi*1.5// fix originc.TranslateCTM -r.width,0// draw PDFc.DrawCGPDFDocument pdf,r,1// cleanupc.RestoreGStatec.EndPagec = nil// show in PDF viewerdestfile.Launch
This code is Mac only as it needs CoreGraphics.