Switch to using double for numbers, since they are also used to record lengths

and other potentially large contents.
This commit is contained in:
Michael R Sweet 2021-05-29 21:16:21 -04:00
parent 35d22705fa
commit a18b8fd606
No known key found for this signature in database
GPG Key ID: 999559A027815955
13 changed files with 142 additions and 166 deletions

View File

@ -16,7 +16,7 @@ ARFLAGS = cr
CC = cc
CFLAGS =
CODESIGN_IDENTITY = Developer ID
COMMONFLAGS = Os -g
COMMONFLAGS = -Os -g
CPPFLAGS =
DESTDIR = $(DSTROOT)
DSO = cc

View File

@ -112,7 +112,7 @@ generates a static library that will be installed under "/usr/local" with:
You can reproduce this with the makefile using:
sudo make 'COMMONFLAGS="-Os -mmacosx-version-min=10.14 -arch x86_64 -arch arm64e"' install
sudo make 'COMMONFLAGS="-Os -mmacosx-version-min=10.14 -arch x86_64 -arch arm64"' install
Legal Stuff

View File

@ -1,14 +1,11 @@
To-Do List
==========
- Graphics mini-library
- Functions to send PDF drawing commands
- Resources:
- Fonts
- ICC profiles/standard color spaces
- Images
- PNG images
- Others?
- Object/page copy methods
- Security handlers (RC4 + AES, MD5 + SHA-256) for reading encrypted documents.
- Signature generation/validation code
- Documentation

View File

@ -162,7 +162,7 @@ pdfioArrayAppendName(
bool // O - `true` on success, `false` on failure
pdfioArrayAppendNumber(
pdfio_array_t *a, // I - Array
float value) // I - Value
double value) // I - Value
{
_pdfio_value_t v; // Value for array
@ -429,12 +429,12 @@ pdfioArrayGetName(pdfio_array_t *a, // I - Array
// 'pdfioArrayGetNumber()' - Get a number from an array.
//
float // O - Value
double // O - Value
pdfioArrayGetNumber(pdfio_array_t *a, // I - Array
size_t n) // I - Index
{
if (!a || n >= a->num_values || a->values[n].type != PDFIO_VALTYPE_NUMBER)
return (0.0f);
return (0.0);
else
return (a->values[n].value.number);
}

View File

@ -27,7 +27,6 @@ typedef pdfio_obj_t *(*image_func_t)(pdfio_dict_t *dict, int fd);
// Local functions...
//
static pdfio_obj_t *copy_gif(pdfio_dict_t *dict, int fd);
static pdfio_obj_t *copy_jpeg(pdfio_dict_t *dict, int fd);
static pdfio_obj_t *copy_png(pdfio_dict_t *dict, int fd);
static bool write_string(pdfio_stream_t *st, const char *s);
@ -69,10 +68,10 @@ bool // O - `true` on success, `false` on failure
pdfioContentDrawImage(
pdfio_stream_t *st, // I - Stream
const char *name, // I - Image name
float x, // I - X offset of image
float y, // I - Y offset of image
float w, // I - Width of image
float h) // I - Height of image
double x, // I - X offset of image
double y, // I - Y offset of image
double w, // I - Width of image
double h) // I - Height of image
{
return (pdfioStreamPrintf(st, "q %g 0 0 %g %g %g cm/%s Do Q\n", w, h, x, y, name));
}
@ -136,7 +135,7 @@ pdfioContentMatrixConcat(
bool // O - `true` on success, `false` on failure
pdfioContentMatrixRotate(
pdfio_stream_t *st, // I - Stream
float degrees) // I - Rotation angle in degrees counter-clockwise
double degrees) // I - Rotation angle in degrees counter-clockwise
{
double dcos = cos(degrees / M_PI); // Cosine
double dsin = sin(degrees / M_PI); // Sine
@ -152,8 +151,8 @@ pdfioContentMatrixRotate(
bool // O - `true` on success, `false` on failure
pdfioContentMatrixScale(
pdfio_stream_t *st, // I - Stream
float sx, // I - X scale
float sy) // I - Y scale
double sx, // I - X scale
double sy) // I - Y scale
{
return (pdfioStreamPrintf(st, "%g 0 0 %g 0 0 cm\n", sx, sy));
}
@ -166,8 +165,8 @@ pdfioContentMatrixScale(
bool // O - `true` on success, `false` on failure
pdfioContentMatrixTranslate(
pdfio_stream_t *st, // I - Stream
float tx, // I - X offset
float ty) // I - Y offset
double tx, // I - X offset
double ty) // I - Y offset
{
return (pdfioStreamPrintf(st, "1 0 0 1 %g %g cm\n", tx, ty));
}
@ -192,12 +191,12 @@ pdfioContentPathClose(
bool // O - `true` on success, `false` on failure
pdfioContentPathCurve(
pdfio_stream_t *st, // I - Stream
float x1, // I - X position 1
float y1, // I - Y position 1
float x2, // I - X position 2
float y2, // I - Y position 2
float x3, // I - X position 3
float y3) // I - Y position 3
double x1, // I - X position 1
double y1, // I - Y position 1
double x2, // I - X position 2
double y2, // I - Y position 2
double x3, // I - X position 3
double y3) // I - Y position 3
{
return (pdfioStreamPrintf(st, "%g %g %g %g %g %g c\n", x1, y1, x2, y2, x3, y3));
}
@ -210,10 +209,10 @@ pdfioContentPathCurve(
bool // O - `true` on success, `false` on failure
pdfioContentPathCurve13(
pdfio_stream_t *st, // I - Stream
float x1, // I - X position 1
float y1, // I - Y position 1
float x3, // I - X position 3
float y3) // I - Y position 3
double x1, // I - X position 1
double y1, // I - Y position 1
double x3, // I - X position 3
double y3) // I - Y position 3
{
return (pdfioStreamPrintf(st, "%g %g %g %g v\n", x1, y1, x3, y3));
}
@ -226,10 +225,10 @@ pdfioContentPathCurve13(
bool // O - `true` on success, `false` on failure
pdfioContentPathCurve23(
pdfio_stream_t *st, // I - Stream
float x2, // I - X position 2
float y2, // I - Y position 2
float x3, // I - X position 3
float y3) // I - Y position 3
double x2, // I - X position 2
double y2, // I - Y position 2
double x3, // I - X position 3
double y3) // I - Y position 3
{
return (pdfioStreamPrintf(st, "%g %g %g %g y\n", x2, y2, x3, y3));
}
@ -242,8 +241,8 @@ pdfioContentPathCurve23(
bool // O - `true` on success, `false` on failure
pdfioContentPathLineTo(
pdfio_stream_t *st, // I - Stream
float x, // I - X position
float y) // I - Y position
double x, // I - X position
double y) // I - Y position
{
return (pdfioStreamPrintf(st, "%g %g l\n", x, y));
}
@ -256,8 +255,8 @@ pdfioContentPathLineTo(
bool // O - `true` on success, `false` on failure
pdfioContentPathMoveTo(
pdfio_stream_t *st, // I - Stream
float x, // I - X position
float y) // I - Y position
double x, // I - X position
double y) // I - Y position
{
return (pdfioStreamPrintf(st, "%g %g m\n", x, y));
}
@ -321,10 +320,10 @@ pdfioContentSetDashPattern(
bool // O - `true` on success, `false` on failure
pdfioContentSetFillColorDeviceCMYK(
pdfio_stream_t *st, // I - Stream
float c, // I - Cyan value (0.0 to 1.0)
float m, // I - Magenta value (0.0 to 1.0)
float y, // I - Yellow value (0.0 to 1.0)
float k) // I - Black value (0.0 to 1.0)
double c, // I - Cyan value (0.0 to 1.0)
double m, // I - Magenta value (0.0 to 1.0)
double y, // I - Yellow value (0.0 to 1.0)
double k) // I - Black value (0.0 to 1.0)
{
return (pdfioStreamPrintf(st, "%g %g %g %g k\n", c, m, y, k));
}
@ -337,7 +336,7 @@ pdfioContentSetFillColorDeviceCMYK(
bool // O - `true` on success, `false` on failure
pdfioContentSetFillColorDeviceGray(
pdfio_stream_t *st, // I - Stream
float g) // I - Gray value (0.0 to 1.0)
double g) // I - Gray value (0.0 to 1.0)
{
return (pdfioStreamPrintf(st, "%g g\n", g));
}
@ -350,9 +349,9 @@ pdfioContentSetFillColorDeviceGray(
bool // O - `true` on success, `false` on failure
pdfioContentSetFillColorDeviceRGB(
pdfio_stream_t *st, // I - Stream
float r, // I - Red value (0.0 to 1.0)
float g, // I - Green value (0.0 to 1.0)
float b) // I - Blue value (0.0 to 1.0)
double r, // I - Red value (0.0 to 1.0)
double g, // I - Green value (0.0 to 1.0)
double b) // I - Blue value (0.0 to 1.0)
{
return (pdfioStreamPrintf(st, "%g %g %g rg\n", r, g, b));
}
@ -365,7 +364,7 @@ pdfioContentSetFillColorDeviceRGB(
bool // O - `true` on success, `false` on failure
pdfioContentSetFillColorGray(
pdfio_stream_t *st, // I - Stream
float g) // I - Gray value (0.0 to 1.0)
double g) // I - Gray value (0.0 to 1.0)
{
return (pdfioStreamPrintf(st, "%g sc\n", g));
}
@ -378,9 +377,9 @@ pdfioContentSetFillColorGray(
bool // O - `true` on success, `false` on failure
pdfioContentSetFillColorRGB(
pdfio_stream_t *st, // I - Stream
float r, // I - Red value (0.0 to 1.0)
float g, // I - Green value (0.0 to 1.0)
float b) // I - Blue value (0.0 to 1.0)
double r, // I - Red value (0.0 to 1.0)
double g, // I - Green value (0.0 to 1.0)
double b) // I - Blue value (0.0 to 1.0)
{
return (pdfioStreamPrintf(st, "%g %g %g sc\n", r, g, b));
}
@ -406,7 +405,7 @@ pdfioContentSetFillColorSpace(
bool // O - `true` on success, `false` on failure
pdfioContentSetFlatness(
pdfio_stream_t *st, // I - Stream
float flatness) // I - Flatness value (0.0 to 100.0)
double flatness) // I - Flatness value (0.0 to 100.0)
{
return (pdfioStreamPrintf(st, "%g i\n", flatness));
}
@ -445,7 +444,7 @@ pdfioContentSetLineJoin(
bool // O - `true` on success, `false` on failure
pdfioContentSetLineWidth(
pdfio_stream_t *st, // I - Stream
float width) // I - Line width value
double width) // I - Line width value
{
return (pdfioStreamPrintf(st, "%g w\n", width));
}
@ -458,7 +457,7 @@ pdfioContentSetLineWidth(
bool // O - `true` on success, `false` on failure
pdfioContentSetMiterLimit(
pdfio_stream_t *st, // I - Stream
float limit) // I - Miter limit value
double limit) // I - Miter limit value
{
return (pdfioStreamPrintf(st, "%g M\n", limit));
}
@ -471,10 +470,10 @@ pdfioContentSetMiterLimit(
bool // O - `true` on success, `false` on failure
pdfioContentSetStrokeColorDeviceCMYK(
pdfio_stream_t *st, // I - Stream
float c, // I - Cyan value (0.0 to 1.0)
float m, // I - Magenta value (0.0 to 1.0)
float y, // I - Yellow value (0.0 to 1.0)
float k) // I - Black value (0.0 to 1.0)
double c, // I - Cyan value (0.0 to 1.0)
double m, // I - Magenta value (0.0 to 1.0)
double y, // I - Yellow value (0.0 to 1.0)
double k) // I - Black value (0.0 to 1.0)
{
return (pdfioStreamPrintf(st, "%g %g %g %g K\n", c, m, y, k));
}
@ -487,7 +486,7 @@ pdfioContentSetStrokeColorDeviceCMYK(
bool // O - `true` on success, `false` on failure
pdfioContentSetStrokeColorDeviceGray(
pdfio_stream_t *st, // I - Stream
float g) // I - Gray value (0.0 to 1.0)
double g) // I - Gray value (0.0 to 1.0)
{
return (pdfioStreamPrintf(st, "%g G\n", g));
}
@ -500,9 +499,9 @@ pdfioContentSetStrokeColorDeviceGray(
bool // O - `true` on success, `false` on failure
pdfioContentSetStrokeColorDeviceRGB(
pdfio_stream_t *st, // I - Stream
float r, // I - Red value (0.0 to 1.0)
float g, // I - Green value (0.0 to 1.0)
float b) // I - Blue value (0.0 to 1.0)
double r, // I - Red value (0.0 to 1.0)
double g, // I - Green value (0.0 to 1.0)
double b) // I - Blue value (0.0 to 1.0)
{
return (pdfioStreamPrintf(st, "%g %g %g RG\n", r, g, b));
}
@ -515,7 +514,7 @@ pdfioContentSetStrokeColorDeviceRGB(
bool // O - `true` on success, `false` on failure
pdfioContentSetStrokeColorGray(
pdfio_stream_t *st, // I - Stream
float g) // I - Gray value (0.0 to 1.0)
double g) // I - Gray value (0.0 to 1.0)
{
return (pdfioStreamPrintf(st, "%g SC\n", g));
}
@ -528,9 +527,9 @@ pdfioContentSetStrokeColorGray(
bool // O - `true` on success, `false` on failure
pdfioContentSetStrokeColorRGB(
pdfio_stream_t *st, // I - Stream
float r, // I - Red value (0.0 to 1.0)
float g, // I - Green value (0.0 to 1.0)
float b) // I - Blue value (0.0 to 1.0)
double r, // I - Red value (0.0 to 1.0)
double g, // I - Green value (0.0 to 1.0)
double b) // I - Blue value (0.0 to 1.0)
{
return (pdfioStreamPrintf(st, "%g %g %g SC\n", r, g, b));
}
@ -556,7 +555,7 @@ pdfioContentSetStrokeColorSpace(
bool // O - `true` on success, `false` on failure
pdfioContentSetTextCharacterSpacing(
pdfio_stream_t *st, // I - Stream
float spacing) // I - Character spacing
double spacing) // I - Character spacing
{
return (pdfioStreamPrintf(st, "%g Tc\n", spacing));
}
@ -570,7 +569,7 @@ bool // O - `true` on success, `false` on failure
pdfioContentSetTextFont(
pdfio_stream_t *st, // I - Stream
const char *name, // I - Font name
float size) // I - Font size
double size) // I - Font size
{
return (pdfioStreamPrintf(st, "/%s %g Tf\n", name, size));
}
@ -583,7 +582,7 @@ pdfioContentSetTextFont(
bool // O - `true` on success, `false` on failure
pdfioContentSetTextLeading(
pdfio_stream_t *st, // I - Stream
float leading) // I - Leading (line height) value
double leading) // I - Leading (line height) value
{
return (pdfioStreamPrintf(st, "%g TL\n", leading));
}
@ -622,7 +621,7 @@ pdfioContentSetTextRenderingMode(
bool // O - `true` on success, `false` on failure
pdfioContentSetTextRise(
pdfio_stream_t *st, // I - Stream
float rise) // I - Y offset
double rise) // I - Y offset
{
return (pdfioStreamPrintf(st, "%g Ts\n", rise));
}
@ -635,7 +634,7 @@ pdfioContentSetTextRise(
bool // O - `true` on success, `false` on failure
pdfioContentSetTextWordSpacing(
pdfio_stream_t *st, // I - Stream
float spacing) // I - Spacing between words
double spacing) // I - Spacing between words
{
return (pdfioStreamPrintf(st, "%g Tw\n", spacing));
}
@ -648,7 +647,7 @@ pdfioContentSetTextWordSpacing(
bool // O - `true` on success, `false` on failure
pdfioContentSetTextXScaling(
pdfio_stream_t *st, // I - Stream
float percent) // I - Horizontal scaling in percent
double percent) // I - Horizontal scaling in percent
{
return (pdfioStreamPrintf(st, "%g Tz\n", percent));
}
@ -672,8 +671,8 @@ pdfioContentStroke(pdfio_stream_t *st) // I - Stream
bool // O - `true` on success, `false` on failure
pdfioContentTextMoveLine(
pdfio_stream_t *st, // I - Stream
float tx, // I - X offset
float ty) // I - Y offset
double tx, // I - X offset
double ty) // I - Y offset
{
return (pdfioStreamPrintf(st, "%g %g TD\n", tx, ty));
}
@ -686,8 +685,8 @@ pdfioContentTextMoveLine(
bool // O - `true` on success, `false` on failure
pdfioContentTextMoveTo(
pdfio_stream_t *st, // I - Stream
float tx, // I - X offset
float ty) // I - Y offset
double tx, // I - X offset
double ty) // I - Y offset
{
return (pdfioStreamPrintf(st, "%g %g Td\n", tx, ty));
}
@ -732,7 +731,7 @@ bool // O - `true` on success, `false` on failure
pdfioContentTextShowJustified(
pdfio_stream_t *st, // I - Stream
size_t num_fragments, // I - Number of text fragments
const float *offsets, // I - Text offsets before fragments
const double *offsets, // I - Text offsets before fragments
const char * const *fragments) // I - Text fragments
{
size_t i; // Looping var
@ -790,8 +789,8 @@ pdfioPageDictAddCalibratedColorSpace(
pdfio_dict_t *dict, // I - Page dictionary
const char *name, // I - Color space name
size_t num_colors, // I - Number of color components
const float *white_point, // I - CIE XYZ white point
float gamma) // I - Gamma value
const double *white_point, // I - CIE XYZ white point
double gamma) // I - Gamma value
{
(void)dict;
(void)name;
@ -940,11 +939,6 @@ pdfioFileCreateImageObject(
// PNG image...
copy_func = copy_png;
}
else if (!memcmp(buffer, "GIF87a", 6) || !memcmp(buffer, "GIF89a", 6))
{
// GIF image...
copy_func = copy_gif;
}
else if (!memcmp(buffer, "\377\330\377", 3))
{
// JPEG image...
@ -982,7 +976,7 @@ pdfioFileCreateImageObject(
// 'pdfioImageGetHeight()' - Get the height of an image object.
//
float // O - Height in lines
double // O - Height in lines
pdfioImageGetHeight(pdfio_obj_t *obj) // I - Image object
{
return (pdfioDictGetNumber(obj->value.value.dict, "Height"));
@ -993,28 +987,13 @@ pdfioImageGetHeight(pdfio_obj_t *obj) // I - Image object
// 'pdfioImageGetWidth()' - Get the width of an image object.
//
float // O - Width in columns
double // O - Width in columns
pdfioImageGetWidth(pdfio_obj_t *obj) // I - Image object
{
return (pdfioDictGetNumber(obj->value.value.dict, "Width"));
}
//
// 'copy_gif()' - Copy a GIF image.
//
static pdfio_obj_t * // O - Object or `NULL` on error
copy_gif(pdfio_dict_t *dict, // I - Dictionary
int fd) // I - File descriptor
{
// TODO: Implement copy_gif
(void)dict;
(void)fd;
return (NULL);
}
//
// 'copy_jpeg()' - Copy a JPEG image.
//

View File

@ -44,7 +44,7 @@ typedef enum pdfio_linejoin_e // Line joining modes
PDFIO_LINEJOIN_BEVEL // Bevel joint
} pdfio_linejoin_t;
typedef float pdfio_matrix_t[3][2]; // Transform matrix
typedef double pdfio_matrix_t[3][2]; // Transform matrix
typedef enum pdfio_textrendering_e // Text rendering modes
{
@ -59,16 +59,16 @@ typedef enum pdfio_textrendering_e // Text rendering modes
PDFIO_TEXTRENDERING_TEXT_PATH // Add text to path (invisible)
} pdfio_textrendering_t;
extern const float pdfioAdobeRGBGamma;
extern const double pdfioAdobeRGBGamma;
// AdobeRGB gamma
extern const float pdfioAdobeRGBWhitePoint[];
extern const double pdfioAdobeRGBWhitePoint[];
// AdobeRGB white point
extern const float pdfioDisplayP3Gamma;
extern const double pdfioDisplayP3Gamma;
// Display P3 gamma
extern const float pdfioDisplayP3WhitePoint[];
extern const double pdfioDisplayP3WhitePoint[];
// Display P3 white point
extern const float pdfioSRGBGamma; // sRGB gamma
extern const float pdfioSRGBWhitePoint[];
extern const double pdfioSRGBGamma; // sRGB gamma
extern const double pdfioSRGBWhitePoint[];
// sRGB white point
@ -79,55 +79,55 @@ extern const float pdfioSRGBWhitePoint[];
// PDF content drawing functions...
extern bool pdfioContentBeginText(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentClip(pdfio_stream_t *st, bool even_odd) PDFIO_PUBLIC;
extern bool pdfioContentDrawImage(pdfio_stream_t *st, const char *name, float x, float y, float w, float h) PDFIO_PUBLIC;
extern bool pdfioContentDrawImage(pdfio_stream_t *st, const char *name, double x, double y, double w, double h) PDFIO_PUBLIC;
extern bool pdfioContentEndText(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentFill(pdfio_stream_t *st, bool even_odd) PDFIO_PUBLIC;
extern bool pdfioContentFillAndStroke(pdfio_stream_t *st, bool even_odd) PDFIO_PUBLIC;
extern bool pdfioContentMatrixConcat(pdfio_stream_t *st, pdfio_matrix_t m) PDFIO_PUBLIC;
extern bool pdfioContentMatrixRotate(pdfio_stream_t *st, float degrees) PDFIO_PUBLIC;
extern bool pdfioContentMatrixScale(pdfio_stream_t *st, float sx, float sy) PDFIO_PUBLIC;
extern bool pdfioContentMatrixTranslate(pdfio_stream_t *st, float tx, float ty) PDFIO_PUBLIC;
extern bool pdfioContentMatrixRotate(pdfio_stream_t *st, double degrees) PDFIO_PUBLIC;
extern bool pdfioContentMatrixScale(pdfio_stream_t *st, double sx, double sy) PDFIO_PUBLIC;
extern bool pdfioContentMatrixTranslate(pdfio_stream_t *st, double tx, double ty) PDFIO_PUBLIC;
extern bool pdfioContentPathClose(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentPathCurve(pdfio_stream_t *st, float x1, float y1, float x2, float y2, float x3, float y3) PDFIO_PUBLIC;
extern bool pdfioContentPathCurve13(pdfio_stream_t *st, float x1, float y1, float x3, float y3) PDFIO_PUBLIC;
extern bool pdfioContentPathCurve23(pdfio_stream_t *st, float x2, float y2, float x3, float y3) PDFIO_PUBLIC;
extern bool pdfioContentPathLineTo(pdfio_stream_t *st, float x, float y) PDFIO_PUBLIC;
extern bool pdfioContentPathMoveTo(pdfio_stream_t *st, float x, float y) PDFIO_PUBLIC;
extern bool pdfioContentPathCurve(pdfio_stream_t *st, double x1, double y1, double x2, double y2, double x3, double y3) PDFIO_PUBLIC;
extern bool pdfioContentPathCurve13(pdfio_stream_t *st, double x1, double y1, double x3, double y3) PDFIO_PUBLIC;
extern bool pdfioContentPathCurve23(pdfio_stream_t *st, double x2, double y2, double x3, double y3) PDFIO_PUBLIC;
extern bool pdfioContentPathLineTo(pdfio_stream_t *st, double x, double y) PDFIO_PUBLIC;
extern bool pdfioContentPathMoveTo(pdfio_stream_t *st, double x, double y) PDFIO_PUBLIC;
extern bool pdfioContentPathRect(pdfio_stream_t *st, pdfio_rect_t *rect) PDFIO_PUBLIC;
extern bool pdfioContentRestore(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentSave(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentSetDashPattern(pdfio_stream_t *st, int phase, int on, int off) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceCMYK(pdfio_stream_t *st, float c, float m, float y, float k) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceGray(pdfio_stream_t *st, float g) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceRGB(pdfio_stream_t *st, float r, float g, float b) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorGray(pdfio_stream_t *st, float g) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorRGB(pdfio_stream_t *st, float r, float g, float b) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceCMYK(pdfio_stream_t *st, double c, double m, double y, double k) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceGray(pdfio_stream_t *st, double g) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorDeviceRGB(pdfio_stream_t *st, double r, double g, double b) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorGray(pdfio_stream_t *st, double g) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorRGB(pdfio_stream_t *st, double r, double g, double b) PDFIO_PUBLIC;
extern bool pdfioContentSetFillColorSpace(pdfio_stream_t *st, const char *name) PDFIO_PUBLIC;
extern bool pdfioContentSetFlatness(pdfio_stream_t *st, float f) PDFIO_PUBLIC;
extern bool pdfioContentSetFlatness(pdfio_stream_t *st, double f) PDFIO_PUBLIC;
extern bool pdfioContentSetLineCap(pdfio_stream_t *st, pdfio_linecap_t lc) PDFIO_PUBLIC;
extern bool pdfioContentSetLineJoin(pdfio_stream_t *st, pdfio_linejoin_t lj) PDFIO_PUBLIC;
extern bool pdfioContentSetLineWidth(pdfio_stream_t *st, float width) PDFIO_PUBLIC;
extern bool pdfioContentSetMiterLimit(pdfio_stream_t *st, float limit) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorDeviceCMYK(pdfio_stream_t *st, float c, float m, float y, float k) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorDeviceGray(pdfio_stream_t *st, float g) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorDeviceRGB(pdfio_stream_t *st, float r, float g, float b) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorGray(pdfio_stream_t *st, float g) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorRGB(pdfio_stream_t *st, float r, float g, float b) PDFIO_PUBLIC;
extern bool pdfioContentSetLineWidth(pdfio_stream_t *st, double width) PDFIO_PUBLIC;
extern bool pdfioContentSetMiterLimit(pdfio_stream_t *st, double limit) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorDeviceCMYK(pdfio_stream_t *st, double c, double m, double y, double k) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorDeviceGray(pdfio_stream_t *st, double g) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorDeviceRGB(pdfio_stream_t *st, double r, double g, double b) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorGray(pdfio_stream_t *st, double g) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorRGB(pdfio_stream_t *st, double r, double g, double b) PDFIO_PUBLIC;
extern bool pdfioContentSetStrokeColorSpace(pdfio_stream_t *st, const char *name) PDFIO_PUBLIC;
extern bool pdfioContentSetTextCharacterSpacing(pdfio_stream_t *st, float spacing) PDFIO_PUBLIC;
extern bool pdfioContentSetTextFont(pdfio_stream_t *st, const char *name, float size) PDFIO_PUBLIC;
extern bool pdfioContentSetTextLeading(pdfio_stream_t *st, float leading) PDFIO_PUBLIC;
extern bool pdfioContentSetTextCharacterSpacing(pdfio_stream_t *st, double spacing) PDFIO_PUBLIC;
extern bool pdfioContentSetTextFont(pdfio_stream_t *st, const char *name, double size) PDFIO_PUBLIC;
extern bool pdfioContentSetTextLeading(pdfio_stream_t *st, double leading) PDFIO_PUBLIC;
extern bool pdfioContentSetTextMatrix(pdfio_stream_t *st, pdfio_matrix_t m) PDFIO_PUBLIC;
extern bool pdfioContentSetTextRenderingMode(pdfio_stream_t *st, pdfio_textrendering_t mode) PDFIO_PUBLIC;
extern bool pdfioContentSetTextRise(pdfio_stream_t *st, float rise) PDFIO_PUBLIC;
extern bool pdfioContentSetTextWordSpacing(pdfio_stream_t *st, float spacing) PDFIO_PUBLIC;
extern bool pdfioContentSetTextXScaling(pdfio_stream_t *st, float percent) PDFIO_PUBLIC;
extern bool pdfioContentSetTextRise(pdfio_stream_t *st, double rise) PDFIO_PUBLIC;
extern bool pdfioContentSetTextWordSpacing(pdfio_stream_t *st, double spacing) PDFIO_PUBLIC;
extern bool pdfioContentSetTextXScaling(pdfio_stream_t *st, double percent) PDFIO_PUBLIC;
extern bool pdfioContentStroke(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentTextMoveLine(pdfio_stream_t *st, float tx, float ty) PDFIO_PUBLIC;
extern bool pdfioContentTextMoveTo(pdfio_stream_t *st, float tx, float ty) PDFIO_PUBLIC;
extern bool pdfioContentTextMoveLine(pdfio_stream_t *st, double tx, double ty) PDFIO_PUBLIC;
extern bool pdfioContentTextMoveTo(pdfio_stream_t *st, double tx, double ty) PDFIO_PUBLIC;
extern bool pdfioContentTextNextLine(pdfio_stream_t *st) PDFIO_PUBLIC;
extern bool pdfioContentTextShow(pdfio_stream_t *st, const char *s, bool new_line) PDFIO_PUBLIC;
extern bool pdfioContentTextShowJustified(pdfio_stream_t *st, size_t num_fragments, const float *offsets, const char * const *fragments) PDFIO_PUBLIC;
extern bool pdfioContentTextShowJustified(pdfio_stream_t *st, size_t num_fragments, const double *offsets, const char * const *fragments) PDFIO_PUBLIC;
// Resource helpers...
extern pdfio_obj_t *pdfioFileCreateFontObject(pdfio_file_t *pdf, const char *filename) PDFIO_PUBLIC;
@ -135,12 +135,12 @@ extern pdfio_obj_t *pdfioFileCreateICCProfileObject(pdfio_file_t *pdf, const cha
extern pdfio_obj_t *pdfioFileCreateImageObject(pdfio_file_t *pdf, const char *filename, bool interpolate) PDFIO_PUBLIC;
// Image object helpers...
extern float pdfioImageGetHeight(pdfio_obj_t *obj) PDFIO_PUBLIC;
extern float pdfioImageGetWidth(pdfio_obj_t *obj) PDFIO_PUBLIC;
extern double pdfioImageGetHeight(pdfio_obj_t *obj) PDFIO_PUBLIC;
extern double pdfioImageGetWidth(pdfio_obj_t *obj) PDFIO_PUBLIC;
// Page dictionary helpers...
extern bool pdfioPageDictAddICCColorSpace(pdfio_dict_t *dict, const char *name, pdfio_obj_t *obj) PDFIO_PUBLIC;
extern bool pdfioPageDictAddCalibratedColorSpace(pdfio_dict_t *dict, const char *name, size_t num_colors, const float *white_point, float gamma) PDFIO_PUBLIC;
extern bool pdfioPageDictAddCalibratedColorSpace(pdfio_dict_t *dict, const char *name, size_t num_colors, const double *white_point, double gamma) PDFIO_PUBLIC;
extern bool pdfioPageDictAddFont(pdfio_dict_t *dict, const char *name, pdfio_obj_t *obj) PDFIO_PUBLIC;
extern bool pdfioPageDictAddImage(pdfio_dict_t *dict, const char *name, pdfio_obj_t *obj) PDFIO_PUBLIC;

View File

@ -66,7 +66,7 @@ pdfioDictCopy(pdfio_file_t *pdf, // I - PDF file
v.value.number = lenobj->value.value.number;
}
else
v.value.number = 0.0f;
v.value.number = 0.0;
}
else if (!_pdfioValueCopy(pdf, &v, dict->pdf, &p->value))
return (NULL); // Let pdfioFileClose do the cleanup...
@ -259,7 +259,7 @@ pdfioDictGetName(pdfio_dict_t *dict, // I - Dictionary
// 'pdfioDictGetNumber()' - Get a key number value from a dictionary.
//
float // O - Value
double // O - Value
pdfioDictGetNumber(pdfio_dict_t *dict, // I - Dictionary
const char *key) // I - Key
{
@ -268,7 +268,7 @@ pdfioDictGetNumber(pdfio_dict_t *dict, // I - Dictionary
if (value && value->type == PDFIO_VALTYPE_NUMBER)
return (value->value.number);
else
return (0.0f);
return (0.0);
}
@ -600,7 +600,7 @@ pdfioDictSetNull(pdfio_dict_t *dict, // I - Dictionary
bool // O - `true` on success, `false` on failure
pdfioDictSetNumber(pdfio_dict_t *dict, // I - Dictionary
const char *key, // I - Key
float value) // I - Value
double value) // I - Value
{
_pdfio_value_t temp; // New value
@ -817,7 +817,7 @@ _pdfioDictWrite(pdfio_dict_t *dict, // I - Dictionary
if (!_pdfioFilePrintf(pdf, "/%s", pair->key))
return (false);
if (length && !strcmp(pair->key, "Length") && pair->value.type == PDFIO_VALTYPE_NUMBER && pair->value.value.number <= 0.0f)
if (length && !strcmp(pair->key, "Length") && pair->value.type == PDFIO_VALTYPE_NUMBER && pair->value.value.number <= 0.0)
{
// Writing an object dictionary with an undefined length
*length = _pdfioFileTell(pdf) + 1;

View File

@ -219,7 +219,7 @@ pdfioFileCreate(
else
{
// Default to "universal" size (intersection of A4 and US Letter)
pdf->media_box.x2 = 210.0f * 72.0f / 25.4f;
pdf->media_box.x2 = 210.0 * 72.0f / 25.4f;
pdf->media_box.y2 = 11.0f * 72.0f;
}
@ -230,7 +230,7 @@ pdfioFileCreate(
else
{
// Default to "universal" size (intersection of A4 and US Letter)
pdf->crop_box.x2 = 210.0f * 72.0f / 25.4f;
pdf->crop_box.x2 = 210.0 * 72.0f / 25.4f;
pdf->crop_box.y2 = 11.0f * 72.0f;
}

View File

@ -164,7 +164,7 @@ pdfioObjCreateStream(
{
// Need a Length key for the stream, add a placeholder that we can fill in
// later...
pdfioDictSetNumber(obj->value.value.dict, "Length", 0.0f);
pdfioDictSetNumber(obj->value.value.dict, "Length", 0.0);
}
if (!write_obj_header(obj))
@ -276,7 +276,7 @@ pdfioObjGetLength(pdfio_obj_t *obj) // I - Object
if (lenobj->value.type == PDFIO_VALTYPE_NONE)
_pdfioObjLoad(lenobj);
if (lenobj->value.type != PDFIO_VALTYPE_NUMBER || lenobj->value.value.number <= 0.0f)
if (lenobj->value.type != PDFIO_VALTYPE_NUMBER || lenobj->value.value.number <= 0.0)
{
_pdfioFileError(obj->pdf, "Unable to get length of stream.");
return (0);

View File

@ -160,7 +160,7 @@ typedef struct _pdfio_value_s // Value structure
unsigned short generation; // Generation number
} indirect; // Indirect object reference
const char *name; // Name value
float number; // Number value
double number; // Number value
const char *string; // String value
} value; // Value union
} _pdfio_value_t;

View File

@ -336,7 +336,7 @@ _pdfioValueRead(pdfio_file_t *pdf, // I - PDF file
// If we get here, we have a number...
v->type = PDFIO_VALTYPE_NUMBER;
v->value.number = (float)strtod(token, NULL);
v->value.number = (double)strtod(token, NULL);
}
else if (!strcmp(token, "true") || !strcmp(token, "false"))
{

16
pdfio.h
View File

@ -72,10 +72,10 @@ typedef enum pdfio_filter_e // Compression/decompression filters for streams
typedef struct _pdfio_obj_s pdfio_obj_t;// Numbered object in PDF file
typedef struct pdfio_rect_s // PDF rectangle
{
float x1; // Lower-left X coordinate
float y1; // Lower-left Y coordinate
float x2; // Upper-right X coordinate
float y2; // Upper-right Y coordinate
double x1; // Lower-left X coordinate
double y1; // Lower-left Y coordinate
double x2; // Upper-right X coordinate
double y2; // Upper-right Y coordinate
} pdfio_rect_t;
typedef struct _pdfio_stream_s pdfio_stream_t;
// Object data stream in PDF file
@ -106,7 +106,7 @@ extern bool pdfioArrayAppendBinary(pdfio_array_t *a, unsigned char *value, size
extern bool pdfioArrayAppendBoolean(pdfio_array_t *a, bool value) PDFIO_PUBLIC;
extern bool pdfioArrayAppendDict(pdfio_array_t *a, pdfio_dict_t *value) PDFIO_PUBLIC;
extern bool pdfioArrayAppendName(pdfio_array_t *a, const char *value) PDFIO_PUBLIC;
extern bool pdfioArrayAppendNumber(pdfio_array_t *a, float value) PDFIO_PUBLIC;
extern bool pdfioArrayAppendNumber(pdfio_array_t *a, double value) PDFIO_PUBLIC;
extern bool pdfioArrayAppendObject(pdfio_array_t *a, pdfio_obj_t *value) PDFIO_PUBLIC;
extern bool pdfioArrayAppendString(pdfio_array_t *a, const char *value) PDFIO_PUBLIC;
extern pdfio_array_t *pdfioArrayCopy(pdfio_file_t *pdf, pdfio_array_t *a) PDFIO_PUBLIC;
@ -116,7 +116,7 @@ extern unsigned char *pdfioArrayGetBinary(pdfio_array_t *a, size_t n, size_t *le
extern bool pdfioArrayGetBoolean(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
extern pdfio_dict_t *pdfioArrayGetDict(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
extern const char *pdfioArrayGetName(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
extern float pdfioArrayGetNumber(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
extern double pdfioArrayGetNumber(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioArrayGetObject(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
extern size_t pdfioArrayGetSize(pdfio_array_t *a) PDFIO_PUBLIC;
extern const char *pdfioArrayGetString(pdfio_array_t *a, size_t n) PDFIO_PUBLIC;
@ -129,7 +129,7 @@ extern unsigned char *pdfioDictGetBinary(pdfio_dict_t *dict, const char *key, si
extern bool pdfioDictGetBoolean(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern pdfio_dict_t *pdfioDictGetDict(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern const char *pdfioDictGetName(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern float pdfioDictGetNumber(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern double pdfioDictGetNumber(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern pdfio_obj_t *pdfioDictGetObject(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern pdfio_rect_t *pdfioDictGetRect(pdfio_dict_t *dict, const char *key, pdfio_rect_t *rect) PDFIO_PUBLIC;
extern const char *pdfioDictGetString(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
@ -140,7 +140,7 @@ extern bool pdfioDictSetBoolean(pdfio_dict_t *dict, const char *key, bool value
extern bool pdfioDictSetDict(pdfio_dict_t *dict, const char *key, pdfio_dict_t *value) PDFIO_PUBLIC;
extern bool pdfioDictSetName(pdfio_dict_t *dict, const char *key, const char *value) PDFIO_PUBLIC;
extern bool pdfioDictSetNull(pdfio_dict_t *dict, const char *key) PDFIO_PUBLIC;
extern bool pdfioDictSetNumber(pdfio_dict_t *dict, const char *key, float value) PDFIO_PUBLIC;
extern bool pdfioDictSetNumber(pdfio_dict_t *dict, const char *key, double value) PDFIO_PUBLIC;
extern bool pdfioDictSetObject(pdfio_dict_t *dict, const char *key, pdfio_obj_t *value) PDFIO_PUBLIC;
extern bool pdfioDictSetRect(pdfio_dict_t *dict, const char *key, pdfio_rect_t *value) PDFIO_PUBLIC;
extern bool pdfioDictSetString(pdfio_dict_t *dict, const char *key, const char *value) PDFIO_PUBLIC;

View File

@ -349,9 +349,9 @@ write_page(pdfio_file_t *pdf, // I - PDF file
// TODO: Add font object support...
pdfio_dict_t *dict; // Page dictionary
pdfio_stream_t *st; // Page contents stream
float width, // Width of image
double width, // Width of image
height; // Height of image
float swidth, // Scaled width
double swidth, // Scaled width
sheight, // Scaled height
tx, // X offset
ty; // Y offset
@ -391,22 +391,22 @@ write_page(pdfio_file_t *pdf, // I - PDF file
return (1);
fputs("pdfioImageGetWidth(): ", stdout);
if ((width = pdfioImageGetWidth(image)) > 0.0f)
if ((width = pdfioImageGetWidth(image)) > 0.0)
puts("PASS");
else
return (1);
fputs("pdfioImageGetHeight(): ", stdout);
if ((height = pdfioImageGetHeight(image)) > 0.0f)
if ((height = pdfioImageGetHeight(image)) > 0.0)
puts("PASS");
else
return (1);
swidth = 400.0f;
swidth = 400.0;
sheight = swidth * height / width;
if (sheight > 600.0f)
if (sheight > 600.0)
{
sheight = 600.0f;
sheight = 600.0;
swidth = sheight * width / height;
}