We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Document Orientation (document rotation)

When printing a document, is there a way to rotate the entire document by 180 degrees? Some printer drivers have this option but is there a way to rotate programmatically.


Thanks for your request. Maybe, in your case, you can just specify orientation of pages in your document. Please follow the link for more information:


Best regards,

Setting the landscape or portrait orientation will no solve the issue. I need the document to print 180 degrees of its original orientation.

So back to the original question. Once the orientation has been selected, either portrait or landscape, is there a way to programmatically rotate the entire print job 180 degrees. So if the printer normally prints the head first then the tail, I need it to print the tail first and then the head. (this is need because of some special issues with certain labels).


Thanks for your request. Unfortunately, I do not see a direct way to achieve this. However, you can try converting the document to a series of images and then rotate the images before printing. Please let me know if you need a code example how to achieve this.

Best regards,

A code sample would be GREAT! Look forward to it.


Thanks for your request. Please see the following code example:


public void Test001()


// Open source document.

Document doc = new Document(@"Test001\in.doc");

// Save the document as an image.

using (MemoryStream imageStream = new MemoryStream())


doc.Save(imageStream, SaveFormat.Tiff);

// Load the image back into another document and rotate the images.

imageStream.Position = 0;

Document imageDoc = LoadImage(imageStream);

// Print the document.





/// Loads an image into Aspose.Words.Document object and rotates the image to 180 degrees.


/// Stream with an image.

public Document LoadImage(Stream inputStream)


// Create Aspose.Words.Document and DocumentBuilder.

// The builder makes it simple to add content to the document.

Document doc = new Document();

DocumentBuilder builder = new DocumentBuilder(doc);

// Read the image from file, ensure it is disposed.

using (Image image = Image.FromStream(inputStream))


// Get the number of frames in the image.

int framesCount = image.GetFrameCount(FrameDimension.Page);

// Loop through all frames.

for (int frameIdx = 0; frameIdx < framesCount; frameIdx++)


// Insert a section break before each new page, in case of a multi-frame TIFF.

if (frameIdx != 0)


// Select active frame.

image.SelectActiveFrame(FrameDimension.Page, frameIdx);

// We want the size of the page to be the same as the size of the image.

// Convert pixels to points to size the page to the actual image size.

PageSetup ps = builder.PageSetup;

ps.PageWidth = ConvertUtil.PixelToPoint(image.Width, image.HorizontalResolution);

ps.PageHeight = ConvertUtil.PixelToPoint(image.Height, image.VerticalResolution);

// Insert the image into the document and position it at the top left corner of the page.

Shape shape = builder.InsertImage(









// Rotate the image.

shape.Rotation = 180;



return doc;


Hope this helps.

Best regards,