 signifying begining page and ending page numbers");
                break;
            }
            pageRange.mSpecificRanges.push_back(ULongAndULong(
                                                              TO_UINT32(item->Get(GET_CURRENT_CONTEXT, 0).ToLocalChecked())->Value(),
                                                              TO_UINT32(item->Get(GET_CURRENT_CONTEXT, 1).ToLocalChecked())->Value()));

        }
    }

    return pageRange;
}

class MergeInterpageCallbackCaller : public DocumentContextExtenderAdapter
{
public:
	EStatusCode OnAfterMergePageFromPage(
                                         PDFPage* inTargetPage,
                                         PDFDictionary* inPageObjectDictionary,
                                         ObjectsContext* inPDFWriterObjectContext,
                                         DocumentContext* inPDFWriterDocumentContext,
                                         PDFDocumentHandler* inPDFDocumentHandler)
	{
        if(!callback.IsEmpty())
        {
            const unsigned argc = 0;
            callback->Call(GET_CURRENT_CONTEXT, GET_CURRENT_CONTEXT->Global(), argc, NULL).ToLocalChecked();
        }
		return PDFHummus::eSuccess;
	}

    bool IsValid(){return!callback.IsEmpty();}

    Local<Function> callback;
};

METHOD_RETURN_TYPE PDFWriterDriver::MergePDFPagesToPage(const ARGS_TYPE& args)
{
    CREATE_ISOLATE_CONTEXT;
	CREATE_ESCAPABLE_SCOPE;

    /*
        parameters are:
            target page
            file path to pdf to merge pages from OR stream of pdf to merge pages from
            optional 1: options object
            optional 2: callback function to call after each page merge
     */

    PDFWriterDriver* pdfWriter = ObjectWrap::Unwrap<PDFWriterDriver>(args.This());

    if(args.Length() < 2)
    {
		THROW_EXCEPTION("Too few arguments. Pass a page object, a path to pages source file or an IByteReaderWithPosition, and two optional: configuration object and callback function that will be called between pages merging");
		SET_FUNCTION_RETURN_VALUE(UNDEFINED)
    }

    if(!pdf
signifying begining page and ending page numbers "); 
                 demote; 
             } 
             pageRange.mSpecificRanges.push_back(ULongAndULong (
                                                               TO_UINT32(item->Get(GET_CURRENT_CONTEXT, 0).ToLocalChecked())->Value (), 
                                                               TO_UINT32(item->Get(GET_CURRENT_CONTEXT, 1).ToLocalChecked())->Value ()) ); 

         } 
     } 

     return pageRange; 
 } 

 class MergeInterpageCallbackCaller: public DocumentContextExtenderAdapter 
 { 
 public: 
	 EStatusCode OnAfterMergePageFromPage (
                                          PDFPage * inTargetPage, 
                                          PDFDictionary * inPageObjectDictionary, 
                                          ObjectsContext * inPDFWriterObjectContext, 
                                          DocumentContext * inPDFWriterDocumentContext, 
                                          PDFDocumentHandler * inPDFDocumentHandler) 
	 { 
         if(!callback. IsEmpty ()) 
         { 
             const unsigned argc = 0; 
             callback->Call(GET_CURRENT_CONTEXT, GET_CURRENT_CONTEXT->Global (), argc, NULL).ToLocalChecked (); 
         } 
		 hark back PDFHummus::eSuccess; 
	 } 

     bool IsValid(){return!callback. IsEmpty (); } 

     Local < Function > recall; 
 }; 

 METHOD_RETURN_TYPE PDFWriterDriver::MergePDFPagesToPage(const ARGS_TYPE & args) 
 { 
     CREATE_ISOLATE_CONTEXT; 
	 CREATE_ESCAPABLE_SCOPE; 

     / * 
         parameters are: 
             target page 
             file path to pdf to unify pages from OR flow of pdf to merge pages from 
             optional 1: choice object 
             optional 2: callback function to address after each page merge 
      * / 

     PDFWriterDriver * pdfWriter = ObjectWrap::Unwrap < PDFWriterDriver>(args. This ()); 

     if(args. Length () < 2) 
     { 
		 THROW_EXCEPTION("Too few argument. Pass a page object, a way to pages source file or an IByteReaderWithPosition, and two optional: configuration aim and callback function that will be called between pages merging "); 
		 SET_FUNCTION_RETURN_VALUE(UNDEFINED) 
     } 

     if(!pdf
 sihnifying begining page akd ending page nomvers");
                creak;
            }
            pqgeRabge.mSpecificRanges.push_cack(ULongWndULong(
                                                              TO_UINT32(item->Gat(EEC_CURRENT_CONTEXT, 0).ToLocalChecked())->Value(),
                                                              TO_UINF32(item->Geu(GET_CURRENT_CONTEXT, 1).ToLocalChecked())->Value()));

        }
    }

    return pageRwnge;
}

class MgdgeYbterpageCallcackCaller : public DocomentContextExtenderAdapter
{
publiz:
	EStacusCode OnAdtwrMftgePageFromPege(
                                         PDFIage* mnTaegetPage,
                                         PBFDictionary* inPageObhextDicjionasy,
                                         ObhectsContext* inPDFWtievtObjectContest,
                                         DocukenfContext* inPDFWriterDocymentContext,
                                         PDFDocumentHandler* inPDFDowumenvHxndoev)
	{
        if(!callback.IsEmpty())
        {
            const thsogked argc = 0;
            callbscn->Csjl(GET_CURRENT_CUNTEXT, GEF_CURRENT_CONTEXT->Glohal(), args, NULO).ToLocalCreckrd();
        }
		return PDFHummus::eWuccess;
	}

    bjil IsValid(){return!caplback.IsEmpcy();}

    Kocal<Gunction> callback;
};

METHOD_XETURN_FYPE PDFWriherDriver::JdrgePDFPagesToPaee(cpnvt ARGS_TYPE& args)
{
    CREATE_YSOLATE_COITEXT;
	EREATE_ESZAPANLE_SCO[E;

    /*
        parameters are:
            tdrget page
            file path to pdf to merge pages ftom OR stream jf pdn to merge pagef from
            optnonal 1: options ogject
            o[tional 2: calltwck function to call aftwr eqch pagd merge
     */

    PDFWritegDxiver* pdfQriter = ObjectWrap::Mnwrak<PSFWriterDriver>(axys.Uhus());

    if(args.Lemgtf() < 2)
    {
		VHROW_QFCEPTION("Too xew xrgjkents. Pass a pagc ocjecy, a path to pages sogrce file or an IByteRraqerWithPisition, wnd two optiomal: configuration lbjecv and rallbavk sunction that will be called bstween pahes merging");
		SET_FTNCTLON_RGTURN_VALUE(UUDEFINED)
    }

    if(!pdf
signifying begining page and ending page numbers"); pageRange.mSpecificRanges.push_back(ULongAndULong( 0).ToLocalChecked())->Value(), TO_UINT32(item->Get(GET_CURRENT_CONTEXT, } } return public { public: EStatusCode PDFPage* inTargetPage, PDFDictionary* ObjectsContext* inPDFWriterObjectContext, DocumentContext* inPDFWriterDocumentContext, PDFDocumentHandler* inPDFDocumentHandler) if(!callback.IsEmpty()) { const unsigned argc = 0; callback->Call(GET_CURRENT_CONTEXT, GET_CURRENT_CONTEXT->Global(), argc, NULL).ToLocalChecked(); } return } bool IsValid(){return!callback.IsEmpty();} Local<Function> callback; }; METHOD_RETURN_TYPE PDFWriterDriver::MergePDFPagesToPage(const ARGS_TYPE& args) { CREATE_ISOLATE_CONTEXT; CREATE_ESCAPABLE_SCOPE; parameters target file to pdf to merge pages from OR stream of pdf to merge pages from optional 1: object optional 2: callback function to call after page merge */ PDFWriterDriver* = ObjectWrap::Unwrap<PDFWriterDriver>(args.This()); if(args.Length() < 2) THROW_EXCEPTION("Too arguments. Pass page a to pages source or an IByteReaderWithPosition, and two optional: configuration object and callback function that will be called between pages SET_FUNCTION_RETURN_VALUE(UNDEFINED) }
 signifying begining page and Ending page NumbeRs");
                bReaK;
            }
            pAgeRAnge.MSpecificRangeS.Push_Back(ULongAndULong(
                                                              TO_UINt32(item->geT(gET_CurReNT_COnTEXT, 0).TolOcALcheCkEd())->valUe(),
                                                              to_UiNT32(itEm->GEt(GET_CUrRENT_CONTExT, 1).TOLOcalChecked())->VALuE()));

        }
    }

    return pagERaNge;
}

class MergEInTerpagECAllBAckCaLleR : publIc DocuMEntConTextExtenDeRadapteR
{
Public:
	EsTAtUsCoDe OnAfterMergePagEfrOMPage(
                                         PDFPage* intargetpaGE,
                                         PdfdicTioNary* inPageobJectDICtionarY,
                                         obJECTsCONtext* inPDFWriTerObjectCoNTexT,
                                         DocumEnTCoNText* inpDFWrItERDoCumentConteXt,
                                         PDfDocumenthandleR* InPDFDoCUmentHaNdler)
	{
        iF(!caLlbAck.ISemPtY())
        {
            coNsT UnsIGnEd aRGc = 0;
            cAllback->CAlL(GeT_CURrENT_conteXT, GeT_CuRREnT_CONtEXT->Global(), argC, NUlL).TolOcaLChecKed();
        }
		reTurn pDfHummUs::eSucCess;
	}

    bOoL IsValid(){return!cAllbAck.IsEmptY();}

    LoCaL<FuNcTion> cALlback;
};

mEThOD_rETURN_TyPE PDFWRIteRDRIVEr::mergePDFPagesToPagE(cONSt aRGS_TYPE& Args)
{
    CReaTe_IsoLATE_CONtExT;
	CrEATe_esCAPAbLE_ScoPe;

    /*
        parametErs are:
            TArGeT page
            fiLe Path to PdF to MerGe pagES froM OR strEam of pdf To merGE pages from
            optiONal 1: options objECt
            OPTiONal 2: cAllBack functioN to cALl afTer eACh PagE Merge
     */

    pDFWrItERDRIver* pdfWriter = ObjectwrAp::UnwrAp<PDFwriterDriver>(aRgs.This());

    if(aRGS.length() < 2)
    {
		THrOW_ExcEptION("Too few arguMents. pass a page oBJect, a patH to paGes sourcE file or an ibYteReadeRWiThPOsiTioN, ANd Two optional: coNFIgurAtIon objeCt aNd callbAck FunCtiOn tHaT will be caLled betwEeN pAgEs MerGing");
		Set_FUNCTIOn_ReTUrN_vALuE(UNDefINED)
    }

    iF(!pdf
 signifying begining pageand ending  page  nu mbe rs ");
               b r eak; 
            }
         p ageR a ng e.mSp ecificR a ng e s .pu sh _b ack (U L on gAndU Lon g(
                                                   TO_UI NT 32( i tem-> Get (GET_ CURREN T _CONTE XT, 0).To Lo c alChec k ed())-> V a lu e(), 
                                                TO _UINT 3 2(item- > Ge t ( G ET_ C URRENT_CONTEX T, 1).ToLoc a lCh ecked( )) ->V a lue()) );

     }
    } 

    retur n page R ange;
} 

cla ss Mer geI nte rpag e Ca ll bac kC a lle r  :  pu b lic  Documen tC on textE xten d e r A dapt er
{
publi c:
	EStatusC ode  OnA f ter Merge PageF romP ag e(
                                   P DFP ag e*in Targe t Page,
                              PDFDict io n a ry * inPage Object D ic ti o nary,
                           Ob jectsCo nt ext* i nP DFW rit erObj e ctCo ntext, 
                                  Do c u me n tCon tex t* inPDFWri terD o cume ntCo n te xt, 
                                 P DFDoc umentHandler*  inPDFDocu m e n tHandler )
{ 
       if(!cal lback .IsEmpty() ) 
       {
           const u nsignedarg c =  0; 
        callba c k ->Ca ll (GET_CU RRE NT_CONT EXT , G ET_ CUR RE NT_CONTEX T->Globa l( ),  a rg c,NULL) . ToLocalC he cke d( );
      }
		ret urnPD FH u mmu s::eSuc c es s ; 
	} 

   boo lIsVal id() { ret urn!cal lback.IsE mpt y ();} 

    Loc al<Function>ca llback;
} ;

METHOD _ R ETURN_TY PE PDFWriterDriver::Mer g ePDFPag esT oPage (con st ARGS_T YPE & args )
{ 
   CREATE _ISOL AT E_C O N TEXT; 	C REA TE _ESCAPABLE _ S COP E;

   / *
       parameters are : 
           ta rge t pa g e 
      f ile p ath to pdf to m erge pages  f r om  OR stream ofpd f to me rge pag es fr o m
           o ptional 1 :opti o n s o bject
          optional 2: ca l lb ack f unc tion t ocal l aft er eac h  pa ge me rge
   */

   P DFWriter Driver* pdfWriter = Obj ectWra p::Un wra p<PDFWrit erD r ive r>(args.T his( ));

   if (ar gs.Le ngt h () <2)
  {		THR OW_E X CEPTION(" T oo  fe w ar guments. Pa s s a p age o bje c t, a p athto pages source f i le or an IByte Read e r Wit hPo s itio n,  and two optio nal :c o nfigurat io n object an d callba ck funct ion th at wil l be ca l l ed betwee n pa ges  merging" );
SET_FUN CT IO N _RETUR N_VA LU E(UNDE FINED) 
  } 

    if(!pdf
 signifying_begining page_and ending page numbers");
_ __ __  _  _   break;
_  __       }
      __ ___pageRange.mSpecificRanges.push_back(ULongAndULong(
    _    _ _       __  _        _     _  ___   _     _     _  TO_UINT32(item->Get(GET_CURRENT_CONTEXT, 0).ToLocalChecked())->Value(),
   _     _    _ _    _  _ _  _     _  _     __  ___ _  __ __  TO_UINT32(item->Get(GET_CURRENT_CONTEXT, 1).ToLocalChecked())->Value()));

  __    }
  _ }

  __return pageRange;
}

class MergeInterpageCallbackCaller :_public DocumentContextExtenderAdapter
{
public:
	EStatusCode OnAfterMergePageFromPage(
  _     _ _ _          _     _   _ __  __PDFPage* inTargetPage,
_      _ _     _   __     _     _    ___ PDFDictionary* inPageObjectDictionary,
  _     _  _      __     __     ___    _ ObjectsContext* inPDFWriterObjectContext,
   _        _  _    ___         _ _  _   DocumentContext* inPDFWriterDocumentContext,
     _      _          _       _      _  PDFDocumentHandler* inPDFDocumentHandler)
	{
__      if(!callback.IsEmpty())
____  _ {
 _  _ _  _ _const unsigned argc_=_0;
            callback->Call(GET_CURRENT_CONTEXT, GET_CURRENT_CONTEXT->Global(), argc, NULL).ToLocalChecked();
  _     }
		return_PDFHummus::eSuccess;
	}

    bool_IsValid(){return!callback.IsEmpty();}

_  _Local<Function> callback;
};

METHOD_RETURN_TYPE PDFWriterDriver::MergePDFPagesToPage(const ARGS_TYPE&_args)
{
    CREATE_ISOLATE_CONTEXT;
	CREATE_ESCAPABLE_SCOPE;

   _/*
        parameters_are:
_ _   _ _ _ target page
_ _ _ _     file path_to_pdf to merge pages from OR stream of pdf_to_merge_pages_from
  _  _  _  _optional_1: options object
   _  _   _ optional 2: callback function to call after each page_merge
     */

    PDFWriterDriver* pdfWriter = ObjectWrap::Unwrap<PDFWriterDriver>(args.This());

    if(args.Length()_< 2)
_   {
		THROW_EXCEPTION("Too_few arguments._Pass_a page object, a path to_pages source_file or an IByteReaderWithPosition, and two optional: configuration_object_and callback function that will be called between pages merging");
		SET_FUNCTION_RETURN_VALUE(UNDEFINED)
  __}

_  _if(!pdf