Free Support Forum - groupdocs.com

Rotate PDF Image


#1

I am trying to use the rotate, but it seems to rotate the underlying page, but not the image and text. After upgrading to 3.5 this


public static RotatePageResponse RotatePage(RotatePageParameters parameters)
{
string guid = parameters.Path;
int pageIndex = parameters.PageNumber;

DocumentInfoOptions documentInfoOptions = new DocumentInfoOptions(guid);
DocumentInfoContainer documentInfoContainer = _imageHandler.GetDocumentInfo(documentInfoOptions);
int pageNumber = documentInfoContainer.Pages[pageIndex].Number;

RotatePageOptions rotatePageOptions = new RotatePageOptions(guid, pageNumber, parameters.RotationAmount);
RotatePageContainer rotatePageContainer = _imageHandler.RotatePage(rotatePageOptions);

RotatePageResponse response = new RotatePageResponse
{
resultAngle = rotatePageContainer.CurrentRotationAngle
};

return response;
}

Complains about obsolete calls. Any help to get rotation working?


#2

Hi Jemoritz,


We apologize for inconvenience.

Can you please provide us the problematic file/document you are using at your end? It will help us to investigate your reported issue at our side. We shall be waiting for your response.

Have a nice day.
Warm Regards

#3

So to make sure it wasn’t something on my end I tried to use the web forms sample program, just downloaded.


When I enable supportPageRotation: true, the program crashed in GetDocumentPageImage.aspx.cs

its on the page load in this loop

foreach (String key in Request.QueryString.AllKeys)
{
if (!string.IsNullOrEmpty(Request.QueryString[key]))
{
var propertyInfo = parameters.GetType().GetProperty(key, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
propertyInfo.SetValue(parameters, ChangeType(Request.QueryString[key], propertyInfo.PropertyType),null);
}
}
When I set rotate to true its adds a dummy key to the query string and it appears the system doesn’t know what to do with it. Its returns a null value back

#4

Hi Jemoritz,


Thanks for providing the details.

I have checked your reported issue in <a rel=“nofollow” href=“https://github.com/groupdocs-viewer/GroupDocs.Viewer-for-.NET/tree/master/Showcases/ASP.NET_WebForm_Front_End” class=“js-navigation-open” id=“3b1c9237c5322dddadcbaffe9171d725-11655f3b2ba96d3f0127f2abbe99163326c1f77f” title=“ASP.NET_WebForm_Front_End” style=“box-sizing: border-box; color: rgb(64, 120, 192); text-decoration: none; font-family: -apple-system, BlinkMacSystemFont, “Segoe UI”, Roboto, Helvetica, Arial, sans-serif, “Apple Color Emoji”, “Segoe UI Emoji”, “Segoe UI Symbol”; font-size: 14px; line-height: 20px; white-space: nowrap; background-color: rgb(255, 255, 255);”>ASP.NET_WebForm_Front_End and the application crashed on your mentioned part of the code. However, if you encapsulate the following code in a try catch block then the issue gets resolved and rotation works using supportPageRotation: true.

try
{
var propertyInfo = parameters.GetType().GetProperty(key, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
propertyInfo.SetValue(parameters, ChangeType(Request.QueryString[key], propertyInfo.PropertyType), null);
}
catch { }


Please try and share your feedback.
Warm Regards