How to rotate some documents based on portrait layout or depending on text orientation

Question

Some documents were rotated when they shouldn't.
How to rotate documents based on portrait layout or depending on text orientation?

Answer

To achieve this it's required to add the additional script to Workflow of DocumentProcessing type:

Use the following code to rotate depending on resolution:

for(int i=0;i<Document.Pages.Count;i++ )
if(Document.Pages[i].Picture.Height < Document.Pages[i].Picture.Width){
    IEditablePictureObject editablePicture = Document.Pages[i].Picture.CreateEditableCopy();
    editablePicture.Rotate(90);
    Document.Pages[i].ReplaceImage(editablePicture);
}

Or this one to rotate the image depending on English text orientation:

for(int i=0;i<Document.Pages.Count;i++ )
{
    IEditablePictureObject editablePicture = Document.Pages[i].Picture.CreateEditableCopy();
    int page_rotation = Document.Pages[i].Picture.DetectPageOrientation("English");
    editablePicture.Rotate(page_rotation*(-1));
    Document.Pages[i].ReplaceImage(editablePicture);
}

Additional information

Processing scripts

IEditablePictureObject

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.

Recently viewed