AsposeWordsPrintDocument class not found

AsposeWordsPrintDocument printDocument = new AsposeWordsPrintDocument(doc);

We are not able to find AsposeWordsPrintDocument class, we are using Aspose.Words(21.12.0) and we are using the following namespaces
using Aspose.Words;
using Aspose.Words.Rendering;

Attached screenshot of the error. please advice at the earliest.
error.png (19.6 KB)

Also, does Aspose word have an implementation for print() method? In the above aspose,words implementation we are not finding any implementation of print().

Thank You.

@manikantakondepati It seems you are using .NET Standard 2.0 dll of Aspose.Words. Printing feature is not supported in .NET Standard version of Aspose.Words.
This feature, though, is available in .NEt Framework and Java versions of Aspose.Words.

@alexey.noskov, we are using .NET Core 3.1 and would like to use Aspose.Words printing feature, what are my options.

@manikantakondepati I have linked your reques to the appropriate issue WORDSNET-17369.
As a workaround you can use System.Drawing.Common for printing documents in .NET Core. The following simple code can be used to print document by using the System.Drawing.Common. For printing, the document is first converted to image and then printed. Please note that in such approach there might be quality degradation because of conversion to image.


DocumentPrinter printer = new DocumentPrinter();
Document doc = new Document(@"C:\Temp\TestRendering.doc");
printer.Print(doc);
public class DocumentPrinter
{
    /// <summary>
    /// Prints the specified document using default printer.
    /// </summary>
    public void Print(Document doc)
    {
        mDoc = doc;
        mPageIndex = 0;
        PrintDocument pd = new PrintDocument();
        pd.PrintPage += PrintPage;
        pd.Print();
    }

    private void PrintPage(object o, PrintPageEventArgs e)
    {
        try
        {
            using (MemoryStream pageImageStream = new MemoryStream())
            {
                ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Png);
                options.PageSet = new PageSet(mPageIndex);

                mDoc.Save(pageImageStream, options);
                pageImageStream.Position = 0;
                using (Image pageImage = Image.FromStream(pageImageStream))
                {
                    e.Graphics.DrawImage(pageImage, new Point(0, 0));
                }

                // Increase page index and check if there are more pages.
                mPageIndex++;
                e.HasMorePages = (mPageIndex < mDoc.PageCount);
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            // Stop printing in case of errors.
            e.HasMorePages = false;
        }
    }

    private int mPageIndex;
    private Document mDoc;
}

@alexey.noskov Thanks for the info, we verified and the Image quality is very poor and can’t got that route. Is there any method/solution that can help us convert Aspose word document to generic microsoft word document. Thanks in advance.

@manikantakondepati You can try adjusting ImageSaveoptions to make the quality of the image better.
Also, you can convert your document to PS or PCL formats, which can be used by printers.

Could you please elaborate what file format you mean?

I am trying to convert aspose.word document to a word document that can then be printed via Microsoft native print method.2022-01-03_10-38-26.png (47.7 KB)

I will try to convert the document to PS or PCL format and give it a shot. Thank You…

@manikantakondepati Thank you for additional information. Aspose.Words.Document cannot be pass directly into the Microsoft.Office.Interop. You should save the document in DOCX or DOC format first and then use Documents.Open method to open it with Microsoft.Office.Interop.
Also, from your code it is not quite clear what is the purpose of using Aspose.Pdf.Document? It seems like you open PDF produced by Aspose.Words and then immediately save it back as PDF. Could you please elaborate why?

Initially we were trying to convert word document to PDF and then print, but the PDF.PrintDocumentWithSettings method is taking 30-40 seconds to print to a network printer. After which we were trying to print from Aspose.word.print method, which was not available as per your first response in this thread. Now, we are tying to take the document created in aspose but use a Microsoft libraries to print the document to network printer but and then we were not able to convert the word document over the fly.
As per your above response we needed to save the document first and then process it.

In simple terms, what we are trying to achieve is:

  1. Create an aspose word document- works as expected.
  2. Convert aspose word to PDF. - Works as expected.
  3. Send the PDF document to network printer using print server - takes 30-40 seconds as Aspose is always trying to download the printer drivers. So, we are trying different things to get around this issue.

We are tying to see if we can use the document or PDF created in Aspose and then sent it to printer using Microsoft native print method.

Alternatively we were also trying to see if it be any fast using aspose.image.print method, but the quality is bad, so we didn’t go that route.

@manikantakondepati For better quality you can also try using the approach I suggested, but instead of saving page to raster PNG format, try saving to vector EMF.

ImageSaveOptions options = new ImageSaveOptions(SaveFormat.Emf);

Let me know if this approach gives an acceptable result on your side.

@alexey.noskov That actually works good, thanks for the info.

@manikantakondepati It is perfect that the suggested solution works good for you. Please feel free to ask in case of any issues. We are always glad to help you.