using System; using System.Drawing; using System.Runtime.InteropServices; namespace Vanara.PInvoke { public static partial class Gdi32 { /// public const int SP_APPABORT = (-2); /// public const int SP_ERROR = (-1); /// public const int SP_NOTREPORTED = 0x4000; /// public const int SP_OUTOFDISK = (-4); /// public const int SP_OUTOFMEMORY = (-5); /// public const int SP_USERABORT = (-3); /// /// The AbortProc function is an application-defined callback function used with the SetAbortProc function. It is called when /// a print job is to be canceled during spooling. The ABORTPROC type defines a pointer to this callback function. /// AbortProc is a placeholder for the application-defined function name. /// /// A handle to the device context for the print job. /// /// Specifies whether an error has occurred. This parameter is zero if no error has occurred; it is SP_OUTOFDISK if Print Manager is /// currently out of disk space and more disk space will become available if the application waits. /// /// The callback function should return TRUE to continue the print job or FALSE to cancel the print job. /// /// /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user /// interface could make the application appear to be unresponsive. /// /// /// If the iError parameter is SP_OUTOFDISK, the application need not cancel the print job. If it does not cancel the job, it must /// yield to Print Manager by calling the PeekMessage or GetMessage function. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nc-wingdi-abortproc ABORTPROC Abortproc; BOOL Abortproc( HDC Arg1, int // Arg2 ) {...} [PInvokeData("wingdi.h", MSDNShortId = "3728a491-28ff-49ec-9131-ed6238b2be3d")] [UnmanagedFunctionPointer(CallingConvention.Winapi)] [return: MarshalAs(UnmanagedType.Bool)] public delegate bool AbortProc(HDC hdc, int iError); /// Specifies additional information about the print job. [PInvokeData("wingdi.h", MSDNShortId = "329bf0d9-399b-4f64-a029-361ef7558aeb")] public enum DI { /// Applications that use banding should set this flag for optimal performance during printing. DI_APPBANDING = 0x00000001, /// The application will use raster operations that involve reading from the destination surface. DI_ROPS_READ_DESTINATION = 0x00000002 } /// The escape function to be performed. [PInvokeData("wingdi.h", MSDNShortId = "5ca74f61-75dd-4a8c-9f0f-9c1b4719c75f")] public enum EscapeFunction { NEWFRAME = 1, ABORTDOC = 2, NEXTBAND = 3, SETCOLORTABLE = 4, GETCOLORTABLE = 5, FLUSHOUTPUT = 6, DRAFTMODE = 7, /// Determines whether a particular escape is implemented by the device driver. QUERYESCSUPPORT = 8, SETABORTPROC = 9, STARTDOC = 10, ENDDOC = 11, GETPHYSPAGESIZE = 12, GETPRINTINGOFFSET = 13, GETSCALINGFACTOR = 14, MFCOMMENT = 15, GETPENWIDTH = 16, SETCOPYCOUNT = 17, SELECTPAPERSOURCE = 18, DEVICEDATA = 19, /// /// The PASSTHROUGH printer escape function sends data directly to a printer driver. /// /// /// Parameter /// Value /// /// /// hdc /// A handle to the printer device context. /// /// /// iEscape /// PASSTHROUGH /// /// /// cjInput /// The number of bytes of data to which the lpszInData parameter points. /// /// /// lpInData /// /// A pointer to the input structure required for the specified escape. The first word in the buffer contains the number of /// bytes of input data. The remaining bytes of the buffer contain the data itself. /// /// /// /// cjOutput /// /// The number of bytes of data to which the lpszOutData parameter points. For this printer escape function, the value of this /// parameter is 0. /// /// /// /// lpOutData /// /// A pointer to the structure that receives output from this escape. For this printer escape function, the value of the /// parameter is NULL. /// /// /// /// PASSTHROUGH = 19, /// /// The GETTECHNOLOGY printer escape function identifies the type of printer driver. /// /// /// Parameter /// Value /// /// /// hdc /// A handle to the printer device context. /// /// /// iEscape /// GETTECHNOLOGY /// /// /// cjInput /// The number of bytes of data to which the lpszInData parameter points. /// /// /// lpInData /// A pointer to the input structure required for the specified escape. /// /// /// cjOutput /// The number of bytes of data to which the lpszOutData parameter points. /// /// /// lpOutData /// /// A pointer to the structure that receives output from this escape. This parameter must not be NULL if ExtEscape is called as /// a query function. If no data is to be returned in this structure, set cbOutput to 0. /// /// /// /// GETTECHNOLOGY = 20, SETLINECAP = 21, SETLINEJOIN = 22, SETMITERLIMIT = 23, BANDINFO = 24, /// /// The DRAWPATTERNRECT printer escape creates a white, gray scale, or solid black rectangle by using the pattern and rule /// capabilities of Page Control Language (PCL) on Hewlett-Packard LaserJet or LaserJet-compatible printers. A gray scale is a /// gray pattern that contains a specific mixture of black and white pixels. /// /// /// Parameter /// Value /// /// /// hdc /// A handle to the printer device context. /// /// /// iEscape /// DRAWPATTERNRECT /// /// /// cjInput /// The number of bytes of data to which the lpszInData parameter points. /// Set this value to sizeof(DRAWPATRECT). /// /// /// /// lpInData /// A pointer to a DRAWPATTERNRECT structure that describes the rectangle. /// /// /// cjOutput /// The number of bytes of data to which the lpszOutData parameter points. /// For this escape, the value of this parameter is 0. /// /// /// /// lpOutData /// A pointer to the structure that will receive output from this escape. /// For this printer escape function, the value of the parameter is NULL. /// /// /// /// DRAWPATTERNRECT = 25, GETVECTORPENSIZE = 26, GETVECTORBRUSHSIZE = 27, ENABLEDUPLEX = 28, GETSETPAPERBINS = 29, GETSETPRINTORIENT = 30, ENUMPAPERBINS = 31, SETDIBSCALING = 32, EPSPRINTING = 33, ENUMPAPERMETRICS = 34, GETSETPAPERMETRICS = 35, /// /// The POSTSCRIPT_DATA printer escape function sends data directly to a printer driver. /// /// /// Parameter /// Value /// /// /// hdc /// A handle to the printer device context. /// /// /// iEscape /// POSTSCRIPT_DATA /// /// /// cjInput /// The number of bytes of data to which the lpszInData parameter points. /// /// /// lpInData /// /// A pointer to the input structure required for the specified escape. The first word in the buffer contains the number of /// bytes of input data. The remaining bytes of the buffer contain the data itself. /// /// /// /// cjOutput /// /// The number of bytes of data to which the lpszOutData parameter points. For this printer escape function, the value of this /// parameter is 0. /// /// /// /// lpOutData /// /// A pointer to the structure that receives output from this escape. For this printer escape function, the value of the /// parameter is NULL. /// /// /// /// POSTSCRIPT_DATA = 37, POSTSCRIPT_IGNORE = 38, MOUSETRAILS = 39, GETDEVICEUNITS = 42, GETEXTENDEDTEXTMETRICS = 256, GETEXTENTTABLE = 257, GETPAIRKERNTABLE = 258, GETTRACKKERNTABLE = 259, EXTTEXTOUT = 512, GETFACENAME = 513, DOWNLOADFACE = 514, ENABLERELATIVEWIDTHS = 768, ENABLEPAIRKERNING = 769, SETKERNTRACK = 770, SETALLJUSTVALUES = 771, SETCHARSET = 772, STRETCHBLT = 2048, METAFILE_DRIVER = 2049, GETSETSCREENPARAMS = 3072, QUERYDIBSUPPORT = 3073, BEGIN_PATH = 4096, CLIP_TO_PATH = 4097, END_PATH = 4098, EXT_DEVICE_CAPS = 4099, RESTORE_CTM = 4100, SAVE_CTM = 4101, SET_ARC_DIRECTION = 4102, SET_BACKGROUND_COLOR = 4103, SET_POLY_MODE = 4104, SET_SCREEN_ANGLE = 4105, SET_SPREAD = 4106, TRANSFORM_CTM = 4107, SET_CLIP_BOX = 4108, SET_BOUNDS = 4109, SET_MIRROR_MODE = 4110, OPENCHANNEL = 4110, DOWNLOADHEADER = 4111, CLOSECHANNEL = 4112, /// /// The POSTSCRIPT_PASSTHROUGH printer escape function sends data directly to a PostScript printer driver. /// /// A PostScript driver supports this escape function when in PostScript-centric mode or in compatibility mode, but not in /// GDI-centric mode. /// /// To set the PostScript driver's mode, call the POSTSCRIPT_IDENTIFY escape function. /// /// /// Parameter /// Value /// /// /// hdc /// A handle to the printer device context. /// /// /// iEscape /// POSTSCRIPT_PASSTHROUGH /// /// /// cjInput /// The number of bytes of data to which the lpszInData parameter points. /// /// /// lpInData /// /// A pointer to the input structure required for the specified escape. The first word in the buffer contains the number of /// bytes of input data. The remaining bytes of the buffer contain the data itself. /// /// /// /// cjOutput /// /// The number of bytes of data to which the lpszOutData parameter points. For this printer escape function, the value of this /// parameter is 0. /// /// /// /// lpOutData /// /// A pointer to the structure that receives output from this escape. For this printer escape function, the value of the /// parameter is NULL. /// /// /// /// POSTSCRIPT_PASSTHROUGH = 4115, ENCAPSULATED_POSTSCRIPT = 4116, /// /// The POSTSCRIPT_IDENTIFY printer escape function sets a PostScript driver to GDI-centric mode or PostScript-centric mode. /// /// /// Parameter /// Value /// /// /// hdc /// A handle to the printer device context. /// /// /// iEscape /// POSTSCRIPT_IDENTIFY /// /// /// cjInput /// The number of bytes of data to which the lpszInData parameter points. /// For this escape, set this value to sizeof(DWORD). /// /// /// /// lpInData /// A pointer to the input structure required for the specified escape. /// /// /// Value /// Meaning /// /// /// PSIDENT_GDICENTRIC /// /// /// GDI-centric mode. Specify this value if the PostScript driver supports the PASSTHROUGH printer escape function, but not the /// POSTSCRIPT_PASSTHROUGH printer escape function. /// /// /// /// /// PSIDENT_PSCENTRIC /// /// /// PostScript-centric mode. Specify this value if the PostScript driver supports the POSTSCRIPT_PASSTHROUGH printer escape /// function, but not the PASSTHROUGH printer escape function. /// /// /// /// /// /// /// /// cjOutput /// /// The number of bytes of data to which the lpszOutData parameter points. For this printer escape function, the value of this /// parameter is 0. /// /// /// /// lpOutData /// /// A pointer to the structure that receives output from this escape. For this printer escape function, the value of the /// parameter is NULL. /// /// /// /// POSTSCRIPT_IDENTIFY = 4117, /// /// The POSTSCRIPT_INJECTION printer escape function inserts a block of raw data at a specified point in a PostScript job stream. /// /// A PostScript driver supports this escape function in GDI-centric mode or PostScript-centric mode support, but not in /// compatibility mode. /// /// To set the PostScript driver's mode, call the POSTSCRIPT_IDENTIFY escape function. /// /// /// Parameter /// Value /// /// /// hdc /// A handle to the printer device context. /// /// /// iEscape /// POSTSCRIPT_INJECTION /// /// /// cjInput /// The number of bytes of data to which the lpszInData parameter points. /// Set this parameter to sizeof(PSINJECTDATA) plus the size of the raw data to inject. /// /// /// /// lpInData /// A pointer to the buffer that contains a PSINJECTDATA structure followed by the raw data to inject. /// /// /// cjOutput /// /// The number of bytes of data to which the lpszOutData parameter points. For this printer escape function, the value of this /// parameter is 0. /// /// /// /// lpOutData /// /// A pointer to the structure that receives output from this escape. For this printer escape function, the value of the /// parameter is NULL. /// /// /// /// POSTSCRIPT_INJECTION = 4118, /// /// The CHECKJPEGFORMAT printer escape function determines whether a printer supports printing a JPEG image. /// /// /// Parameter /// Value /// /// /// hdc /// A handle to the printer device context. /// /// /// iEscape /// CHECKJPEGFORMAT /// /// /// cjInput /// The size, in bytes, of the JPEG image buffer pointed to by the lpInData parameter. /// /// /// lpInData /// A pointer to a buffer that contains the JPEG image. /// /// /// cjOutput /// The number of bytes of data pointed to by the lpOutData parameter. /// For this escape, set this value to sizeof(DWORD). /// /// /// /// lpOutData /// /// A pointer to the DWORD variable that receives the output from this escape. This parameter must not be NULL. /// If the printer supports the image type, this value is set to 1. Otherwise, it is set to zero. /// /// /// /// CHECKJPEGFORMAT = 4119, /// /// The CHECKJPEGFORMAT printer escape function determines whether a printer supports printing a PNG image. /// /// /// Parameter /// Value /// /// /// hdc /// A handle to the printer device context. /// /// /// iEscape /// CHECKPNGFORMAT /// /// /// cjInput /// The size, in bytes, of the PNG image buffer pointed to by the lpInData parameter. /// /// /// lpInData /// A pointer to a buffer that contains the PNG image. /// /// /// cjOutput /// The number of bytes of data pointed to by the lpOutData parameter. /// For this escape, set this value to sizeof(DWORD). /// /// /// /// lpOutData /// /// A pointer to the DWORD variable that receives the output from this escape. This parameter must not be NULL. /// If the printer supports the image type, this value is set to 1. Otherwise, it is set to zero. /// /// /// /// CHECKPNGFORMAT = 4120, /// /// The GET_PS_FEATURESETTING printer escape function retrieves information about a specified feature setting for a PostScript driver. /// /// This escape function is supported only if the PostScript driver is in PostScript-centric mode or in GDI-centric mode. To set /// the PostScript driver mode, call the POSTSCRIPT_IDENTIFY escape function. /// /// /// /// Parameter /// Value /// /// /// hdc /// A handle to the printer device context. /// /// /// iEscape /// DRAWPATTERNRECT /// /// /// cjInput /// The number of bytes of data to which the lpszInData parameter points. /// Set this value to sizeof(INT). /// /// /// /// lpInData /// A pointer to the INT variable that contains a feature setting value from the following table. /// /// Windows XP and later versions of Windows support the private use of this parameter. For private use, you can use the numbers /// in the range from FEATURESETTING_PRIVATE_BEGIN to FEATURESETTING_PRIVATE_END. Private parties that intend to use numbers in /// this range should contact Microsoft first to avoid conflicts with other applications. /// /// /// /// Value /// Meaning /// /// /// FEATURESETTING_CUSTPAPER /// /// Retrieves the custom paper parameters. /// Set cbOutput to sizeof ( PSFEATURE_CUSTPAPER ) and lpszOutData to point to a PSFEATURE_CUSTPAPER structure. /// /// /// /// FEATURESETTING_MIRROR /// /// Retrieves the mirrored output setting. /// Set cbOutput to sizeof ( BOOL ) and lpszOutData to point to a BOOL variable. /// If mirrored output is selected, the value returned in lpszOutData is TRUE. /// If mirrored output is not selected, the value returned in lpszOutData is FALSE /// /// /// /// FEATURESETTING_NEGATIVE /// /// Retrieves the negative output setting. /// Set cbOutput to sizeof ( BOOL ) and lpszOutData to point to a BOOL variable. /// /// When the function returns, the lpszOutData variable is TRUE if "Negative Output: Yes" is selected; otherwise, it is FALSE. /// /// /// /// /// FEATURESETTING_NUP /// /// Retrieves the N-Up setting of the page layout. /// Set cbOutput to sizeof ( BOOL ) and lpszOutData to point to a BOOL variable. /// If an N-Up page layout is not being used, the lpszOutData variable returns FALSE. /// /// If an N-Up page layout is being used, the lpszOutData variable returns TRUE. However, the variable does not indicate the /// format of the N-Up page layout or its semantics. /// /// /// /// /// FEATURESETTING_OUTPUT /// /// Retrieves information about PostScript driver output options. /// Set cbOutput to sizeof ( PSFEATURE_OUTPUT ) and lpszOutData to point to a PSFEATURE_OUTPUT structure. /// /// /// /// FEATURESETTING_PROTOCOL /// /// Retrieves the output protocol setting. /// Sets cbOutput to sizeof( INT ) and lpszOutData to point to an INT variable. /// When the function returns, the lpszOutData variable is set to one of the following output protocol values: /// PSPROTOCOL_ASCII PSPROTOCOL_BCP PSPROTOCOL_TBCP PSPROTOCOL_BINARY /// /// /// /// FEATURESETTING_PSLEVEL /// /// Retrieves the PostScript language level. /// Set cbOutput to sizeof ( INT ) and lpszOutData to point to an INT variable. /// /// When the function returns, the lpszOutData variable is set to 1, 2, 3, or higher to indicate the PostScript language level. /// /// /// /// /// /// /// /// cjOutput /// The number of bytes of data to which the lpszOutData parameter points. /// /// /// lpOutData /// /// A pointer to the structure that receives output from this escape. This parameter must not be NULL if ExtEscape is called as /// a query function. If no data is to be returned in this structure, set cbOutput to 0. /// /// /// /// GET_PS_FEATURESETTING = 4121, GDIPLUS_TS_QUERYVER = 4122, GDIPLUS_TS_RECORD = 4123, /// /// The SPCLPASSTHROUGH2 printer escape function allows applications that print to PostScript devices using EPSPRINTING to /// include private PostScript procedures and other resources at the document-level save context. /// /// This escape is supported only for backward compatibility with Adobe Acrobat. Other applications should not use this obsolete escape. /// /// /// /// Parameter /// Value /// /// /// hdc /// A handle to the printer device context. /// /// /// iEscape /// SPCLPASSTHROUGH2 /// /// /// cjInput /// The number of bytes of data to which the lpszInData parameter points. /// /// /// lpInData /// A pointer to the input structure required for the specified escape. /// /// /// cjOutput /// /// The number of bytes of data to which the lpszOutData parameter points. For this printer escape function, the value of this /// parameter is 0. /// /// /// /// lpOutData /// /// A pointer to the structure that receives output from this escape. For this printer escape function, the value of the /// parameter is NULL. /// /// /// /// SPCLPASSTHROUGH2 = 4568, } /// Specifies where to inject the raw data in the PostScript output. [PInvokeData("wingdi.h", MSDNShortId = "f42c8f69-7fe9-4740-b295-32ef2a5b714c")] public enum PSINJECT : ushort { /// Before the first byte of job stream. PSINJECT_BEGINSTREAM = 1, /// Before %!PS-Adobe. PSINJECT_PSADOBE = 2, /// Replaces driver's %%Pages (atend). PSINJECT_PAGESATEND = 3, /// Replaces driver's %%Pages nnn. PSINJECT_PAGES = 4, /// After %%DocumentNeededResources. PSINJECT_DOCNEEDEDRES = 5, /// After %%DocumentSuppliedResources. PSINJECT_DOCSUPPLIEDRES = 6, /// Replaces driver's %%PageOrder. PSINJECT_PAGEORDER = 7, /// Replaces driver's %%Orientation. PSINJECT_ORIENTATION = 8, /// Replaces driver's %%BoundingBox. PSINJECT_BOUNDINGBOX = 9, /// Replaces driver's %%DocumentProcessColors <color>. PSINJECT_DOCUMENTPROCESSCOLORS = 10, /// Before %%EndComments. PSINJECT_COMMENTS = 11, /// After %%BeginDefaults. PSINJECT_BEGINDEFAULTS = 12, /// Before %%EndDefaults. PSINJECT_ENDDEFAULTS = 13, /// After %%BeginProlog. PSINJECT_BEGINPROLOG = 14, /// Before %%EndProlog. PSINJECT_ENDPROLOG = 15, /// After %%BeginSetup. PSINJECT_BEGINSETUP = 16, /// TBefore %%EndSetup. PSINJECT_ENDSETUP = 17, /// After %%Trailer PSINJECT_TRAILER = 18, /// After %%EOF PSINJECT_EOF = 19, /// After the last byte of job stream PSINJECT_ENDSTREAM = 20, /// Replaces driver's %%DocumentProcessColors (atend) PSINJECT_DOCUMENTPROCESSCOLORSATEND = 21, /// Replaces driver's %%Page PSINJECT_PAGENUMBER = 100, /// After %%BeginPageSetup PSINJECT_BEGINPAGESETUP = 101, /// Before %%EndPageSetup PSINJECT_ENDPAGESETUP = 102, /// After %%PageTrailer PSINJECT_PAGETRAILER = 103, /// Replace driver's %%PlateColor: <color> PSINJECT_PLATECOLOR = 104, /// Before showpage operator PSINJECT_SHOWPAGE = 105, /// Replaces driver's %%PageBoundingBox PSINJECT_PAGEBBOX = 106, /// Before %%EndPageComments PSINJECT_ENDPAGECOMMENTS = 107, /// Before save operator PSINJECT_VMSAVE = 200, /// After restore operator PSINJECT_VMRESTORE = 201, } /// /// The AbortDoc function stops the current print job and erases everything drawn since the last call to the StartDoc function. /// /// Handle to the device context for the print job. /// /// If the function succeeds, the return value is greater than zero. /// If the function fails, the return value is SP_ERROR. /// /// /// /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user /// interface could make the application appear to be unresponsive. /// /// /// Applications should call the AbortDoc function to stop a print job if an error occurs, or to stop a print job after the /// user cancels that job. To end a successful print job, an application should call the EndDoc function. /// /// /// If Print Manager was used to start the print job, calling AbortDoc erases the entire spool job, so that the printer /// receives nothing. If Print Manager was not used to start the print job, the data may already have been sent to the printer. In /// this case, the printer driver resets the printer (when possible) and ends the print job. /// /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-abortdoc int AbortDoc( HDC hdc ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "4ecc371c-34fa-4073-96fe-0de03b84d7e3")] public static extern int AbortDoc(HDC hdc); /// The EndDoc function ends a print job. /// Handle to the device context for the print job. /// /// If the function succeeds, the return value is greater than zero. /// If the function fails, the return value is less than or equal to zero. /// /// /// /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user /// interface could make the application appear to be unresponsive. /// /// Applications should call EndDoc immediately after finishing a print job. /// Examples /// For a sample program that uses this function, see How To: Print Using the GDI Print API. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-enddoc int EndDoc( HDC hdc ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "bf63ea0f-cc73-4943-9c84-52b3b77e141c")] public static extern int EndDoc(HDC hdc); /// /// The EndPage function notifies the device that the application has finished writing to a page. This function is typically /// used to direct the device driver to advance to a new page. /// /// A handle to the device context for the print job. /// /// If the function succeeds, the return value is greater than zero. /// If the function fails, the return value is less than or equal to zero. /// /// /// /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user /// interface could make the application appear to be unresponsive. /// /// /// Use the ResetDC function to change the device mode, if necessary, after calling the EndPage function. Note that a call to /// ResetDC resets all device context attributes back to default values. Neither EndPage nor StartPage resets the /// device context attributes. Device context attributes remain constant across subsequent pages. You do not need to re-select /// objects and set up the mapping mode again before printing the next page; however, doing so will produce the same results and /// reduce code differences between versions of Windows. /// /// /// When a page in a spooled file exceeds approximately 350 MB, it may fail to print and not send an error message. For example, /// this can occur when printing large EMF files. The page size limit depends on many factors including the amount of virtual memory /// available, the amount of memory allocated by calling processes, and the amount of fragmentation in the process heap. /// /// Examples /// For a sample program that uses this function, see How To: Print Using the GDI Print API. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-endpage int EndPage( HDC hdc ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "33e6d005-f00d-4b87-bf7c-fc79c1d05514")] public static extern int EndPage(HDC hdc); /// /// The Escape function enables an application to access the system-defined device capabilities that are not available /// through GDI. Escape calls made by an application are translated and sent to the driver. /// /// A handle to the device context. /// /// The escape function to be performed. This parameter must be one of the predefined escape values listed in Remarks. Use the /// ExtEscape function if your application defines a private escape value. /// /// The number of bytes of data pointed to by the lpvInData parameter. This can be 0. /// A pointer to the input structure required for the specified escape. /// /// A pointer to the structure that receives output from this escape. This parameter should be NULL if no data is returned. /// /// /// /// If the function succeeds, the return value is greater than zero, except with the QUERYESCSUPPORT printer escape, which checks /// for implementation only. If the escape is not implemented, the return value is zero. /// /// If the function fails, the return value is a system error code. /// /// /// /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user /// interface could make the application appear to be unresponsive. /// /// The effect of passing 0 for cbInput will depend on the value of nEscape and on the driver that is handling the escape. /// Of the original printer escapes, only the following can be used. /// /// /// Escape /// Description /// /// /// QUERYESCSUPPORT /// Determines whether a particular escape is implemented by the device driver. /// /// /// PASSTHROUGH /// Allows the application to send data directly to a printer. /// /// /// For information about printer escapes, see ExtEscape. /// Use the StartPage function to prepare the printer driver to receive data. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-escape int Escape( HDC hdc, int iEscape, int cjIn, LPCSTR // pvIn, LPVOID pvOut ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "ba21b680-78a8-45a2-94e1-01b377b74787")] public static extern int Escape(HDC hdc, EscapeFunction iEscape, int cjIn, [In] IntPtr pvIn, [Out] IntPtr pvOut); /// /// The ExtEscape function enables an application to access device capabilities that are not available through GDI. /// /// A handle to the device context. /// /// The escape function to be performed. It can be one of the following or it can be an application-defined escape function. /// /// /// Value /// Meaning /// /// /// CHECKJPEGFORMAT /// Checks whether the printer supports a JPEG image. /// /// /// CHECKPNGFORMAT /// Checks whether the printer supports a PNG image. /// /// /// DRAWPATTERNRECT /// Draws a white, gray-scale, or black rectangle. /// /// /// GET_PS_FEATURESETTING /// Gets information on a specified feature setting for a PostScript driver. /// /// /// GETTECHNOLOGY /// Reports on whether or not the driver is a Postscript driver. /// /// /// PASSTHROUGH /// Allows the application to send data directly to a printer. Supported in compatibility mode and GDI-centric mode. /// /// /// POSTSCRIPT_DATA /// Allows the application to send data directly to a printer. Supported only in compatibility mode. /// /// /// POSTSCRIPT_IDENTIFY /// Sets a PostScript driver to GDI-centric or PostScript-centric mode. /// /// /// POSTSCRIPT_INJECTION /// Inserts a block of raw data in a PostScript job stream. /// /// /// POSTSCRIPT_PASSTHROUGH /// Sends data directly to a PostScript printer driver. Supported in compatibility mode and PostScript-centric mode. /// /// /// QUERYESCSUPPORT /// Determines whether a particular escape is implemented by the device driver. /// /// /// SPCLPASSTHROUGH2 /// Enables applications to include private procedures and other resources at the document level-save context. /// /// /// /// The number of bytes of data pointed to by the lpszInData parameter. /// A pointer to the input structure required for the specified escape. See also Remarks. /// The number of bytes of data pointed to by the lpszOutData parameter. /// /// A pointer to the structure that receives output from this escape. This parameter must not be NULL if ExtEscape is /// called as a query function. If no data is to be returned in this structure, set cbOutput to 0. See also Remarks. /// /// /// The return value specifies the outcome of the function. It is greater than zero if the function is successful, except for the /// QUERYESCSUPPORT printer escape, which checks for implementation only. The return value is zero if the escape is not implemented. /// A return value less than zero indicates an error. /// /// /// /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user /// interface could make the application appear to be unresponsive. /// /// Use this function to pass a driver-defined escape value to a device. /// /// Use the Escape function to pass one of the system-defined escape values to a device, unless the escape is one of the defined /// escapes in nEscape. ExtEscape might not work properly with the system-defined escapes. In particular, escapes in which /// lpszInData is a pointer to a structure that contains a member that is a pointer will fail. /// /// /// Note, that the behavior described in this article is the expected behavior, but it is up to the driver to comply with this model. /// /// /// The variables referenced by lpszInData and lpszOutData should not be the same or overlap. If the input and the output buffer /// size variables overlap, they may not contain the correct values after the call returns. For the best results, lpszInData and /// lpszOutData should refer to different variables. /// /// The CHECKJPEGFORMAT printer escape function determines whether a printer supports printing a JPEG image. /// /// Before using the CHECKJPEGFORMAT printer escape function, call the QUERYESCSUPPORT printer escape function to determine whether /// the driver supports CHECKJPEGFORMAT. For sample code that demonstrates the use of CHECKJPEGFORMAT, see Testing a /// Printer for JPEG or PNG Support. /// /// The CHECKPNGFORMAT printer escape function determines whether a printer supports printing a PNG image. /// /// Before using the CHECKJPEGFORMAT printer escape function, call the QUERYESCSUPPORT printer escape function to determine whether /// the driver supports CHECKJPEGFORMAT. For sample code, see Testing a Printer for JPEG or PNG Support. /// /// /// The DRAWPATTERNRECT printer escape creates a white, gray scale, or solid black rectangle by using the pattern and rule /// capabilities of Page Control Language (PCL) on Hewlett-Packard LaserJet or LaserJet-compatible printers. A gray scale is a gray /// pattern that contains a specific mixture of black and white pixels. /// /// /// An application should use the QUERYESCSUPPORT escape to determine whether the printer is capable of drawing patterns and rules /// before using the DRAWPATTERNRECT escape. /// /// /// /// Rules drawn with DRAWPATTERNRECT are not subject to clipping regions in the device context. /// /// /// Applications should not try to erase patterns and rules created with DRAWPATTERNRECT by placing opaque objects over them. /// /// /// /// If the printer supports white rules, these can be used to erase patterns created by DRAWPATTERNRECT. If the printer does not /// support white rules, there is no method for erasing these patterns. /// /// /// If an application cannot use the DRAWPATTERNRECT escape and the device is a printer, it should generally use the PatBlt function /// instead. Note that if PatBlt is used to print a black rectangle, the application should use the BLACKNESS raster /// operator. If the device is a plotter, however, the application should use the Rectangle function. /// /// /// The GET_PS_FEATURESETTING printer escape function retrieves information about a specified feature setting for a PostScript driver. /// /// /// This escape function is supported only if the PostScript driver is in PostScript-centric mode or in GDI-centric mode. To set the /// PostScript driver mode, call the POSTSCRIPT_IDENTIFY escape function. /// /// To perform this operation, call the ExtEscape function with the following parameters. /// /// The GET_PS_FEATURESETTING printer escape function is valid if called any time after calling the CreateDC function and before /// calling the DeleteDC function. /// /// The GETTECHNOLOGY printer escape function identifies the type of printer driver. /// For non-XPSDrv printers, this escape reports whether the driver is a Postscript driver. /// /// For XPSDrv printers, this escape reports whether the driver is the Microsoft XPS Document Converter (MXDC). If it is, the escape /// returns the zero-terminated string "http://schemas.microsoft.com/xps/2005/06" /// /// /// The PASSTHROUGH printer escape function sends data directly to a printer driver. To perform this operation, call the /// ExtEscape function with the following parameters. /// /// /// The PASSTHROUGH printer escape function is supported by PostScript drivers in GDI-centric mode or compatibility mode, but /// not in PostScript-centric mode. Drivers in PostScript-centric mode can use the POSTSCRIPT_PASSTHROUGH escape function. To set a /// PostScript driver mode, call the POSTSCRIPT_IDENTIFY escape function. /// /// /// For PASSTHROUGH data sent by EPSPRINTING or PostScript-centric applications, the PostScript driver will not make any /// modifications. For PASSTHROUGH data sent by other applications, if the PostScript driver is using BCP (Binary Communication /// Protocol) or TBCP (Tagged Binary Communication Protocol) output protocol, the driver does the appropriate BCP or TBCP quoting on /// special characters, as described in "Adobe Serial and Parallel Communications Protocols Specification." This means that the /// application should send either ASCII or pure binary PASSTHROUGH data. /// /// /// The POSTSCRIPT_DATA printer escape function sends data directly to a printer driver. To perform this operation, call the /// ExtEscape function with the following parameters. /// /// /// The POSTSCRIPT_DATA function is identical to the PASSTHROUGH escape function except that it is supported by PostScript drivers /// in compatibility mode only. It is not supported by PostScript drivers in PostScript-centric mode or in GDI-centric mode. /// /// /// Drivers in PostScript-centric mode can use the POSTSCRIPT_PASSTHROUGH escape function, and drivers in GDI-centric mode can use /// the PASSTHROUGH escape function. To set a PostScript driver's mode, call the POSTSCRIPT_IDENTIFY escape function. /// /// The POSTSCRIPT_IDENTIFY printer escape function sets a PostScript driver to GDI-centric mode or PostScript-centric mode. /// /// To put the driver in GDI-centric or PostScript-centric modes, first call the QUERYESCSUPPORT printer escape function to /// determine whether the driver supports the POSTSCRIPT_IDENTIFY printer escape function. If so, you can assume the driver is /// PSCRIPT 5.0. Then, before you call any other printer escape function, you must call POSTSCRIPT_IDENTIFY and specify /// either PSIDENT_GDICENTRIC or PSIDENT_PSCENTRIC. You must call the QUERYESCSUPPORT and /// POSTSCRIPT_IDENTIFY printer escape functions before calling any other printer escape function. /// /// /// Note After the PostScript driver is set to GDI-centric mode or PostScript-centric mode, you will not be allowed to call /// the POSTSCRIPT_IDENTIFY printer escape function anymore. /// /// /// If you do not use the POSTSCRIPT_IDENTIFY printer escape function, the PostScript driver is in compatibility mode and provides /// identical support for the PASSTHROUGH, POSTSCRIPT_PASSTHROUGH, and POSTSCRIPT_DATA printer escape functions. /// /// /// For PostScript drivers that support the POSTSCRIPT_PASSTHROUGH, PASSTHROUGH, and POSTSCRIPT_PASSTHROUGH printer escape /// functions are identical. /// /// /// In PostScript-centric mode, the application is responsible for all PostScript output that marks the paper using the /// POSTSCRIPT_PASSTHROUGH escape function. GDI functions are not allowed. The driver is responsible for the overall document /// structure and printer control settings. The application can use the POSTSCRIPT_INJECTION printer escape function to inject a /// block of raw data (including DSC comments) into the job stream at specific places. /// /// /// The POSTSCRIPT_INJECTION printer escape function inserts a block of raw data at a specified point in a PostScript job stream. /// /// /// A PostScript driver supports this escape function in GDI-centric mode or PostScript-centric mode support, but not in /// compatibility mode. /// /// To set the PostScript driver's mode, call the POSTSCRIPT_IDENTIFY escape function. /// To perform this operation, call the ExtEscape function with the following parameters. /// /// The driver internally caches the injection data and emits it at appropriate points in the output. The cached information is /// flushed when it is no longer needed. At the latest, it is flushed after the EndDoc call. /// /// /// In GDI-centric mode, the application can only inject valid DSC block data by using the POSTSCRIPT_INJECTION printer escape /// function. A valid DSC block must satisfy all of the following conditions: /// /// /// /// It consists of an integral sequence of "lines." /// /// /// Each "line" must begin with "%%". /// /// /// /// Each "line" except the last line must end with <CR>, <LF>, or <CR><LF> except for the last line. If the /// last line does not end with <CR>, <LF>, or <CR><LF>, the driver appends <CR><LF> after the /// last byte of the injection data. /// /// /// /// Each "line" must be 255 bytes or less including the "%%" but not counting the <CR>/<LF> line termination. /// /// /// The POSTSCRIPT_PASSTHROUGH printer escape function sends data directly to a PostScript printer driver. /// /// A PostScript driver supports this escape function when in PostScript-centric mode or in compatibility mode, but not in /// GDI-centric mode. /// /// To set the PostScript driver's mode, call the POSTSCRIPT_IDENTIFY escape function. /// The QUERYESCSUPPORT printer escape function checks the implementation of a printer escape function. /// /// The SPCLPASSTHROUGH2 printer escape function allows applications that print to PostScript devices using EPSPRINTING to include /// private PostScript procedures and other resources at the document-level save context. /// /// /// This escape is supported only for backward compatibility with Adobe Acrobat. Other applications should not use this obsolete escape. /// /// /// The application must call this escape before calling StartDoc so that the driver will cache the data for insertion at the /// correct point in the PostScript stream. If this escape is supported, the driver will also allow escape DOWNLOADFACE calls /// prior to StartDoc. The driver internally caches the data to be inserted and the data required by any escape /// DOWNLOADFACE calls prior to StartDoc and emits them all immediately before %%EndProlog. The sequence of /// SPCLPASSTHROUGH2 and DOWNLOADFACE calls will be preserved in the order their data is passed in, that is, a later call /// results in data output after an earlier call's data. The driver will consider fonts downloaded by pre- StartDoc escape /// DOWNLOADFACE calls as unavailable for removal during the scope of the job. /// /// /// This escape is not recorded in EMF files by the operating system, therefore applications must ensure that EMF recording is /// turned off for those jobs using the escape. /// /// Examples /// For an example, see Sizing a JPEG or PNG Image. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-extescape int ExtEscape( HDC hdc, int iEscape, int cjInput, // LPCSTR lpInData, int cjOutput, LPSTR lpOutData ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "5ca74f61-75dd-4a8c-9f0f-9c1b4719c75f")] public static extern int ExtEscape(HDC hdc, EscapeFunction iEscape, int cjInput, [In] IntPtr lpInData, int cjOutput, [Out] IntPtr lpOutData); /// /// The SetAbortProc function sets the application-defined abort function that allows a print job to be canceled during spooling. /// /// Handle to the device context for the print job. /// /// Pointer to the application-defined abort function. For more information about the callback function, see the AbortProc callback function. /// /// /// If the function succeeds, the return value is greater than zero. /// If the function fails, the return value is SP_ERROR. /// /// /// /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user /// interface could make the application appear to be unresponsive. /// /// Examples /// For an example, see How to Collect Print Job Information from the User. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-setabortproc int SetAbortProc( HDC hdc, ABORTPROC proc ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "5b6333fc-f1c3-4c76-906c-0fd13bb73953")] public static extern int SetAbortProc(HDC hdc, AbortProc proc); /// The StartDoc function starts a print job. /// A handle to the device context for the print job. /// A pointer to a DOCINFO structure containing the name of the document file and the name of the output file. /// /// If the function succeeds, the return value is greater than zero. This value is the print job identifier for the document. /// If the function fails, the return value is less than or equal to zero. /// /// /// /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user /// interface could make the application appear to be unresponsive. /// /// /// Applications should call the StartDoc function immediately before beginning a print job. Using this function ensures that /// multipage documents are not interspersed with other print jobs. /// /// /// Applications can use the value returned by StartDoc to retrieve or set the priority of a print job. Call the GetJob or /// SetJob function and supply this value as one of the required arguments. /// /// Examples /// For a sample program that uses this function, see How To: Print Using the GDI Print API. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-startdoca int StartDocA( HDC hdc, const DOCINFOA *lpdi ); [DllImport(Lib.Gdi32, SetLastError = false, CharSet = CharSet.Auto)] [PInvokeData("wingdi.h", MSDNShortId = "53143463-b9fc-4378-aea9-da6c73a7cd03")] public static extern int StartDoc(HDC hdc, in DOCINFO lpdi); /// The StartPage function prepares the printer driver to accept data. /// A handle to the device context for the print job. /// /// If the function succeeds, the return value is greater than zero. /// If the function fails, the return value is less than or equal to zero. /// /// /// /// Note This is a blocking or synchronous function and might not return immediately. How quickly this function returns /// depends on run-time factors such as network status, print server configuration, and printer driver implementation—factors that /// are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user /// interface could make the application appear to be unresponsive. /// /// /// The system disables the ResetDC function between calls to the StartPage and EndPage functions. This means that you cannot /// change the device mode except at page boundaries. After calling EndPage, you can call ResetDC to change the device /// mode, if necessary. Note that a call to ResetDC resets all device context attributes back to default values. /// /// /// Neither EndPage nor StartPage resets the device context attributes. Device context attributes remain constant across /// subsequent pages. You do not need to re-select objects and set up the mapping mode again before printing the next page; however, /// doing so will produce the same results and reduce code differences between versions of Windows. /// /// Examples /// For a sample program that uses this function, see How To: Print Using the GDI Print API. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-startpage int StartPage( HDC hdc ); [DllImport(Lib.Gdi32, SetLastError = false, ExactSpelling = true)] [PInvokeData("wingdi.h", MSDNShortId = "b2bc0593-5eaf-40af-aa38-fbdfa1ea5f76")] public static extern int StartPage(HDC hdc); /// /// The DOCINFO structure contains the input and output file names and other information used by the StartDoc function. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-docinfoa typedef struct _DOCINFOA { int cbSize; LPCSTR // lpszDocName; LPCSTR lpszOutput; LPCSTR lpszDatatype; DWORD fwType; } DOCINFOA, *LPDOCINFOA; [PInvokeData("wingdi.h", MSDNShortId = "329bf0d9-399b-4f64-a029-361ef7558aeb")] [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)] public struct DOCINFO { /// The size, in bytes, of the structure. public int cbSize; /// Pointer to a null-terminated string that specifies the name of the document. [MarshalAs(UnmanagedType.LPTStr)] public string lpszDocName; /// /// Pointer to a null-terminated string that specifies the name of an output file. If this pointer is NULL, the output /// will be sent to the device identified by the device context handle that was passed to the StartDoc function. /// [MarshalAs(UnmanagedType.LPTStr)] public string lpszOutput; /// /// Pointer to a null-terminated string that specifies the type of data used to record the print job. The legal values for this /// member can be found by calling EnumPrintProcessorDatatypes and can include such values as raw, emf, or XPS_PASS. This member /// can be NULL. Note that the requested data type might be ignored. /// [MarshalAs(UnmanagedType.LPTStr)] public string lpszDatatype; /// /// Specifies additional information about the print job. This member must be zero or one of the following values. /// /// /// Value /// Meaning /// /// /// DI_APPBANDING /// Applications that use banding should set this flag for optimal performance during printing. /// /// /// DI_ROPS_READ_DESTINATION /// The application will use raster operations that involve reading from the destination surface. /// /// /// public DI fwType; } /// The DRAWPATRECT structure defines a rectangle to be created. /// This structure is used with the DRAWPATTERNRECT printer escape. // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-drawpatrect typedef struct _DRAWPATRECT { POINT ptPosition; // POINT ptSize; WORD wStyle; WORD wPattern; } DRAWPATRECT, *PDRAWPATRECT; [PInvokeData("wingdi.h", MSDNShortId = "8b374a0e-8ad0-40d4-a082-e90aff6336ba")] [StructLayout(LayoutKind.Sequential)] public struct DRAWPATRECT { /// The upper-left corner of the rectangle, in logical units. public Point ptPosition; /// The lower-right corner of the rectangle, in logical units. public Point ptSize; /// /// The style of the rectangle. It can be one of the following. /// /// /// Value /// Meaning /// /// /// 0 /// Black rectangle. /// /// /// 1 /// White rectangle. /// /// /// 2 /// Gray rectangle. Used with wPattern. /// /// /// public ushort wStyle; /// /// Amount of grayness of the rectangle, as a percentage (0-100). A value of 0 means a white rectangle and 100 means a black /// rectangle. This is only used when wStyle is 2. /// public ushort wPattern; } /// /// The PSFEATURE_CUSTPAPER structure contains information about a custom paper size for a PostScript driver. This structure /// is used with the GET_PS_FEATURESETTING printer escape function. /// /// /// For the semantics of the lOrientation, lWidth, lHeight, lWidthOffset, and lHeightOffset /// members, please refer to "Custom Page Size Parameters" in "PostScript Printer Description File Format Specification" v.4.3. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-psfeature_custpaper typedef struct _PSFEATURE_CUSTPAPER { // LONG lOrientation; LONG lWidth; LONG lHeight; LONG lWidthOffset; LONG lHeightOffset; } PSFEATURE_CUSTPAPER, *PPSFEATURE_CUSTPAPER; [PInvokeData("wingdi.h", MSDNShortId = "3858154c-425f-4333-a637-6d977caf7290")] [StructLayout(LayoutKind.Sequential)] public struct PSFEATURE_CUSTPAPER { /// /// Indicates the custom paper orientation. This member can be 0 to 3 if custom page size is selected. Otherwise, it is 1 and /// all other structure members are zero /// public int lOrientation; /// Custom page width, in points. public int lWidth; /// Custom page height, in points. public int lHeight; /// Custom page width offset, in points. public int lWidthOffset; /// Custom page height offset, in points. public int lHeightOffset; } /// /// The PSFEATURE_OUTPUT structure contains information about PostScript driver output options. This structure is used with /// the GET_PS_FEATURESETTING printer escape function. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-psfeature_output typedef struct _PSFEATURE_OUTPUT { BOOL // bPageIndependent; BOOL bSetPageDevice; } PSFEATURE_OUTPUT, *PPSFEATURE_OUTPUT; [PInvokeData("wingdi.h", MSDNShortId = "4ff96d45-e70e-4d80-9bab-dd1d67aee8f3")] [StructLayout(LayoutKind.Sequential)] public struct PSFEATURE_OUTPUT { /// TRUE if PostScript output is page-independent or FALSE if PostScript output is page-dependent. [MarshalAs(UnmanagedType.Bool)] public bool bPageIndependent; /// /// TRUE if printer feature code (setpagedevice's) is included or FALSE if all printer feature code is suppressed. /// [MarshalAs(UnmanagedType.Bool)] public bool bSetPageDevice; } /// /// The PSINJECTDATA structure is a header for the input buffer used with the POSTSCRIPT_INJECTION printer escape function. /// // https://docs.microsoft.com/en-us/windows/win32/api/wingdi/ns-wingdi-psinjectdata typedef struct _PSINJECTDATA { DWORD DataBytes; // WORD InjectionPoint; WORD PageNumber; } PSINJECTDATA, *PPSINJECTDATA; [PInvokeData("wingdi.h", MSDNShortId = "f42c8f69-7fe9-4740-b295-32ef2a5b714c")] [StructLayout(LayoutKind.Sequential)] public struct PSINJECTDATA { /// /// The number of bytes of raw data to be injected. The raw data begins immediately following this structure. This size does not /// include the size of the PSINJECTDATA structure. /// public uint DataBytes; /// /// Specifies where to inject the raw data in the PostScript output. This member can be one of the following values. /// /// /// Value /// Meaning /// /// /// PSINJECT_BEGINSTREAM /// Before the first byte of job stream. /// /// /// PSINJECT_PSADOBE /// Before %!PS-Adobe. /// /// /// PSINJECT_PAGESATEND /// Replaces driver's %%Pages (atend). /// /// /// PSINJECT_PAGES /// Replaces driver's %%Pages nnn. /// /// /// PSINJECT_DOCNEEDEDRES /// After %%DocumentNeededResources. /// /// /// PSINJECT_DOCSUPPLIEDRES /// After %%DocumentSuppliedResources. /// /// /// PSINJECT_PAGEORDER /// Replaces driver's %%PageOrder. /// /// /// PSINJECT_ORIENTATION /// Replaces driver's %%Orientation. /// /// /// PSINJECT_BOUNDINGBOX /// Replaces driver's %%BoundingBox. /// /// /// PSINJECT_DOCUMENTPROCESSCOLORS /// Replaces driver's %%DocumentProcessColors <color>. /// /// /// PSINJECT_COMMENTS /// Before %%EndComments. /// /// /// PSINJECT_BEGINDEFAULTS /// After %%BeginDefaults. /// /// /// PSINJECT_ENDDEFAULTS /// Before %%EndDefaults. /// /// /// PSINJECT_BEGINPROLOG /// After %%BeginProlog. /// /// /// PSINJECT_ENDPROLOG /// Before %%EndProlog. /// /// /// PSINJECT_BEGINSETUP /// After %%BeginSetup. /// /// /// PSINJECT_ENDSETUP /// Before %%EndSetup. /// /// /// PSINJECT_TRAILER /// After %%Trailer /// /// /// PSINJECT_EOF /// After %%EOF /// /// /// PSINJECT_ENDSTREAM /// After the last byte of job stream /// /// /// PSINJECT_DOCUMENTPROCESSCOLORSATEND /// Replaces driver's %%DocumentProcessColors (atend) /// /// /// Page level injection points /// /// /// PSINJECT_PAGENUMBER /// Replaces driver's %%Page /// /// /// PSINJECT_BEGINPAGESETUP /// After %%BeginPageSetup /// /// /// PSINJECT_ENDPAGESETUP /// Before %%EndPageSetup /// /// /// PSINJECT_PAGETRAILER /// After %%PageTrailer /// /// /// PSINJECT_PLATECOLOR /// Replace driver's %%PlateColor: <color> /// /// /// PSINJECT_SHOWPAGE /// Before showpage operator /// /// /// PSINJECT_PAGEBBOX /// Replaces driver's %%PageBoundingBox /// /// /// PSINJECT_ENDPAGECOMMENTS /// Before %%EndPageComments /// /// /// PSINJECT_VMSAVE /// Before save operator /// /// /// PSINJECT_VMRESTORE /// After restore operator /// /// /// public PSINJECT InjectionPoint; /// /// The page number (starting from 1) to which the injection data is applied. Specify zero to apply the injection data to all /// pages. This member is meaningful only for page level injection points starting from PSINJECT_PAGENUMBER. For other injection /// points, set PageNumber to zero. /// public ushort PageNumber; } } }