Browse Source

Updated to libharu.f80dfbc

Brucey 2 years ago
parent
commit
a74e3216c5

+ 12 - 0
pdf.mod/common.bmx

@@ -162,6 +162,7 @@ Extern
 	Function HPDF_Page_CreateDestination:Byte Ptr(handle:Byte Ptr)
 	Function HPDF_SetOpenAction:ULongInt(handle:Byte Ptr, action:Byte Ptr)
 	Function HPDF_Page_SetSlideShow:ULongInt(handle:Byte Ptr, style:EPDFTransitionStyle, dispTime:Float, transTime:Float)
+	Function HPDF_Page_SetBoundary:ULongInt(handle:Byte Ptr, boundary:EPDFPageBoundary, left:Float, bottom:Float, right:Float, top:Float)
 
 	Function HPDF_Font_MeasureText:UInt(handle:Byte Ptr, t:Byte Ptr, length:UInt, width:Float, fontSize:Float, charSpace:Float, wordSpace:Float, wordwrap:Int, realWidth:Float Ptr)
 	Function HPDF_Font_GetFontName:Byte Ptr(handle:Byte Ptr)
@@ -578,6 +579,17 @@ Enum EPDFByteType
     TRAIL
 End Enum
 
+Rem
+bbdoc: 
+End Rem
+Enum EPDFPageBoundary
+	MEDIABOX
+    CROPBOX
+    BLEEDBOX
+    TRIMBOX
+    ARTBOX
+End Enum
+
 Rem
 bbdoc: Succeeded.
 End Rem

+ 7 - 0
pdf.mod/libharu/include/hpdf.h

@@ -256,6 +256,13 @@ HPDF_EXPORT(HPDF_STATUS)
 HPDF_Page_SetHeight  (HPDF_Page   page,
                       HPDF_REAL   value);
 
+HPDF_EXPORT(HPDF_STATUS)
+HPDF_Page_SetBoundary  (HPDF_Page           page,
+                        HPDF_PageBoundary   boundary,
+                        HPDF_REAL           left,
+                        HPDF_REAL           bottom,
+                        HPDF_REAL           right,
+                        HPDF_REAL           top);
 
 HPDF_EXPORT(HPDF_STATUS)
 HPDF_Page_SetSize  (HPDF_Page            page,

+ 1 - 1
pdf.mod/libharu/include/hpdf_error.h

@@ -145,7 +145,7 @@ extern "C" {
 #define HPDF_INVALID_U3D_DATA                     0x1083
 #define HPDF_NAME_CANNOT_GET_NAMES                0x1084
 #define HPDF_INVALID_ICC_COMPONENT_NUM            0x1085
-/*                                                0x1086 */
+#define HPDF_PAGE_INVALID_BOUNDARY                0x1086
 /*                                                0x1087 */
 #define HPDF_INVALID_SHADING_TYPE                 0x1088
 

+ 10 - 0
pdf.mod/libharu/include/hpdf_types.h

@@ -583,6 +583,16 @@ typedef enum _HPDF_NameDictKey {
 
 /*----------------------------------------------------------------------------*/
 
+typedef enum _HPDF_PageBoundary {
+    HPDF_PAGE_MEDIABOX = 0,
+    HPDF_PAGE_CROPBOX,
+    HPDF_PAGE_BLEEDBOX,
+    HPDF_PAGE_TRIMBOX,
+    HPDF_PAGE_ARTBOX
+} HPDF_PageBoundary;
+
+/*----------------------------------------------------------------------------*/
+
 typedef enum _HPDF_ShadingType {
   HPDF_SHADING_FREE_FORM_TRIANGLE_MESH = 4 /* TODO the rest */
 } HPDF_ShadingType;

+ 39 - 0
pdf.mod/libharu/src/hpdf_pages.c

@@ -2362,3 +2362,42 @@ HPDF_Page_SetFilter  (HPDF_Page    page,
     attr = (HPDF_PageAttr)page->attr;
     attr->contents->filter = filter;
 }
+
+
+
+HPDF_EXPORT(HPDF_STATUS)
+HPDF_Page_SetBoundary  (HPDF_Page           page,
+                        HPDF_PageBoundary   boundary,
+                        HPDF_REAL           left,
+                        HPDF_REAL           bottom,
+                        HPDF_REAL           right,
+                        HPDF_REAL           top)
+{
+
+    char *key;
+
+    switch(boundary){
+        case HPDF_PAGE_MEDIABOX:
+            key = "MediaBox";
+            break;
+        case HPDF_PAGE_CROPBOX:
+            key = "CropBox";
+            break;
+        case HPDF_PAGE_BLEEDBOX:
+            key = "BleedBox";
+            break;
+        case HPDF_PAGE_TRIMBOX:
+            key = "TrimBox";
+            break;
+        case HPDF_PAGE_ARTBOX:
+            key = "ArtBox";
+            break;
+        default:
+            return HPDF_RaiseError(page->error, HPDF_PAGE_INVALID_BOUNDARY, 0);
+            break;
+    }
+
+    return HPDF_Dict_Add (page, key, HPDF_Box_Array_New (page->mmgr,
+                HPDF_ToBox ((HPDF_INT16)left, (HPDF_INT16)bottom, (HPDF_INT16)right, (HPDF_INT16)top)));
+
+}

+ 11 - 1
pdf.mod/pdf.bmx

@@ -23,13 +23,16 @@ bbdoc: A PDF encoder.
 End Rem
 Module Text.PDF
 
-ModuleInfo "Version: 1.00"
+ModuleInfo "Version: 1.01"
 ModuleInfo "Author: Bruce A Henderson"
 ModuleInfo "License: zlib/libpng"
 ModuleInfo "libharu - Copyright (c) 1999-2006 Takeshi Kanno"
 ModuleInfo "libharu - Copyright (c) 2007-2009 Antony Dovgal"
+ModuleInfo "libharu - https://github.com/woollybah/libharu"
 ModuleInfo "Copyright: 2023 Bruce A Henderson"
 
+ModuleInfo "History: 1.01"
+ModuleInfo "History: Update to libharu.f80dfbc"
 ModuleInfo "History: 1.00"
 ModuleInfo "History: Initial Release"
 
@@ -1429,6 +1432,13 @@ The parameters that are saved by #GSave are:
 		Return HPDF_Page_SetSlideShow(pagePtr, style, dispTime, transTime)
 	End Method
 
+	Rem
+	bbdoc: Sets the size of the given page @boundary.
+	End Rem
+	Method SetBoundary:Int(boundary:EPDFPageBoundary, left:Float, bottom:Float, right:Float, top:Float)
+		Return HPDF_Page_SetBoundary(pagePtr, boundary, left, bottom, right, top)
+	End Method
+
 End Type
 
 Rem