Aspose.Words.Examples.CSharp.Rendering_and_Printing.XpsPrintHelper.CopyJob C# (CSharp) Method

CopyJob() private static method

private static CopyJob ( Stream stream, IXpsPrintJob job, IXpsPrintJobStream jobStream ) : void
stream Stream
job IXpsPrintJob
jobStream IXpsPrintJobStream
return void
        private static void CopyJob(Stream stream, IXpsPrintJob job, IXpsPrintJobStream jobStream)
        {

            //            try
            //            {
            byte[] buff = new byte[4096];
            while (true)
            {
                uint read = (uint)stream.Read(buff, 0, buff.Length);
                if (read == 0)
                    break;

                uint written;
                jobStream.Write(buff, read, out written);

                if (read != written)
                    throw new Exception("Failed to copy data to the print job stream.");
            }

            // Indicate that the entire document has been copied.
            jobStream.Close();
            //            }
            //            catch (Exception)
            //            {
            //                // Cancel the job if we had any trouble submitting it.
            //                job.Cancel();
            //                throw;
            //            }
        }