Exemple #1
0
        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;
            //            }
        }
Exemple #2
0
        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.");
                    }
                }


                jobStream.Close();
            }
            catch (Exception)
            {
                job.Cancel();
                throw;
            }
        }
Exemple #3
0
 private static extern int StartXpsPrintJob(
     [MarshalAs(UnmanagedType.LPWStr)] string printerName,
     [MarshalAs(UnmanagedType.LPWStr)] string jobName,
     [MarshalAs(UnmanagedType.LPWStr)] string outputFileName,
     IntPtr progressEvent,
     IntPtr completionEvent,
     [MarshalAs(UnmanagedType.LPArray)] byte[] printablePagesOn,
     uint printablePagesOnCount,
     out IXpsPrintJob xpsPrintJob,
     out IXpsPrintJobStream documentStream,
     IntPtr printTicketStream); // "out IXpsPrintJobStream", we don't use it and just want to pass null, hence IntPtr.
Exemple #4
0
        //ExEnd:XpsPrint_PrintStream

        private static void StartJob(string printerName, string jobName, IntPtr completionEvent, out IXpsPrintJob job,
                                     out IXpsPrintJobStream jobStream)
        {
            int result = StartXpsPrintJob(printerName, jobName, null, IntPtr.Zero, completionEvent,
                                          null, 0, out job, out jobStream, IntPtr.Zero);

            if (result != 0)
            {
                throw new Win32Exception(result);
            }
        }
Exemple #5
0
        private static void CopyJob(Stream stream, IXpsPrintJobStream jobStream)
        {
            byte[] buff = new byte[4096];
            while (true)
            {
                uint read = (uint)stream.Read(buff, 0, buff.Length);
                if (read == 0)
                {
                    break;
                }

                jobStream.Write(buff, read, out uint 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();
        }
        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;
            }
        }
        // ExEnd:XpsPrint_PrintStream

        private static void StartJob(string printerName, string jobName, IntPtr completionEvent, out IXpsPrintJob job, out IXpsPrintJobStream jobStream)
        {
            int result = StartXpsPrintJob(printerName, jobName, null, IntPtr.Zero, completionEvent,
                null, 0, out job, out jobStream, IntPtr.Zero);
            if (result != 0)
                throw new Win32Exception(result);
        }
 private static extern int StartXpsPrintJob(
     [MarshalAs(UnmanagedType.LPWStr)] String printerName,
     [MarshalAs(UnmanagedType.LPWStr)] String jobName,
     [MarshalAs(UnmanagedType.LPWStr)] String outputFileName,
     IntPtr progressEvent,   // HANDLE
     IntPtr completionEvent, // HANDLE
     [MarshalAs(UnmanagedType.LPArray)] byte[] printablePagesOn,
     UInt32 printablePagesOnCount,
     out IXpsPrintJob xpsPrintJob,
     out IXpsPrintJobStream documentStream,
     IntPtr printTicketStream);  // This is actually "out IXpsPrintJobStream", but we don't use it and just want to pass null, hence IntPtr.
Exemple #9
0
 public static extern HRESULT StartXpsPrintJob([MarshalAs(UnmanagedType.LPWStr)] string printerName, [Optional, MarshalAs(UnmanagedType.LPWStr)] string jobName,
                                               [Optional, MarshalAs(UnmanagedType.LPWStr)] string outputFileName, [Optional] IntPtr progressEvent, [Optional] IntPtr completionEvent, [Optional] byte[] printablePagesOn,
                                               uint printablePagesOnCount, out IXpsPrintJob xpsPrintJob, out IXpsPrintJobStream documentStream, out IXpsPrintJobStream printTicketStream);
 private static extern int StartXpsPrintJob(
     [MarshalAs(UnmanagedType.LPWStr)] String printerName,
     [MarshalAs(UnmanagedType.LPWStr)] String jobName,
     [MarshalAs(UnmanagedType.LPWStr)] String outputFileName,
     IntPtr progressEvent,   // HANDLE
     IntPtr completionEvent, // HANDLE
     [MarshalAs(UnmanagedType.LPArray)] byte[] printablePagesOn,
     UInt32 printablePagesOnCount,
     out IXpsPrintJob xpsPrintJob,
     out IXpsPrintJobStream documentStream,
     IntPtr printTicketStream);