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

Have more questions? Submit a request

Comments

2 comments

  • Avatar

    yong_lee7015

    But for me , I can't find the script functions in work flow stage . it is related to my version?

    0
  • Avatar

    yong_lee7015

    I found it,it works ,thanks

    0

Please sign in to leave a comment.