• Merge PDF

  • Nous essayons de faire OpenKM aussi intuitif que possible, mais tout avis est bienvenu.
Nous essayons de faire OpenKM aussi intuitif que possible, mais tout avis est bienvenu.

Moderator: dedisoft

Forum rules: Avant de poser une question, merci de regarder la documentation du wiki ou d'utiliser la fonction recherche du forum. Et rappelez vous que nous n'avons ni boule de cristal ni possibilité de lire dans les pensées, aussi pensez à spécifier quelle version d'OpenKM vous utilisez ainsi que la version du navigateur web et du système d'exploitation. Pour de plus amples informations lisez Comment reporter un bug efficacement (anglais).
 #43179  by jimac
 
Hello Jllort, :D

Is this possible?? :

When 2 documents have a specific property group assigned, can the property group be also taken when the 2 documents is merged?
wherein when the 2 document is merged, the property group is automatically taken. (therefore the merged pdf will have 2 property group assigned)

Thanks
 #43193  by jllort
 
First of all, the merge PDF feature is only available at professional version. About inherit metadata, can be done something in the direction you propose, but is necessary create an specific logic for your case. Here are the cases
A and B have not metadata
A and B have both metadata ( something to thinking about )
A or B have metadata -> then can inherit directly
 #43198  by jimac
 
jllort wrote:First of all, the merge PDF feature is only available at professional version. About inherit metadata, can be done something in the direction you propose, but is necessary create an specific logic for your case. Here are the cases
A and B have not metadata
A and B have both metadata ( something to thinking about )
A or B have metadata -> then can inherit directly
Yep, that are the possible cases.
Is it possible..
--
I have merge PDF even though Im using openKM community..
Please see the attached picture.
Attachments
33.png
33.png (43.46 KiB) Viewed 30077 times
 #43211  by jllort
 
The best option will be create an event for it ( automation ) and link in the event the logic. If you want I can guide you in the changes should be done in source code.
 #43221  by jimac
 
jllort wrote:The best option will be create an event for it ( automation ) and link in the event the logic. If you want I can guide you in the changes should be done in source code.
In changing the source code, I need to download openKM dev and configure it?
That means, I will be using a new openkm right?
 #43237  by jllort
 
You will use an OpenKM with small modification. If you share with us the modification and we think is general purpose one, we will introduce in the main code. But althought we do not doing it, you can periodicaly update your local code with remote code changes and be updated.
 #45920  by jorseng
 
Hi jllort,
I am very much interested in automation to merge pdf based on the property group and then remove the files which has been merged to reduce duplicate. Can you guide me to make the necessary changes in the source code?
 #45942  by jorseng
 
Dear jllort,

Noted with Thanks! :lol:
 #46032  by jorseng
 
Hi,

I am testing out the merge method in PDFUtils package. I search documents based on metadata, when there are 2 documents with the same property value, i merge them together using PDFUtils.merge(token,docid,dstpath).
The following is the results, somehow the files merged but without content.
Merged with no content.png
Merged with no content.png (13.34 KiB) Viewed 29312 times
The following is my code
Code: Select all
// Automation for PDF merging

package com.openkm.automation.action;
import java.util.Map;
import com.openkm.api.OKMRepository;
import com.openkm.util.PDFUtils;
import com.openkm.api.*;
import com.openkm.module.db.stuff.DbSessionManager;
import com.openkm.automation.AutomationUtils;
import com.openkm.dao.bean.Automation;
import com.openkm.automation.Action;
import net.xeoh.plugins.base.annotations.PluginImplementation;

    String systemToken = DbSessionManager.getInstance().getSystemToken();
    // Lookup for MRN, if same merge
    String uuid = "52cc9baf-f981-4e87-add5-94115ad037e5";
	String group = "okg:medicalrecord";
	List pg = OKMPropertyGroup.getInstance().getProperties(systemToken,uuid,group);

for (Object x : pg) {
    int y =1;
    String pName ="okp:medicalrecord.mrn";
    String gName ="okg:medicalrecord";
    
    if(x.name.contains(pName)){
    	print(x.value);
        searchResult = OKMSearch.getInstance().getDocumentsByPropertyValue(systemToken,gName,pName,x.value);
        //print(searchResult);
        List<String> docMerge = new ArrayList<String>();
        
        if (searchResult !=null) {
            for(Object doc : searchResult) {
                print(doc.path);
                docMerge.add(new String (doc.path));
                }
        print(docMerge.size());
        Object lastDoc = searchResult.get(searchResult.size()-1);
		
		if(docMerge.size()>1) {
        	//print("more than 1");
        	int endIndex = lastDoc.path.lastIndexOf("/");
        	
        	if(endIndex != -1){
        		String folderPath = lastDoc.path.substring(0,endIndex);
        		//String newDocName = folderPath + lastDoc.path.substring(endIndex) + " Merged";
        		String newDocName = folderPath + docMerge.get(0).substring(endIndex) + " " + docMerge.get(1).substring(endIndex).replace("/","");
        		print(newDocName);

        		PDFUtils.merge(systemToken,docMerge,newDocName);
    		}
        }
        } 
      	
      	print(docMerge);
	}
        //Search for documents with the same MRN.
        //get attachment
    }
Am i using the merge() function wrong?
 #46035  by jorseng
 
It seems that after merging, the file extension becomes octet-stream instead of pdf using the merge() function.
I tried changing the new document name with extension .pdf seems to not affect any changes on the MIME-type.
I suspect the preview isn't working for the pdf simply because of the extension.

In the merge() code, has this line
Code: Select all
docOut = FileUtils.createTempFileFromMime(MimeTypeConfig.MIME_PDF);
but resulting file doesn't seem to follow this.
 #46047  by jllort
 
The dstPath variable of the method merge ends with .pdf ? might be this is the reason why is not working
 #46053  by jorseng
 
Yup you are right!
I added .pdf to the filename, it is working now.
Thanks a lot jllort!

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.