Rotate

what is the recommended way to roate page 1 to 10?Do you have optimized code sample to do that?Should i roate after getpages method for performance?

HtmlOptions htmlOptions = CreateHtmlOptions();
htmlOptions.PageNumber = 1
htmlOptions.CountPagesToRender = 10

_htmlHandler.GetPages(documentPath, options);
;

@philipthomas32,

Thanks for using GroupDocs.Viewer and posting on our forum. You will have to rotate pages using RotatePage method before GetPages to get the rotated content and it won’t work if you rotate pages after GetPages. In fact, RotatePage just updates the file data in fd.xml and saves the value of the rotation angle for the mentioned page(s). When you call GetPages, it reads the value of the angle from fd.xml and generates the rotated Html pages. Following is the sample code that can be used for rotating first 10 pages.

ViewerHtmlHandler htmlHandler = new ViewerHtmlHandler(config);

HtmlOptions options = new HtmlOptions();

htmlOptions.PageNumber = 1
htmlOptions.CountPagesToRender = 10

for (int i = 1; i <= 10; i++)
{
        RotatePageOptions rotatePageOptions = new RotatePageOptions(i, 90);
        htmlHandler.RotatePage(guid, rotatePageOptions);
}

options.Transformations = Transformation.Rotate;
List<PageHtml> pages = htmlHandler.GetPages(guid, options);

thanks for the fast response as usual.
Rotation looks good for non excel file
In excel file it doesnt show all the rows when i rotate
What is the recommended code to rotate an excel file?
This is our paging as default for excel
HtmlOptions options = new HtmlOptions();
htmlOptions.PageNumber = 1
htmlOptions.CountPagesToRender = 8
Assuming excel display 800 rows in first page

@philipthomas32,

Thanks for your response. Would you please tell us if you are also using the CellsOptions properties as shown in the following sample? Also, please mention the angle’s value.

htmlOptions.CellsOptions.OnePagePerSheet = false;
htmlOptions.CellsOptions.CountRowsPerPage = 800;

Looking forward to your response.

What is the rotatePageOptions when using following htmloption for excel file?We display 800 lines of excel in one page

RotatePageOptions rotatePageOptions = new RotatePageOptions(???,90);
_htmlHandler.RotatePage(previewDocumentInfo.RawDocumentPath, rotatePageOptions);

HtmlOptions options = new HtmlOptions();
htmlOptions.PageNumber = 1
htmlOptions.CountPagesToRender = 8
htmlOptions.CellsOptions.OnePagePerSheet = false;
htmlOptions.CellsOptions.CountRowsPerPage = 100;

@philipthomas32,

Thanks for providing the details. The rotate feature works in the same way for all the document formats including the Excel documents and the same code is used for all document formats.

Furthermore, we have tested to render Excel files with rotation but unable to reproduce the issue of missing rows. Would you please provide us the problematic Excel document and the resultant Html that is generated after applying rotation? Moreover, it would be helpful for us if you would share the screenshots with pointing the areas where the rows are missing in the Html pages. We shall be looking forward to your response.

This is basically a logical question
HtmlOptions options = new HtmlOptions();
htmlOptions.PageNumber = 1
htmlOptions.CountPagesToRender = 8
htmlOptions.CellsOptions.OnePagePerSheet = false;
htmlOptions.CellsOptions.CountRowsPerPage = 100;

Following code create 8 pages in cache folder

before that code i loop to rotate 8 pages

for (i=1;i<=8;i++)
{
RotatePageOptions rotatePageOptions = new RotatePageOptions(2,90);
_htmlHandler.RotatePage(previewDocumentInfo.RawDocumentPath, rotatePageOptions);
}

but i get error when i =2 say page number 2 doesnt exist with RotatePage, then why cache folder create page 1 to 8?

I will attach the file now

RotatePageOptions rotatePageOptions = new RotatePageOptions(1,90);
_htmlHandler.RotatePage(previewDocumentInfo.RawDocumentPath, rotatePageOptions);
htmlOptions.PageNumber = 1
htmlOptions.CountPagesToRender = 8
htmlOptions.CellsOptions.OnePagePerSheet = false;
htmlOptions.CellsOptions.CountRowsPerPage = 100;
_htmlHandler.GetPages(documentPath, htmlOptions);20180130-114526852_16473.zip (2.7 MB)

when i rotate 90 i dont see 800 rows

Basically htmlOptions has pagenumber and
CountPagesToRender

RotatePageOptions only has only starting page number, how does
RotatePageOptions know how to many pages to roate

You can give me an example on how to roatate many pages in an excel file like for loop of rotatepage

we have paging in ui. In page 1 i display 800 rows of excel, page 2 i display 801 to 1600 rows
that works, but when i rotate page 2, not sure about roatepage to be used specifically RotatePageOptions.
Let me know in how can i rotate scenario1 and 2

Rotation code for scenario 1 and 2 is needed

Senario 1( page 1 in ui)
// means row 1 to 800 in excel
htmlOptions.PageNumber = 1
htmlOptions.CountPagesToRender = 8
htmlOptions.CellsOptions.OnePagePerSheet = false;
htmlOptions.CellsOptions.CountRowsPerPage = 100;

Senario 2( page 2 in ui)
// means row 801 to 1600 in excel
htmlOptions.PageNumber = 9
htmlOptions.CountPagesToRender = 8
htmlOptions.CellsOptions.OnePagePerSheet = false;
htmlOptions.CellsOptions.CountRowsPerPage = 100;

@philipthomas32,

Thanks for providing the detailed information.

In fact, the source Excel document actually contains only 1 sheet and GroupDocs.Viewer considers one sheet as one page. When you call RotatePage function, it checks the file data (fd.xml) in the cache. If the file data exists, it reads the information and sets the angle accordingly and if file data doesn’t exist, it simply checks the page count in the source document that contains only one page/sheet. As the RotatePage doesn’t know about the CellsOptions, it simply creates the info for only one page in the fd.xml. Here comes the difference in Excel documents and the other document formats.

As a result, when accessing the second page that does not exist in the source document, the error occurs. Although you have set the HtmlOptions.CellsOptions to divide the sheet into multiple pages, the RotatePage function has the info about only one page.

To handle this situation, you can generate the fd.xml using GetDocumentInfo function before RotatePage as shown in the sample code. It will generate the file data containing the information that the Excel sheet will be divided into multiple pages. Hence, the RotatePage funtion will read the file data from cache and will know that the Excel sheet is going be rendered into multiple Html pages.

DocumentInfoOptions infoOptions = new DocumentInfoOptions();
infoOptions.CellsOptions.OnePagePerSheet = false;
infoOptions.CellsOptions.CountRowsPerPage = 100;

DocumentInfoContainer docInfo = htmlHandler.GetDocumentInfo(FileName, infoOptions);
for (int i = 1; i <= docInfo.Pages.Count; i++)
{
        htmlHandler.RotatePage(FileName, new RotatePageOptions(i, 90));
}

Using the above code, the API will generate fd.xml containing the information that the Excel sheet will be divided into multiple pages and RotatePage will also work accordingly without throwing any exception.

The code I have provided above will also serve this requirement as well and the RotatePage function will know how many pages are supposed to be created for the complete Excel sheet.

If I understood your requirement correctly, you need to render 800 rows for each page. However, the settings you have provided us are rendering 1 to 8 pages and 100 rows per page. In my opinion, you can render each page containing 800 rows using the following code.

HtmlOptions options = new HtmlOptions();
// Senario 1( page 1 in ui), means row 1 to 800 in excel
options.PageNumber = 1;
options.CountPagesToRender = 1;
options.CellsOptions.OnePagePerSheet = false;
options.CellsOptions.CountRowsPerPage = 800;
// Get pages
var pages = htmlHandler.GetPages(FileName, options);


// Senario 2( page 2 in ui), means row 801 to 1600 in excel
options.PageNumber =2;
options.CountPagesToRender = 1;
options.CellsOptions.OnePagePerSheet = false;
options.CellsOptions.CountRowsPerPage = 800;
// Get pages
var pages = htmlHandler.GetPages(FileName, options);

Using the above code, we have the following results.

For rotating the second page you can use the following code.

options.PageNumber = 2;
options.CountPagesToRender = 1;
options.CellsOptions.OnePagePerSheet = false;
options.CellsOptions.CountRowsPerPage = 800;
options.Transformations = Transformation.Rotate;

// Get document info
DocumentInfoOptions infoOptions = new DocumentInfoOptions();
infoOptions.CellsOptions.OnePagePerSheet = false;
infoOptions.CellsOptions.CountRowsPerPage = 800;
DocumentInfoContainer docInfo = htmlHandler.GetDocumentInfo(FileName, infoOptions);

htmlHandler.RotatePage(FileName, new RotatePageOptions(2, 90));

// Get pages
var pages = htmlHandler.GetPages(FileName, options);

We are able to reproduce this issue at our end using version 17.4 of GroupDocs.Viewer. However, the issue is fixed in version 18.1. You can download the Html that we have generated using version 18.1 from here. We would recommend you to upgrade the API in order to get this issue fixed.

You can download the complete sample application that we used to perform rotation in your provided Excel document from here.

Thanks for the detailed code description. I will try it out.
Also if i want to use 18.1 version , is it supported with our current license ? OrderID180103043152

Is it possible to give a 18.1 build with the mutex fix you already added for the 17.4.1?

@philipthomas32,

Thanks for your response.

If your subscription has not expired before the release of version 18.1 then you can feel free to use the same license else you will have to renew your license to get the updates.

As version 18.1 has already been released therefore the Mutex fix is not available in that. However, the fix will be included in version 18.2 which is expected to be released in the second half of February.

thanks ,can you let me know after second half of February where i can download 18.2(please make sure mutex fix go with 18.2)

Our Subscription Expiry is 20190110,we renewed few month back

thanks ,can you let me know after second half of February where i can download 18.2(please make sure mutex fix go with 18.2)

Our Subscription Expiry is 20190110,we renewed few months back

@philipthomas32,

Thanks for your response.

Sure thing. When the release will be onboard, it will be available in our download section as well as on NuGet. We will also notify you here and provide you the download link.

Then you can feel free to use version 18.1.

Thanks again for your knowledge sharing and quick responses, good job

@philipthomas32,

You are always welcome.

can you give me a notification version 18.2 is ready that include the mutex fix also

@philipthomas32,

Thanks for coming back to us. Currently, we don’t have any fixed date for the release of version 18.2. However, the release is expected in the second half of the current month. As soon as the version 18.2 is released, we’ll notify you here. We appreciate your cooperation in this regards.

thanks for the response