Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF/UA and WCAG compliance issue with embedded files (attachments) #66

Open
osnard opened this issue Jul 29, 2024 · 1 comment
Open

Comments

@osnard
Copy link

osnard commented Jul 29, 2024

I need to create WCAG and PDF/UA compliant PDF from HTML. Therefore I have followed the instructions on https://github.com/danfickle/openhtmltopdf/wiki/PDF-Accessibility-(PDF-UA,-WCAG,-Section-508)-Support

It already works really well! Thanks for this awesome library!

I then added attachment files as described here: https://github.com/danfickle/openhtmltopdf/wiki/Embedding-downloadable-files

Unfortunately, this causes the following errors in the validation tool I am using (PAC 2021):

Issue 1

image
Sorry, german version of PAC. It basically reads "PDF document not readable (Operator 'CS' not allowed in this current state".

I have checked the PDF file in an editor, but did not find any occurrence of CS.

Issue 2

image
This one reads: "Annotation not within a 'Annot' structure element"

30 0 obj
<<
/Type /Annot
/Subtype /FileAttachment
/FS 320 0 R
/AP 321 0 R
/AF [320 0 R]
/Rect [49.612503 603.1875 160.3125 619.05]
/F 4
/BS 322 0 R
/StructParent 15
>>
endobj

I guess /StructParents 0 in

9 0 obj
<<
/Type /Page
/MediaBox [0.0 0.0 595.275 841.875]
/Parent 2 0 R
/Contents 25 0 R
/Resources 26 0 R
/Annots [27 0 R 28 0 R 29 0 R 30 0 R 31 0 R 32 0 R 33 0 R 34 0 R 35 0 R 36 0 R
37 0 R 38 0 R 39 0 R 40 0 R 41 0 R 42 0 R]
/StructParents 0
/Tabs /S
>>
endobj

may cause the issue, but I don't know how to solve it.

The <a download=... element is only nested in body > p, without any further semantics. Maybe that's the issue.

<html>
    ...
    <body>
        ...
       <p>...</p>
       <p>
            <a ... href="attachments/Some_attachment.docx" ... download="" ...>Some attachment link</a>
        </p>
        ...

Any ideas or hints? If you can help me understand the issue, I may be able to provide a patch, in case it is related to the library code rather than to my code.

(originally posted on danfickle#977)

@osnard
Copy link
Author

osnard commented Jul 30, 2024

Found some additional info regarding those errors:

OPERANDS OPERATOR DESCRIPTION
CS
(PDF 1.1) Set the current color space to use for stroking operations. The operand
name must be a name object. If the color space is one that can be specified by a
name and no additional parameters (DeviceGray, DeviceRGB, DeviceCMYK, and
certain cases of Pattern), the name may be specified directly. Otherwise, it must
be a name defined in the ColorSpace subdictionary of the current resource dictionary (see Section 3.7.2, “Resource Dictionaries”); the associated value is an
array describing the color space (see Section 4.5.2, “Color Space Families”).
Note: The names DeviceGray, DeviceRGB, DeviceCMYK, and Pattern always identify the corresponding color spaces directly; they never refer to resources in the
ColorSpace subdictionary.
The CS operator also sets the current stroking color to its initial value, which depends on the color space:
• In a DeviceGray, DeviceRGB, CalGray, or CalRGB color space, the initial color
has all components equal to 0.0.
• In a DeviceCMYK color space, the initial color is [0.0 0.0 0.0 1.0].
• In a Lab or ICCBased color space, the initial color has all components equal to
0.0 unless that falls outside the intervals specified by the space’s Range entry,
in which case the nearest valid value is substituted.
• In an Indexed color space, the initial color value is 0.
• In a Separation or DeviceN color space, the initial tint value is 1.0 for all colorants.
• In a Pattern color space, the initial color is a pattern object that causes nothing
to be painted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant