Ejemplo n.º 1
0
HPDF_Page_CreateLinkAnnot  (HPDF_Page          page,
                            HPDF_Rect          rect,
                            HPDF_Destination   dst)
{
    HPDF_PageAttr attr;
    HPDF_Annotation annot;

    HPDF_PTRACE((" HPDF_Page_CreateLinkAnnot\n"));

    if (!HPDF_Page_Validate (page))
        return NULL;

    attr = (HPDF_PageAttr)page->attr;

    if (!HPDF_Destination_Validate (dst)) {
        HPDF_RaiseError (page->error, HPDF_INVALID_DESTINATION, 0);
        return NULL;
    }

    annot = HPDF_LinkAnnot_New (page->mmgr, attr->xref, rect, dst);
    if (annot) {
        if (AddAnnotation (page, annot) != HPDF_OK) {
            HPDF_CheckError (page->error);
            annot = NULL;
        }
    } else
        HPDF_CheckError (page->error);

    return annot;
}
Ejemplo n.º 2
0
HPDF_Destination_SetFitBV  (HPDF_Destination  dst,
                            HPDF_REAL         left)
{
    HPDF_STATUS ret = HPDF_OK;
    HPDF_Page target;

    HPDF_PTRACE((" HPDF_Destination_SetFitBV\n"));

    if (!HPDF_Destination_Validate (dst))
        return HPDF_INVALID_DESTINATION;

    target = (HPDF_Page)HPDF_Array_GetItem (dst, 0, HPDF_OCLASS_DICT);

    if (dst->list->count > 1) {
        HPDF_Array_Clear (dst);
        ret += HPDF_Array_Add (dst, target);
    }

    ret += HPDF_Array_AddName (dst,
                HPDF_DESTINATION_TYPE_NAMES[(HPDF_INT)HPDF_FIT_BV]);
    ret += HPDF_Array_AddReal (dst, left);

    if (ret != HPDF_OK)
        return HPDF_CheckError (dst->error);

    return HPDF_OK;

}
Ejemplo n.º 3
0
HPDF_Destination_SetXYZ  (HPDF_Destination  dst,
                          HPDF_REAL         left,
                          HPDF_REAL         top,
                          HPDF_REAL         zoom)
{
    HPDF_STATUS ret = HPDF_OK;
    HPDF_Page target;

    HPDF_PTRACE((" HPDF_Destination_SetXYZ\n"));

    if (!HPDF_Destination_Validate (dst))
        return HPDF_INVALID_DESTINATION;

    if (left < 0 || top < 0 || zoom < 0.08 || zoom > 32)
        return HPDF_RaiseError (dst->error, HPDF_INVALID_PARAMETER, 0);


    target = (HPDF_Page)HPDF_Array_GetItem (dst, 0, HPDF_OCLASS_DICT);

    if (dst->list->count > 1) {
        HPDF_Array_Clear (dst);
        ret += HPDF_Array_Add (dst, target);
    }

    ret += HPDF_Array_AddName (dst,
                HPDF_DESTINATION_TYPE_NAMES[(HPDF_INT)HPDF_XYZ]);
    ret += HPDF_Array_AddReal (dst, left);
    ret += HPDF_Array_AddReal (dst, top);
    ret += HPDF_Array_AddReal (dst, zoom);

    if (ret != HPDF_OK)
        return HPDF_CheckError (dst->error);

    return HPDF_OK;
}
Ejemplo n.º 4
0
HPDF_SetOpenAction  (HPDF_Doc            pdf,
                     HPDF_Destination    open_action)
{
    HPDF_STATUS ret;

    HPDF_PTRACE ((" HPDF_SetOpenAction\n"));

    if (!HPDF_HasDoc (pdf))
        return HPDF_INVALID_DOCUMENT;

    if (open_action && !HPDF_Destination_Validate (open_action))
        return HPDF_RaiseError (&pdf->error, HPDF_INVALID_DESTINATION, 0);

    ret = HPDF_Catalog_SetOpenAction (pdf->catalog, open_action);
    if (ret != HPDF_OK)
        return HPDF_CheckError (&pdf->error);

    return HPDF_OK;
}