/* * Class: org_libharu_PdfDocument * Method: create * Signature: (I)Z */ JNIEXPORT jboolean JNICALL Java_org_libharu_PdfDocument_create__I(JNIEnv *env, jclass cls, jint pdf) { HPDF_STATUS status; status = HPDF_NewDoc((HPDF_Doc) pdf); if (status != HPDF_OK) { return JNI_FALSE; } return JNI_TRUE; }
HPDF_NewEx (HPDF_Error_Handler user_error_fn, HPDF_Alloc_Func user_alloc_fn, HPDF_Free_Func user_free_fn, HPDF_UINT mem_pool_buf_size, void *user_data) { HPDF_Doc pdf; HPDF_MMgr mmgr; HPDF_Error_Rec tmp_error; HPDF_PTRACE ((" HPDF_NewEx\n")); /* initialize temporary-error object */ HPDF_Error_Init (&tmp_error, user_data); /* create memory-manager object */ mmgr = HPDF_MMgr_New (&tmp_error, mem_pool_buf_size, user_alloc_fn, user_free_fn); if (!mmgr) { HPDF_CheckError (&tmp_error); return NULL; } /* now create pdf_doc object */ pdf = HPDF_GetMem (mmgr, sizeof (HPDF_Doc_Rec)); if (!pdf) { HPDF_MMgr_Free (mmgr); HPDF_CheckError (&tmp_error); return NULL; } HPDF_MemSet (pdf, 0, sizeof (HPDF_Doc_Rec)); pdf->sig_bytes = HPDF_SIG_BYTES; pdf->mmgr = mmgr; pdf->pdf_version = HPDF_VER_13; pdf->compression_mode = HPDF_COMP_NONE; /* copy the data of temporary-error object to the one which is included in pdf_doc object */ pdf->error = tmp_error; /* switch the error-object of memory-manager */ mmgr->error = &pdf->error; if (HPDF_NewDoc (pdf) != HPDF_OK) { HPDF_Free (pdf); HPDF_CheckError (&tmp_error); return NULL; } pdf->error.error_fn = user_error_fn; return pdf; }