Pàgina inicial > Hacking Invenio > WebSubmit Internals > Stamping fulltextes |
The WebSubmit File Stamper library (websubmit_file_stamper.py) let you stamps your PDFs.
def stamp_file(options): """The driver for the stamping process. This is effectively the function that is responsible for coordinating the stamping of a file. @param options: (dictionary) - a dictionary of options that are required by the function in order to carry out the stamping process. The dictionary must have the following structure: + latex-template: (string) - the path to the LaTeX template to be used for the creation of the stamp itself; + latex-template-var: (dictionary) - This dictionary contains variables that should be sought in the LaTeX template file, and the values that should be substituted in their place. E.g.: { "TITLE" : "An Introduction to Invenio" } + input-file: (string) - the path to the input file (i.e. that which is to be stamped; + output-file: (string) - the name of the stamped file that should be created by the program. This is optional - if not provided, a default name will be applied to a file instead; + stamp: (string) - the type of stamp that is to be applied to the input file. It must take one of 3 values: - "first": Stamp only the first page of the document; - "all": Apply the stamp to all pages of the document; - "coverpage": Add a "cover page" to the document; + layer: (string) - the position of the stamp in the layers of the file. Is one of the following values: - "background": stamp applied to the background layer; - "foreground": stamp applied to the foreground layer; + verbosity: (integer) - the verbosity level under which the program is to run; + skip-metadata: (boolean) - whether to skip copying the metadata or not; So, an example of the returned dictionary would be something like: { 'latex-template' : "demo-stamp-left.tex", 'latex-template-var' : { "REPORTNUMBER" : "TEST-2008-001", "DATE" : "15/02/2008", }, 'input-file' : "test-doc.pdf", 'output-file' : "", 'stamp' : "first", 'layer' : "background", 'verbosity' : 0, 'skip-metadata' : False, } @return: (tuple) - consisting of two strings: 1. the path to the working directory in which all stamping-related files are stored; 2. The name of the "stamped" file; @Exceptions raised: (InvenioWebSubmitFileStamperError) exceptions may be raised or propagated by this function when the stamping process fails for one reason or another. """
See websubmit_file_stamper API for a complete API description.