2014-02-03 18:11 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/hbct/dattime2.c
! fixed potential GPF trap due to wrong protection condition
and change internal variable name (synced with Viktor's branch)
* src/vm/classes.c
! fixed typo in alternative code - thanks to Lorenzo for the info
* contrib/hbhpdf/3rd/libhpdf/*
* updated HARUPDF library 2.3.0RC2 -> 2.3.0RC3
(the same version is used in Viktor's branch)
This commit is contained in:
@@ -10,6 +10,18 @@
|
||||
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
|
||||
*/
|
||||
|
||||
2014-02-03 18:11 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* contrib/hbct/dattime2.c
|
||||
! fixed potential GPF trap due to wrong protection condition
|
||||
and change internal variable name (synced with Viktor's branch)
|
||||
|
||||
* src/vm/classes.c
|
||||
! fixed typo in alternative code - thanks to Lorenzo for the info
|
||||
|
||||
* contrib/hbhpdf/3rd/libhpdf/*
|
||||
* updated HARUPDF library 2.3.0RC2 -> 2.3.0RC3
|
||||
(the same version is used in Viktor's branch)
|
||||
|
||||
2014-02-03 09:59 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* ChangeLog.txt
|
||||
* updated previous ChangeLog entry to mark group of files.
|
||||
|
||||
@@ -83,10 +83,10 @@ static int ct_daysinmonth( int iMonth, HB_BOOL bLeap )
|
||||
|
||||
static int ct_daystomonth( int iMonth, HB_BOOL bLeap )
|
||||
{
|
||||
static const int sc_iMonthes[] = {
|
||||
static const int sc_iMonths[] = {
|
||||
0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
|
||||
|
||||
return ( iMonth < 1 && iMonth > 12 ) ? 0 : sc_iMonthes[ iMonth - 1 ] +
|
||||
return ( iMonth < 1 || iMonth > 12 ) ? 0 : sc_iMonths[ iMonth - 1 ] +
|
||||
( ( bLeap && iMonth > 2 ) ? 1 : 0 );
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
#include "hbapi.h"
|
||||
|
||||
#if defined( HB_OS_WIN_CE )
|
||||
|
||||
@@ -765,6 +765,11 @@ HPDF_EXPORT(HPDF_Image)
|
||||
HPDF_LoadU3DFromFile (HPDF_Doc pdf,
|
||||
const char *filename);
|
||||
|
||||
HPDF_EXPORT(HPDF_Image)
|
||||
HPDF_LoadU3DFromMem (HPDF_Doc pdf,
|
||||
const HPDF_BYTE *buffer,
|
||||
HPDF_UINT size);
|
||||
|
||||
HPDF_EXPORT(HPDF_Image)
|
||||
HPDF_Image_LoadRaw1BitImageFromMem (HPDF_Doc pdf,
|
||||
const HPDF_BYTE *buf,
|
||||
@@ -1460,6 +1465,17 @@ HPDF_EXPORT(HPDF_STATUS)
|
||||
HPDF_Page_ExecuteXObject (HPDF_Page page,
|
||||
HPDF_XObject obj);
|
||||
|
||||
/*--- Content streams ----------------------------------------------------*/
|
||||
|
||||
HPDF_EXPORT(HPDF_STATUS)
|
||||
HPDF_Page_New_Content_Stream (HPDF_Page page,
|
||||
HPDF_Dict* new_stream);
|
||||
|
||||
HPDF_EXPORT(HPDF_STATUS)
|
||||
HPDF_Page_Insert_Shared_Content_Stream (HPDF_Page page,
|
||||
HPDF_Dict shared_stream);
|
||||
|
||||
|
||||
/*--- Marked content -----------------------------------------------------*/
|
||||
|
||||
/* BMC --not implemented yet */
|
||||
|
||||
@@ -115,7 +115,7 @@
|
||||
#define HPDF_LIMIT_MAX_STRING_LEN 65535
|
||||
#define HPDF_LIMIT_MAX_NAME_LEN 127
|
||||
|
||||
#define HPDF_LIMIT_MAX_ARRAY 8191
|
||||
#define HPDF_LIMIT_MAX_ARRAY 32767
|
||||
#define HPDF_LIMIT_MAX_DICT_ELEMENT 4095
|
||||
#define HPDF_LIMIT_MAX_XREF_ELEMENT 8388607
|
||||
#define HPDF_LIMIT_MAX_GSTATE 28
|
||||
@@ -142,7 +142,7 @@
|
||||
#define HPDF_MAX_WORDSPACE 300
|
||||
#define HPDF_MIN_CHARSPACE -30
|
||||
#define HPDF_MAX_CHARSPACE 300
|
||||
#define HPDF_MAX_FONTSIZE 300
|
||||
#define HPDF_MAX_FONTSIZE 600
|
||||
#define HPDF_MAX_ZOOMSIZE 10
|
||||
#define HPDF_MAX_LEADING 300
|
||||
#define HPDF_MAX_LINEWIDTH 100
|
||||
|
||||
@@ -1528,8 +1528,7 @@ LoadTTFontFromStream (HPDF_Doc pdf,
|
||||
HPDF_FontDef tmpdef = HPDF_Doc_FindFontDef (pdf, def->base_font);
|
||||
if (tmpdef) {
|
||||
HPDF_FontDef_Free (def);
|
||||
HPDF_SetError (&pdf->error, HPDF_FONT_EXISTS, 0);
|
||||
return NULL;
|
||||
return tmpdef->base_font;
|
||||
}
|
||||
|
||||
if (HPDF_List_Add (pdf->fontdef_list, def) != HPDF_OK) {
|
||||
@@ -1607,8 +1606,7 @@ LoadTTFontFromStream2 (HPDF_Doc pdf,
|
||||
HPDF_FontDef tmpdef = HPDF_Doc_FindFontDef (pdf, def->base_font);
|
||||
if (tmpdef) {
|
||||
HPDF_FontDef_Free (def);
|
||||
HPDF_SetError (&pdf->error, HPDF_FONT_EXISTS, 0);
|
||||
return NULL;
|
||||
return tmpdef->base_font;
|
||||
}
|
||||
|
||||
if (HPDF_List_Add (pdf->fontdef_list, def) != HPDF_OK) {
|
||||
|
||||
@@ -1097,7 +1097,7 @@ static const HPDF_UNICODE HPDF_UNICODE_MAP_STANDARD[] = {
|
||||
0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x00D1, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
@@ -1132,9 +1132,9 @@ static const HPDF_UNICODE HPDF_UNICODE_MAP_WIN_ANSI[] = {
|
||||
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x017D, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x0000, 0x017E, 0x0178,
|
||||
0x0000, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x0000, 0x00AE, 0x00AF,
|
||||
0x02DA, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
||||
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
|
||||
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
|
||||
@@ -1159,21 +1159,21 @@ static const HPDF_UNICODE HPDF_UNICODE_MAP_MAC_ROMAN[] = {
|
||||
0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
|
||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
||||
0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x0000,
|
||||
0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x0000, 0x00D6, 0x00DC, 0x00E1,
|
||||
0x00C4, 0x00C5, 0x00C7, 0x00C9, 0x00D1, 0x00D6, 0x00DC, 0x00E1,
|
||||
0x00E0, 0x00E2, 0x00E4, 0x00E3, 0x00E5, 0x00E7, 0x00E9, 0x00E8,
|
||||
0x00EA, 0x00EB, 0x00ED, 0x00EC, 0x00EE, 0x00EF, 0x00F1, 0x00F3,
|
||||
0x00F2, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x00F9, 0x00FB, 0x00FC,
|
||||
0x2020, 0x00B0, 0x00A2, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
|
||||
0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x0000, 0x00C6, 0x00D8,
|
||||
0x0000, 0x00B1, 0x0000, 0x0000, 0x00A5, 0x00B5, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0x0000, 0x00AA, 0x00BA, 0x0000, 0x00E6, 0x00F8,
|
||||
0x00BF, 0x00A1, 0x00AC, 0x0000, 0x0192, 0x0000, 0x0000, 0x00AB,
|
||||
0x00BB, 0x2026, 0x0020, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153,
|
||||
0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x0000,
|
||||
0x00FF, 0x0178, 0x2044, 0x00A4, 0x2039, 0x203A, 0xFB01, 0xFB02,
|
||||
0x00AE, 0x00A9, 0x2122, 0x00B4, 0x00A8, 0x2260, 0x00C6, 0x00D8,
|
||||
0x221E, 0x00B1, 0x2264, 0x2265, 0x00A5, 0x00B5, 0x2202, 0x2211,
|
||||
0x220F, 0x03C0, 0x222B, 0x00AA, 0x00BA, 0x03A9, 0x00E6, 0x00F8,
|
||||
0x00BF, 0x00A1, 0x00AC, 0x221A, 0x0192, 0x2248, 0x2206, 0x00AB,
|
||||
0x00BB, 0x2026, 0x00A0, 0x00C0, 0x00C3, 0x00D5, 0x0152, 0x0153,
|
||||
0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
|
||||
0x00FF, 0x0178, 0x2044, 0x20AC, 0x2039, 0x203A, 0xFB01, 0xFB02,
|
||||
0x2021, 0x00B7, 0x201A, 0x201E, 0x2030, 0x00C2, 0x00CA, 0x00C1,
|
||||
0x00CB, 0x00C8, 0x00CD, 0x00CE, 0x00CF, 0x00CC, 0x00D3, 0x00D4,
|
||||
0x0000, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC,
|
||||
0xF8FF, 0x00D2, 0x00DA, 0x00DB, 0x00D9, 0x0131, 0x02C6, 0x02DC,
|
||||
0x00AF, 0x02D8, 0x02D9, 0x02DA, 0x00B8, 0x02DD, 0x02DB, 0x02C7
|
||||
};
|
||||
|
||||
@@ -2235,6 +2235,7 @@ HPDF_BasicEncoder_New (HPDF_MMgr mmgr,
|
||||
encoder->error = mmgr->error;
|
||||
encoder->type = HPDF_ENCODER_TYPE_SINGLE_BYTE;
|
||||
encoder->to_unicode_fn = HPDF_BasicEncoder_ToUnicode;
|
||||
encoder->encode_text_fn = NULL;
|
||||
encoder->write_fn = HPDF_BasicEncoder_Write;
|
||||
encoder->free_fn = HPDF_BasicEncoder_Free;
|
||||
|
||||
@@ -2520,7 +2521,7 @@ HPDF_Encoder_Validate (HPDF_Encoder encoder)
|
||||
|
||||
HPDF_Encoder
|
||||
HPDF_CMapEncoder_New (HPDF_MMgr mmgr,
|
||||
char *name,
|
||||
char *name,
|
||||
HPDF_Encoder_Init_Func init_fn)
|
||||
{
|
||||
HPDF_Encoder encoder;
|
||||
@@ -2625,7 +2626,6 @@ HPDF_CMapEncoder_ToCID (HPDF_Encoder encoder,
|
||||
return attr->cid_map[l][h];
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HPDF_CMapEncoder_Free (HPDF_Encoder encoder)
|
||||
{
|
||||
@@ -2751,20 +2751,26 @@ HPDF_CMapEncoder_AddCMap (HPDF_Encoder encoder,
|
||||
HPDF_PTRACE ((" HPDF_CMapEncoder_AddCMap\n"));
|
||||
|
||||
/* Copy specified pdf_cid_range array to fRangeArray. */
|
||||
while (range->from != 0xffff && range->to != 0xffff) {
|
||||
HPDF_UINT16 code = range->from;
|
||||
HPDF_UINT16 cid = range->cid;
|
||||
HPDF_CidRange_Rec *prange;
|
||||
HPDF_STATUS ret;
|
||||
while (range->from != 0xffff || range->to != 0xffff) {
|
||||
HPDF_CidRange_Rec *prange;
|
||||
HPDF_STATUS ret;
|
||||
|
||||
while (code <= range->to) {
|
||||
HPDF_BYTE l = (HPDF_BYTE)code;
|
||||
HPDF_BYTE h = (HPDF_BYTE)(code >> 8);
|
||||
/*
|
||||
* Only if we have the default to_unicode_fn
|
||||
*/
|
||||
if (encoder->to_unicode_fn == HPDF_CMapEncoder_ToUnicode) {
|
||||
HPDF_UINT16 code = range->from;
|
||||
HPDF_UINT16 cid = range->cid;
|
||||
|
||||
attr->cid_map[l][h] = cid;
|
||||
code++;
|
||||
cid++;
|
||||
}
|
||||
while (code <= range->to) {
|
||||
HPDF_BYTE l = code;
|
||||
HPDF_BYTE h = code >> 8;
|
||||
|
||||
attr->cid_map[l][h] = cid;
|
||||
code++;
|
||||
cid++;
|
||||
}
|
||||
}
|
||||
|
||||
prange = HPDF_GetMem (encoder->mmgr, sizeof(HPDF_CidRange_Rec));
|
||||
if (!prange)
|
||||
@@ -2994,4 +3000,3 @@ HPDF_Encoder_GetWritingMode (HPDF_Encoder encoder)
|
||||
|
||||
return HPDF_WMODE_HORIZONTAL;
|
||||
}
|
||||
|
||||
|
||||
@@ -93,6 +93,11 @@ typedef HPDF_UNICODE
|
||||
(*HPDF_Encoder_ToUnicode_Func) (HPDF_Encoder encoder,
|
||||
HPDF_UINT16 code);
|
||||
|
||||
typedef char *
|
||||
(*HPDF_Encoder_EncodeText_Func) (HPDF_Encoder encoder,
|
||||
const char *text,
|
||||
HPDF_UINT len,
|
||||
HPDF_UINT *encoded_length);
|
||||
|
||||
typedef HPDF_STATUS
|
||||
(*HPDF_Encoder_Write_Func) (HPDF_Encoder encoder,
|
||||
@@ -109,13 +114,14 @@ typedef void
|
||||
|
||||
typedef struct _HPDF_Encoder_Rec {
|
||||
HPDF_UINT32 sig_bytes;
|
||||
char name[HPDF_LIMIT_MAX_NAME_LEN + 1];
|
||||
char name[HPDF_LIMIT_MAX_NAME_LEN + 1];
|
||||
HPDF_MMgr mmgr;
|
||||
HPDF_Error error;
|
||||
HPDF_EncoderType type;
|
||||
|
||||
HPDF_Encoder_ByteType_Func byte_type_fn;
|
||||
HPDF_Encoder_ToUnicode_Func to_unicode_fn;
|
||||
HPDF_Encoder_EncodeText_Func encode_text_fn;
|
||||
HPDF_Encoder_Write_Func write_fn;
|
||||
HPDF_Encoder_Free_Func free_fn;
|
||||
HPDF_Encoder_Init_Func init_fn;
|
||||
@@ -231,7 +237,7 @@ typedef struct _HPDF_CMapEncoderAttr_Rec {
|
||||
|
||||
HPDF_Encoder
|
||||
HPDF_CMapEncoder_New (HPDF_MMgr mmgr,
|
||||
char *name,
|
||||
char *name,
|
||||
HPDF_Encoder_Init_Func init_fn);
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
74
contrib/hbhpdf/3rd/libhpdf/hpdffdfj.c
Normal file → Executable file
74
contrib/hbhpdf/3rd/libhpdf/hpdffdfj.c
Normal file → Executable file
@@ -780,7 +780,7 @@ static const HPDF_CID_Width MS_PGothic_W_ARRAY[] = {
|
||||
};
|
||||
|
||||
|
||||
static const HPDF_CID_Width MS_Mincyo_W_ARRAY[] = {
|
||||
static const HPDF_CID_Width MS_Mincho_W_ARRAY[] = {
|
||||
{1, 500},
|
||||
{2, 500},
|
||||
{3, 500},
|
||||
@@ -1039,7 +1039,7 @@ static const HPDF_CID_Width MS_Mincyo_W_ARRAY[] = {
|
||||
|
||||
|
||||
|
||||
static const HPDF_CID_Width MS_PMincyo_W_ARRAY[] = {
|
||||
static const HPDF_CID_Width MS_PMincho_W_ARRAY[] = {
|
||||
{1, 304},
|
||||
{2, 304},
|
||||
{3, 460},
|
||||
@@ -1545,7 +1545,7 @@ static const HPDF_CID_Width MS_PMincyo_W_ARRAY[] = {
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/*----- Mincyo Font ---------------------------------------------------------*/
|
||||
/*----- Mincho Font ---------------------------------------------------------*/
|
||||
|
||||
|
||||
static HPDF_STATUS
|
||||
@@ -1671,11 +1671,11 @@ MS_PGothic_BoldItalic_Init (HPDF_FontDef fontdef)
|
||||
|
||||
|
||||
static HPDF_STATUS
|
||||
MS_Mincyo_Init (HPDF_FontDef fontdef)
|
||||
MS_Mincho_Init (HPDF_FontDef fontdef)
|
||||
{
|
||||
HPDF_STATUS ret;
|
||||
|
||||
HPDF_PTRACE ((" HPDF_FontDef_MS_Mincyo_Init\n"));
|
||||
HPDF_PTRACE ((" HPDF_FontDef_MS_Mincho_Init\n"));
|
||||
|
||||
fontdef->ascent = 859;
|
||||
fontdef->descent = -140;
|
||||
@@ -1698,9 +1698,9 @@ MS_Mincyo_Init (HPDF_FontDef fontdef)
|
||||
|
||||
|
||||
static HPDF_STATUS
|
||||
MS_Mincyo_Bold_Init (HPDF_FontDef fontdef)
|
||||
MS_Mincho_Bold_Init (HPDF_FontDef fontdef)
|
||||
{
|
||||
HPDF_STATUS ret = MS_Mincyo_Init (fontdef);
|
||||
HPDF_STATUS ret = MS_Mincho_Init (fontdef);
|
||||
|
||||
if (ret != HPDF_OK)
|
||||
return ret;
|
||||
@@ -1710,9 +1710,9 @@ MS_Mincyo_Bold_Init (HPDF_FontDef fontdef)
|
||||
|
||||
|
||||
static HPDF_STATUS
|
||||
MS_Mincyo_Italic_Init (HPDF_FontDef fontdef)
|
||||
MS_Mincho_Italic_Init (HPDF_FontDef fontdef)
|
||||
{
|
||||
HPDF_STATUS ret = MS_Mincyo_Init (fontdef);
|
||||
HPDF_STATUS ret = MS_Mincho_Init (fontdef);
|
||||
|
||||
if (ret != HPDF_OK)
|
||||
return ret;
|
||||
@@ -1721,9 +1721,9 @@ MS_Mincyo_Italic_Init (HPDF_FontDef fontdef)
|
||||
}
|
||||
|
||||
static HPDF_STATUS
|
||||
MS_Mincyo_BoldItalic_Init (HPDF_FontDef fontdef)
|
||||
MS_Mincho_BoldItalic_Init (HPDF_FontDef fontdef)
|
||||
{
|
||||
HPDF_STATUS ret = MS_Mincyo_Init (fontdef);
|
||||
HPDF_STATUS ret = MS_Mincho_Init (fontdef);
|
||||
|
||||
if (ret != HPDF_OK)
|
||||
return ret;
|
||||
@@ -1733,11 +1733,11 @@ MS_Mincyo_BoldItalic_Init (HPDF_FontDef fontdef)
|
||||
|
||||
|
||||
static HPDF_STATUS
|
||||
MS_PMincyo_Init (HPDF_FontDef fontdef)
|
||||
MS_PMincho_Init (HPDF_FontDef fontdef)
|
||||
{
|
||||
HPDF_STATUS ret;
|
||||
|
||||
HPDF_PTRACE ((" HPDF_FontDef_MS_PMincyo_Init\n"));
|
||||
HPDF_PTRACE ((" HPDF_FontDef_MS_PMincho_Init\n"));
|
||||
|
||||
fontdef->ascent = 859;
|
||||
fontdef->descent = -140;
|
||||
@@ -1759,9 +1759,9 @@ MS_PMincyo_Init (HPDF_FontDef fontdef)
|
||||
|
||||
|
||||
static HPDF_STATUS
|
||||
MS_PMincyo_Bold_Init (HPDF_FontDef fontdef)
|
||||
MS_PMincho_Bold_Init (HPDF_FontDef fontdef)
|
||||
{
|
||||
HPDF_STATUS ret = MS_PMincyo_Init (fontdef);
|
||||
HPDF_STATUS ret = MS_PMincho_Init (fontdef);
|
||||
|
||||
if (ret != HPDF_OK)
|
||||
return ret;
|
||||
@@ -1771,9 +1771,9 @@ MS_PMincyo_Bold_Init (HPDF_FontDef fontdef)
|
||||
|
||||
|
||||
static HPDF_STATUS
|
||||
MS_PMincyo_Italic_Init (HPDF_FontDef fontdef)
|
||||
MS_PMincho_Italic_Init (HPDF_FontDef fontdef)
|
||||
{
|
||||
HPDF_STATUS ret = MS_PMincyo_Init (fontdef);
|
||||
HPDF_STATUS ret = MS_PMincho_Init (fontdef);
|
||||
|
||||
if (ret != HPDF_OK)
|
||||
return ret;
|
||||
@@ -1782,9 +1782,9 @@ MS_PMincyo_Italic_Init (HPDF_FontDef fontdef)
|
||||
}
|
||||
|
||||
static HPDF_STATUS
|
||||
MS_PMincyo_BoldItalic_Init (HPDF_FontDef fontdef)
|
||||
MS_PMincho_BoldItalic_Init (HPDF_FontDef fontdef)
|
||||
{
|
||||
HPDF_STATUS ret = MS_PMincyo_Init (fontdef);
|
||||
HPDF_STATUS ret = MS_PMincho_Init (fontdef);
|
||||
|
||||
if (ret != HPDF_OK)
|
||||
return ret;
|
||||
@@ -1852,52 +1852,52 @@ HPDF_UseJPFonts (HPDF_Doc pdf)
|
||||
if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
/* MS-Mincyo */
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Mincyo",
|
||||
MS_Mincyo_Init);
|
||||
/* MS-Mincho */
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Mincho",
|
||||
MS_Mincho_Init);
|
||||
|
||||
if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Mincyo,Bold",
|
||||
MS_Mincyo_Bold_Init);
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Mincho,Bold",
|
||||
MS_Mincho_Bold_Init);
|
||||
|
||||
if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Mincyo,Italic",
|
||||
MS_Mincyo_Italic_Init);
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Mincho,Italic",
|
||||
MS_Mincho_Italic_Init);
|
||||
|
||||
if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Mincyo,BoldItalic",
|
||||
MS_Mincyo_BoldItalic_Init);
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-Mincho,BoldItalic",
|
||||
MS_Mincho_BoldItalic_Init);
|
||||
|
||||
if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
/* MS-PMincyo */
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PMincyo",
|
||||
MS_PMincyo_Init);
|
||||
/* MS-PMincho */
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PMincho",
|
||||
MS_PMincho_Init);
|
||||
|
||||
if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PMincyo,Bold",
|
||||
MS_PMincyo_Bold_Init);
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PMincho,Bold",
|
||||
MS_PMincho_Bold_Init);
|
||||
|
||||
if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PMincyo,Italic",
|
||||
MS_PMincyo_Italic_Init);
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PMincho,Italic",
|
||||
MS_PMincho_Italic_Init);
|
||||
|
||||
if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PMincyo,BoldItalic",
|
||||
MS_PMincyo_BoldItalic_Init);
|
||||
fontdef = HPDF_CIDFontDef_New (pdf->mmgr, "MS-PMincho,BoldItalic",
|
||||
MS_PMincho_BoldItalic_Init);
|
||||
|
||||
if ((ret = HPDF_Doc_RegisterFontDef (pdf, fontdef)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
@@ -1678,6 +1678,7 @@ ParseOS2 (HPDF_FontDef fontdef)
|
||||
HPDF_TTFontDefAttr attr = (HPDF_TTFontDefAttr)fontdef->attr;
|
||||
HPDF_TTFTable *tbl = FindTable (fontdef, "OS/2");
|
||||
HPDF_STATUS ret;
|
||||
HPDF_UINT16 version;
|
||||
HPDF_UINT len;
|
||||
|
||||
HPDF_PTRACE ((" ParseOS2\n"));
|
||||
@@ -1685,11 +1686,19 @@ ParseOS2 (HPDF_FontDef fontdef)
|
||||
if (!tbl)
|
||||
return HPDF_SetError (fontdef->error, HPDF_TTF_MISSING_TABLE, 0);
|
||||
|
||||
/* get the number version. */
|
||||
ret = HPDF_Stream_Seek (attr->stream, tbl->offset, HPDF_SEEK_SET);
|
||||
if (ret != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
if ((ret = GetUINT16 (attr->stream, &version)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
/* check whether the font is allowed to be embedded. */
|
||||
ret = HPDF_Stream_Seek (attr->stream, tbl->offset + 8, HPDF_SEEK_SET);
|
||||
if (ret != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
/* check whether the font is allowed to be embedded. */
|
||||
if ((ret = GetUINT16 (attr->stream, &attr->fs_type)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
@@ -1697,32 +1706,59 @@ ParseOS2 (HPDF_FontDef fontdef)
|
||||
return HPDF_SetError (fontdef->error, HPDF_TTF_CANNOT_EMBEDDING_FONT,
|
||||
0);
|
||||
|
||||
if ((ret = HPDF_Stream_Seek (attr->stream, tbl->offset + 20, HPDF_SEEK_SET))
|
||||
/* get fields sfamilyclass and panose. */
|
||||
if ((ret = HPDF_Stream_Seek (attr->stream, tbl->offset + 30, HPDF_SEEK_SET))
|
||||
!= HPDF_OK)
|
||||
return ret;
|
||||
|
||||
len = 12;
|
||||
len = 2;
|
||||
if ((ret = HPDF_Stream_Read (attr->stream, attr->sfamilyclass, &len)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
len = 10;
|
||||
if ((ret = HPDF_Stream_Read (attr->stream, attr->panose, &len)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
HPDF_PTRACE((" ParseOS2 PANOSE=%u-%u "
|
||||
"%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X\n",
|
||||
HPDF_PTRACE((" ParseOS2 sFamilyClass=%d-%d "
|
||||
"Panose=%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X\n",
|
||||
attr->sfamilyclass[0], attr->sfamilyclass[1],
|
||||
attr->panose[0], attr->panose[1], attr->panose[2], attr->panose[3],
|
||||
attr->panose[4], attr->panose[5], attr->panose[6], attr->panose[7],
|
||||
attr->panose[8], attr->panose[9], attr->panose[10], attr->panose[11]));
|
||||
attr->panose[8], attr->panose[9]));
|
||||
|
||||
if (attr->panose[0] == 1 || attr->panose[0] == 4)
|
||||
/* Class ID = 1 Oldstyle Serifs
|
||||
Class ID = 2 Transitional Serifs
|
||||
Class ID = 3 Modern Serifs
|
||||
Class ID = 4 Clarendon Serifs
|
||||
Class ID = 5 Slab Serifs
|
||||
Class ID = 6 (reserved for future use)
|
||||
Class ID = 7 Freeform Serifs
|
||||
Class ID = 8 Sans Serif
|
||||
Class ID = 9 Ornamentals
|
||||
Class ID = 10 Scripts
|
||||
Class ID = 11 (reserved for future use)
|
||||
Class ID = 12 Symbolic */
|
||||
if ((attr->sfamilyclass[0] > 0 && attr->sfamilyclass[0] < 6)
|
||||
|| (attr->sfamilyclass[0] == 7))
|
||||
fontdef->flags = fontdef->flags | HPDF_FONT_SERIF;
|
||||
|
||||
/* get ulCodePageRange1 */
|
||||
if ((ret = HPDF_Stream_Seek (attr->stream, 78, HPDF_SEEK_CUR)) != HPDF_OK)
|
||||
return ret;
|
||||
if (attr->sfamilyclass[0] == 10)
|
||||
fontdef->flags = fontdef->flags | HPDF_FONT_SCRIPT;
|
||||
|
||||
if ((ret = GetUINT32 (attr->stream, &attr->code_page_range1)) != HPDF_OK)
|
||||
return ret;
|
||||
if (attr->sfamilyclass[0] == 12)
|
||||
fontdef->flags = fontdef->flags | HPDF_FONT_SYMBOLIC;
|
||||
|
||||
if ((ret = GetUINT32 (attr->stream, &attr->code_page_range2)) != HPDF_OK)
|
||||
return ret;
|
||||
/* get fields ulCodePageRange1 and ulCodePageRange2 */
|
||||
if(version > 0) {
|
||||
if ((ret = HPDF_Stream_Seek (attr->stream, 36, HPDF_SEEK_CUR)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
if ((ret = GetUINT32 (attr->stream, &attr->code_page_range1)) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
if ((ret = GetUINT32 (attr->stream, &attr->code_page_range2)) != HPDF_OK)
|
||||
return ret;
|
||||
}
|
||||
|
||||
HPDF_PTRACE((" ParseOS2 CodePageRange1=%08X CodePageRange2=%08X\n",
|
||||
(HPDF_UINT)attr->code_page_range1,
|
||||
@@ -1959,6 +1995,9 @@ HPDF_TTFontDef_SaveFontData (HPDF_FontDef fontdef,
|
||||
HPDF_STATUS ret;
|
||||
HPDF_UINT32 offset_base;
|
||||
HPDF_UINT32 tmp_check_sum = 0xB1B0AFBA;
|
||||
HPDF_TTFTable emptyTable;
|
||||
emptyTable.length = 0;
|
||||
emptyTable.offset = 0;
|
||||
|
||||
HPDF_PTRACE ((" SaveFontData\n"));
|
||||
|
||||
@@ -1991,6 +2030,12 @@ HPDF_TTFontDef_SaveFontData (HPDF_FontDef fontdef,
|
||||
HPDF_UINT32 *poffset;
|
||||
HPDF_UINT32 value;
|
||||
|
||||
if (!tbl) {
|
||||
tbl = &emptyTable;
|
||||
HPDF_MemCpy((HPDF_BYTE *)tbl->tag,
|
||||
(const HPDF_BYTE *)REQUIRED_TAGS[i], 4);
|
||||
}
|
||||
|
||||
if (!tbl) {
|
||||
ret = HPDF_SetError (fontdef->error, HPDF_TTF_MISSING_TABLE, i);
|
||||
goto Exit;
|
||||
@@ -2228,4 +2273,3 @@ INT16Swap (HPDF_INT16 *value)
|
||||
HPDF_MemCpy (b, (HPDF_BYTE *)value, 2);
|
||||
*value = (HPDF_INT16)((HPDF_INT16)b[0] << 8 | (HPDF_INT16)b[1]);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,10 +48,16 @@ MeasureText (HPDF_Font font,
|
||||
|
||||
|
||||
static char*
|
||||
UINT16ToHex (char *s,
|
||||
HPDF_UINT16 val,
|
||||
char *eptr);
|
||||
UINT16ToHex (char *s,
|
||||
HPDF_UINT16 val,
|
||||
char *eptr,
|
||||
HPDF_BYTE width);
|
||||
|
||||
static char *
|
||||
CidRangeToHex (char *s,
|
||||
HPDF_UINT16 from,
|
||||
HPDF_UINT16 to,
|
||||
char *eptr);
|
||||
|
||||
static HPDF_Dict
|
||||
CreateCMap (HPDF_Encoder encoder,
|
||||
@@ -132,12 +138,31 @@ HPDF_Type0Font_New (HPDF_MMgr mmgr,
|
||||
if (fontdef->type == HPDF_FONTDEF_TYPE_CID) {
|
||||
ret += HPDF_Dict_AddName (font, "Encoding", encoder->name);
|
||||
} else {
|
||||
attr->cmap_stream = CreateCMap (encoder, xref);
|
||||
/*
|
||||
* Handle the Unicode encoding, see hpdf_encoding_utf.c For some
|
||||
* reason, xpdf-based readers cannot deal with our cmap but work
|
||||
* fine when using the predefined "Identity-H"
|
||||
* encoding. However, text selection does not work, unless we
|
||||
* add a ToUnicode cmap. This CMap should also be "Identity",
|
||||
* but that does not work -- specifying our cmap as a stream however
|
||||
* does work. Who can understand that ?
|
||||
*/
|
||||
if (HPDF_StrCmp(encoder_attr->ordering, "Identity-H") == 0) {
|
||||
ret += HPDF_Dict_AddName (font, "Encoding", "Identity-H");
|
||||
attr->cmap_stream = CreateCMap (encoder, xref);
|
||||
|
||||
if (attr->cmap_stream) {
|
||||
ret += HPDF_Dict_Add (font, "Encoding", attr->cmap_stream);
|
||||
} else
|
||||
return NULL;
|
||||
if (attr->cmap_stream) {
|
||||
ret += HPDF_Dict_Add (font, "ToUnicode", attr->cmap_stream);
|
||||
} else
|
||||
return NULL;
|
||||
} else {
|
||||
attr->cmap_stream = CreateCMap (encoder, xref);
|
||||
|
||||
if (attr->cmap_stream) {
|
||||
ret += HPDF_Dict_Add (font, "Encoding", attr->cmap_stream);
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != HPDF_OK)
|
||||
@@ -372,15 +397,25 @@ CIDFontType2_New (HPDF_Font parent, HPDF_Xref xref)
|
||||
HPDF_UINT j;
|
||||
|
||||
for (j = 0; j < 256; j++) {
|
||||
HPDF_UINT16 cid = encoder_attr->cid_map[i][j];
|
||||
if (cid != 0) {
|
||||
HPDF_UNICODE unicode = encoder_attr->unicode_map[i][j];
|
||||
HPDF_UINT16 gid = HPDF_TTFontDef_GetGlyphid (fontdef, unicode);
|
||||
tmp_map[cid] = gid;
|
||||
if (max < cid)
|
||||
max = cid;
|
||||
}
|
||||
}
|
||||
if (encoder->to_unicode_fn == HPDF_CMapEncoder_ToUnicode) {
|
||||
HPDF_UINT16 cid = encoder_attr->cid_map[i][j];
|
||||
if (cid != 0) {
|
||||
HPDF_UNICODE unicode = encoder_attr->unicode_map[i][j];
|
||||
HPDF_UINT16 gid = HPDF_TTFontDef_GetGlyphid (fontdef,
|
||||
unicode);
|
||||
tmp_map[cid] = gid;
|
||||
if (max < cid)
|
||||
max = cid;
|
||||
}
|
||||
} else {
|
||||
HPDF_UNICODE unicode = (i << 8) | j;
|
||||
HPDF_UINT16 gid = HPDF_TTFontDef_GetGlyphid (fontdef,
|
||||
unicode);
|
||||
tmp_map[unicode] = gid;
|
||||
if (max < unicode)
|
||||
max = unicode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (max > 0) {
|
||||
@@ -575,7 +610,7 @@ TextWidth (HPDF_Font font,
|
||||
HPDF_Encoder_SetParseText (encoder, &parse_state, text, len);
|
||||
|
||||
while (i < len) {
|
||||
HPDF_ByteType btype = HPDF_CMapEncoder_ByteType (encoder, &parse_state);
|
||||
HPDF_ByteType btype = (encoder->byte_type_fn)(encoder, &parse_state);
|
||||
HPDF_UINT16 cid;
|
||||
HPDF_UNICODE unicode;
|
||||
HPDF_UINT16 code;
|
||||
@@ -597,7 +632,7 @@ TextWidth (HPDF_Font font,
|
||||
w = HPDF_CIDFontDef_GetCIDWidth (attr->fontdef, cid);
|
||||
} else {
|
||||
/* unicode-based font */
|
||||
unicode = HPDF_CMapEncoder_ToUnicode (encoder, code);
|
||||
unicode = (encoder->to_unicode_fn)(encoder, code);
|
||||
w = HPDF_TTFontDef_GetCharWidth (attr->fontdef, unicode);
|
||||
}
|
||||
} else {
|
||||
@@ -713,7 +748,7 @@ MeasureText (HPDF_Font font,
|
||||
tmp_w = HPDF_CIDFontDef_GetCIDWidth (attr->fontdef, cid);
|
||||
} else {
|
||||
/* unicode-based font */
|
||||
unicode = HPDF_CMapEncoder_ToUnicode (encoder, code);
|
||||
unicode = (encoder->to_unicode_fn)(encoder, code);
|
||||
tmp_w = HPDF_TTFontDef_GetCharWidth (attr->fontdef,
|
||||
unicode);
|
||||
}
|
||||
@@ -745,10 +780,12 @@ MeasureText (HPDF_Font font,
|
||||
}
|
||||
|
||||
|
||||
|
||||
static char*
|
||||
UINT16ToHex (char *s,
|
||||
HPDF_UINT16 val,
|
||||
char *eptr)
|
||||
UINT16ToHex (char *s,
|
||||
HPDF_UINT16 val,
|
||||
char *eptr,
|
||||
HPDF_BYTE width)
|
||||
{
|
||||
HPDF_BYTE b[2];
|
||||
HPDF_UINT16 val2;
|
||||
@@ -765,8 +802,15 @@ UINT16ToHex (char *s,
|
||||
|
||||
*s++ = '<';
|
||||
|
||||
if (b[0] != 0) {
|
||||
c = (char)(b[0] >> 4);
|
||||
/*
|
||||
* In principle a range of <00> - <1F> can now not be
|
||||
* distinguished from <0000> - <001F>..., this seems something
|
||||
* that is wrong with CID ranges. For the UCS-2 encoding we need
|
||||
* to add <0000> - <FFFF> and this cannot be <00> - <FFFF> (or at
|
||||
* least, that crashes Mac OSX Preview).
|
||||
*/
|
||||
if (width == 2) {
|
||||
c = b[0] >> 4;
|
||||
if (c <= 9)
|
||||
c += 0x30;
|
||||
else
|
||||
@@ -801,6 +845,21 @@ UINT16ToHex (char *s,
|
||||
return s;
|
||||
}
|
||||
|
||||
static char*
|
||||
CidRangeToHex (char *s,
|
||||
HPDF_UINT16 from,
|
||||
HPDF_UINT16 to,
|
||||
char *eptr)
|
||||
{
|
||||
HPDF_BYTE width = (to > 255) ? 2 : 1;
|
||||
char *pbuf;
|
||||
|
||||
pbuf = UINT16ToHex (s, from, eptr, width);
|
||||
*pbuf++ = ' ';
|
||||
pbuf = UINT16ToHex (pbuf, to, eptr, width);
|
||||
|
||||
return pbuf;
|
||||
}
|
||||
|
||||
static HPDF_Dict
|
||||
CreateCMap (HPDF_Encoder encoder,
|
||||
@@ -930,9 +989,8 @@ CreateCMap (HPDF_Encoder encoder,
|
||||
HPDF_CidRange_Rec *range = HPDF_List_ItemAt (attr->code_space_range,
|
||||
i);
|
||||
|
||||
pbuf = UINT16ToHex (buf, range->from, eptr);
|
||||
*pbuf++ = ' ';
|
||||
pbuf = UINT16ToHex (pbuf, range->to, eptr);
|
||||
pbuf = CidRangeToHex(buf, range->from, range->to, eptr);
|
||||
|
||||
HPDF_StrCpy (pbuf, "\r\n", eptr);
|
||||
|
||||
ret += HPDF_Stream_WriteStr (cmap->stream, buf);
|
||||
@@ -954,9 +1012,7 @@ CreateCMap (HPDF_Encoder encoder,
|
||||
for (i = 0; i < attr->notdef_range->count; i++) {
|
||||
HPDF_CidRange_Rec *range = HPDF_List_ItemAt (attr->notdef_range, i);
|
||||
|
||||
pbuf = UINT16ToHex (buf, range->from, eptr);
|
||||
*pbuf++ = ' ';
|
||||
pbuf = UINT16ToHex (pbuf, range->to, eptr);
|
||||
pbuf = CidRangeToHex(buf, range->from, range->to, eptr);
|
||||
*pbuf++ = ' ';
|
||||
pbuf = HPDF_IToA (pbuf, range->cid, eptr);
|
||||
HPDF_StrCpy (pbuf, "\r\n", eptr);
|
||||
@@ -985,9 +1041,7 @@ CreateCMap (HPDF_Encoder encoder,
|
||||
for (i = 0; i < attr->cmap_range->count; i++) {
|
||||
HPDF_CidRange_Rec *range = HPDF_List_ItemAt (attr->cmap_range, i);
|
||||
|
||||
pbuf = UINT16ToHex (buf, range->from, eptr);
|
||||
*pbuf++ = ' ';
|
||||
pbuf = UINT16ToHex (pbuf, range->to, eptr);
|
||||
pbuf = CidRangeToHex(buf, range->from, range->to, eptr);
|
||||
*pbuf++ = ' ';
|
||||
pbuf = HPDF_IToA (pbuf, range->cid, eptr);
|
||||
HPDF_StrCpy (pbuf, "\r\n", eptr);
|
||||
|
||||
@@ -303,7 +303,8 @@ typedef struct _HPDF_TTFontDefAttr_Rec {
|
||||
HPDF_TTF_OffsetTbl offset_tbl;
|
||||
HPDF_TTF_CmapRange cmap;
|
||||
HPDF_UINT16 fs_type;
|
||||
HPDF_BYTE panose[12];
|
||||
HPDF_BYTE sfamilyclass[2];
|
||||
HPDF_BYTE panose[10];
|
||||
HPDF_UINT32 code_page_range1;
|
||||
HPDF_UINT32 code_page_range2;
|
||||
|
||||
@@ -403,4 +404,3 @@ HPDF_CIDFontDef_ChangeStyle (HPDF_FontDef fontdef,
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _HPDF_FONTDEF_H */
|
||||
|
||||
|
||||
@@ -180,6 +180,7 @@ CreateDescriptor (HPDF_Font font)
|
||||
ret += HPDF_Dict_AddName (descriptor, "Type", "FontDescriptor");
|
||||
ret += HPDF_Dict_AddNumber (descriptor, "Ascent", def->ascent);
|
||||
ret += HPDF_Dict_AddNumber (descriptor, "Descent", def->descent);
|
||||
ret += HPDF_Dict_AddNumber (descriptor, "CapHeight", def->cap_height);
|
||||
ret += HPDF_Dict_AddNumber (descriptor, "Flags", def->flags);
|
||||
|
||||
array = HPDF_Box_Array_New (font->mmgr, def->font_bbox);
|
||||
@@ -405,5 +406,3 @@ OnFree (HPDF_Dict obj)
|
||||
HPDF_FreeMem (obj->mmgr, attr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -62,6 +62,7 @@ HPDF_GState_New (HPDF_MMgr mmgr,
|
||||
|
||||
gstate->font = current->font;
|
||||
gstate->font_size = current->font_size;
|
||||
gstate->writing_mode = current->writing_mode;
|
||||
|
||||
gstate->prev = current;
|
||||
gstate->depth = current->depth + 1;
|
||||
|
||||
@@ -175,6 +175,8 @@ HPDF_Fax3SetupState(struct _HPDF_CCITT_Data *pData, HPDF_UINT width,
|
||||
HPDF_Fax3CodecState* esp = EncoderState(pData);
|
||||
uint32 rowbytes, rowpixels, nruns;
|
||||
|
||||
HPDF_UNUSED (height);
|
||||
|
||||
rowbytes = line_width;
|
||||
rowpixels = width;
|
||||
|
||||
@@ -650,6 +652,8 @@ HPDF_Stream_CcittToStream( const HPDF_BYTE *buf,
|
||||
int lineIncrement;
|
||||
struct _HPDF_CCITT_Data data;
|
||||
|
||||
HPDF_UNUSED (e);
|
||||
|
||||
if(height==0) return 1;
|
||||
if(top_is_first) {
|
||||
pBufPos = buf;
|
||||
@@ -750,7 +754,7 @@ HPDF_Image_Load1BitImageFromMem (HPDF_MMgr mmgr,
|
||||
* TRUE if image is oriented TOP-BOTTOM;
|
||||
* FALSE if image is oriented BOTTOM-TOP
|
||||
*/
|
||||
HPDF_Image
|
||||
HPDF_EXPORT(HPDF_Image)
|
||||
HPDF_Image_LoadRaw1BitImageFromMem (HPDF_Doc pdf,
|
||||
const HPDF_BYTE *buf,
|
||||
HPDF_UINT width,
|
||||
|
||||
@@ -67,7 +67,7 @@ HPDF_OutlineRoot_New (HPDF_MMgr mmgr,
|
||||
open_flg->header.obj_id |= HPDF_OTYPE_HIDDEN;
|
||||
|
||||
ret += HPDF_Dict_Add (outline, "_OPENED", open_flg);
|
||||
ret += HPDF_Dict_AddName (outline, "Type", "Outline");
|
||||
ret += HPDF_Dict_AddName (outline, "Type", "Outlines");
|
||||
|
||||
if (ret != HPDF_OK)
|
||||
return NULL;
|
||||
@@ -117,7 +117,7 @@ HPDF_Outline_New (HPDF_MMgr mmgr,
|
||||
open_flg->header.obj_id |= HPDF_OTYPE_HIDDEN;
|
||||
ret += HPDF_Dict_Add (outline, "_OPENED", open_flg);
|
||||
|
||||
ret += HPDF_Dict_AddName (outline, "Type", "Outline");
|
||||
ret += HPDF_Dict_AddName (outline, "Type", "Outlines");
|
||||
ret += AddChild (parent, outline);
|
||||
|
||||
if (ret != HPDF_OK)
|
||||
@@ -328,5 +328,3 @@ HPDF_Outline_SetOpened (HPDF_Outline outline,
|
||||
|
||||
return HPDF_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1155,7 +1155,7 @@ HPDF_Page_SetFontAndSize (HPDF_Page page,
|
||||
return HPDF_RaiseError (page->error, HPDF_PAGE_INVALID_FONT, 0);
|
||||
|
||||
if (size <= 0 || size > HPDF_MAX_FONTSIZE)
|
||||
return HPDF_RaiseError (page->error, HPDF_PAGE_INVALID_FONT_SIZE, 0);
|
||||
return HPDF_RaiseError (page->error, HPDF_PAGE_INVALID_FONT_SIZE, size);
|
||||
|
||||
if (page->mmgr != font->mmgr)
|
||||
return HPDF_RaiseError (page->error, HPDF_PAGE_INVALID_FONT, 0);
|
||||
@@ -2183,7 +2183,7 @@ HPDF_Page_Arc (HPDF_Page page,
|
||||
|
||||
HPDF_PTRACE ((" HPDF_Page_Arc\n"));
|
||||
|
||||
if (ang1 >= ang2 || (ang2 - ang1) >= 360)
|
||||
if (fabs(ang2 - ang1) >= 360)
|
||||
HPDF_RaiseError (page->error, HPDF_PAGE_OUT_OF_RANGE, 0);
|
||||
|
||||
if (ret != HPDF_OK)
|
||||
@@ -2196,10 +2196,10 @@ HPDF_Page_Arc (HPDF_Page page,
|
||||
|
||||
|
||||
for (;;) {
|
||||
if (ang2 - ang1 <= 90)
|
||||
if (fabs(ang2 - ang1) <= 90)
|
||||
return InternalArc (page, x, y, ray, ang1, ang2, cont_flg);
|
||||
else {
|
||||
HPDF_REAL tmp_ang = ang1 + 90;
|
||||
HPDF_REAL tmp_ang = (ang2 > ang1 ? ang1 + 90 : ang1 - 90);
|
||||
|
||||
if ((ret = InternalArc (page, x, y, ray, ang1, tmp_ang, cont_flg))
|
||||
!= HPDF_OK)
|
||||
@@ -2208,7 +2208,7 @@ HPDF_Page_Arc (HPDF_Page page,
|
||||
ang1 = tmp_ang;
|
||||
}
|
||||
|
||||
if (ang1 >= ang2)
|
||||
if (fabs(ang1 - ang2) < 0.1)
|
||||
break;
|
||||
|
||||
cont_flg = HPDF_TRUE;
|
||||
@@ -2271,7 +2271,11 @@ InternalArc (HPDF_Page page,
|
||||
pbuf = HPDF_FToA (pbuf, (HPDF_REAL)x0, eptr);
|
||||
*pbuf++ = ' ';
|
||||
pbuf = HPDF_FToA (pbuf, (HPDF_REAL)y0, eptr);
|
||||
pbuf = (char *)HPDF_StrCpy (pbuf, " m\012", eptr);
|
||||
|
||||
if (attr->gmode == HPDF_GMODE_PATH_OBJECT)
|
||||
pbuf = (char *)HPDF_StrCpy (pbuf, " l\012", eptr);
|
||||
else
|
||||
pbuf = (char *)HPDF_StrCpy (pbuf, " m\012", eptr);
|
||||
}
|
||||
|
||||
pbuf = HPDF_FToA (pbuf, (HPDF_REAL)x1, eptr);
|
||||
@@ -2333,13 +2337,34 @@ InternalWriteText (HPDF_PageAttr attr,
|
||||
|
||||
if (font_attr->type == HPDF_FONT_TYPE0_TT ||
|
||||
font_attr->type == HPDF_FONT_TYPE0_CID) {
|
||||
HPDF_Encoder encoder;
|
||||
HPDF_UINT len;
|
||||
|
||||
if ((ret = HPDF_Stream_WriteStr (attr->stream, "<")) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
if ((ret = HPDF_Stream_WriteBinary (attr->stream, (HPDF_BYTE *)text,
|
||||
HPDF_StrLen (text, HPDF_LIMIT_MAX_STRING_LEN), NULL))
|
||||
!= HPDF_OK)
|
||||
return ret;
|
||||
encoder = font_attr->encoder;
|
||||
len = HPDF_StrLen (text, HPDF_LIMIT_MAX_STRING_LEN);
|
||||
|
||||
if (encoder->encode_text_fn == NULL) {
|
||||
if ((ret = HPDF_Stream_WriteBinary (attr->stream, (HPDF_BYTE *)text,
|
||||
len, NULL))
|
||||
!= HPDF_OK)
|
||||
return ret;
|
||||
} else {
|
||||
char *encoded;
|
||||
HPDF_UINT length;
|
||||
|
||||
encoded = (encoder->encode_text_fn)(encoder, text, len, &length);
|
||||
|
||||
ret = HPDF_Stream_WriteBinary (attr->stream, (HPDF_BYTE *)encoded,
|
||||
length, NULL);
|
||||
|
||||
free(encoded);
|
||||
|
||||
if (ret != HPDF_OK)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return HPDF_Stream_WriteStr (attr->stream, ">");
|
||||
}
|
||||
@@ -2598,12 +2623,28 @@ InternalShowTextNextLine (HPDF_Page page,
|
||||
|
||||
if (font_attr->type == HPDF_FONT_TYPE0_TT ||
|
||||
font_attr->type == HPDF_FONT_TYPE0_CID) {
|
||||
HPDF_Encoder encoder = font_attr->encoder;
|
||||
|
||||
if ((ret = HPDF_Stream_WriteStr (attr->stream, "<")) != HPDF_OK)
|
||||
return ret;
|
||||
|
||||
if ((ret = HPDF_Stream_WriteBinary (attr->stream, (HPDF_BYTE *)text, len, NULL))
|
||||
!= HPDF_OK)
|
||||
return ret;
|
||||
if (encoder->encode_text_fn == NULL) {
|
||||
if ((ret = HPDF_Stream_WriteBinary (attr->stream, (HPDF_BYTE *)text,
|
||||
len, NULL))
|
||||
!= HPDF_OK)
|
||||
return ret;
|
||||
} else {
|
||||
char *encoded;
|
||||
HPDF_UINT length;
|
||||
|
||||
encoded = (encoder->encode_text_fn)(encoder, text, len, &length);
|
||||
ret = HPDF_Stream_WriteBinary (attr->stream, (HPDF_BYTE *)encoded,
|
||||
length, NULL);
|
||||
free(encoded);
|
||||
|
||||
if (ret != HPDF_OK)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if ((ret = HPDF_Stream_WriteStr (attr->stream, ">")) != HPDF_OK)
|
||||
return ret;
|
||||
@@ -2761,3 +2802,100 @@ Fail:
|
||||
HPDF_Dict_Free (dict);
|
||||
return HPDF_Error_GetCode (page->error);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function is contributed by Finn Arildsen.
|
||||
*/
|
||||
|
||||
HPDF_EXPORT(HPDF_STATUS)
|
||||
HPDF_Page_New_Content_Stream (HPDF_Page page,
|
||||
HPDF_Dict* new_stream)
|
||||
{
|
||||
/* Call this function to start a new content stream on a page. The
|
||||
handle is returned to new_stream.
|
||||
new_stream can later be used on other pages as a shared content stream;
|
||||
insert using HPDF_Page_Insert_Shared_Content_Stream */
|
||||
|
||||
HPDF_STATUS ret = HPDF_Page_CheckState (page, HPDF_GMODE_PAGE_DESCRIPTION |
|
||||
HPDF_GMODE_TEXT_OBJECT);
|
||||
HPDF_PageAttr attr;
|
||||
HPDF_UINT filter;
|
||||
HPDF_Array contents_array;
|
||||
|
||||
HPDF_PTRACE((" HPDF_Page_New_Content_Stream\n"));
|
||||
|
||||
attr = (HPDF_PageAttr)page->attr;
|
||||
filter = attr->contents->filter;
|
||||
|
||||
/* check if there is already an array of contents */
|
||||
contents_array = (HPDF_Array) HPDF_Dict_GetItem(page,"Contents", HPDF_OCLASS_ARRAY);
|
||||
if (!contents_array) {
|
||||
HPDF_Error_Reset (page->error);
|
||||
/* no contents_array already -- create one
|
||||
and replace current single contents item */
|
||||
contents_array = HPDF_Array_New(page->mmgr);
|
||||
if (!contents_array)
|
||||
return HPDF_Error_GetCode (page->error);
|
||||
ret += HPDF_Array_Add(contents_array,attr->contents);
|
||||
ret += HPDF_Dict_Add (page, "Contents", contents_array);
|
||||
}
|
||||
|
||||
/* create new contents stream and add it to the page's contents array */
|
||||
attr->contents = HPDF_DictStream_New (page->mmgr, attr->xref);
|
||||
attr->contents->filter = filter;
|
||||
attr->stream = attr->contents->stream;
|
||||
|
||||
if (!attr->contents)
|
||||
return HPDF_Error_GetCode (page->error);
|
||||
|
||||
ret += HPDF_Array_Add (contents_array,attr->contents);
|
||||
|
||||
/* return the value of the new stream, so that
|
||||
the application can use it as a shared contents stream */
|
||||
if (ret == HPDF_OK && new_stream != NULL)
|
||||
*new_stream = attr->contents;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This function is contributed by Finn Arildsen.
|
||||
*/
|
||||
|
||||
HPDF_EXPORT(HPDF_STATUS)
|
||||
HPDF_Page_Insert_Shared_Content_Stream (HPDF_Page page,
|
||||
HPDF_Dict shared_stream)
|
||||
{
|
||||
/* Call this function to insert a previously (with HPDF_New_Content_Stream) created content stream
|
||||
as a shared content stream on this page */
|
||||
|
||||
HPDF_STATUS ret = HPDF_Page_CheckState (page, HPDF_GMODE_PAGE_DESCRIPTION |
|
||||
HPDF_GMODE_TEXT_OBJECT);
|
||||
HPDF_Array contents_array;
|
||||
|
||||
HPDF_PTRACE((" HPDF_Page_Insert_Shared_Content_Stream\n"));
|
||||
|
||||
/* check if there is already an array of contents */
|
||||
contents_array = (HPDF_Array) HPDF_Dict_GetItem(page,"Contents", HPDF_OCLASS_ARRAY);
|
||||
if (!contents_array) {
|
||||
HPDF_PageAttr attr;
|
||||
HPDF_Error_Reset (page->error);
|
||||
/* no contents_array already -- create one
|
||||
and replace current single contents item */
|
||||
contents_array = HPDF_Array_New(page->mmgr);
|
||||
if (!contents_array)
|
||||
return HPDF_Error_GetCode (page->error);
|
||||
attr = (HPDF_PageAttr)page->attr;
|
||||
ret += HPDF_Array_Add(contents_array,attr->contents);
|
||||
ret += HPDF_Dict_Add (page, "Contents", contents_array);
|
||||
}
|
||||
|
||||
ret += HPDF_Array_Add (contents_array,shared_stream);
|
||||
|
||||
/* Continue with a new stream */
|
||||
ret += HPDF_Page_New_Content_Stream (page, NULL);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ typedef struct _HPDF_PageSizeValue {
|
||||
static const HPDF_PageSizeValue HPDF_PREDEFINED_PAGE_SIZES[] = {
|
||||
{612, 792}, /* HPDF_PAGE_SIZE_LETTER */
|
||||
{612, 1008}, /* HPDF_PAGE_SIZE_LEGAL */
|
||||
{(HPDF_REAL)841.89, (HPDF_REAL)1199.551}, /* HPDF_PAGE_SIZE_A3 */
|
||||
{(HPDF_REAL)841.89, (HPDF_REAL)1190.551}, /* HPDF_PAGE_SIZE_A3 */
|
||||
{(HPDF_REAL)595.276, (HPDF_REAL)841.89}, /* HPDF_PAGE_SIZE_A4 */
|
||||
{(HPDF_REAL)419.528, (HPDF_REAL)595.276}, /* HPDF_PAGE_SIZE_A5 */
|
||||
{(HPDF_REAL)708.661, (HPDF_REAL)1000.63}, /* HPDF_PAGE_SIZE_B4 */
|
||||
|
||||
@@ -25,20 +25,33 @@
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define XMP_HEADER "<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?><?adobe-xap-filters esc=\"CRLF\"?><x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='XMP toolkit 2.9.1-13, framework 1.6'><rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:iX='http://ns.adobe.com/iX/1.0/'>"
|
||||
#define XMP_FOOTER "</rdf:RDF></x:xmpmeta><?xpacket end='w'?>"
|
||||
#define XMP_PDFA1A "<rdf:Description rdf:about='' xmlns:pdfaid='http://www.aiim.org/pdfa/ns/id/' pdfaid:part='1' pdfaid:conformance='A'/>"
|
||||
#define XMP_PDFA1B "<rdf:Description rdf:about='' xmlns:pdfaid='http://www.aiim.org/pdfa/ns/id/' pdfaid:part='1' pdfaid:conformance='B'/>"
|
||||
#define XMP_PRODUCER_STARTTAG "<rdf:Description rdf:about='' xmlns:pdf='http://ns.adobe.com/pdf/1.3/' pdf:Producer='"
|
||||
#define XMP_PRODUCER_ENDTAG "'/>"
|
||||
#define XMP_INFODATA_STARTTAG "<rdf:Description rdf:about='' xmlns:xmp='http://ns.adobe.com/xap/1.0/'>"
|
||||
#define XMP_INFODATA_ENDTAG "</rdf:Description>"
|
||||
#define XMP_CREATE_DATE_STARTTAG "<xmp:CreateDate>"
|
||||
#define XMP_CREATE_DATE_ENDTAG "</xmp:CreateDate>"
|
||||
#define XMP_MOD_DATE_STARTTAG "<xmp:ModifyDate>"
|
||||
#define XMP_MOD_DATE_ENDTAG "</xmp:ModifyDate>"
|
||||
#define HEADER "<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?><x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='XMP toolkit 2.9.1-13, framework 1.6'><rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#' xmlns:iX='http://ns.adobe.com/iX/1.0/'>"
|
||||
#define DC_HEADER "<rdf:Description xmlns:dc='http://purl.org/dc/elements/1.1/' rdf:about=''>"
|
||||
#define DC_TITLE_STARTTAG "<dc:title><rdf:Alt><rdf:li xml:lang=\"x-default\">"
|
||||
#define DC_TITLE_ENDTAG "</rdf:li></rdf:Alt></dc:title>"
|
||||
#define DC_CREATOR_STARTTAG "<dc:creator><rdf:Seq><rdf:li>"
|
||||
#define DC_CREATOR_ENDTAG "</rdf:li></rdf:Seq></dc:creator>"
|
||||
#define DC_DESCRIPTION_STARTTAG "<dc:description><rdf:Alt><rdf:li xml:lang=\"x-default\">"
|
||||
#define DC_DESCRIPTION_ENDTAG "</rdf:li></rdf:Alt></dc:description>"
|
||||
#define DC_FOOTER "</rdf:Description>"
|
||||
#define XMP_HEADER "<rdf:Description xmlns:xmp='http://ns.adobe.com/xap/1.0/' rdf:about=''>"
|
||||
#define XMP_CREATORTOOL_STARTTAG "<xmp:CreatorTool>"
|
||||
#define XMP_CREATORTOOL_ENDTAG "</xmp:CreatorTool>"
|
||||
#define XMP_CREATORTOOL_ENDTAG "</xmp:CreatorTool>"
|
||||
#define XMP_CREATE_DATE_STARTTAG "<xmp:CreateDate>"
|
||||
#define XMP_CREATE_DATE_ENDTAG "</xmp:CreateDate>"
|
||||
#define XMP_MOD_DATE_STARTTAG "<xmp:ModifyDate>"
|
||||
#define XMP_MOD_DATE_ENDTAG "</xmp:ModifyDate>"
|
||||
#define XMP_FOOTER "</rdf:Description>"
|
||||
#define PDF_HEADER "<rdf:Description xmlns:pdf='http://ns.adobe.com/pdf/1.3/' rdf:about=''>"
|
||||
#define PDF_KEYWORDS_STARTTAG "<pdf:Keywords>"
|
||||
#define PDF_KEYWORDS_ENDTAG "</pdf:Keywords>"
|
||||
#define PDF_PRODUCER_STARTTAG "<pdf:Producer>"
|
||||
#define PDF_PRODUCER_ENDTAG "</pdf:Producer>"
|
||||
#define PDF_FOOTER "</rdf:Description>"
|
||||
#define PDFAID_PDFA1A "<rdf:Description rdf:about='' xmlns:pdfaid='http://www.aiim.org/pdfa/ns/id/' pdfaid:part='1' pdfaid:conformance='A'/>"
|
||||
#define PDFAID_PDFA1B "<rdf:Description rdf:about='' xmlns:pdfaid='http://www.aiim.org/pdfa/ns/id/' pdfaid:part='1' pdfaid:conformance='B'/>"
|
||||
#define FOOTER "</rdf:RDF></x:xmpmeta><?xpacket end='w'?>"
|
||||
|
||||
|
||||
/*
|
||||
* Convert date in PDF specific format: D:YYYYMMDDHHmmSS
|
||||
@@ -100,12 +113,21 @@ HPDF_STATUS ConvertDateToXMDate(HPDF_Stream stream, const char *pDate)
|
||||
pDate+=2;
|
||||
/* Write +... */
|
||||
if(pDate[0]==0) {
|
||||
ret = HPDF_Stream_Write(stream, (const HPDF_BYTE*)"+0:00", 5);
|
||||
ret = HPDF_Stream_Write(stream, (const HPDF_BYTE*)"Z", 1);
|
||||
return ret;
|
||||
}
|
||||
if(pDate[0]=='+'||pDate[0]=='-') {
|
||||
ret = HPDF_Stream_Write(stream, (const HPDF_BYTE*)pDate, strlen(pDate));
|
||||
return ret;
|
||||
ret = HPDF_Stream_Write(stream, (const HPDF_BYTE*)pDate, 3);
|
||||
if (ret != HPDF_OK)
|
||||
return ret;
|
||||
pDate+=4;
|
||||
ret = HPDF_Stream_Write(stream, (const HPDF_BYTE*)":", 1);
|
||||
if (ret != HPDF_OK)
|
||||
return ret;
|
||||
ret = HPDF_Stream_Write(stream, (const HPDF_BYTE*)pDate, 2);
|
||||
if (ret != HPDF_OK)
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
return HPDF_SetError (stream->error, HPDF_INVALID_PARAMETER, 0);
|
||||
}
|
||||
@@ -117,68 +139,148 @@ HPDF_PDFA_SetPDFAConformance (HPDF_Doc pdf,HPDF_PDFAType pdfatype)
|
||||
{
|
||||
HPDF_OutputIntent xmp;
|
||||
HPDF_STATUS ret;
|
||||
|
||||
const char *dc_title = NULL;
|
||||
const char *dc_creator = NULL;
|
||||
const char *dc_description = NULL;
|
||||
|
||||
const char *xmp_CreatorTool = NULL;
|
||||
const char *xmp_CreateDate = NULL;
|
||||
const char *xmp_ModifyDate = NULL;
|
||||
|
||||
const char *pdf_Keywords = NULL;
|
||||
const char *pdf_Producer = NULL;
|
||||
|
||||
const char *info = NULL;
|
||||
|
||||
|
||||
if (!HPDF_HasDoc(pdf)) {
|
||||
return HPDF_INVALID_DOCUMENT;
|
||||
}
|
||||
|
||||
xmp = HPDF_DictStream_New(pdf->mmgr,pdf->xref);
|
||||
if (!xmp) {
|
||||
return HPDF_INVALID_STREAM;
|
||||
}
|
||||
|
||||
HPDF_Dict_AddName(xmp,"Type","Metadata");
|
||||
HPDF_Dict_AddName(xmp,"SubType","XML");
|
||||
|
||||
ret = HPDF_OK;
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_HEADER);
|
||||
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_PRODUCER_STARTTAG);
|
||||
|
||||
info = (const char *)HPDF_GetInfoAttr(pdf, HPDF_INFO_PRODUCER);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, info);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_PRODUCER_ENDTAG);
|
||||
|
||||
/* Add CreateDate, ModifyDate, and CreatorTool */
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_INFODATA_STARTTAG);
|
||||
info = (const char *)HPDF_GetInfoAttr(pdf, HPDF_INFO_CREATION_DATE);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_CREATE_DATE_STARTTAG);
|
||||
/* Convert date to XMP compatible format */
|
||||
ret += ConvertDateToXMDate(xmp->stream, info);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_CREATE_DATE_ENDTAG);
|
||||
|
||||
info = (const char *)HPDF_GetInfoAttr(pdf, HPDF_INFO_MOD_DATE);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_MOD_DATE_STARTTAG);
|
||||
ret += ConvertDateToXMDate(xmp->stream, info);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_MOD_DATE_ENDTAG);
|
||||
|
||||
info = (const char *)HPDF_GetInfoAttr(pdf, HPDF_INFO_CREATOR);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_CREATORTOOL_STARTTAG);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, info);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_CREATORTOOL_ENDTAG);
|
||||
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_INFODATA_ENDTAG);
|
||||
|
||||
switch(pdfatype) {
|
||||
case HPDF_PDFA_1A:
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_PDFA1A);
|
||||
break;
|
||||
case HPDF_PDFA_1B:
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_PDFA1B);
|
||||
break;
|
||||
}
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_FOOTER);
|
||||
dc_title = (const char *)HPDF_GetInfoAttr(pdf, HPDF_INFO_TITLE);
|
||||
dc_creator = (const char *)HPDF_GetInfoAttr(pdf, HPDF_INFO_AUTHOR);
|
||||
dc_description = (const char *)HPDF_GetInfoAttr(pdf, HPDF_INFO_SUBJECT);
|
||||
|
||||
if (ret != HPDF_OK) {
|
||||
return HPDF_INVALID_STREAM;
|
||||
xmp_CreateDate = (const char *)HPDF_GetInfoAttr(pdf, HPDF_INFO_CREATION_DATE);
|
||||
xmp_ModifyDate = (const char *)HPDF_GetInfoAttr(pdf, HPDF_INFO_MOD_DATE);
|
||||
xmp_CreatorTool = (const char *)HPDF_GetInfoAttr(pdf, HPDF_INFO_CREATOR);
|
||||
|
||||
pdf_Keywords = (const char *)HPDF_GetInfoAttr(pdf, HPDF_INFO_KEYWORDS);
|
||||
pdf_Producer = (const char *)HPDF_GetInfoAttr(pdf, HPDF_INFO_PRODUCER);
|
||||
|
||||
if((dc_title != NULL) || (dc_creator != NULL) || (dc_description != NULL)
|
||||
|| (xmp_CreateDate != NULL) || (xmp_ModifyDate != NULL) || (xmp_CreatorTool != NULL)
|
||||
|| (pdf_Keywords != NULL)) {
|
||||
|
||||
xmp = HPDF_DictStream_New(pdf->mmgr,pdf->xref);
|
||||
if (!xmp) {
|
||||
return HPDF_INVALID_STREAM;
|
||||
}
|
||||
|
||||
/* Update the PDF number version */
|
||||
pdf->pdf_version = HPDF_VER_14;
|
||||
|
||||
HPDF_Dict_AddName(xmp,"Type","Metadata");
|
||||
HPDF_Dict_AddName(xmp,"SubType","XML");
|
||||
|
||||
ret = HPDF_OK;
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, HEADER);
|
||||
|
||||
/* Add the dc block */
|
||||
if((dc_title != NULL) || (dc_creator != NULL) || (dc_description != NULL)) {
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, DC_HEADER);
|
||||
|
||||
if(dc_title != NULL) {
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, DC_TITLE_STARTTAG);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, dc_title);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, DC_TITLE_ENDTAG);
|
||||
}
|
||||
|
||||
if(dc_creator != NULL) {
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, DC_CREATOR_STARTTAG);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, dc_creator);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, DC_CREATOR_ENDTAG);
|
||||
}
|
||||
|
||||
if(dc_description != NULL) {
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, DC_DESCRIPTION_STARTTAG);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, dc_description);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, DC_DESCRIPTION_ENDTAG);
|
||||
}
|
||||
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, DC_FOOTER);
|
||||
}
|
||||
|
||||
/* Add the xmp block */
|
||||
if((xmp_CreateDate != NULL) || (xmp_ModifyDate != NULL) || (xmp_CreatorTool != NULL)) {
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_HEADER);
|
||||
|
||||
/* Add CreateDate, ModifyDate, and CreatorTool */
|
||||
if(xmp_CreatorTool != NULL) {
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_CREATORTOOL_STARTTAG);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, xmp_CreatorTool);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_CREATORTOOL_ENDTAG);
|
||||
}
|
||||
|
||||
if(xmp_CreateDate != NULL) {
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_CREATE_DATE_STARTTAG);
|
||||
/* Convert date to XMP compatible format */
|
||||
ret += ConvertDateToXMDate(xmp->stream, xmp_CreateDate);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_CREATE_DATE_ENDTAG);
|
||||
}
|
||||
|
||||
if(xmp_ModifyDate != NULL) {
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_MOD_DATE_STARTTAG);
|
||||
ret += ConvertDateToXMDate(xmp->stream, xmp_ModifyDate);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_MOD_DATE_ENDTAG);
|
||||
}
|
||||
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, XMP_FOOTER);
|
||||
}
|
||||
|
||||
/* Add the pdf block */
|
||||
if((pdf_Keywords != NULL) || (pdf_Producer != NULL)) {
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, PDF_HEADER);
|
||||
|
||||
if(pdf_Keywords != NULL) {
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, PDF_KEYWORDS_STARTTAG);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, pdf_Keywords);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, PDF_KEYWORDS_ENDTAG);
|
||||
}
|
||||
|
||||
if(pdf_Producer != NULL) {
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, PDF_PRODUCER_STARTTAG);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, pdf_Producer);
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, PDF_PRODUCER_ENDTAG);
|
||||
}
|
||||
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, PDF_FOOTER);
|
||||
}
|
||||
|
||||
/* Add the pdfaid block */
|
||||
switch(pdfatype) {
|
||||
case HPDF_PDFA_1A:
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, PDFAID_PDFA1A);
|
||||
break;
|
||||
case HPDF_PDFA_1B:
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, PDFAID_PDFA1B);
|
||||
break;
|
||||
}
|
||||
|
||||
ret += HPDF_Stream_WriteStr(xmp->stream, FOOTER);
|
||||
|
||||
if (ret != HPDF_OK) {
|
||||
return HPDF_INVALID_STREAM;
|
||||
}
|
||||
|
||||
if ((ret = HPDF_Dict_Add(pdf->catalog, "Metadata", xmp)) != HPDF_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return HPDF_PDFA_GenerateID(pdf);
|
||||
}
|
||||
|
||||
if ((ret = HPDF_Dict_Add(pdf->catalog, "Metadata", xmp)) != HPDF_OK) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
return HPDF_PDFA_GenerateID(pdf);
|
||||
|
||||
return HPDF_OK;
|
||||
}
|
||||
|
||||
/* Generate an ID for the trailer dict, PDF/A needs this.
|
||||
|
||||
@@ -132,6 +132,48 @@ HPDF_LoadU3DFromFile (HPDF_Doc pdf,
|
||||
return image;
|
||||
}
|
||||
|
||||
HPDF_EXPORT(HPDF_Image)
|
||||
HPDF_LoadU3DFromMem (HPDF_Doc pdf,
|
||||
const HPDF_BYTE *buffer,
|
||||
HPDF_UINT size)
|
||||
{
|
||||
HPDF_Stream imagedata;
|
||||
HPDF_Image image;
|
||||
|
||||
HPDF_PTRACE ((" HPDF_LoadU3DFromMem\n"));
|
||||
|
||||
if (!HPDF_HasDoc (pdf)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* create file stream */
|
||||
imagedata = HPDF_MemStream_New (pdf->mmgr, size);
|
||||
|
||||
if (!HPDF_Stream_Validate (imagedata)) {
|
||||
HPDF_RaiseError (&pdf->error, HPDF_INVALID_STREAM, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (HPDF_Stream_Write (imagedata, buffer, size) != HPDF_OK) {
|
||||
HPDF_Stream_Free (imagedata);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (HPDF_Stream_Validate (imagedata)) {
|
||||
image = HPDF_U3D_LoadU3D (pdf->mmgr, imagedata, pdf->xref);
|
||||
} else {
|
||||
image = NULL;
|
||||
}
|
||||
|
||||
/* destroy file stream */
|
||||
HPDF_Stream_Free (imagedata);
|
||||
|
||||
if (!image) {
|
||||
HPDF_CheckError (&pdf->error);
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
HPDF_U3D
|
||||
HPDF_U3D_LoadU3D (HPDF_MMgr mmgr,
|
||||
HPDF_Stream u3d_data,
|
||||
|
||||
@@ -28,6 +28,7 @@ HPDF_EXPORT(HPDF_JavaScript) HPDF_CreateJavaScript(HPDF_Doc pdf, const char *cod
|
||||
|
||||
|
||||
HPDF_EXPORT(HPDF_U3D) HPDF_LoadU3DFromFile (HPDF_Doc pdf, const char *filename);
|
||||
HPDF_EXPORT(HPDF_Image) HPDF_LoadU3DFromMem (HPDF_Doc pdf, const HPDF_BYTE *buffer, HPDF_UINT size);
|
||||
HPDF_EXPORT(HPDF_Dict) HPDF_Create3DView (HPDF_MMgr mmgr, const char *name);
|
||||
HPDF_EXPORT(HPDF_STATUS) HPDF_U3D_Add3DView(HPDF_U3D u3d, HPDF_Dict view);
|
||||
HPDF_EXPORT(HPDF_STATUS) HPDF_U3D_SetDefault3DView(HPDF_U3D u3d, const char *name);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
diff -urN libhpdf.orig/hpdf.h libhpdf/hpdf.h
|
||||
--- libhpdf.orig/hpdf.h 2013-06-12 13:30:26.932035572 +0200
|
||||
+++ libhpdf/hpdf.h 2013-06-12 13:30:26.932035572 +0200
|
||||
--- libhpdf.orig/hpdf.h 2014-02-03 17:57:08.252031640 +0100
|
||||
+++ libhpdf/hpdf.h 2014-02-03 17:57:08.252031640 +0100
|
||||
@@ -17,7 +17,7 @@
|
||||
#ifndef _HPDF_H
|
||||
#define _HPDF_H
|
||||
@@ -20,8 +20,8 @@ diff -urN libhpdf.orig/hpdf.h libhpdf/hpdf.h
|
||||
HPDF_Rect rect,
|
||||
const char *text,
|
||||
diff -urN libhpdf.orig/hpdfimac.c libhpdf/hpdfimac.c
|
||||
--- libhpdf.orig/hpdfimac.c 2013-06-12 13:30:26.856035571 +0200
|
||||
+++ libhpdf/hpdfimac.c 2013-06-12 13:30:26.856035571 +0200
|
||||
--- libhpdf.orig/hpdfimac.c 2014-02-03 17:57:08.168031638 +0100
|
||||
+++ libhpdf/hpdfimac.c 2014-02-03 17:57:08.168031638 +0100
|
||||
@@ -78,7 +78,7 @@
|
||||
|
||||
#define Fax3State(tif) (&(tif)->tif_data->b)
|
||||
@@ -31,20 +31,9 @@ diff -urN libhpdf.orig/hpdfimac.c libhpdf/hpdfimac.c
|
||||
|
||||
/* NB: the uint32 casts are to silence certain ANSI-C compilers */
|
||||
#define TIFFhowmany(x, y) ((((uint32)(x))+(((uint32)(y))-1))/((uint32)(y)))
|
||||
diff -urN libhpdf.orig/hpdfimap.c libhpdf/hpdfimap.c
|
||||
--- libhpdf.orig/hpdfimap.c 2013-06-12 13:30:26.860035571 +0200
|
||||
+++ libhpdf/hpdfimap.c 2013-06-12 13:30:26.860035571 +0200
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#ifndef LIBHPDF_HAVE_NOPNGLIB
|
||||
#include <png.h>
|
||||
+#include <string.h>
|
||||
|
||||
static void
|
||||
PngErrorFunc (png_structp png_ptr,
|
||||
diff -urN libhpdf.orig/hpdfutil.h libhpdf/hpdfutil.h
|
||||
--- libhpdf.orig/hpdfutil.h 2013-06-12 13:30:26.968035573 +0200
|
||||
+++ libhpdf/hpdfutil.h 2013-06-12 13:30:26.968035573 +0200
|
||||
--- libhpdf.orig/hpdfutil.h 2014-02-03 17:57:08.288031641 +0100
|
||||
+++ libhpdf/hpdfutil.h 2014-02-03 17:57:08.288031641 +0100
|
||||
@@ -18,7 +18,7 @@
|
||||
#ifndef _HPDF_UTILS_H
|
||||
#define _HPDF_UTILS_H
|
||||
@@ -55,8 +44,8 @@ diff -urN libhpdf.orig/hpdfutil.h libhpdf/hpdfutil.h
|
||||
|
||||
#ifdef __cplusplus
|
||||
diff -urN libhpdf.orig/t4.h libhpdf/t4.h
|
||||
--- libhpdf.orig/t4.h 2013-06-12 13:30:26.920035572 +0200
|
||||
+++ libhpdf/t4.h 2013-06-12 13:30:26.920035572 +0200
|
||||
--- libhpdf.orig/t4.h 2014-02-03 17:57:08.244031640 +0100
|
||||
+++ libhpdf/t4.h 2014-02-03 17:57:08.244031640 +0100
|
||||
@@ -1,4 +1,4 @@
|
||||
-/* $Id: t4.h,v 1.20 2007/11/10 18:40:44 drolon Exp $ */
|
||||
+/* $Id$ */
|
||||
|
||||
@@ -93,8 +93,8 @@ hpdfutil.c
|
||||
hpdfxref.c
|
||||
|
||||
# ORIGIN http://libharu.org/
|
||||
# VER 2.3.0RC2
|
||||
# URL http://libharu.org/files/libhpdf-2.3.0RC2.tar.gz
|
||||
# VER 2.3.0RC3
|
||||
# URL https://github.com/libharu/libharu/archive/RELEASE_2_3_0RC3.zip
|
||||
# DIFF libhpdf.dif
|
||||
#
|
||||
# MAP README
|
||||
|
||||
@@ -1917,7 +1917,7 @@ PHB_SYMB hb_objGetMethod( PHB_ITEM pObject, PHB_SYMB pMessage,
|
||||
}
|
||||
#else
|
||||
{
|
||||
PMETHOD pMethod = b_clsFindMsg( pClass, pMsg );
|
||||
PMETHOD pMethod = hb_clsFindMsg( pClass, pMsg );
|
||||
if( pMethod )
|
||||
{
|
||||
pStack->uiMethod = ( HB_USHORT ) ( pMethod - pClass->pMethods );
|
||||
|
||||
Reference in New Issue
Block a user