Switch to Landscape Mode

I have created a print job that lists Word Document Templates in a tabular format using DocBuilder’s table, cell, and row features. It’s come out pretty good; I even nest two types of related documents within it. Now I need to, should my user request it, display the template text for the templates within the print job. Some of the templates are in Landscape Mode, such as envelopes.

I think I’m reading in the template text okay but I cannot change the landscape mode if the document text requires it. I am closing the table out, reading in the document in a loop reading its sections, thencreating the table again.

Is there a way I can change the landscape mode for the document text, then restore it?

This message was posted using Page2Forum from Orientation Enumeration - Aspose.Words for .NET and Java

Please reply to my correct email address of
and copy to

Thank you.

Hi Earle,

Thanks for your inquiry. Unfortunately, it is not quite clear for me what you need to achieve. Could you please provide me your code and attach the input documents and the document, which show what is the expected output (you can create it in MS Word). I will investigate the issue and provide you more information.

Best regards.

Hey, that was a prompt reply!

In trying to get my code ready to send you (I’d tried a suggestion form a co-worker that didn’t work out), I came across

Word Combining Documents

and found my answer in there. I applied this line of its code sample:


(I’d been reading in sections into new sections) and this did the trick for me.


It is perfect, that you already resolved the problem.

Best regards,

Turns out that didn’t quite take care of everything. But I’m closer.

I’m uploading my current code that appends the Word documents’ text at the end of the output file. What I want to do is append each of them right after the tabular data for that particular document. The method I would do that in is DisplayTemplateText().

What I want to do is something like start a new section and move to it and continue building my tabular data after adding a Word document to my output document.

Is this doable? How would I go about it?

How do I tell my Document (or DocumentBuilder?) that I want it to now move to a new Section?


Save Edit

I got another step closer when I found an article with a method called InsertDocument(). I grabbed this and can now get the document printed in place in my tabular data. Some of the documents though “jump up” and cover some of the tabular data. Here’s the modified code in my DisplayTemplateText() that gets me that far:

builder.InsertCell().CellFormat.Width = 620;

InsertDocument(builder.CurrentParagraph, ttd);

In order to avoid the overprinting, I added this above that:


but that once agan forces all the read-in Word documents to appear at the end of my report instead of in-place.

How can I force a page break there, so that my document starts on a fresh page, while keeping it in its position rather than have it drop down to the end of the file?


Thanks for your request. I think in your case you can try using construction like following

InsertDocument(builder.CurrentParagraph, ttd);

And I suppose you should consider option of using AppendDocument method.

Hope this helps.

Best regards,

The two lines of code in your response; did you notice they were both in the message you were responding to? Maybe I should rephrase my current problem:

I wish to insert the body of Word documents into a print document I’m constructing in place after the tabular data related to that document and before the tabular data for the next document. If I have to append the Word documents at the end, so be it, but that is not what I’m hoping to accomplish. I have come real close to getting it done but some of the Word documents partially cover the tabular data. To avoid that I would like to start the Word document on a new page. Still in order, right after its related tabular data and before the tabular data for the next document. I know of no way to force a page break within a table so I EndTable(), InsertBreak(), and StartTable(). I hoped that would do it but the inserted Word document then appears at the end of the print document I’m constructing.

Is this the expected behavior? Is there a way for me to accomplish what I’ve described with your product?

Thank you.

I’ve attached a PDF of a print run to demonstrate my current problem. If you look at Page 19 you’ll see how the embedded Word document overlays part of the tabular data and why I want to insert page breaks.


Thank you for additional information. The problem might occur, because your document, which you insert into the table, contains floating content (text box I suppose). Could you please attach this document here for testing (especially the document, which you insert on 19th page)? I will check it and provide you more information.

Best regards,

Here’s the Word document.

Thank you.


Thanks you for additional information. The problem occurs, because there is text frame in your document and this text frame has absolute position relative to page. So when you insert this document into another document, the frame will have the same position on the page and can overlap some text on it.

Best regards,

Thanks. It’s nice to know what causes it. But I really need to know how to deal with it. Adding a page break is what struck me as a good way to do it. But that turns my Insert into an Append, that is, it forces the document to the end rather than inserting it in the flow.

Is there a way I can do a page break that doesn’t cause the insert to appear at the end? If not, what would be involved in removing the page frame?

Hi Earle,

Thanks for your inquiry. May I suggest you another way of building your document? As I can see, the output document is a list of templates. This list consists of short template description and simple preview of the template. I think, if the output document should be always PDF, you can insert preview of your templates as images. You can use Document.SaveToImage method to generate preview of your templates. Please let me know if such approach is acceptable for you.

Best regards,

Thanks. That approach works well for both PDF and Print.