I am using Aspose.Words to create a PostScript document that I sent to a printer using Windows PrintAPI, and CUPS on Mac/Linux.
This is how I generate the file:
Aspose.Words.Document asposeDoc = new Aspose.Words.Document();
// image format
DocumentBuilder builder = new DocumentBuilder(asposeDoc);
// Read the image from file, ensure it is disposed.
using (Image image = Image.FromStream(pageData))
{
// Find which dimension the frames in this image represent. For example
// the frames of a BMP or TIFF are "page dimension" whereas frames of a GIF image are "time dimension".
FrameDimension dimension = new FrameDimension(image.FrameDimensionsList[0]);
// Get the number of frames in the image.
int framesCount = image.GetFrameCount(dimension);
// 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)
builder.InsertBreak(BreakType.SectionBreakNewPage);
// Select active frame.
image.SelectActiveFrame(dimension, 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.
builder.InsertImage(
image,
RelativeHorizontalPosition.Page,
0,
RelativeVerticalPosition.Page,
0,
ps.PageWidth,
ps.PageHeight,
WrapType.None);
}
}
SaveOptions opts = PsSaveOptions.CreateSaveOptions(SaveFormat.Ps);
asposeDoc.Save(outStream, opts);
outStream.Seek(0, SeekOrigin.Begin);
return outStream;
When I send this PS file to the print APIs, the image prints rotated 90 degrees.
However, if I instead save this exact document with SaveFormat.PNG, the image is not rotated.
Am I doing something wrong when making the PostScript file?
The PS file views correctly if I look at it with various online viewers.
Thanks!