cancel
Showing results for 
Search instead for 
Did you mean: 

How to write metadata into document

giluka
Champ in-the-making
Champ in-the-making
Hi all,
i want to copy all metadata i've added or updated into an alfresco node (related to a document) to document itself.
In this manner when document will be downloaded it will contains all metadata like in alfresco.

Is it possibile to do that ?

Thanks.
10 REPLIES 10

rjohnson
Star Contributor
Star Contributor
What document types? How do you want to see it in the document. Will the document have content or just metadata?

giluka
Champ in-the-making
Champ in-the-making
The documents are .doc or .pdf with a content. The metadata i want to insert into them are all metadata i can see in Alfresco (in node object).

Thanks !

rjohnson
Star Contributor
Star Contributor
You can use Apache POI for .doc and PDFBox for PDF to update the documents own "properties". However that is not "out-of-the-box" so you will need to do some Java development and .doc and PDF only have a limited number of proeprties fields that you could populate.

Try this add-on. It may do what you need. http://addons.alfresco.com/addons/metadata-writer

pavo83
Champ in-the-making
Champ in-the-making
Hi,

I used the metadata-writer add-on on my local alfresco and I changed original metadata of my document and, also, I created new ones (for doc and docx, but not for pdf).
However, I am looking for a way to insert new info in my .doc file content.
e.g.: I have a document where I need to insert an information from one property of my custom model, in a specific point of the content itself.

Is there a way to do so using the metadata-writer?

mrogers
Star Contributor
Star Contributor
Yes probably.  

Could you add a macro to your docx before uploading to alfresco that reads the doc properties which will be injected by the metadata writer.  

Or use the POI libraries directly to author a doc or docx file.

pavo83
Champ in-the-making
Champ in-the-making
Thanks for the answer.

Is there some example on how to get the content of the doc, uploaded in Alfresco, with a java class, I suppose throught some filestream method, that will be used by the POI libraries to modify it?

scopio
Champ in-the-making
Champ in-the-making
Hi pavo83
I am trying to get metadatawriter working without any luck. Can you please post the solution. I am trying to map my metadate to word document properties.

pavo83
Champ in-the-making
Champ in-the-making
Hi Scopio,

I modified the metadata-writer-service-context.xml (inside src->main->config->alfresco->extension->model) and created a bean to map my metadata to a word document properties.
I could not modify the content of the word document, but through word I can add standard word properties into the content of the document itself.

This is how I modified the xml:

   <bean id="metadata-writer.service"
      class="org.redpill.alfresco.module.metadatawriter.services.impl.MetadataServiceImpl"
      init-method="register" parent="metadata-writer.abstract.service">
      <property name="serviceName" value="metadata-writer.service" />
      <property name="converters">
         <list></list>
      </property>
      <property name="mappings">
         <props>
            <prop key="Description">cm:description</prop>
            <prop key="category">ne:aziendaDiAppartenenza</prop>
            <prop key="Author">cm:author</prop>
            <prop key="Title">cm:title</prop>

            <prop key="Subject">cm:modifier</prop>
            <prop key="Keywords">ne:mittenteMail</prop>
            <prop key="Producer">cm:creator</prop>
            
            <prop key="Fattura">ne:numFattura</prop>
            <prop key="Stato2">ne:ufficioCompetenza</prop>
         </props>
      </property>
   </bean>


As you can see, I modified the property "mappings" adding some props throught key and the metadata form my model that I wanted to return to the document.
The Italian key value are custom properties added by me in the word document.

I hope this could help.

scopio
Champ in-the-making
Champ in-the-making
Hi Pavo83, Thank you very much for your reply.

I cannot find this folder structure(src->main->config->alfresco->extension->model). Please see below for how I installed it.

I downloaded metadatawriter-3.4.12.jar file from metadatawriter project website and dropped the file into /opt/alfresco-4.2.e/tomcat/webapps/share/WEB-INF/lib folder and restarted Alfresco share.

then I exposed 'Metadata Writer' aspect on alfresco share. That is all i've done. Now I cannot see metadata-writer-service-context.xml file nor above file structure.

Please instruct me how to do this.

Regards,
Scopio





Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.