cancel
Showing results for 
Search instead for 
Did you mean: 

Autocad (dwg) to pdf transformation

konsultex
Confirmed Champ
Confirmed Champ
I need to transform dwg files to pdf for read access by a group pf users in another space. I know that this is not something Alfresco does out of the box but I wonder if anyone has a suggestions. I imagine that there is some tool that can be called from the command line to do this. This leads to another question related to this problem. Since Alfresco uses OpenOffice to convert documents, I assume that I can configure dwg conversions to usat other program. Is this possible and where do I configure these things?
27 REPLIES 27

steve
Champ in-the-making
Champ in-the-making
Hi,

Our Wiki contains info on how to add your own transformer to perform what you want:
http://wiki.alfresco.com/wiki/Content_Transformations

Note, you'll need to have a tool that can perform the conversion you want to be able to plug in.

Hope this helps,

Steve

konsultex
Confirmed Champ
Confirmed Champ
Steve;

Thanks for the link. The tool I found (in case you run in Windows) is the converter from this company: http://www.autodwg.com/ It has a command line option to convert a single file. I tested the quality of the conversion and it is pretty good for the use I need it for. So now I have to see how to plug this into Alfresco.

konsultex
Confirmed Champ
Confirmed Champ
I found the code for "RuntimeExecutableContentTransformer" which is probably the one I want. My transformation command is:

d2p.exe /InFile source-file-name /OutFile destination-pdf-file-name

Can you tell me if I have to change things in the source and compile a class and/or if I just need to change these lines as in the Wiki page (http://wiki.alfresco.com/wiki/Content_Transformations#RuntimeExecutableContentTransformer😞

<entry key="Windows.*">
     <value>tidy -asxhtml -o "${target}" "${source}"</value>
</entry>

(other lines as well)

to:

<entry key="Windows.*">
     <value>d2p.exe /InFile "${target}" /OutFile "${source}"</value>
</entry>

If the latter case, are these lines supposed to go in my-transformers-context.xml and/or somewhere else?

Thanks.

wayzz1992
Champ in-the-making
Champ in-the-making
can you please tell me where you have found this file?

resplin
Elite Collaborator
Elite Collaborator
The thread you posted to is more than 7 years old. If you didn't find the class, you should suspect that the information there probably does not apply to current versions of Alfresco. You would be best off starting a new thread and asking about your goal, rather than trying to track down this specific class.

konsultex
Confirmed Champ
Confirmed Champ
After some more investigations and testing I think I found the way to do this but I am getting an error.

here is what I did:

a) C:\Alfresco\tomcat\shared\classes\alfresco\extension\mimetypes-custom-extension.xml has:

<alfresco-config area="mimetype-map">
  
   <config evaluator="string-compare" condition="Mimetype Map">
      <mimetypes>

         <mimetype mimetype="image/vnd.dwg" display="Example mimetype">
            <extension default="true">pcl</extension>
         </mimetype>

      </mimetypes>
   </config>

b) C:\Alfresco\tomcat\shared\classes\alfresco\extension\transformers-custom-context.xml has:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
 
<beans>

   <bean id="transformer.d2p" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformer" parent="baseContentTransformer">
      <property name="explicitTransformations">
         <list>
            <bean class="org.alfresco.repo.content.transform.ContentTransformerRegistry$TransformationKey" > 
      <constructor-arg><value>image/vnd.dwg</value></constructor-arg>             
                <constructor-arg><value>application/pdf</value></constructor-arg>      
            </bean>
         </list>
      </property>
   
      <property name="checkCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="commandMap">
                <map>
                    <entry key=".*">
                        <value>d2p.exe /InFile c:\001.dwg /OutFile c:\001.pdf</value>
                    </entry>
                </map>
            </property>
       <property name="errorCodes">
               <value>2</value>
            </property>
         </bean>
      </property>
     
      <property name="transformCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="errorCodes">
               <value>2</value>
            </property>
            <property name="commandMap">
                <map>
                    <entry key="Linux">
                        <value>d2p.exe /InFile '${source}' /OutFile '${target}'</value>
                    </entry>
                    <entry key="Windows.*">
                        <value>d2p.exe /InFile "${source}" /OutFile "${target}"</value>
                    </entry>
                </map>
            </property>
         </bean>
      </property>
   </bean>

</beans>

c) I verified that the line d2p.exe /InFile c:\001.dwg /OutFile c:\001.pdf works because d2p.exe is on the server PATH and 001.pdf was created. I do it this way because otherwise d2p.exe brings up a dialog box and waits for user input. Alfresco knows about my mime type because when I upload a dwg file it shows the default content type to be AutoCAD drawing.

d) I created a rule that converts *.dwg (I also tried it with mime type "AutoCAD drawing") to pdf in the same space.

Notice that I did not compile any classes.

What happens is that after I upload a dwg file right after I hit "Ok" I get an error. This is the relevant portion of it:

16:31:59,031 ERROR [org.alfresco.web.ui.common.Utils] A system error happened during the operation: Unknown Exception in Transaction.
org.alfresco.error.AlfrescoRuntimeException: Unknown Exception in Transaction.
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:292)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:155)
   at org.alfresco.web.bean.dialog.BaseDialogBean.finish(BaseDialogBean.java:120)
etc, etc, etc….

and then:

Caused by: javax.transaction.RollbackException: Transaction didn't commit: No transformation exists between mimetypes image/x-dwg and application/pdf
   at org.alfresco.util.transaction.SpringAwareUserTransaction.commit(SpringAwareUserTransaction.java:430)
   at org.alfresco.repo.transaction.RetryingTransactionHelper.doInTransaction(RetryingTransactionHelper.java:239)
   … 32 more
Caused by: org.alfresco.service.cmr.repository.NoTransformerException: No transformation exists between mimetypes image/x-dwg and application/pdf
   at org.alfresco.repo.action.executer.TransformActionExecuter.executeImpl(TransformActionExecuter.java:189)
   at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.execute(ActionExecuterAbstractBase.java:120)
   at org.alfresco.repo.action.ActionServiceImpl.directActionExecution(ActionServiceImpl.java:537)
etc, etc, etc.

So it looks like my transformation tool is not recognized.

Does anything else need to be configured?

Thanks.

konsultex
Confirmed Champ
Confirmed Champ
Sorry I made a mistake with the mime types. The correct content of the files is:

a) C:\Alfresco\tomcat\shared\classes\alfresco\extension\mimetypes-custom-extension.xml has:

<alfresco-config area="mimetype-map">
  
   <config evaluator="string-compare" condition="Mimetype Map">
      <mimetypes>

         <mimetype mimetype="image/x-dwg" display="Desenho AutoCAD">
            <extension default="true">dwg</extension>
         </mimetype>

      </mimetypes>
   </config>


b) C:\Alfresco\tomcat\shared\classes\alfresco\extension\transformers-custom-context.xml has:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
 
<beans>

   <bean id="transformer.d2p" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformer" parent="baseContentTransformer">
      <property name="explicitTransformations">
         <list>
            <bean class="org.alfresco.repo.content.transform.ContentTransformerRegistry$TransformationKey" > 
      <constructor-arg><value>image/x-dwg</value></constructor-arg>             
                <constructor-arg><value>application/pdf</value></constructor-arg>      
            </bean>
         </list>
      </property>
   
      <property name="checkCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="commandMap">
                <map>
                    <entry key=".*">
                        <value>d2p.exe /InFile c:\001.dwg /OutFile c:\001.pdf</value>
                    </entry>
                </map>
            </property>
       <property name="errorCodes">
               <value>2</value>
            </property>
         </bean>
      </property>
     
      <property name="transformCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="errorCodes">
               <value>2</value>
            </property>
            <property name="commandMap">
                <map>
                    <entry key="Linux">
                        <value>d2p.exe /InFile '${source}' /OutFile '${target}'</value>
                    </entry>
                    <entry key="Windows.*">
                        <value>d2p.exe /InFile "${source}" /OutFile "${target}"</value>
                    </entry>
                </map>
            </property>
         </bean>
      </property>
   </bean>

</beans>

This configuration creates the pdf file.

I still have a problem though because the pdf file is empty (0 bytes). If I run the d2p.exe tool manually I get the correct pdf. It's just inside Alfresco that it fails somewhat.

I would like to look at a log to see what is going on. Any pointers of how to make Alfresco log DEBUG for the transformes?

Thanks.

konsultex
Confirmed Champ
Confirmed Champ
Well, I figured out what was wrong.

The line:

d2p.exe /InFile '${source}' /OutFile '${target}'

can not have the sigle quotation marks. I was not aware what they were for but I think that Alfresco sends them to the tool which does not like that. So I remved them and now my conversion works perfectly.

Like this:

d2p.exe /InFile ${source} /OutFile ${target}

I hope this can help anybody that has a similar problem.

alexr
Champ in-the-making
Champ in-the-making
While testing the evaluation versions of both p2d.exe (http://anydwg.com/)  and acs.exe (http://www.autodwg.com/), I found out
that I could not find "text" within the converted pdf's (in Adobe Reader).
The drawings contain text entries.
Now this could be the restraint for the evaluation version, but has anybody encountered an issue with text inside pdf from converted AutoCAD drawings?

- When transforming to pdf and configuring the transformation as described in this thread, how then will the text inside the pdf drawing be indexed?
- If not automatically then how should one configure the DWG to PDF transformation and then Full Text index the resulting PDF file?
- Will the converted pdf be automatically used in the Share pdf2swf transformation? (for the Flash document viewer)?


Regards,

Alex

PS: Has anybody found an equivalent (command line) conversion tool for MicroStation drawings (dgn)?