We cannot use the Words.Document.SaveToPdf function because it degrades
the quality of our output and does not have full support for Asian fonts. So, we must use the PdfViewer.
Below is the code used. This code has not changed for about 3 versions of our software, except for the PrintDocumentWithSettings function where we now have to explicitly set the page range even if its all pages. Both print calls produce the same result.
PdfViewer viewer;
MemoryStream pdfStream;
Aspose.Pdf.Pdf pdf;
viewer = new PdfViewer();
try
{
pdfStream = new MemoryStream(1 << 17);
pdf = (Aspose.Pdf.Pdf)_result;
pdf.Save(pdfStream);
pdfStream.Position = 0;
viewer.AutoResize = true;
viewer.AutoRotate = true;
viewer.PrintPageDialog = false;
viewer.OpenPdfFile(pdfStream);
if (printerSettings != null)
{
printerSettings.FromPage = 1;
printerSettings.ToPage = viewer.PageCount;
viewer.PrintDocumentWithSettings(printerSettings);
}
else
viewer.PrintDocument();
viewer.ClosePdfFile();
I tested this again and have again attached the output. Please verify that you see the problems in the outputs that I have attached.
I also tried the following variant to the code to correct the doubling of the margins in the printed output and even setting the margins to zero did not work:
printerSettings = new PrinterSettings();
if (printerSettings.PrinterName == “Microsoft XPS Document Writer”)
{
if (!_outputDirectory.Exists)
_outputDirectory.Create();
printerSettings.DefaultPageSettings.Margins = new Margins(0,0,0,0);
printerSettings.PrintToFile = true;
printerSettings.PrintFileName = _outputDirectory.FullName + Path.GetFileNameWithoutExtension(_controller.Package.FileName) + “.xps”;
printerSettings.FromPage = 1;
printerSettings.ToPage = viewer.PageCount;
viewer.PrintDocumentWithSettings(printerSettings);
}
We are coming up on a release date and need to have resolution to these issues. This has been a serious regression from the previous versions of your software that we were using. However, the newer versions contain other critical fixes that were promised to our clients, so we cannot just revert back to the old dll’s.
Thanks for you support in this!