Input files (PDF/key/ODT)

  • Alexandro Colorado

    Hi I wonder how this works from If I have a document and I need to sing it, I would expect that the add-on will sign the current PDF or ODF loaded on the OOo.

    My question is, why would I have to re-declare the file on the input PDF field. Can it just be an output PDF so I can just generate the signed PDF on the fly?

    A similar question is with the Keys. Why do I need to export the certificate from Firefox into a separate file, and then use it as my private key. Wouldn't be enough that OOo uses the Mozilla certificate store to generate the key/xpf file from?

    A third question (sorry to bloat this post), if i already have a certificate on my ODT, is it possible that jSignPDF can just automagically take that? Would it be too hard to access the OOo signed document and transcode it into the PDF version?

    Please comment.

  • Josef Cacek

    Josef Cacek - 2011-04-19

    There is only a "weak connection" between OOo and JSignPdf. It's able only to register the JSignPdf as a plugin but no more. (The same for second question).
    The ODT->PDF conversion can be started from command line using for instance JOD Converter. And then you can sign it with JSignPdf CLI.

  • Alexandro Colorado

    That seems a bit of a long process. Specially wondering how hard would it be to trigger the PDF export from OOo through Java.

    AFAIK the process should be something like this:
    - Connect to OOo API
    - Trigger the Current Document function. If no document is currently loaded then display Input File form, otherwise gray it out.
    - Trigger the OOo PDF transform to a /tmp/ enviromental variable
    - Apply signture
    - Output to the output path

    For the second process (Apply ODT signature) I wonder if jSignPDF can sign from CER directly as opposed to xpf.
    - Connect to the OOo API
    - Access the Current Document
    - Identify signature
    - Trigger PDF Export
    - Reapply signature to PDF
    - Send it to output

    I do have a big question since the document doesnt carry the key but the final signature, so in theory this might not work and the process would be a bit trickier.

    Access the Mozilla Keystore
    Prompt for signature
    Catch the Seal ID
    Generate PDF
    Apply signature to PDF

  • Alexandro Colorado

    I guess I couldn't stop :D
    Here is the source code files that usually applies the signature on the documents in the source code of OOo.
    reading the code, we can see that uses a Template and after verification it signs it using a UNO component. Even thought this is C++, I guess that this component is also reachable from the UNO API giving it a clear look to use signatures.
    I will try to ask my OOo friends and see how can this be possible to work together.

    /****** SignatureEngine/tryToPerform *****************************************
     *   NAME
     *  tryToPerform -- tries to perform the signature operation.
     *   SYNOPSIS
     *  tryToPerform( );
     *   FUNCTION
     *  if the situation is ready, perform following operations.
     *  1. prepares a signature template;
     *  2. calls the signature bridge component;
     *  3. clears up all used resources;
     *  4. notifies the result listener;
     *  5. sets the "accomplishment" flag.
     *   INPUTS
     *  empty
     *   RESULT
     *  empty
     *   HISTORY
     *  05.01.2004 -    implemented
     *   AUTHOR
     *  Michael Mi
     *  Email:
        if (checkReady())
            const rtl::OUString ouSignatureTemplate (
            cssu::Reference < cssxc::XXMLSignatureTemplate >
                xSignatureTemplate( mxMSF->createInstance( ouSignatureTemplate ), cssu::UNO_QUERY );
            OSL_ASSERT( );
            cssu::Reference< cssxw::XXMLElementWrapper >
                xXMLElement = m_xSAXEventKeeper->getElement( m_nIdOfTemplateEC );
            std::vector< sal_Int32 >::const_iterator ii = m_vReferenceIds.begin();
            for( ; ii != m_vReferenceIds.end() ; ++ii ) 
                xXMLElement = m_xSAXEventKeeper->getElement( *ii );
             * set the Uri binding
            xSignatureTemplate->setBinding( this );
            startEngine( xSignatureTemplate );
             * done
            clearUp( );
            m_bMissionDone = true;
    void SignatureEngine::clearUp( ) const
  • Josef Cacek

    Josef Cacek - 2011-04-22

    Thanks. Volunteers are always welcomed.
    If you can share the patch which adds the requested functionality to JSignPdf, I will be happy to commit it.

  • Alexandro Colorado

    Unfortunately that would be a huge task for someone that doesn't know Java, but I guess I could send you some snippets of code that could help the project get there.

  • Alexandro Colorado

    Here are some snippets that will get some of the steps closer, I get an abstraction of the CurrentDocument and load it as a UNO URL and the second will Convert it to another format (Export to PDF?).
    * CreateUNOCompatibleURL
    * ConvertDocument

  • Alexandro Colorado

    Ok it took a while and sorry for being flooding the forum but I got to find a reference snippet to do exactly fine-tuned PDF exports.
    The code is pretty long but is more of a reference code to do everything that the export to PDF supports. I guess this can be bootstrapped almost 80%.
    Should be copy-paste process from here.