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

Document does not conform to PDF/A. #750

Open
maxirobaina opened this issue Feb 5, 2024 · 2 comments
Open

Document does not conform to PDF/A. #750

maxirobaina opened this issue Feb 5, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@maxirobaina
Copy link

maxirobaina commented Feb 5, 2024

Describe the Bug

Hi,

I ran into a problem with pdf generated with xhtml2pdf. The result pdf does not conform to PDF/A.
This creates a problem when using Acrobat Reader. The document has two digital signatures and Acrobat Reader shows me that one of the signatures is broken.

I use https://www.pdf-online.com/osa/validate.aspx to validate pdf structure an all pdf generated with xhtml2pdf
have the same problem.

Details:
Validating file "LD-00010026__6985966014674491277-f.pdf" for conformance level pdf1.3
The value of the key file specification dictionary must be an indirect object.
The document does not conform to the requested standard.
The document doesn't conform to the PDF reference (missing required entries, wrong value types, etc.).
The document does not conform to the PDF 1.3 standard.

Minimal Example to Reproduce

Function to generate pdf from a django template.
The pdf is generated from a django view.

def render_pdf(content, context_dict={}):
    template = Template(content)
    html = template.render(Context(context_dict))
    result = BytesIO()
    pdf = pisa.CreatePDF(BytesIO(html.encode("utf-8")), result)
    if not pdf.err:
        return result
    return None

Example template

<!DOCTYPE html PUBLIC >

<html lang="es">

<head>
  <meta charset="UTF-8">
  <meta name="title" content="TEST">

	<style type="text/css">
		tr,table,thead,tbody,tfoot,tr,th,td,p { font-family:"Times New Roman"; font-size: 14px; }

    @page {
      size: a4 portrait;
      border: 0pt solid white;
      margin-right: 0cm;
      margin-left: 0cm;
      margin-top: 1cm;
      margin-bottom: 1cm;

      @frame sign_frame {
        top: 21.8cm;
        left: 5.6cm;
        height: 4cm;
        width: 4cm;
        -pdf-frame-content: sign_content;
        /* -pdf-frame-border: 1;    for debugging the layout */
      }
    }
	</style>
</head>

<body>

<table align="left" cellspacing="0" border="0">
	<tbody>
	<tr>
    <td colspan="2" align="right"></td>
    <td colspan="15" align="right" style="padding: 3px;">
        <!--  guarda superior -->
        <img src="static/img/header.jpg" style="width: 27cm; height: 4cm" >
    </td>
	</tr>
  <tr>
    <td colspan="13"></td>
    <td colspan="4" align="right" style="padding: 1px 40px 1px 10px;">
      <font size="15px"><b> {{ lega.nro_lega }} </b></font>
    </td>
  </tr>
  </tbody>
</table>

<table>
    <tbody>
      <tr>
        <td valign="top" colspan="3">
          <br/>
          <div style="width: 4cm;">
            <div id="escudo">
                 <!-- escudo cfna -->
            </div>

            <div id="qr_local" class="escudo" style="margin-left: 50px;">
              <img src="data:image/jpeg;base64,{{ qr.qr_local }}" width="3cm"/>
            </div>
          </div>
        </td>

        <td colspan="11" valign="top" style="border-top: 0.8px solid black; border-left: 0.8px solid black; border-bottom: 0.8px solid black; border-right: 0px none; margin-left: 1px;">
          <p style="text-align: justify; padding: 10px; line-height: 250%">

            text.... 

            {{ city }}, {% now "j \d\e F \d\e Y" %}.-
          </p>

          {% if debug %}
          <p style="padding: 0 10px 0 10px;"> <b> BORRADOR </b> </p>
          {% endif %}

          <div id="sign_content">
            <img src="static/img/firma.png" style="width: 3.81cm; height: 2.52cm;">
          </div>
      </td>

      <td valign="top" align="left" style="padding-right: 3px;">
        <!-- guarda lateral derecha -->
        <img src="static/img/nq/legas/lateral.jpg" style="margin-right: 0cm; border-top: 0.8px solid black; border-bottom: 0.8px solid black;" height="1000" valign="top">
      </td>
    </tr>

    <tr style="padding: 1em;">
      <td colspan="2"> </td>
      <td colspan="13" style="margin-left: 22px;">
        Para verificar el documento ingresar a <a href="{{ cvs_url }}"> {% url 'app:verify' %} </a>
        <br>
        CVS: {{ hash_code }}
      </td>
    </tr>
  </tbody>
</table>

</body>
</html>

System Information

OS version: Ubuntu 20.04
Python version: 3.7
XHTML2PDF version: 0.2.11

@maxirobaina maxirobaina added the bug Something isn't working label Feb 5, 2024
@stefan6419846
Copy link
Contributor

Please provide some more details and corresponding example code on how you generate your PDF file.

@stefan6419846
Copy link
Contributor

Where does xhtml2pdf claim that it would generate PDF/A compliant documents? If ever, this is a feature request and not a bug, while I consider this something which might be something which should be done after generating the PDF with xhtml2pdf in a separate step/with a separate tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants