You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-#define HPDF_LIMIT_MAX_REAL 32767-#define HPDF_LIMIT_MIN_REAL -32767+#define HPDF_LIMIT_MAX_REAL 3.4E38f // per PDF 1.7 spec, Annex C, old value 32767+#define HPDF_LIMIT_MIN_REAL -3.4E38f // per PDF 1.7 spec, Annex C, old value -32767
But this was not adopted in the code of HPDF_FToA. In HPDF_FToA there is a
charbuf[HPDF_REAL_LEN+1];
with (in pdf_consts.h)
#defineHPDF_REAL_LEN 11
Thus using larger values will create output similar to
- - - 420.5 297.5 420.5 c
420.5 - - c
or even
-.(-*,( -.(-*,( -.(-*,( 0 297.5 0 c
.(-*,( 0 .(-*,( -.(-*,( .(-*,( -.(-*,( c
in the PDF.
I suggest the following patch ¹):
In pdf_consts.h change to
#defineHPDF_TMP_BUF_SIZ 1024 // old value 512
#defineHPDF_SHORT_BUF_SIZ 32
#defineHPDF_REAL_LEN 48 // old value 11
and in hpdf_utils.c replace old HPDF_FToA with
#include<math.h>char*HPDF_FToA (char*s,
HPDF_REALval,
char*eptr)
{
HPDF_DOUBLEint_val;
HPDF_DOUBLEfpart_val;
HPDF_DOUBLEdig;
charbuf[HPDF_REAL_LEN+1];
char*sptr=s;
char*t;
HPDF_UINT32i;
if (val>HPDF_LIMIT_MAX_REAL)
val=HPDF_LIMIT_MAX_REAL;
elseif (val<HPDF_LIMIT_MIN_REAL)
val=HPDF_LIMIT_MIN_REAL;
t=buf+HPDF_REAL_LEN;
*t--=0;
if (val!=0&&val<0) {
*s++='-';
val=-val;
}
/* separate an integer part and a decimal part. */fpart_val=modf(val,&int_val);
/* process integer part */do{
dig=modf(int_val/10.0,&int_val);
*t= (char)((char)(dig*10+0.5) +'0');
t--;
}while (int_val>0) ;
/* copy do destination buffer */t++;
while (s <= eptr&&*t!=0)
*s++=*t++;
if(fpart_val!=0.0)
{
if(s <= eptr)*s++='.';
for (i=0; i<5; i++)
{
fpart_val=modf(fpart_val*10,&int_val);
if(s <= eptr)*s++= (char)((char)(int_val+0.5) +'0');
if(fpart_val==0)
break;
}
}
*s=0;
returns;
}
This code works fine for me. Please review it and use it, if you like to
¹) No, I cannot create a pull request due firewall restrictions in my office.
The text was updated successfully, but these errors were encountered:
With ac6052c the following patch was done
But this was not adopted in the code of HPDF_FToA. In HPDF_FToA there is a
with (in pdf_consts.h)
Thus using larger values will create output similar to
or even
in the PDF.
I suggest the following patch ¹):
In pdf_consts.h change to
and in hpdf_utils.c replace old HPDF_FToA with
This code works fine for me. Please review it and use it, if you like to
¹) No, I cannot create a pull request due firewall restrictions in my office.
The text was updated successfully, but these errors were encountered: