Aspose.Diagram.Examples.CSharp.Working_with_Print.XpsPrintHelper.Print C# (CSharp) Метод

Print() публичный статический Метод

Sends an Aspose.Diagram document to a printer using the XpsPrint API.
Thrown if any error occurs.
public static Print ( Diagram diagram, string printerName, string jobName, bool isWait ) : void
diagram Diagram
printerName string
jobName string Job name. Can be null.
isWait bool True to wait for the job to complete. False to return immediately after submitting the job.
Результат void
        public static void Print(Diagram diagram, string printerName, string jobName, bool isWait)
        {
            if (diagram == null)
                throw new ArgumentNullException("document");

            // Use Aspose.Diagram to convert the document to XPS and store in a memory stream.
            MemoryStream stream = new MemoryStream();
            diagram.Save(stream, SaveFileFormat.XPS);
            stream.Position = 0;

            Print(stream, printerName, jobName, isWait);
        }
        // ExEnd:XpsPrint_PrintDocument

Same methods

XpsPrintHelper::Print ( Stream stream, string printerName, string jobName, bool isWait ) : void

Usage Example

        public static void Run()
        {
            // ExStart:PrintDiagramVisXPSPrinterAPI
            // The path to the documents directory.
            string dataDir = RunExamples.GetDataDir_Print();

            // Load source Visio diagram
            Diagram diagram = new Diagram(dataDir + "Drawing1.vsdx");

            // Specify the name of the printer you want to print to.
            const string printerName = @"\\COMPANY\Brother MFC-885CW Printer";

            // Print the document.
            XpsPrintHelper.Print(diagram, printerName, "My Test Job", true);
            // ExEnd:PrintDiagramVisXPSPrinterAPI
        }