How do I rotate a PDF page?

Q: We are using the SDK to rotate PDF documents.It works fine with
most PDFs, but it doesn't work with some. The C# code fragment is
listed below:

  PDFDoc doc = new PDFDoc(PdfBytes, PdfBytesSize);
  Page.Rotate originalRotation = doc.GetPage(0).GetRotation();
  Page.Rotate rotation;
  switch (originalRotation) {
      case Page.Rotate.e_0: rotation = Page.Rotate.e_90; break;
      case Page.Rotate.e_90: rotation = Page.Rotate.e_180; break;
      case Page.Rotate.e_180: rotation = Page.Rotate.e_270; break;
      case Page.Rotate.e_270: rotation = Page.Rotate.e_0; break;
      default: rotation = Page.Rotate.e_0; break;
  }
  doc.GetPage(0).SetRotation(rotation);
  string tempFileName = Path.GetTempFileName() + ".pdf";
  doc.Save(tempFileName, SDFDoc.SaveOptions.e_hex_strings);