Created
May 8, 2013 20:46
-
-
Save mcw0933/5543526 to your computer and use it in GitHub Desktop.
Getting the first page of a fixed document sequence as a reference page to know how to set page orientation. Assumes that all pages in the document are the same size and same orientation as page 1.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Gets the PageOrientation of the first page of a fixed document sequence, based on that page's dimensions. | |
/// </summary> | |
/// <param name="docSeq">The fixed document sequence.</param> | |
/// <returns> | |
/// If the first page could not be found, returns Unknown. | |
/// Returns Portrait when the page width is less than the height. | |
/// Otherwise (width is greater than OR EQUAL), returns Landscape. | |
/// </returns> | |
private static PageOrientation GetPageOrientationOfFirstPageOfFixedDocSeq(FixedDocumentSequence docSeq) { | |
PageOrientation orientation = PageOrientation.Unknown; | |
FixedPage firstPage = GetFirstPageOfFixedDocSeq(docSeq); | |
if (firstPage != null) { | |
orientation = (firstPage.Width >= firstPage.Height) ? PageOrientation.Landscape : PageOrientation.Portrait; | |
} | |
return orientation; | |
} | |
/// <summary> | |
/// Gets the first fixed document in a fixed document sequence, or null. | |
/// </summary> | |
/// <param name="docSeq">The fixed document sequence</param> | |
/// <returns>The first fixed document, or null.</returns> | |
private static FixedDocument GetFirstDocumentOfFixedDocSeq(FixedDocumentSequence docSeq) | |
{ | |
FixedDocument firstDoc = null; | |
if (docSeq != null && docSeq.References != null && docSeq.References.Count > 0) | |
{ | |
DocumentReference firstDocRef = docSeq.References[0]; | |
firstDoc = firstDocRef.GetDocument(true); | |
} | |
return firstDoc; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment