Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

convertir PDF en base64

Spoiler
Bonjour,
Je souhaite pouvoir classer des PDF issus d'un scanner, dans des répertoires spécifiques d'après un mot clé. A priori, il me faut d'abord convertir le pdf en base64.
Auriez-vous une solution à m'apporter ?
Merci
--------------------- I am not very good in English but I try it--------------------
Hello,
I wish dispatch PDF's files from my scanner, in specific directories. It would seems, I have to convert the pdf's file to base64.
Would you have a solution to bring me ?
Thanks
Labels (2)
11 Replies
TRF
Creator III
Creator III

Here a post I replied with an other pseudo https://community.talend.com/t5/Design-and-Development/resolved-Upload-Attachment-into-Salesforce/m-...
The purpose was to convert documents to Base64 before to upload them into Salesforce. Anyway, you get the piece of code you need for your use case.
I don't know why you have to convert files, maybe you could explain this point.
Try to continue in english, it's better for sharing reason.
If it's not possible, send me a PM in french.
Anonymous
Not applicable
Author

Hi TRF,

thank's for your answer.

Maybe it's not necessary to convert files to base64. In fact, i just want recup pdf's files from my scanner and dispath them in proper repertories.
Tehe base64 conversion was for use Elasticsearch which associated with Kibana allowed to read the pdf and thus to detect a key word.
I'm open to any solution...

TRF
Creator III
Creator III

So you have a method to convert your files to Base64 with my previous answer.
It the result is as expected, don't forget to give your feedback and to mark your case as solved.
Anonymous
Not applicable
Author

Hi TRF,

 

I haven't seen your answer, I start on the Forum 🙂

I followed your explanations, but I have this error : Syntax error, insert "Dimensions" to complete Expression

 

I think it's due to a bad format but I dont find where ?

 

 

Bellow, the impacted code :
row3.Parent_ID = row2.Parent_ID; // Related object's Id
row3.Name = row2.Name; // The document's name such as xxxxx.docx or yyyyyy.xlsx or anything else
row3.ContentType = row2.ContentType; // Object's name such as Account, Task and so on
row3.Body = null; // The place to put the conversion result
// In this case, I iterate over the input directory using a tFileList
File file = new File((String)globalMap.get("tFileList_1_CURRENT_FILEPATH"));
try {
// Read file
documentInFile = new FileInputStream(file);
byte documentData[] = new byte;
documentInFile.read(documentData);
// Convert bytes array to Base64 string to fill Body field
row3.Body = new String(Base64.encodeBase64(documentData));
System.out.println("+++ File converted "+(String)globalMap.get("tFileList_1_CURRENT_FILEPATH"));
} catch (FileNotFoundException e) {
row3.conversionCode = "FILE_NOT_FOUND";
row3.conversionMessage = "File not found "+(String)globalMap.get("tFileList_1_CURRENT_FILEPATH");
System.out.println("*** File not found "+(String)globalMap.get("tFileList_1_CURRENT_FILEPATH")+"\n"+e);
} catch (IOException ioe) {
row3.conversionCode = "CONVERSION_ERROR";

 






TRF
Creator III
Creator III

Not sure the problem comes from this piece of Java code. To be sure of what's wrong, click on the Code tab, then click on the red cross in the right margin. You will be redirected on the source line where the error is located. Move the mouse pointer over the symbol representing the compilation error to discover the full error message.
Anonymous
Not applicable
Author

Hi TRF,

Here my job with an error message on the Sleep.

I don't understand how tSalesForceOutput works ?

 

 

0683p000009M0Xi.jpg0683p000009M0a3.png

 

Furthermore, here the message after running job :

0683p000009M0bF.jpg 0683p000009M0bK.jpg

TRF
Creator III
Creator III

Not the same subject.

Anyway, the message is clear, you cannot have a main row after a component which doesn't have an input row.

Change the main row after tSleep by an onComponentOk trigger.

Anonymous
Not applicable
Author

I can only attach main row after tSleep. I don't know why !!

I think I have to learn English before use Talend successfully 🙂

TRF
Creator III
Creator III

Because the component (tJavaRow) requires an input row.

So you have to change for a tJava (I assume you don't have anything you expect from a row in the actual tJavaRow component).

If you are not sure of how to write what you expect, you can write your message in english + french (I'm french), but english is better on this forum (elsewhere this is an other question).