using System; using System.Runtime.InteropServices; using static Vanara.PInvoke.DocumentTarget; using static Vanara.PInvoke.Ole32; namespace Vanara.PInvoke { /// Items defined in DocumentSource.idl. // https://docs.microsoft.com/en-us/windows/win32/api/documentsource/ public static partial class DocumentSource { /// Implemented by the app to provide access to the content to be printed. [ComImport, Guid("a96bb1db-172e-4667-82b5-ad97a252318f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IPrintDocumentPageSource { /// Requests that the document source creates a preview page collection for the document being printed. /// A pointer to the package target. /// A pointer to the destination for the preview images. /// /// If the GetPreviewPageCollection method completes successfully, it returns an S_OK. Otherwise it returns an appropriate /// HRESULT error code. /// /// For details on how to extract and use GetPreviewPageCollection, see IPrintPreviewDxgiPackageTarget. [PreserveSig] HRESULT GetPreviewPageCollection(IPrintDocumentPackageTarget docPackageTarget, out IPrintPreviewPageCollection docPageCollection); /// Informs the app to create the document. /// The print options. /// The packaged target types. /// /// If the MakeDocument method completes successfully, it returns an S_OK. Otherwise it returns an appropriate HRESULT error code. /// [PreserveSig] HRESULT MakeDocument(IInspectable printTaskOptions, IPrintDocumentPackageTarget docPackageTarget); } /// Implemented by the app to provide access to print preview pages. [ComImport, Guid("0b31cc62-d7ec-4747-9d6e-f2537d870f2b"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IPrintPreviewPageCollection { /// /// This method is called whenever the system detects that the physical dimensions of the page has changed or when the app has /// requested pagination via a call to IPrintPreviewDxgiPreviewTarget::InvalidatePreview. /// /// The current page being displayed to the user. /// The print options. /// /// If the Paginate method completes successfully, it returns an S_OK. Otherwise it returns an appropriate HRESULT error code. /// /// /// For standard options which result in changes to the physical layout of the page, the system will automatically generate a /// Paginate call. The app does not need to call IPrintPreviewDxgiPackageTarget::InvalidatePreview in these scenarios; e.g. /// portrait changed to landscape. For custom options such as handling greyscale and color, apps should call InvalidatePreview /// to trigger a pagination. /// Note A Pagination request does not have to require a new pagination to occur. /// /// Apps should examine the state of the provided printTaskOptions and determine if the changes warrant a repagination.For /// example, if the imageable area changes and the content already fits within the new imageable area there is no need to /// perform a new pagination. /// /// /// An app may use the currentJobPage parameter to determine what page is visible if it wants to maintain user context when the /// layout changes.For example, keeping the same content on the screen when orientation switches from portrait to landscape. /// /// [PreserveSig] HRESULT Paginate(uint currentJobPage, IInspectable printTaskOptions); /// Provides the system with a new page to present in print preview. /// The page number. /// The width of the page. /// The height of the page. /// /// If the MakePage method completes successfully, it returns an S_OK. Otherwise it returns an appropriate HRESULT error code. /// /// /// Apps should not assume that the system will cache all retrieved pages. For example, the system may ask for page 1 again /// without making a call to Paginate first. When the desiredJobPage is JOB_PAGE_APPLICATION_DEFINED the app may return the page /// to be presented as the next preview page. The page number provided in the next call to /// IPrintPreviewDxgiPackageTarget::MakePage will be used as the next page to show the user. When a specific page is requested /// this is the page that is being requested by the preview experience and the app should respond with this page. Page counts /// are 1-based and desiredJobPage is 1 when requesting the first page of the document. /// [PreserveSig] HRESULT MakePage(uint desiredJobPage, float width, float height); } } }