1 /*
    2  * << Haru Free PDF Library >> -- hpdf_doc.h
    3  *
    4  * URL: http://libharu.org
    5  *
    6  * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp>
    7  * Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org>
    8  *
    9  * Permission to use, copy, modify, distribute and sell this software
   10  * and its documentation for any purpose is hereby granted without fee,
   11  * provided that the above copyright notice appear in all copies and
   12  * that both that copyright notice and this permission notice appear
   13  * in supporting documentation.
   14  * It is provided "as is" without express or implied warranty.
   15  *
   16  */
   17 
   18 
   19 #ifndef _HPDF_DOC_H
   20 #define _HPDF_DOC_H
   21 
   22 #define HPDF_SIG_BYTES 0x41504446L
   23 
   24 #include "hpdf_catalog.h"
   25 #include "hpdf_image.h"
   26 #include "hpdf_pages.h"
   27 #include "hpdf_outline.h"
   28 #include "hpdf_ext_gstate.h"
   29 
   30 #ifdef __cplusplus
   31 extern "C" {
   32 #endif
   33 
   34 #define HPDF_VER_DEFAULT  HPDF_VER_12
   35 
   36 typedef struct _HPDF_Doc_Rec {
   37     HPDF_UINT32     sig_bytes;
   38     HPDF_PDFVer     pdf_version;
   39 
   40     HPDF_MMgr         mmgr;
   41     HPDF_Catalog      catalog;
   42     HPDF_Outline      outlines;
   43     HPDF_Xref         xref;
   44     HPDF_Pages        root_pages;
   45     HPDF_Pages        cur_pages;
   46     HPDF_Page         cur_page;
   47     HPDF_List         page_list;
   48     HPDF_Error_Rec    error;
   49     HPDF_Dict         info;
   50     HPDF_Dict         trailer;
   51 
   52     HPDF_List         font_mgr;
   53     HPDF_BYTE         ttfont_tag[6];
   54 
   55     /* list for loaded fontdefs */
   56     HPDF_List         fontdef_list;
   57 
   58     /* list for loaded encodings */
   59     HPDF_List         encoder_list;
   60 
   61     HPDF_Encoder      cur_encoder;
   62 
   63     /* default compression mode */
   64     HPDF_BOOL         compression_mode;
   65 
   66     HPDF_BOOL         encrypt_on;
   67     HPDF_EncryptDict  encrypt_dict;
   68 
   69     HPDF_Encoder      def_encoder;
   70 
   71     HPDF_UINT         page_per_pages;
   72     HPDF_UINT         cur_page_num;
   73 
   74     /* buffer for saving into memory stream */
   75     HPDF_Stream       stream;
   76 } HPDF_Doc_Rec;
   77 
   78 typedef struct _HPDF_Doc_Rec  *HPDF_Doc;
   79 
   80 
   81 HPDF_Encoder
   82 HPDF_Doc_FindEncoder (HPDF_Doc         pdf,
   83                       const char  *encoding_name);
   84 
   85 
   86 HPDF_FontDef
   87 HPDF_Doc_FindFontDef (HPDF_Doc         pdf,
   88                       const char  *font_name);
   89 
   90 
   91 HPDF_Font
   92 HPDF_Doc_FindFont  (HPDF_Doc         pdf,
   93                     const char  *font_name,
   94                     const char  *encoding_name);
   95 
   96 
   97 HPDF_BOOL
   98 HPDF_Doc_Validate  (HPDF_Doc  pdf);
   99 
  100 
  101 /*----- page handling -------------------------------------------------------*/
  102 
  103 HPDF_Pages
  104 HPDF_Doc_GetCurrentPages  (HPDF_Doc  pdf);
  105 
  106 
  107 HPDF_Pages
  108 HPDF_Doc_AddPagesTo  (HPDF_Doc     pdf,
  109                       HPDF_Pages   parent);
  110 
  111 
  112 HPDF_STATUS
  113 HPDF_Doc_SetCurrentPages  (HPDF_Doc    pdf,
  114                            HPDF_Pages  pages);
  115 
  116 
  117 HPDF_STATUS
  118 HPDF_Doc_SetCurrentPage  (HPDF_Doc   pdf,
  119                           HPDF_Page  page);
  120 
  121 
  122 
  123 
  124 /*----- font handling -------------------------------------------------------*/
  125 
  126 HPDF_FontDef
  127 HPDF_GetFontDef (HPDF_Doc         pdf,
  128                  const char  *font_name);
  129 
  130 
  131 HPDF_STATUS
  132 HPDF_Doc_RegisterFontDef  (HPDF_Doc       pdf,
  133                            HPDF_FontDef   fontdef);
  134 
  135 
  136 /*----- encoding handling ---------------------------------------------------*/
  137 
  138 HPDF_STATUS
  139 HPDF_Doc_RegisterEncoder  (HPDF_Doc       pdf,
  140                            HPDF_Encoder   encoder);
  141 
  142 
  143 
  144 /*----- encryptio------------------------------------------------------------*/
  145 
  146 HPDF_STATUS
  147 HPDF_Doc_SetEncryptOn (HPDF_Doc  pdf);
  148 
  149 
  150 HPDF_STATUS
  151 HPDF_Doc_SetEncryptOff (HPDF_Doc  pdf);
  152 
  153 
  154 HPDF_STATUS
  155 HPDF_Doc_PrepareEncryption (HPDF_Doc  pdf);
  156 
  157 #ifdef __cplusplus
  158 }
  159 #endif /* __cplusplus */
  160 
  161 #endif /* _HPDF_DOC_H */
  162