/*
//
//   ADOBE SYSTEMS INCORPORATED
//   Copyright (C) 2000-2005 Adobe Systems Incorporated
//   All rights reserved.
//
//   NOTICE: Adobe permits you to use, modify, and distribute this file
//   in accordance with the terms of the Adobe license agreement
//   accompanying it. If you have received this file from a source other
//   than Adobe, then your use, modification, or distribution of it
//   requires the prior written permission of Adobe.
//
*/
/*
// 
// Project: - "Create Pattern" Example 
//                                               
//             Demonstrates creation of tiling patterns through lower level PDF object / element programming.
// 
// // Steps:
// 
// * Initialize PDFL.
// * Create new PDF doc and new page.
// * Create new page contents which include patterns created through lower level programming.
// * Add the contents to page
// * Save the output PDF.
// * Release all objects acquired/created
// * Terminate PDFL
// 
*/

#ifdef MAC_ENV
#include <Carbon/Carbon.h>
#else
#include <sys/types.h>
#include <sys/stat.h>
#endif

#include <stdio.h>
#include <math.h>
#include <string.h>

#include "PDFInit.h"
#include "ASCalls.h"
#include "CosCalls.h"
#include "PDCalls.h"
#include "PEWCalls.h"
#include "PERCalls.h"

#include "MyPDFLibUtils.h"
#include "PatternUtils.h"


// Name of a new PDF file with tiling patterns. It will be saved in the working directory.
const   char *  NewPDF  =  "TestPatterns.pdf" ;

#ifdef MAC_ENV                                                                   
#include "macUtils.h"
#endif

void   MainProc( void );
void   MainProc( void )
{
                PDDoc  newDoc =  NULL;
                PDPage  newPage =  NULL;
                PDEContent  newContent =  NULL;
                ASErrorCode  errCode = 0;
                // main process to create a new PDF with patterns.
                DURING  
               {
               newDoc =  PDDocCreate();
               newPage =  s_CreateNewPage(newDoc);

               newContent =  s_CreateBoxesWithPatterns(newDoc);
                                s_SetContentToPage(newPage, newContent);

                                s_SaveDoc(newDoc,  NewPDF);
               } 
                HANDLER  
               {
                               errCode =  ERRORCODE;
               }
                END_HANDLER  

                if (errCode)
                                DisplayError(errCode);

                if (newContent)    PDERelease((PDEObject)newContent);
                if (newPage)                          PDPageRelease(newPage);
                if (newDoc)                            PDDocClose(newDoc);
}


#define INCLUDE_MYPDFLIBAPP_CPP 1
#include "MyPDFLibApp.cpp"
#undef INCLUDE_MYPDFLIBAPP_CPP