From f417a2512191156cd1f74aba8246f7bb0db4e7f5 Mon Sep 17 00:00:00 2001 From: vididvidid Date: Wed, 1 Oct 2025 08:17:17 +0000 Subject: [PATCH] block usage of incompatible operators and functions, for example the pdfioFileCreateFontObjFromBase function, the use of transparency in pdfioFileCreateImageObjFrom..., and so forth. --- pdfio-content.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pdfio-content.c b/pdfio-content.c index 81e1134..c3009ce 100644 --- a/pdfio-content.c +++ b/pdfio-content.c @@ -1700,6 +1700,11 @@ pdfioFileCreateFontObjFromBase( pdfio_dict_t *dict; // Font dictionary pdfio_obj_t *obj; // Font object + if (pdf && pdf->pdfa != _PDFIO_PDFA_NONE) + { + _pdfioFileError(pdf, "Base fonts are not allowed in PDF/A files; use pdfioFileCreateFontObjFromFile to embed a font."); + return (NULL); + } if ((dict = pdfioDictCreate(pdf)) == NULL) return (NULL); @@ -2064,6 +2069,12 @@ pdfioFileCreateImageObjFromData( }; + if (pdf && (pdf->pdfa == _PDFIO_PDFA_1A || pdf->pdfa == _PDFIO_PDFA_1B) && alpha) + { + _pdfioFileError(pdf, "Images with transparency (alpha channels) are not allowed in PDF/A-1 files."); + return (NULL); + } + // Range check input... if (!pdf || !data || !width || !height || num_colors < 1 || num_colors == 2 || num_colors > 4) return (NULL); @@ -2730,6 +2741,12 @@ copy_png(pdfio_dict_t *dict, // I - Dictionary depth = png_get_bit_depth(pp, info); color_type = png_get_color_type(pp, info); + if ((dict->pdf->pdfa == _PDFIO_PDFA_1A || dict->pdf->pdfa == _PDFIO_PDFA_1B) && (color_type & PNG_COLOR_MASK_ALPHA)) + { + _pdfioFileError(dict->pdf, "PNG images with transparency (alpha channels) are not allowed in PDF/A-1 files."); + goto finish_png; + } + if (color_type & PNG_COLOR_MASK_PALETTE) num_colors = 1; else if (color_type & PNG_COLOR_MASK_COLOR)