const char * pdf__utf32_to_utf16(PDF *p, const char *utf32string, int len, const char *ordering, int *outlen) { char *utf16string = pdc_utf32_to_utf16(p->pdc, utf32string, len, ordering, 0, outlen); pdf_insert_utilstring(p, utf16string, pdc_false); return utf16string; }
const char * pdf__utf16_to_utf8(PDF *p, const char *utf16string, int len, int *size) { char *utf8string; int convflags = PDC_CONV_WITHBOM | PDC_CONV_EBCDIC | PDC_CONV_TRY7BYTES; pdf_set_convertflags(p, &convflags); utf8string = pdc_utf16_to_utf8(p->pdc, utf16string, len, convflags, size); pdf_insert_utilstring(p, utf8string, pdc_false); return utf8string; }
const char * pdf__utf8_to_utf16(PDF *p, const char *utf8string, const char *ordering, int *outlen) { char *utf16string; int convflags = PDC_CONV_EBCDIC; pdf_set_convertflags(p, &convflags); utf16string = pdc_utf8_to_utf16(p->pdc, utf8string, ordering, convflags, outlen); pdf_insert_utilstring(p, utf16string, pdc_false); return utf16string; }
double pdf__info_matchbox(PDF *p, const char *boxname, int len, int num, const char *keyword) { pdf_mbox *mbox; double mbinfo = 0; int infokey, count; if (boxname == NULL) pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "boxname", 0, 0, 0); if (keyword == NULL || *keyword == '0') pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "keyword", 0, 0, 0); /* Converting boxname */ boxname = pdf_convert_name(p, boxname, len, PDC_CONV_TMPALLOC); if (boxname == NULL || *boxname == '\0') pdc_error(p->pdc, PDC_E_ILLARG_EMPTY, "boxname", 0, 0, 0); infokey = pdc_get_keycode_ci(keyword, pdf_info_keylist); if (infokey == PDC_KEY_NOTFOUND) pdc_error(p->pdc, PDC_E_ILLARG_STRING, "keyword", keyword, 0, 0); if (!strcmp(boxname, "*")) boxname = NULL; /* count */ if (!infokey) { pdf_get_mbox(p, NULL, boxname, -1, &count); mbinfo = (double) count; } else { if (num < 1) pdc_error(p->pdc, PDC_E_ILLARG_INT, "num", pdc_errprintf(p->pdc, "%d", num), 0, 0); mbox = pdf_get_mbox(p, NULL, boxname, num, NULL); if (mbox != NULL) { pdc_vector polyline[5]; if (infokey > 1) pdf_get_mbox_rectangle(p, mbox, polyline); switch (infokey) { /* exists */ case 1: mbinfo = 1; break; /* name */ case 2: mbinfo = (double) pdf_insert_utilstring(p, mbox->name, pdc_true); break; /* geometrical keys */ case 3: mbinfo = pdc_get_vector_length(&polyline[0], &polyline[1]); break; case 4: mbinfo = pdc_get_vector_length(&polyline[0], &polyline[3]); break; case 5: mbinfo = polyline[0].x; break; case 6: mbinfo = polyline[0].y; break; case 7: mbinfo = polyline[1].x; break; case 8: mbinfo = polyline[1].y; break; case 9: mbinfo = polyline[2].x; break; case 10: mbinfo = polyline[2].y; break; case 11: mbinfo = polyline[3].x; break; case 12: mbinfo = polyline[3].y; break; } } else if (infokey == 2) { mbinfo = -1; } } return mbinfo; }