{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)

/No description available in the introspection data./
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.Poppler.Objects.Page
    (

-- * Exported types
    Page(..)                                ,
    IsPage                                  ,
    toPage                                  ,
    noPage                                  ,


 -- * Methods
-- ** addAnnot #method:addAnnot#

#if ENABLE_OVERLOADING
    PageAddAnnotMethodInfo                  ,
#endif
    pageAddAnnot                            ,


-- ** findText #method:findText#

#if ENABLE_OVERLOADING
    PageFindTextMethodInfo                  ,
#endif
    pageFindText                            ,


-- ** findTextWithOptions #method:findTextWithOptions#

#if ENABLE_OVERLOADING
    PageFindTextWithOptionsMethodInfo       ,
#endif
    pageFindTextWithOptions                 ,


-- ** freeAnnotMapping #method:freeAnnotMapping#

    pageFreeAnnotMapping                    ,


-- ** freeFormFieldMapping #method:freeFormFieldMapping#

    pageFreeFormFieldMapping                ,


-- ** freeImageMapping #method:freeImageMapping#

    pageFreeImageMapping                    ,


-- ** freeLinkMapping #method:freeLinkMapping#

    pageFreeLinkMapping                     ,


-- ** freeTextAttributes #method:freeTextAttributes#

    pageFreeTextAttributes                  ,


-- ** getAnnotMapping #method:getAnnotMapping#

#if ENABLE_OVERLOADING
    PageGetAnnotMappingMethodInfo           ,
#endif
    pageGetAnnotMapping                     ,


-- ** getCropBox #method:getCropBox#

#if ENABLE_OVERLOADING
    PageGetCropBoxMethodInfo                ,
#endif
    pageGetCropBox                          ,


-- ** getDuration #method:getDuration#

#if ENABLE_OVERLOADING
    PageGetDurationMethodInfo               ,
#endif
    pageGetDuration                         ,


-- ** getFormFieldMapping #method:getFormFieldMapping#

#if ENABLE_OVERLOADING
    PageGetFormFieldMappingMethodInfo       ,
#endif
    pageGetFormFieldMapping                 ,


-- ** getImage #method:getImage#

#if ENABLE_OVERLOADING
    PageGetImageMethodInfo                  ,
#endif
    pageGetImage                            ,


-- ** getImageMapping #method:getImageMapping#

#if ENABLE_OVERLOADING
    PageGetImageMappingMethodInfo           ,
#endif
    pageGetImageMapping                     ,


-- ** getIndex #method:getIndex#

#if ENABLE_OVERLOADING
    PageGetIndexMethodInfo                  ,
#endif
    pageGetIndex                            ,


-- ** getLabel #method:getLabel#

#if ENABLE_OVERLOADING
    PageGetLabelMethodInfo                  ,
#endif
    pageGetLabel                            ,


-- ** getLinkMapping #method:getLinkMapping#

#if ENABLE_OVERLOADING
    PageGetLinkMappingMethodInfo            ,
#endif
    pageGetLinkMapping                      ,


-- ** getSelectedRegion #method:getSelectedRegion#

#if ENABLE_OVERLOADING
    PageGetSelectedRegionMethodInfo         ,
#endif
    pageGetSelectedRegion                   ,


-- ** getSelectedText #method:getSelectedText#

#if ENABLE_OVERLOADING
    PageGetSelectedTextMethodInfo           ,
#endif
    pageGetSelectedText                     ,


-- ** getSelectionRegion #method:getSelectionRegion#

#if ENABLE_OVERLOADING
    PageGetSelectionRegionMethodInfo        ,
#endif
    pageGetSelectionRegion                  ,


-- ** getSize #method:getSize#

#if ENABLE_OVERLOADING
    PageGetSizeMethodInfo                   ,
#endif
    pageGetSize                             ,


-- ** getText #method:getText#

#if ENABLE_OVERLOADING
    PageGetTextMethodInfo                   ,
#endif
    pageGetText                             ,


-- ** getTextAttributes #method:getTextAttributes#

#if ENABLE_OVERLOADING
    PageGetTextAttributesMethodInfo         ,
#endif
    pageGetTextAttributes                   ,


-- ** getTextAttributesForArea #method:getTextAttributesForArea#

#if ENABLE_OVERLOADING
    PageGetTextAttributesForAreaMethodInfo  ,
#endif
    pageGetTextAttributesForArea            ,


-- ** getTextForArea #method:getTextForArea#

#if ENABLE_OVERLOADING
    PageGetTextForAreaMethodInfo            ,
#endif
    pageGetTextForArea                      ,


-- ** getTextLayout #method:getTextLayout#

#if ENABLE_OVERLOADING
    PageGetTextLayoutMethodInfo             ,
#endif
    pageGetTextLayout                       ,


-- ** getTextLayoutForArea #method:getTextLayoutForArea#

#if ENABLE_OVERLOADING
    PageGetTextLayoutForAreaMethodInfo      ,
#endif
    pageGetTextLayoutForArea                ,


-- ** getThumbnail #method:getThumbnail#

#if ENABLE_OVERLOADING
    PageGetThumbnailMethodInfo              ,
#endif
    pageGetThumbnail                        ,


-- ** getThumbnailSize #method:getThumbnailSize#

#if ENABLE_OVERLOADING
    PageGetThumbnailSizeMethodInfo          ,
#endif
    pageGetThumbnailSize                    ,


-- ** getTransition #method:getTransition#

#if ENABLE_OVERLOADING
    PageGetTransitionMethodInfo             ,
#endif
    pageGetTransition                       ,


-- ** removeAnnot #method:removeAnnot#

#if ENABLE_OVERLOADING
    PageRemoveAnnotMethodInfo               ,
#endif
    pageRemoveAnnot                         ,


-- ** render #method:render#

#if ENABLE_OVERLOADING
    PageRenderMethodInfo                    ,
#endif
    pageRender                              ,


-- ** renderForPrinting #method:renderForPrinting#

#if ENABLE_OVERLOADING
    PageRenderForPrintingMethodInfo         ,
#endif
    pageRenderForPrinting                   ,


-- ** renderForPrintingWithOptions #method:renderForPrintingWithOptions#

#if ENABLE_OVERLOADING
    PageRenderForPrintingWithOptionsMethodInfo,
#endif
    pageRenderForPrintingWithOptions        ,


-- ** renderSelection #method:renderSelection#

#if ENABLE_OVERLOADING
    PageRenderSelectionMethodInfo           ,
#endif
    pageRenderSelection                     ,


-- ** renderToPs #method:renderToPs#

#if ENABLE_OVERLOADING
    PageRenderToPsMethodInfo                ,
#endif
    pageRenderToPs                          ,


-- ** selectionRegionFree #method:selectionRegionFree#

    pageSelectionRegionFree                 ,




 -- * Properties
-- ** label #attr:label#
{- | The label of the page or 'Nothing'. See also 'GI.Poppler.Objects.Page.pageGetLabel'
-}
#if ENABLE_OVERLOADING
    PageLabelPropertyInfo                   ,
#endif
    getPageLabel                            ,
#if ENABLE_OVERLOADING
    pageLabel                               ,
#endif




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import qualified GI.Cairo.Structs.Context as Cairo.Context
import qualified GI.Cairo.Structs.Region as Cairo.Region
import qualified GI.Cairo.Structs.Surface as Cairo.Surface
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Poppler.Enums as Poppler.Enums
import {-# SOURCE #-} qualified GI.Poppler.Flags as Poppler.Flags
import {-# SOURCE #-} qualified GI.Poppler.Objects.Annot as Poppler.Annot
import {-# SOURCE #-} qualified GI.Poppler.Objects.PSFile as Poppler.PSFile
import {-# SOURCE #-} qualified GI.Poppler.Structs.AnnotMapping as Poppler.AnnotMapping
import {-# SOURCE #-} qualified GI.Poppler.Structs.Color as Poppler.Color
import {-# SOURCE #-} qualified GI.Poppler.Structs.FormFieldMapping as Poppler.FormFieldMapping
import {-# SOURCE #-} qualified GI.Poppler.Structs.ImageMapping as Poppler.ImageMapping
import {-# SOURCE #-} qualified GI.Poppler.Structs.LinkMapping as Poppler.LinkMapping
import {-# SOURCE #-} qualified GI.Poppler.Structs.PageTransition as Poppler.PageTransition
import {-# SOURCE #-} qualified GI.Poppler.Structs.Rectangle as Poppler.Rectangle
import {-# SOURCE #-} qualified GI.Poppler.Structs.TextAttributes as Poppler.TextAttributes

-- | Memory-managed wrapper type.
newtype Page = Page (ManagedPtr Page)
foreign import ccall "poppler_page_get_type"
    c_poppler_page_get_type :: IO GType

instance GObject Page where
    gobjectType = c_poppler_page_get_type


-- | Type class for types which can be safely cast to `Page`, for instance with `toPage`.
class (GObject o, O.IsDescendantOf Page o) => IsPage o
instance (GObject o, O.IsDescendantOf Page o) => IsPage o

instance O.HasParentTypes Page
type instance O.ParentTypes Page = '[GObject.Object.Object]

-- | Cast to `Page`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toPage :: (MonadIO m, IsPage o) => o -> m Page
toPage = liftIO . unsafeCastTo Page

-- | A convenience alias for `Nothing` :: `Maybe` `Page`.
noPage :: Maybe Page
noPage = Nothing

#if ENABLE_OVERLOADING
type family ResolvePageMethod (t :: Symbol) (o :: *) :: * where
    ResolvePageMethod "addAnnot" o = PageAddAnnotMethodInfo
    ResolvePageMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolvePageMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolvePageMethod "findText" o = PageFindTextMethodInfo
    ResolvePageMethod "findTextWithOptions" o = PageFindTextWithOptionsMethodInfo
    ResolvePageMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolvePageMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolvePageMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolvePageMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolvePageMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolvePageMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolvePageMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolvePageMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolvePageMethod "removeAnnot" o = PageRemoveAnnotMethodInfo
    ResolvePageMethod "render" o = PageRenderMethodInfo
    ResolvePageMethod "renderForPrinting" o = PageRenderForPrintingMethodInfo
    ResolvePageMethod "renderForPrintingWithOptions" o = PageRenderForPrintingWithOptionsMethodInfo
    ResolvePageMethod "renderSelection" o = PageRenderSelectionMethodInfo
    ResolvePageMethod "renderToPs" o = PageRenderToPsMethodInfo
    ResolvePageMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolvePageMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolvePageMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolvePageMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolvePageMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolvePageMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolvePageMethod "getAnnotMapping" o = PageGetAnnotMappingMethodInfo
    ResolvePageMethod "getCropBox" o = PageGetCropBoxMethodInfo
    ResolvePageMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolvePageMethod "getDuration" o = PageGetDurationMethodInfo
    ResolvePageMethod "getFormFieldMapping" o = PageGetFormFieldMappingMethodInfo
    ResolvePageMethod "getImage" o = PageGetImageMethodInfo
    ResolvePageMethod "getImageMapping" o = PageGetImageMappingMethodInfo
    ResolvePageMethod "getIndex" o = PageGetIndexMethodInfo
    ResolvePageMethod "getLabel" o = PageGetLabelMethodInfo
    ResolvePageMethod "getLinkMapping" o = PageGetLinkMappingMethodInfo
    ResolvePageMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolvePageMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolvePageMethod "getSelectedRegion" o = PageGetSelectedRegionMethodInfo
    ResolvePageMethod "getSelectedText" o = PageGetSelectedTextMethodInfo
    ResolvePageMethod "getSelectionRegion" o = PageGetSelectionRegionMethodInfo
    ResolvePageMethod "getSize" o = PageGetSizeMethodInfo
    ResolvePageMethod "getText" o = PageGetTextMethodInfo
    ResolvePageMethod "getTextAttributes" o = PageGetTextAttributesMethodInfo
    ResolvePageMethod "getTextAttributesForArea" o = PageGetTextAttributesForAreaMethodInfo
    ResolvePageMethod "getTextForArea" o = PageGetTextForAreaMethodInfo
    ResolvePageMethod "getTextLayout" o = PageGetTextLayoutMethodInfo
    ResolvePageMethod "getTextLayoutForArea" o = PageGetTextLayoutForAreaMethodInfo
    ResolvePageMethod "getThumbnail" o = PageGetThumbnailMethodInfo
    ResolvePageMethod "getThumbnailSize" o = PageGetThumbnailSizeMethodInfo
    ResolvePageMethod "getTransition" o = PageGetTransitionMethodInfo
    ResolvePageMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolvePageMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolvePageMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolvePageMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolvePageMethod t Page, O.MethodInfo info Page p) => OL.IsLabel t (Page -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif

-- VVV Prop "label"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable]
   -- Nullable: (Nothing,Nothing)

{- |
Get the value of the “@label@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' page #label
@
-}
getPageLabel :: (MonadIO m, IsPage o) => o -> m (Maybe T.Text)
getPageLabel obj = liftIO $ B.Properties.getObjectPropertyString obj "label"

#if ENABLE_OVERLOADING
data PageLabelPropertyInfo
instance AttrInfo PageLabelPropertyInfo where
    type AttrAllowedOps PageLabelPropertyInfo = '[ 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint PageLabelPropertyInfo = (~) ()
    type AttrBaseTypeConstraint PageLabelPropertyInfo = IsPage
    type AttrGetType PageLabelPropertyInfo = (Maybe T.Text)
    type AttrLabel PageLabelPropertyInfo = "label"
    type AttrOrigin PageLabelPropertyInfo = Page
    attrGet _ = getPageLabel
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList Page
type instance O.AttributeList Page = PageAttributeList
type PageAttributeList = ('[ '("label", PageLabelPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
pageLabel :: AttrLabelProxy "label"
pageLabel = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
type instance O.SignalList Page = PageSignalList
type PageSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method Page::add_annot
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "annot", argType = TInterface (Name {namespace = "Poppler", name = "Annot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerAnnot to add", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_add_annot" poppler_page_add_annot ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr Poppler.Annot.Annot ->              -- annot : TInterface (Name {namespace = "Poppler", name = "Annot"})
    IO ()

{- |
Adds annotation /@annot@/ to /@page@/.

/Since: 0.16/
-}
pageAddAnnot ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a, Poppler.Annot.IsAnnot b) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> b
    {- ^ /@annot@/: a 'GI.Poppler.Objects.Annot.Annot' to add -}
    -> m ()
pageAddAnnot page annot = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    annot' <- unsafeManagedPtrCastPtr annot
    poppler_page_add_annot page' annot'
    touchManagedPtr page
    touchManagedPtr annot
    return ()

#if ENABLE_OVERLOADING
data PageAddAnnotMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsPage a, Poppler.Annot.IsAnnot b) => O.MethodInfo PageAddAnnotMethodInfo a signature where
    overloadedMethod _ = pageAddAnnot

#endif

-- method Page::find_text
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the text to search for (UTF-8 encoded)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Poppler", name = "Rectangle"})))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_find_text" poppler_page_find_text ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    CString ->                              -- text : TBasicType TUTF8
    IO (Ptr (GList (Ptr Poppler.Rectangle.Rectangle)))

{- |
Finds /@text@/ in /@page@/ with the default options ('GI.Poppler.Flags.FindFlagsDefault') and
returns a 'GI.GLib.Structs.List.List' of rectangles for each occurrence of the text on the page.
The coordinates are in PDF points.
-}
pageFindText ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> T.Text
    {- ^ /@text@/: the text to search for (UTF-8 encoded) -}
    -> m [Poppler.Rectangle.Rectangle]
    {- ^ __Returns:__ a 'GI.GLib.Structs.List.List' of 'GI.Poppler.Structs.Rectangle.Rectangle', -}
pageFindText page text = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    text' <- textToCString text
    result <- poppler_page_find_text page' text'
    result' <- unpackGList result
    result'' <- mapM (wrapBoxed Poppler.Rectangle.Rectangle) result'
    g_list_free result
    touchManagedPtr page
    freeMem text'
    return result''

#if ENABLE_OVERLOADING
data PageFindTextMethodInfo
instance (signature ~ (T.Text -> m [Poppler.Rectangle.Rectangle]), MonadIO m, IsPage a) => O.MethodInfo PageFindTextMethodInfo a signature where
    overloadedMethod _ = pageFindText

#endif

-- method Page::find_text_with_options
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "text", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the text to search for (UTF-8 encoded)", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "options", argType = TInterface (Name {namespace = "Poppler", name = "FindFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "find options", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Poppler", name = "Rectangle"})))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_find_text_with_options" poppler_page_find_text_with_options ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    CString ->                              -- text : TBasicType TUTF8
    CUInt ->                                -- options : TInterface (Name {namespace = "Poppler", name = "FindFlags"})
    IO (Ptr (GList (Ptr Poppler.Rectangle.Rectangle)))

{- |
Finds /@text@/ in /@page@/ with the given 'GI.Poppler.Flags.FindFlags' options and
returns a 'GI.GLib.Structs.List.List' of rectangles for each occurrence of the text on the page.
The coordinates are in PDF points.

/Since: 0.22/
-}
pageFindTextWithOptions ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> T.Text
    {- ^ /@text@/: the text to search for (UTF-8 encoded) -}
    -> [Poppler.Flags.FindFlags]
    {- ^ /@options@/: find options -}
    -> m [Poppler.Rectangle.Rectangle]
    {- ^ __Returns:__ a 'GI.GLib.Structs.List.List' of 'GI.Poppler.Structs.Rectangle.Rectangle', -}
pageFindTextWithOptions page text options = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    text' <- textToCString text
    let options' = gflagsToWord options
    result <- poppler_page_find_text_with_options page' text' options'
    result' <- unpackGList result
    result'' <- mapM (wrapBoxed Poppler.Rectangle.Rectangle) result'
    g_list_free result
    touchManagedPtr page
    freeMem text'
    return result''

#if ENABLE_OVERLOADING
data PageFindTextWithOptionsMethodInfo
instance (signature ~ (T.Text -> [Poppler.Flags.FindFlags] -> m [Poppler.Rectangle.Rectangle]), MonadIO m, IsPage a) => O.MethodInfo PageFindTextWithOptionsMethodInfo a signature where
    overloadedMethod _ = pageFindTextWithOptions

#endif

-- method Page::get_annot_mapping
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Poppler", name = "AnnotMapping"})))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_annot_mapping" poppler_page_get_annot_mapping ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    IO (Ptr (GList (Ptr Poppler.AnnotMapping.AnnotMapping)))

{- |
Returns a list of 'GI.Poppler.Structs.AnnotMapping.AnnotMapping' items that map from a location on
/@page@/ to a 'GI.Poppler.Objects.Annot.Annot'.  This list must be freed with
'GI.Poppler.Objects.Page.pageFreeAnnotMapping' when done.
-}
pageGetAnnotMapping ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: A 'GI.Poppler.Objects.Page.Page' -}
    -> m [Poppler.AnnotMapping.AnnotMapping]
    {- ^ __Returns:__ A 'GI.GLib.Structs.List.List' of 'GI.Poppler.Structs.AnnotMapping.AnnotMapping' -}
pageGetAnnotMapping page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    result <- poppler_page_get_annot_mapping page'
    result' <- unpackGList result
    result'' <- mapM (wrapBoxed Poppler.AnnotMapping.AnnotMapping) result'
    g_list_free result
    touchManagedPtr page
    return result''

#if ENABLE_OVERLOADING
data PageGetAnnotMappingMethodInfo
instance (signature ~ (m [Poppler.AnnotMapping.AnnotMapping]), MonadIO m, IsPage a) => O.MethodInfo PageGetAnnotMappingMethodInfo a signature where
    overloadedMethod _ = pageGetAnnotMapping

#endif

-- method Page::get_crop_box
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "rect", argType = TInterface (Name {namespace = "Poppler", name = "Rectangle"}), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerRectangle to fill", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = True, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_crop_box" poppler_page_get_crop_box ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr Poppler.Rectangle.Rectangle ->      -- rect : TInterface (Name {namespace = "Poppler", name = "Rectangle"})
    IO ()

{- |
Retrurns the crop box of /@page@/
-}
pageGetCropBox ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> m (Poppler.Rectangle.Rectangle)
pageGetCropBox page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    rect <- callocBoxedBytes 32 :: IO (Ptr Poppler.Rectangle.Rectangle)
    poppler_page_get_crop_box page' rect
    rect' <- (wrapBoxed Poppler.Rectangle.Rectangle) rect
    touchManagedPtr page
    return rect'

#if ENABLE_OVERLOADING
data PageGetCropBoxMethodInfo
instance (signature ~ (m (Poppler.Rectangle.Rectangle)), MonadIO m, IsPage a) => O.MethodInfo PageGetCropBoxMethodInfo a signature where
    overloadedMethod _ = pageGetCropBox

#endif

-- method Page::get_duration
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TDouble)
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_duration" poppler_page_get_duration ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    IO CDouble

{- |
Returns the duration of /@page@/
-}
pageGetDuration ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> m Double
    {- ^ __Returns:__ duration in seconds of /@page@/ or -1. -}
pageGetDuration page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    result <- poppler_page_get_duration page'
    let result' = realToFrac result
    touchManagedPtr page
    return result'

#if ENABLE_OVERLOADING
data PageGetDurationMethodInfo
instance (signature ~ (m Double), MonadIO m, IsPage a) => O.MethodInfo PageGetDurationMethodInfo a signature where
    overloadedMethod _ = pageGetDuration

#endif

-- method Page::get_form_field_mapping
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Poppler", name = "FormFieldMapping"})))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_form_field_mapping" poppler_page_get_form_field_mapping ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    IO (Ptr (GList (Ptr Poppler.FormFieldMapping.FormFieldMapping)))

{- |
Returns a list of 'GI.Poppler.Structs.FormFieldMapping.FormFieldMapping' items that map from a
location on /@page@/ to a form field.  This list must be freed
with 'GI.Poppler.Objects.Page.pageFreeFormFieldMapping' when done.
-}
pageGetFormFieldMapping ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: A 'GI.Poppler.Objects.Page.Page' -}
    -> m [Poppler.FormFieldMapping.FormFieldMapping]
    {- ^ __Returns:__ A 'GI.GLib.Structs.List.List' of 'GI.Poppler.Structs.FormFieldMapping.FormFieldMapping' -}
pageGetFormFieldMapping page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    result <- poppler_page_get_form_field_mapping page'
    result' <- unpackGList result
    result'' <- mapM (wrapBoxed Poppler.FormFieldMapping.FormFieldMapping) result'
    g_list_free result
    touchManagedPtr page
    return result''

#if ENABLE_OVERLOADING
data PageGetFormFieldMappingMethodInfo
instance (signature ~ (m [Poppler.FormFieldMapping.FormFieldMapping]), MonadIO m, IsPage a) => O.MethodInfo PageGetFormFieldMappingMethodInfo a signature where
    overloadedMethod _ = pageGetFormFieldMapping

#endif

-- method Page::get_image
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "image_id", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "The image identifier", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "cairo", name = "Surface"}))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_image" poppler_page_get_image ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Int32 ->                                -- image_id : TBasicType TInt
    IO (Ptr Cairo.Surface.Surface)

{- |
Returns a cairo surface for the image of the /@page@/
-}
pageGetImage ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: A 'GI.Poppler.Objects.Page.Page' -}
    -> Int32
    {- ^ /@imageId@/: The image identifier -}
    -> m Cairo.Surface.Surface
    {- ^ __Returns:__ A cairo surface for the image -}
pageGetImage page imageId = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    result <- poppler_page_get_image page' imageId
    checkUnexpectedReturnNULL "pageGetImage" result
    result' <- (wrapBoxed Cairo.Surface.Surface) result
    touchManagedPtr page
    return result'

#if ENABLE_OVERLOADING
data PageGetImageMethodInfo
instance (signature ~ (Int32 -> m Cairo.Surface.Surface), MonadIO m, IsPage a) => O.MethodInfo PageGetImageMethodInfo a signature where
    overloadedMethod _ = pageGetImage

#endif

-- method Page::get_image_mapping
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Poppler", name = "ImageMapping"})))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_image_mapping" poppler_page_get_image_mapping ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    IO (Ptr (GList (Ptr Poppler.ImageMapping.ImageMapping)))

{- |
Returns a list of 'GI.Poppler.Structs.ImageMapping.ImageMapping' items that map from a
location on /@page@/ to an image of the page. This list must be freed
with 'GI.Poppler.Objects.Page.pageFreeImageMapping' when done.
-}
pageGetImageMapping ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: A 'GI.Poppler.Objects.Page.Page' -}
    -> m [Poppler.ImageMapping.ImageMapping]
    {- ^ __Returns:__ A 'GI.GLib.Structs.List.List' of 'GI.Poppler.Structs.ImageMapping.ImageMapping' -}
pageGetImageMapping page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    result <- poppler_page_get_image_mapping page'
    result' <- unpackGList result
    result'' <- mapM (wrapBoxed Poppler.ImageMapping.ImageMapping) result'
    g_list_free result
    touchManagedPtr page
    return result''

#if ENABLE_OVERLOADING
data PageGetImageMappingMethodInfo
instance (signature ~ (m [Poppler.ImageMapping.ImageMapping]), MonadIO m, IsPage a) => O.MethodInfo PageGetImageMappingMethodInfo a signature where
    overloadedMethod _ = pageGetImageMapping

#endif

-- method Page::get_index
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_index" poppler_page_get_index ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    IO Int32

{- |
Returns the index of /@page@/
-}
pageGetIndex ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> m Int32
    {- ^ __Returns:__ index value of /@page@/ -}
pageGetIndex page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    result <- poppler_page_get_index page'
    touchManagedPtr page
    return result

#if ENABLE_OVERLOADING
data PageGetIndexMethodInfo
instance (signature ~ (m Int32), MonadIO m, IsPage a) => O.MethodInfo PageGetIndexMethodInfo a signature where
    overloadedMethod _ = pageGetIndex

#endif

-- method Page::get_label
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_label" poppler_page_get_label ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    IO CString

{- |
Returns the label of /@page@/. Note that page labels
and page indices might not coincide.

/Since: 0.16/
-}
pageGetLabel ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> m T.Text
    {- ^ __Returns:__ a new allocated string containing the label of /@page@/,
              or 'Nothing' if /@page@/ doesn\'t have a label -}
pageGetLabel page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    result <- poppler_page_get_label page'
    checkUnexpectedReturnNULL "pageGetLabel" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr page
    return result'

#if ENABLE_OVERLOADING
data PageGetLabelMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsPage a) => O.MethodInfo PageGetLabelMethodInfo a signature where
    overloadedMethod _ = pageGetLabel

#endif

-- method Page::get_link_mapping
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Poppler", name = "LinkMapping"})))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_link_mapping" poppler_page_get_link_mapping ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    IO (Ptr (GList (Ptr Poppler.LinkMapping.LinkMapping)))

{- |
Returns a list of 'GI.Poppler.Structs.LinkMapping.LinkMapping' items that map from a
location on /@page@/ to a 'GI.Poppler.Unions.Action.Action'.  This list must be freed
with 'GI.Poppler.Objects.Page.pageFreeLinkMapping' when done.
-}
pageGetLinkMapping ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: A 'GI.Poppler.Objects.Page.Page' -}
    -> m [Poppler.LinkMapping.LinkMapping]
    {- ^ __Returns:__ A 'GI.GLib.Structs.List.List' of 'GI.Poppler.Structs.LinkMapping.LinkMapping' -}
pageGetLinkMapping page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    result <- poppler_page_get_link_mapping page'
    result' <- unpackGList result
    result'' <- mapM (wrapBoxed Poppler.LinkMapping.LinkMapping) result'
    g_list_free result
    touchManagedPtr page
    return result''

#if ENABLE_OVERLOADING
data PageGetLinkMappingMethodInfo
instance (signature ~ (m [Poppler.LinkMapping.LinkMapping]), MonadIO m, IsPage a) => O.MethodInfo PageGetLinkMappingMethodInfo a signature where
    overloadedMethod _ = pageGetLinkMapping

#endif

-- method Page::get_selected_region
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "scale", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "scale specified as pixels per point", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "style", argType = TInterface (Name {namespace = "Poppler", name = "SelectionStyle"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerSelectionStyle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "selection", argType = TInterface (Name {namespace = "Poppler", name = "Rectangle"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "start and end point of selection as a rectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "cairo", name = "Region"}))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_selected_region" poppler_page_get_selected_region ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    CDouble ->                              -- scale : TBasicType TDouble
    CUInt ->                                -- style : TInterface (Name {namespace = "Poppler", name = "SelectionStyle"})
    Ptr Poppler.Rectangle.Rectangle ->      -- selection : TInterface (Name {namespace = "Poppler", name = "Rectangle"})
    IO (Ptr Cairo.Region.Region)

{- |
Returns a region containing the area that would be rendered by
'GI.Poppler.Objects.Page.pageRenderSelection'.
The returned region must be freed with @/cairo_region_destroy()/@

/Since: 0.16/
-}
pageGetSelectedRegion ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> Double
    {- ^ /@scale@/: scale specified as pixels per point -}
    -> Poppler.Enums.SelectionStyle
    {- ^ /@style@/: a 'GI.Poppler.Enums.SelectionStyle' -}
    -> Poppler.Rectangle.Rectangle
    {- ^ /@selection@/: start and end point of selection as a rectangle -}
    -> m Cairo.Region.Region
    {- ^ __Returns:__ a cairo_region_t -}
pageGetSelectedRegion page scale style selection = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    let scale' = realToFrac scale
    let style' = (fromIntegral . fromEnum) style
    selection' <- unsafeManagedPtrGetPtr selection
    result <- poppler_page_get_selected_region page' scale' style' selection'
    checkUnexpectedReturnNULL "pageGetSelectedRegion" result
    result' <- (wrapBoxed Cairo.Region.Region) result
    touchManagedPtr page
    touchManagedPtr selection
    return result'

#if ENABLE_OVERLOADING
data PageGetSelectedRegionMethodInfo
instance (signature ~ (Double -> Poppler.Enums.SelectionStyle -> Poppler.Rectangle.Rectangle -> m Cairo.Region.Region), MonadIO m, IsPage a) => O.MethodInfo PageGetSelectedRegionMethodInfo a signature where
    overloadedMethod _ = pageGetSelectedRegion

#endif

-- method Page::get_selected_text
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "style", argType = TInterface (Name {namespace = "Poppler", name = "SelectionStyle"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerSelectionStyle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "selection", argType = TInterface (Name {namespace = "Poppler", name = "Rectangle"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #PopplerRectangle including the text", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_selected_text" poppler_page_get_selected_text ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    CUInt ->                                -- style : TInterface (Name {namespace = "Poppler", name = "SelectionStyle"})
    Ptr Poppler.Rectangle.Rectangle ->      -- selection : TInterface (Name {namespace = "Poppler", name = "Rectangle"})
    IO CString

{- |
Retrieves the contents of the specified /@selection@/ as text.

/Since: 0.16/
-}
pageGetSelectedText ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> Poppler.Enums.SelectionStyle
    {- ^ /@style@/: a 'GI.Poppler.Enums.SelectionStyle' -}
    -> Poppler.Rectangle.Rectangle
    {- ^ /@selection@/: the 'GI.Poppler.Structs.Rectangle.Rectangle' including the text -}
    -> m T.Text
    {- ^ __Returns:__ a pointer to the contents of the /@selection@/
              as a string -}
pageGetSelectedText page style selection = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    let style' = (fromIntegral . fromEnum) style
    selection' <- unsafeManagedPtrGetPtr selection
    result <- poppler_page_get_selected_text page' style' selection'
    checkUnexpectedReturnNULL "pageGetSelectedText" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr page
    touchManagedPtr selection
    return result'

#if ENABLE_OVERLOADING
data PageGetSelectedTextMethodInfo
instance (signature ~ (Poppler.Enums.SelectionStyle -> Poppler.Rectangle.Rectangle -> m T.Text), MonadIO m, IsPage a) => O.MethodInfo PageGetSelectedTextMethodInfo a signature where
    overloadedMethod _ = pageGetSelectedText

#endif

-- method Page::get_selection_region
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "scale", argType = TBasicType TDouble, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "scale specified as pixels per point", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "style", argType = TInterface (Name {namespace = "Poppler", name = "SelectionStyle"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerSelectionStyle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "selection", argType = TInterface (Name {namespace = "Poppler", name = "Rectangle"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "start and end point of selection as a rectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Poppler", name = "Rectangle"})))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_selection_region" poppler_page_get_selection_region ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    CDouble ->                              -- scale : TBasicType TDouble
    CUInt ->                                -- style : TInterface (Name {namespace = "Poppler", name = "SelectionStyle"})
    Ptr Poppler.Rectangle.Rectangle ->      -- selection : TInterface (Name {namespace = "Poppler", name = "Rectangle"})
    IO (Ptr (GList (Ptr Poppler.Rectangle.Rectangle)))

{-# DEPRECATED pageGetSelectionRegion ["(Since version 0.16)","Use 'GI.Poppler.Objects.Page.pageGetSelectedRegion' instead."] #-}
{- |
Returns a region containing the area that would be rendered by
'GI.Poppler.Objects.Page.pageRenderSelection' as a 'GI.GLib.Structs.List.List' of
'GI.Poppler.Structs.Rectangle.Rectangle'. The returned list must be freed with
'GI.Poppler.Objects.Page.pageSelectionRegionFree'.
-}
pageGetSelectionRegion ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> Double
    {- ^ /@scale@/: scale specified as pixels per point -}
    -> Poppler.Enums.SelectionStyle
    {- ^ /@style@/: a 'GI.Poppler.Enums.SelectionStyle' -}
    -> Poppler.Rectangle.Rectangle
    {- ^ /@selection@/: start and end point of selection as a rectangle -}
    -> m [Poppler.Rectangle.Rectangle]
    {- ^ __Returns:__ a 'GI.GLib.Structs.List.List' of 'GI.Poppler.Structs.Rectangle.Rectangle' -}
pageGetSelectionRegion page scale style selection = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    let scale' = realToFrac scale
    let style' = (fromIntegral . fromEnum) style
    selection' <- unsafeManagedPtrGetPtr selection
    result <- poppler_page_get_selection_region page' scale' style' selection'
    result' <- unpackGList result
    result'' <- mapM (wrapBoxed Poppler.Rectangle.Rectangle) result'
    g_list_free result
    touchManagedPtr page
    touchManagedPtr selection
    return result''

#if ENABLE_OVERLOADING
data PageGetSelectionRegionMethodInfo
instance (signature ~ (Double -> Poppler.Enums.SelectionStyle -> Poppler.Rectangle.Rectangle -> m [Poppler.Rectangle.Rectangle]), MonadIO m, IsPage a) => O.MethodInfo PageGetSelectionRegionMethodInfo a signature where
    overloadedMethod _ = pageGetSelectionRegion

#endif

-- method Page::get_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "width", argType = TBasicType TDouble, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the width of @page", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "height", argType = TBasicType TDouble, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for the height of @page", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_size" poppler_page_get_size ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr CDouble ->                          -- width : TBasicType TDouble
    Ptr CDouble ->                          -- height : TBasicType TDouble
    IO ()

{- |
Gets the size of /@page@/ at the current scale and rotation.
-}
pageGetSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: A 'GI.Poppler.Objects.Page.Page' -}
    -> m ((Double, Double))
pageGetSize page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    width <- allocMem :: IO (Ptr CDouble)
    height <- allocMem :: IO (Ptr CDouble)
    poppler_page_get_size page' width height
    width' <- peek width
    let width'' = realToFrac width'
    height' <- peek height
    let height'' = realToFrac height'
    touchManagedPtr page
    freeMem width
    freeMem height
    return (width'', height'')

#if ENABLE_OVERLOADING
data PageGetSizeMethodInfo
instance (signature ~ (m ((Double, Double))), MonadIO m, IsPage a) => O.MethodInfo PageGetSizeMethodInfo a signature where
    overloadedMethod _ = pageGetSize

#endif

-- method Page::get_text
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_text" poppler_page_get_text ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    IO CString

{- |
Retrieves the text of /@page@/.

/Since: 0.16/
-}
pageGetText ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> m T.Text
    {- ^ __Returns:__ a pointer to the text of the /@page@/
              as a string -}
pageGetText page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    result <- poppler_page_get_text page'
    checkUnexpectedReturnNULL "pageGetText" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr page
    return result'

#if ENABLE_OVERLOADING
data PageGetTextMethodInfo
instance (signature ~ (m T.Text), MonadIO m, IsPage a) => O.MethodInfo PageGetTextMethodInfo a signature where
    overloadedMethod _ = pageGetText

#endif

-- method Page::get_text_attributes
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Poppler", name = "TextAttributes"})))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_text_attributes" poppler_page_get_text_attributes ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    IO (Ptr (GList (Ptr Poppler.TextAttributes.TextAttributes)))

{- |
Obtains the attributes of the text as a 'GI.GLib.Structs.List.List' of 'GI.Poppler.Structs.TextAttributes.TextAttributes'.
This list must be freed with 'GI.Poppler.Objects.Page.pageFreeTextAttributes' when done.

Each list element is a 'GI.Poppler.Structs.TextAttributes.TextAttributes' struct where start_index and
end_index indicates the range of text (as returned by 'GI.Poppler.Objects.Page.pageGetText')
to which text attributes apply.

See also 'GI.Poppler.Objects.Page.pageGetTextAttributesForArea'

/Since: 0.18/
-}
pageGetTextAttributes ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: A 'GI.Poppler.Objects.Page.Page' -}
    -> m [Poppler.TextAttributes.TextAttributes]
    {- ^ __Returns:__ A 'GI.GLib.Structs.List.List' of 'GI.Poppler.Structs.TextAttributes.TextAttributes' -}
pageGetTextAttributes page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    result <- poppler_page_get_text_attributes page'
    result' <- unpackGList result
    result'' <- mapM (wrapBoxed Poppler.TextAttributes.TextAttributes) result'
    g_list_free result
    touchManagedPtr page
    return result''

#if ENABLE_OVERLOADING
data PageGetTextAttributesMethodInfo
instance (signature ~ (m [Poppler.TextAttributes.TextAttributes]), MonadIO m, IsPage a) => O.MethodInfo PageGetTextAttributesMethodInfo a signature where
    overloadedMethod _ = pageGetTextAttributes

#endif

-- method Page::get_text_attributes_for_area
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "area", argType = TInterface (Name {namespace = "Poppler", name = "Rectangle"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerRectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGList (TInterface (Name {namespace = "Poppler", name = "TextAttributes"})))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_text_attributes_for_area" poppler_page_get_text_attributes_for_area ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr Poppler.Rectangle.Rectangle ->      -- area : TInterface (Name {namespace = "Poppler", name = "Rectangle"})
    IO (Ptr (GList (Ptr Poppler.TextAttributes.TextAttributes)))

{- |
Obtains the attributes of the text in /@area@/ as a 'GI.GLib.Structs.List.List' of 'GI.Poppler.Structs.TextAttributes.TextAttributes'.
This list must be freed with 'GI.Poppler.Objects.Page.pageFreeTextAttributes' when done.

Each list element is a 'GI.Poppler.Structs.TextAttributes.TextAttributes' struct where start_index and
end_index indicates the range of text (as returned by 'GI.Poppler.Objects.Page.pageGetTextForArea')
to which text attributes apply.

/Since: 0.26/
-}
pageGetTextAttributesForArea ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: A 'GI.Poppler.Objects.Page.Page' -}
    -> Poppler.Rectangle.Rectangle
    {- ^ /@area@/: a 'GI.Poppler.Structs.Rectangle.Rectangle' -}
    -> m [Poppler.TextAttributes.TextAttributes]
    {- ^ __Returns:__ A 'GI.GLib.Structs.List.List' of 'GI.Poppler.Structs.TextAttributes.TextAttributes' -}
pageGetTextAttributesForArea page area = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    area' <- unsafeManagedPtrGetPtr area
    result <- poppler_page_get_text_attributes_for_area page' area'
    result' <- unpackGList result
    result'' <- mapM (wrapBoxed Poppler.TextAttributes.TextAttributes) result'
    g_list_free result
    touchManagedPtr page
    touchManagedPtr area
    return result''

#if ENABLE_OVERLOADING
data PageGetTextAttributesForAreaMethodInfo
instance (signature ~ (Poppler.Rectangle.Rectangle -> m [Poppler.TextAttributes.TextAttributes]), MonadIO m, IsPage a) => O.MethodInfo PageGetTextAttributesForAreaMethodInfo a signature where
    overloadedMethod _ = pageGetTextAttributesForArea

#endif

-- method Page::get_text_for_area
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "area", argType = TInterface (Name {namespace = "Poppler", name = "Rectangle"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerRectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_text_for_area" poppler_page_get_text_for_area ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr Poppler.Rectangle.Rectangle ->      -- area : TInterface (Name {namespace = "Poppler", name = "Rectangle"})
    IO CString

{- |
Retrieves the text of /@page@/ contained in /@area@/.

/Since: 0.26/
-}
pageGetTextForArea ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> Poppler.Rectangle.Rectangle
    {- ^ /@area@/: a 'GI.Poppler.Structs.Rectangle.Rectangle' -}
    -> m T.Text
    {- ^ __Returns:__ a pointer to the text as a string -}
pageGetTextForArea page area = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    area' <- unsafeManagedPtrGetPtr area
    result <- poppler_page_get_text_for_area page' area'
    checkUnexpectedReturnNULL "pageGetTextForArea" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr page
    touchManagedPtr area
    return result'

#if ENABLE_OVERLOADING
data PageGetTextForAreaMethodInfo
instance (signature ~ (Poppler.Rectangle.Rectangle -> m T.Text), MonadIO m, IsPage a) => O.MethodInfo PageGetTextForAreaMethodInfo a signature where
    overloadedMethod _ = pageGetTextForArea

#endif

-- method Page::get_text_layout
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "rectangles", argType = TCArray False (-1) 2 (TInterface (Name {namespace = "Poppler", name = "Rectangle"})), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for an array of #PopplerRectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferContainer},Arg {argCName = "n_rectangles", argType = TBasicType TUInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of returned array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : [Arg {argCName = "n_rectangles", argType = TBasicType TUInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of returned array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_text_layout" poppler_page_get_text_layout ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr (Ptr Poppler.Rectangle.Rectangle) -> -- rectangles : TCArray False (-1) 2 (TInterface (Name {namespace = "Poppler", name = "Rectangle"}))
    Ptr Word32 ->                           -- n_rectangles : TBasicType TUInt
    IO CInt

{- |
Obtains the layout of the text as a list of 'GI.Poppler.Structs.Rectangle.Rectangle'
This array must be freed with 'GI.GLib.Functions.free' when done.

The position in the array represents an offset in the text returned by
'GI.Poppler.Objects.Page.pageGetText'

See also 'GI.Poppler.Objects.Page.pageGetTextLayoutForArea'.

/Since: 0.16/
-}
pageGetTextLayout ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: A 'GI.Poppler.Objects.Page.Page' -}
    -> m ((Bool, [Poppler.Rectangle.Rectangle]))
    {- ^ __Returns:__ 'True' if the page contains text, 'False' otherwise -}
pageGetTextLayout page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    rectangles <- allocMem :: IO (Ptr (Ptr Poppler.Rectangle.Rectangle))
    nRectangles <- allocMem :: IO (Ptr Word32)
    result <- poppler_page_get_text_layout page' rectangles nRectangles
    nRectangles' <- peek nRectangles
    let result' = (/= 0) result
    rectangles' <- peek rectangles
    rectangles'' <- (unpackBoxedArrayWithLength 32 nRectangles') rectangles'
    rectangles''' <- mapM (newBoxed Poppler.Rectangle.Rectangle) rectangles''
    freeMem rectangles'
    touchManagedPtr page
    freeMem rectangles
    freeMem nRectangles
    return (result', rectangles''')

#if ENABLE_OVERLOADING
data PageGetTextLayoutMethodInfo
instance (signature ~ (m ((Bool, [Poppler.Rectangle.Rectangle]))), MonadIO m, IsPage a) => O.MethodInfo PageGetTextLayoutMethodInfo a signature where
    overloadedMethod _ = pageGetTextLayout

#endif

-- method Page::get_text_layout_for_area
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "area", argType = TInterface (Name {namespace = "Poppler", name = "Rectangle"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerRectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "rectangles", argType = TCArray False (-1) 3 (TInterface (Name {namespace = "Poppler", name = "Rectangle"})), direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for an array of #PopplerRectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferContainer},Arg {argCName = "n_rectangles", argType = TBasicType TUInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of returned array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : [Arg {argCName = "n_rectangles", argType = TBasicType TUInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "length of returned array", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_text_layout_for_area" poppler_page_get_text_layout_for_area ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr Poppler.Rectangle.Rectangle ->      -- area : TInterface (Name {namespace = "Poppler", name = "Rectangle"})
    Ptr (Ptr Poppler.Rectangle.Rectangle) -> -- rectangles : TCArray False (-1) 3 (TInterface (Name {namespace = "Poppler", name = "Rectangle"}))
    Ptr Word32 ->                           -- n_rectangles : TBasicType TUInt
    IO CInt

{- |
Obtains the layout of the text contained in /@area@/ as a list of 'GI.Poppler.Structs.Rectangle.Rectangle'
This array must be freed with 'GI.GLib.Functions.free' when done.

The position in the array represents an offset in the text returned by
'GI.Poppler.Objects.Page.pageGetTextForArea'

/Since: 0.26/
-}
pageGetTextLayoutForArea ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: A 'GI.Poppler.Objects.Page.Page' -}
    -> Poppler.Rectangle.Rectangle
    {- ^ /@area@/: a 'GI.Poppler.Structs.Rectangle.Rectangle' -}
    -> m ((Bool, [Poppler.Rectangle.Rectangle]))
    {- ^ __Returns:__ 'True' if the page contains text, 'False' otherwise -}
pageGetTextLayoutForArea page area = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    area' <- unsafeManagedPtrGetPtr area
    rectangles <- allocMem :: IO (Ptr (Ptr Poppler.Rectangle.Rectangle))
    nRectangles <- allocMem :: IO (Ptr Word32)
    result <- poppler_page_get_text_layout_for_area page' area' rectangles nRectangles
    nRectangles' <- peek nRectangles
    let result' = (/= 0) result
    rectangles' <- peek rectangles
    rectangles'' <- (unpackBoxedArrayWithLength 32 nRectangles') rectangles'
    rectangles''' <- mapM (newBoxed Poppler.Rectangle.Rectangle) rectangles''
    freeMem rectangles'
    touchManagedPtr page
    touchManagedPtr area
    freeMem rectangles
    freeMem nRectangles
    return (result', rectangles''')

#if ENABLE_OVERLOADING
data PageGetTextLayoutForAreaMethodInfo
instance (signature ~ (Poppler.Rectangle.Rectangle -> m ((Bool, [Poppler.Rectangle.Rectangle]))), MonadIO m, IsPage a) => O.MethodInfo PageGetTextLayoutForAreaMethodInfo a signature where
    overloadedMethod _ = pageGetTextLayoutForArea

#endif

-- method Page::get_thumbnail
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #PopplerPage to get the thumbnail for", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "cairo", name = "Surface"}))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_thumbnail" poppler_page_get_thumbnail ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    IO (Ptr Cairo.Surface.Surface)

{- |
Get the embedded thumbnail for the specified page.  If the document
doesn\'t have an embedded thumbnail for the page, this function
returns 'Nothing'.
-}
pageGetThumbnail ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: the 'GI.Poppler.Objects.Page.Page' to get the thumbnail for -}
    -> m Cairo.Surface.Surface
    {- ^ __Returns:__ the tumbnail as a cairo_surface_t or 'Nothing' if the document
doesn\'t have a thumbnail for this page. -}
pageGetThumbnail page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    result <- poppler_page_get_thumbnail page'
    checkUnexpectedReturnNULL "pageGetThumbnail" result
    result' <- (wrapBoxed Cairo.Surface.Surface) result
    touchManagedPtr page
    return result'

#if ENABLE_OVERLOADING
data PageGetThumbnailMethodInfo
instance (signature ~ (m Cairo.Surface.Surface), MonadIO m, IsPage a) => O.MethodInfo PageGetThumbnailMethodInfo a signature where
    overloadedMethod _ = pageGetThumbnail

#endif

-- method Page::get_thumbnail_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "width", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for width", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "height", argType = TBasicType TInt, direction = DirectionOut, mayBeNull = False, argDoc = Documentation {rawDocText = Just "return location for height", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_thumbnail_size" poppler_page_get_thumbnail_size ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr Int32 ->                            -- width : TBasicType TInt
    Ptr Int32 ->                            -- height : TBasicType TInt
    IO CInt

{- |
Returns 'True' if /@page@/ has a thumbnail associated with it.  It also
fills in /@width@/ and /@height@/ with the width and height of the
thumbnail.  The values of width and height are not changed if no
appropriate thumbnail exists.
-}
pageGetThumbnailSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: A 'GI.Poppler.Objects.Page.Page' -}
    -> m ((Bool, Int32, Int32))
    {- ^ __Returns:__ 'True', if /@page@/ has a thumbnail associated with it. -}
pageGetThumbnailSize page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    width <- allocMem :: IO (Ptr Int32)
    height <- allocMem :: IO (Ptr Int32)
    result <- poppler_page_get_thumbnail_size page' width height
    let result' = (/= 0) result
    width' <- peek width
    height' <- peek height
    touchManagedPtr page
    freeMem width
    freeMem height
    return (result', width', height')

#if ENABLE_OVERLOADING
data PageGetThumbnailSizeMethodInfo
instance (signature ~ (m ((Bool, Int32, Int32))), MonadIO m, IsPage a) => O.MethodInfo PageGetThumbnailSizeMethodInfo a signature where
    overloadedMethod _ = pageGetThumbnailSize

#endif

-- method Page::get_transition
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Poppler", name = "PageTransition"}))
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_get_transition" poppler_page_get_transition ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    IO (Ptr Poppler.PageTransition.PageTransition)

{- |
Returns the transition effect of /@page@/
-}
pageGetTransition ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> m Poppler.PageTransition.PageTransition
    {- ^ __Returns:__ a 'GI.Poppler.Structs.PageTransition.PageTransition' or 'Nothing'. -}
pageGetTransition page = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    result <- poppler_page_get_transition page'
    checkUnexpectedReturnNULL "pageGetTransition" result
    result' <- (wrapBoxed Poppler.PageTransition.PageTransition) result
    touchManagedPtr page
    return result'

#if ENABLE_OVERLOADING
data PageGetTransitionMethodInfo
instance (signature ~ (m Poppler.PageTransition.PageTransition), MonadIO m, IsPage a) => O.MethodInfo PageGetTransitionMethodInfo a signature where
    overloadedMethod _ = pageGetTransition

#endif

-- method Page::remove_annot
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "annot", argType = TInterface (Name {namespace = "Poppler", name = "Annot"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerAnnot to remove", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_remove_annot" poppler_page_remove_annot ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr Poppler.Annot.Annot ->              -- annot : TInterface (Name {namespace = "Poppler", name = "Annot"})
    IO ()

{- |
Removes annotation /@annot@/ from /@page@/

/Since: 0.22/
-}
pageRemoveAnnot ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a, Poppler.Annot.IsAnnot b) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> b
    {- ^ /@annot@/: a 'GI.Poppler.Objects.Annot.Annot' to remove -}
    -> m ()
pageRemoveAnnot page annot = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    annot' <- unsafeManagedPtrCastPtr annot
    poppler_page_remove_annot page' annot'
    touchManagedPtr page
    touchManagedPtr annot
    return ()

#if ENABLE_OVERLOADING
data PageRemoveAnnotMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsPage a, Poppler.Annot.IsAnnot b) => O.MethodInfo PageRemoveAnnotMethodInfo a signature where
    overloadedMethod _ = pageRemoveAnnot

#endif

-- method Page::render
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the page to render from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cairo", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "cairo context to render to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_render" poppler_page_render ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr Cairo.Context.Context ->            -- cairo : TInterface (Name {namespace = "cairo", name = "Context"})
    IO ()

{- |
Render the page to the given cairo context. This function
is for rendering a page that will be displayed. If you want
to render a page that will be printed use
'GI.Poppler.Objects.Page.pageRenderForPrinting' instead
-}
pageRender ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: the page to render from -}
    -> Cairo.Context.Context
    {- ^ /@cairo@/: cairo context to render to -}
    -> m ()
pageRender page cairo = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    cairo' <- unsafeManagedPtrGetPtr cairo
    poppler_page_render page' cairo'
    touchManagedPtr page
    touchManagedPtr cairo
    return ()

#if ENABLE_OVERLOADING
data PageRenderMethodInfo
instance (signature ~ (Cairo.Context.Context -> m ()), MonadIO m, IsPage a) => O.MethodInfo PageRenderMethodInfo a signature where
    overloadedMethod _ = pageRender

#endif

-- method Page::render_for_printing
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the page to render from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cairo", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "cairo context to render to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_render_for_printing" poppler_page_render_for_printing ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr Cairo.Context.Context ->            -- cairo : TInterface (Name {namespace = "cairo", name = "Context"})
    IO ()

{- |
Render the page to the given cairo context for printing.
-}
pageRenderForPrinting ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: the page to render from -}
    -> Cairo.Context.Context
    {- ^ /@cairo@/: cairo context to render to -}
    -> m ()
pageRenderForPrinting page cairo = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    cairo' <- unsafeManagedPtrGetPtr cairo
    poppler_page_render_for_printing page' cairo'
    touchManagedPtr page
    touchManagedPtr cairo
    return ()

#if ENABLE_OVERLOADING
data PageRenderForPrintingMethodInfo
instance (signature ~ (Cairo.Context.Context -> m ()), MonadIO m, IsPage a) => O.MethodInfo PageRenderForPrintingMethodInfo a signature where
    overloadedMethod _ = pageRenderForPrinting

#endif

-- method Page::render_for_printing_with_options
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the page to render from", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cairo", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "cairo context to render to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "options", argType = TInterface (Name {namespace = "Poppler", name = "PrintFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "print options", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_render_for_printing_with_options" poppler_page_render_for_printing_with_options ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr Cairo.Context.Context ->            -- cairo : TInterface (Name {namespace = "cairo", name = "Context"})
    CUInt ->                                -- options : TInterface (Name {namespace = "Poppler", name = "PrintFlags"})
    IO ()

{- |
Render the page to the given cairo context for printing
with the specified options

/Since: 0.16/
-}
pageRenderForPrintingWithOptions ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: the page to render from -}
    -> Cairo.Context.Context
    {- ^ /@cairo@/: cairo context to render to -}
    -> [Poppler.Flags.PrintFlags]
    {- ^ /@options@/: print options -}
    -> m ()
pageRenderForPrintingWithOptions page cairo options = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    cairo' <- unsafeManagedPtrGetPtr cairo
    let options' = gflagsToWord options
    poppler_page_render_for_printing_with_options page' cairo' options'
    touchManagedPtr page
    touchManagedPtr cairo
    return ()

#if ENABLE_OVERLOADING
data PageRenderForPrintingWithOptionsMethodInfo
instance (signature ~ (Cairo.Context.Context -> [Poppler.Flags.PrintFlags] -> m ()), MonadIO m, IsPage a) => O.MethodInfo PageRenderForPrintingWithOptionsMethodInfo a signature where
    overloadedMethod _ = pageRenderForPrintingWithOptions

#endif

-- method Page::render_selection
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the #PopplerPage for which to render selection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cairo", argType = TInterface (Name {namespace = "cairo", name = "Context"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "cairo context to render to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "selection", argType = TInterface (Name {namespace = "Poppler", name = "Rectangle"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "start and end point of selection as a rectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "old_selection", argType = TInterface (Name {namespace = "Poppler", name = "Rectangle"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "previous selection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "style", argType = TInterface (Name {namespace = "Poppler", name = "SelectionStyle"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerSelectionStyle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "glyph_color", argType = TInterface (Name {namespace = "Poppler", name = "Color"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "color to use for drawing glyphs", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "background_color", argType = TInterface (Name {namespace = "Poppler", name = "Color"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "color to use for the selection background", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_render_selection" poppler_page_render_selection ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr Cairo.Context.Context ->            -- cairo : TInterface (Name {namespace = "cairo", name = "Context"})
    Ptr Poppler.Rectangle.Rectangle ->      -- selection : TInterface (Name {namespace = "Poppler", name = "Rectangle"})
    Ptr Poppler.Rectangle.Rectangle ->      -- old_selection : TInterface (Name {namespace = "Poppler", name = "Rectangle"})
    CUInt ->                                -- style : TInterface (Name {namespace = "Poppler", name = "SelectionStyle"})
    Ptr Poppler.Color.Color ->              -- glyph_color : TInterface (Name {namespace = "Poppler", name = "Color"})
    Ptr Poppler.Color.Color ->              -- background_color : TInterface (Name {namespace = "Poppler", name = "Color"})
    IO ()

{- |
Render the selection specified by /@selection@/ for /@page@/ to
the given cairo context.  The selection will be rendered, using
/@glyphColor@/ for the glyphs and /@backgroundColor@/ for the selection
background.

If non-NULL, /@oldSelection@/ specifies the selection that is already
rendered to /@cairo@/, in which case this function will (some day)
only render the changed part of the selection.
-}
pageRenderSelection ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a) =>
    a
    {- ^ /@page@/: the 'GI.Poppler.Objects.Page.Page' for which to render selection -}
    -> Cairo.Context.Context
    {- ^ /@cairo@/: cairo context to render to -}
    -> Poppler.Rectangle.Rectangle
    {- ^ /@selection@/: start and end point of selection as a rectangle -}
    -> Poppler.Rectangle.Rectangle
    {- ^ /@oldSelection@/: previous selection -}
    -> Poppler.Enums.SelectionStyle
    {- ^ /@style@/: a 'GI.Poppler.Enums.SelectionStyle' -}
    -> Poppler.Color.Color
    {- ^ /@glyphColor@/: color to use for drawing glyphs -}
    -> Poppler.Color.Color
    {- ^ /@backgroundColor@/: color to use for the selection background -}
    -> m ()
pageRenderSelection page cairo selection oldSelection style glyphColor backgroundColor = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    cairo' <- unsafeManagedPtrGetPtr cairo
    selection' <- unsafeManagedPtrGetPtr selection
    oldSelection' <- unsafeManagedPtrGetPtr oldSelection
    let style' = (fromIntegral . fromEnum) style
    glyphColor' <- unsafeManagedPtrGetPtr glyphColor
    backgroundColor' <- unsafeManagedPtrGetPtr backgroundColor
    poppler_page_render_selection page' cairo' selection' oldSelection' style' glyphColor' backgroundColor'
    touchManagedPtr page
    touchManagedPtr cairo
    touchManagedPtr selection
    touchManagedPtr oldSelection
    touchManagedPtr glyphColor
    touchManagedPtr backgroundColor
    return ()

#if ENABLE_OVERLOADING
data PageRenderSelectionMethodInfo
instance (signature ~ (Cairo.Context.Context -> Poppler.Rectangle.Rectangle -> Poppler.Rectangle.Rectangle -> Poppler.Enums.SelectionStyle -> Poppler.Color.Color -> Poppler.Color.Color -> m ()), MonadIO m, IsPage a) => O.MethodInfo PageRenderSelectionMethodInfo a signature where
    overloadedMethod _ = pageRenderSelection

#endif

-- method Page::render_to_ps
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "page", argType = TInterface (Name {namespace = "Poppler", name = "Page"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #PopplerPage", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ps_file", argType = TInterface (Name {namespace = "Poppler", name = "PSFile"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the PopplerPSFile to render to", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_render_to_ps" poppler_page_render_to_ps ::
    Ptr Page ->                             -- page : TInterface (Name {namespace = "Poppler", name = "Page"})
    Ptr Poppler.PSFile.PSFile ->            -- ps_file : TInterface (Name {namespace = "Poppler", name = "PSFile"})
    IO ()

{- |
Render the page on a postscript file
-}
pageRenderToPs ::
    (B.CallStack.HasCallStack, MonadIO m, IsPage a, Poppler.PSFile.IsPSFile b) =>
    a
    {- ^ /@page@/: a 'GI.Poppler.Objects.Page.Page' -}
    -> b
    {- ^ /@psFile@/: the PopplerPSFile to render to -}
    -> m ()
pageRenderToPs page psFile = liftIO $ do
    page' <- unsafeManagedPtrCastPtr page
    psFile' <- unsafeManagedPtrCastPtr psFile
    poppler_page_render_to_ps page' psFile'
    touchManagedPtr page
    touchManagedPtr psFile
    return ()

#if ENABLE_OVERLOADING
data PageRenderToPsMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsPage a, Poppler.PSFile.IsPSFile b) => O.MethodInfo PageRenderToPsMethodInfo a signature where
    overloadedMethod _ = pageRenderToPs

#endif

-- method Page::free_annot_mapping
-- method type : MemberFunction
-- Args : [Arg {argCName = "list", argType = TGList (TInterface (Name {namespace = "Poppler", name = "AnnotMapping"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A list of\n  #PopplerAnnotMapping<!-- -->s", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_free_annot_mapping" poppler_page_free_annot_mapping ::
    Ptr (GList (Ptr Poppler.AnnotMapping.AnnotMapping)) -> -- list : TGList (TInterface (Name {namespace = "Poppler", name = "AnnotMapping"}))
    IO ()

{- |
Frees a list of 'GI.Poppler.Structs.AnnotMapping.AnnotMapping'\<!-- -->s allocated by
'GI.Poppler.Objects.Page.pageGetAnnotMapping'.  It also unreferences the 'GI.Poppler.Objects.Annot.Annot'\<!-- -->s
that each mapping contains, so if you want to keep them around, you need to
reference them with 'GI.GObject.Objects.Object.objectRef'.
-}
pageFreeAnnotMapping ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Poppler.AnnotMapping.AnnotMapping]
    {- ^ /@list@/: A list of
  'GI.Poppler.Structs.AnnotMapping.AnnotMapping'\<!-- -->s -}
    -> m ()
pageFreeAnnotMapping list = liftIO $ do
    list' <- mapM unsafeManagedPtrGetPtr list
    list'' <- packGList list'
    poppler_page_free_annot_mapping list''
    mapM_ touchManagedPtr list
    g_list_free list''
    return ()

#if ENABLE_OVERLOADING
#endif

-- method Page::free_form_field_mapping
-- method type : MemberFunction
-- Args : [Arg {argCName = "list", argType = TGList (TInterface (Name {namespace = "Poppler", name = "FormFieldMapping"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A list of\n  #PopplerFormFieldMapping<!-- -->s", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_free_form_field_mapping" poppler_page_free_form_field_mapping ::
    Ptr (GList (Ptr Poppler.FormFieldMapping.FormFieldMapping)) -> -- list : TGList (TInterface (Name {namespace = "Poppler", name = "FormFieldMapping"}))
    IO ()

{- |
Frees a list of 'GI.Poppler.Structs.FormFieldMapping.FormFieldMapping'\<!-- -->s allocated by
'GI.Poppler.Objects.Page.pageGetFormFieldMapping'.
-}
pageFreeFormFieldMapping ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Poppler.FormFieldMapping.FormFieldMapping]
    {- ^ /@list@/: A list of
  'GI.Poppler.Structs.FormFieldMapping.FormFieldMapping'\<!-- -->s -}
    -> m ()
pageFreeFormFieldMapping list = liftIO $ do
    list' <- mapM unsafeManagedPtrGetPtr list
    list'' <- packGList list'
    poppler_page_free_form_field_mapping list''
    mapM_ touchManagedPtr list
    g_list_free list''
    return ()

#if ENABLE_OVERLOADING
#endif

-- method Page::free_image_mapping
-- method type : MemberFunction
-- Args : [Arg {argCName = "list", argType = TGList (TInterface (Name {namespace = "Poppler", name = "ImageMapping"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A list of\n  #PopplerImageMapping<!-- -->s", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_free_image_mapping" poppler_page_free_image_mapping ::
    Ptr (GList (Ptr Poppler.ImageMapping.ImageMapping)) -> -- list : TGList (TInterface (Name {namespace = "Poppler", name = "ImageMapping"}))
    IO ()

{- |
Frees a list of 'GI.Poppler.Structs.ImageMapping.ImageMapping'\<!-- -->s allocated by
'GI.Poppler.Objects.Page.pageGetImageMapping'.
-}
pageFreeImageMapping ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Poppler.ImageMapping.ImageMapping]
    {- ^ /@list@/: A list of
  'GI.Poppler.Structs.ImageMapping.ImageMapping'\<!-- -->s -}
    -> m ()
pageFreeImageMapping list = liftIO $ do
    list' <- mapM unsafeManagedPtrGetPtr list
    list'' <- packGList list'
    poppler_page_free_image_mapping list''
    mapM_ touchManagedPtr list
    g_list_free list''
    return ()

#if ENABLE_OVERLOADING
#endif

-- method Page::free_link_mapping
-- method type : MemberFunction
-- Args : [Arg {argCName = "list", argType = TGList (TInterface (Name {namespace = "Poppler", name = "LinkMapping"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A list of\n  #PopplerLinkMapping<!-- -->s", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_free_link_mapping" poppler_page_free_link_mapping ::
    Ptr (GList (Ptr Poppler.LinkMapping.LinkMapping)) -> -- list : TGList (TInterface (Name {namespace = "Poppler", name = "LinkMapping"}))
    IO ()

{- |
Frees a list of 'GI.Poppler.Structs.LinkMapping.LinkMapping'\<!-- -->s allocated by
'GI.Poppler.Objects.Page.pageGetLinkMapping'.  It also frees the 'GI.Poppler.Unions.Action.Action'\<!-- -->s
that each mapping contains, so if you want to keep them around, you need to
copy them with 'GI.Poppler.Unions.Action.actionCopy'.
-}
pageFreeLinkMapping ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Poppler.LinkMapping.LinkMapping]
    {- ^ /@list@/: A list of
  'GI.Poppler.Structs.LinkMapping.LinkMapping'\<!-- -->s -}
    -> m ()
pageFreeLinkMapping list = liftIO $ do
    list' <- mapM unsafeManagedPtrGetPtr list
    list'' <- packGList list'
    poppler_page_free_link_mapping list''
    mapM_ touchManagedPtr list
    g_list_free list''
    return ()

#if ENABLE_OVERLOADING
#endif

-- method Page::free_text_attributes
-- method type : MemberFunction
-- Args : [Arg {argCName = "list", argType = TGList (TInterface (Name {namespace = "Poppler", name = "TextAttributes"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "A list of\n  #PopplerTextAttributes<!-- -->s", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_free_text_attributes" poppler_page_free_text_attributes ::
    Ptr (GList (Ptr Poppler.TextAttributes.TextAttributes)) -> -- list : TGList (TInterface (Name {namespace = "Poppler", name = "TextAttributes"}))
    IO ()

{- |
Frees a list of 'GI.Poppler.Structs.TextAttributes.TextAttributes'\<!-- -->s allocated by
'GI.Poppler.Objects.Page.pageGetTextAttributes'.

/Since: 0.18/
-}
pageFreeTextAttributes ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Poppler.TextAttributes.TextAttributes]
    {- ^ /@list@/: A list of
  'GI.Poppler.Structs.TextAttributes.TextAttributes'\<!-- -->s -}
    -> m ()
pageFreeTextAttributes list = liftIO $ do
    list' <- mapM unsafeManagedPtrGetPtr list
    list'' <- packGList list'
    poppler_page_free_text_attributes list''
    mapM_ touchManagedPtr list
    g_list_free list''
    return ()

#if ENABLE_OVERLOADING
#endif

-- method Page::selection_region_free
-- method type : MemberFunction
-- Args : [Arg {argCName = "region", argType = TGList (TInterface (Name {namespace = "Poppler", name = "Rectangle"})), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GList of\n  #PopplerRectangle", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "poppler_page_selection_region_free" poppler_page_selection_region_free ::
    Ptr (GList (Ptr Poppler.Rectangle.Rectangle)) -> -- region : TGList (TInterface (Name {namespace = "Poppler", name = "Rectangle"}))
    IO ()

{-# DEPRECATED pageSelectionRegionFree ["(Since version 0.16)"] #-}
{- |
Frees /@region@/
-}
pageSelectionRegionFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Poppler.Rectangle.Rectangle]
    {- ^ /@region@/: a 'GI.GLib.Structs.List.List' of
  'GI.Poppler.Structs.Rectangle.Rectangle' -}
    -> m ()
pageSelectionRegionFree region = liftIO $ do
    region' <- mapM unsafeManagedPtrGetPtr region
    region'' <- packGList region'
    poppler_page_selection_region_free region''
    mapM_ touchManagedPtr region
    g_list_free region''
    return ()

#if ENABLE_OVERLOADING
#endif