HOW TO CONVERT A PDF FILE TO BASE64 - MIRTH CONNECT

แชร์
ฝัง
  • เผยแพร่เมื่อ 13 ม.ค. 2018
  • Encodes pdf to base64 through Mirth transformer and Java script

ความคิดเห็น • 18

  • @TheNikhilv
    @TheNikhilv 4 ปีที่แล้ว

    Man.. you have made it look so simple and easy. Thanks for making this video. Cheers!

  • @mikloskontra1981
    @mikloskontra1981 ปีที่แล้ว

    Very good explanation!

  • @prakhargoel4142
    @prakhargoel4142 4 ปีที่แล้ว

    Thanks a lot with simple demo.

  • @obscureclouds8392
    @obscureclouds8392 2 ปีที่แล้ว

    That was helpful. Thank you.

  • @klaatutwo
    @klaatutwo 13 วันที่ผ่านมา

    😀 Perfect. Worked second time ! (I had put the the wrong info in the Destination Template. It was supposed to be ${message.rawData})

  • @gloriamfloyd
    @gloriamfloyd 6 ปีที่แล้ว

    Great video

  • @SajjadKhan-BSK
    @SajjadKhan-BSK 4 ปีที่แล้ว

    Nice explanation

  • @vishvavivethan5955
    @vishvavivethan5955 2 ปีที่แล้ว

    what do you mean by "file path" in OBX segement 5.1 (used as a template)

  • @yuvansuresh8935
    @yuvansuresh8935 5 ปีที่แล้ว

    how to convert from xml with xsl file to proper xml using mirth connect?? Please tell me bro

  • @comasmusica7548
    @comasmusica7548 ปีที่แล้ว

    Simple and clear, thanks.
    But, can you make a part 2 in which you decode the encoded pdf? Obviously you need something like
    var decodedByte = new Array();
    decodedByte = FileUtil.decode(strData);
    return new Packages.java.lang.String(decodedByte);
    But somehow this does not return a copy of the original.

    • @comasmusica7548
      @comasmusica7548 ปีที่แล้ว

      "But somehow this does not return a copy of the original."
      This, however, does:
      //read the path to the pdf from OBX.5.1 and get the encoded contents of this pdf
      var pdfBytes = FileUtil.readBytes(msg['OBX']['OBX.5']['OBX.5.1'].toString());
      var encodedPdfBytes = org.apache.commons.codec.binary.Base64.encodeBase64(pdfBytes);
      var encodedPdfString = new Packages.java.lang.String(encodedPdfBytes);
      //apparently newlines must be removed
      var index = encodedPdfString.indexOf('
      ');
      while(index != -1) {
      encodedPdfString = encodedPdfString.replace('
      ', '');
      index = encodedPdfString.indexOf('
      ');
      }
      //store
      msg['OBX']['OBX.6']['OBX.6.1'] = encodedPdfString;
      //retrieve the original pdf as follows:
      //var decodedPdfBytes = org.apache.commons.codec.binary.Base64.decodeBase64(msg['OBX']['OBX.6']['OBX.6.1'].toString());
      //FileUtil.write('C:\\temp\\test_out.pdf', false, decodedPdfBytes);

  • @luisbarrera4262
    @luisbarrera4262 ปีที่แล้ว

    is it possible for you to share the xml of the channel ?

  • @ubaidurrehman1594
    @ubaidurrehman1594 2 ปีที่แล้ว

    Nicely explained ...
    Created Library with new code template for PDF to base64 conversion.
    Transformation done with sample message using (pdf --> OBX5.1 and base64 --> OBX6.1
    Assigned user defined library to channel.
    Followed same steps for Destination connector with "File" Method BUT constantly getting "error in the form for connector "file writer"".
    Also I am able to successfully test writer directory.
    Tried with the same file name "msg.hl7" as demonstrated.
    Can you please assist for the error code to resolve.

    • @comptech4us192
      @comptech4us192  2 ปีที่แล้ว

      Sure, Can you share me the exact error? Which version of Mirth are you trying with? You mean to say that the conversion to base64 is happening, however, while writing the file to the destination folder throws the error?

    • @ubaidurrehman1594
      @ubaidurrehman1594 2 ปีที่แล้ว

      @@comptech4us192 I am using Mirth Connect 3.9.0 version and I have noticed it has two additional parameters while configuring destination of the channel.
      1. Keep connection open
      2. Max Idle time (ms)
      Error: Error in the form for connector "File Writer"

    • @comptech4us192
      @comptech4us192  2 ปีที่แล้ว

      @@ubaidurrehman1594 Ok. Can you export the channel and send it to me. I can have a look into it.

  • @vishvas3472
    @vishvas3472 2 ปีที่แล้ว

    Error: File does not exist
    I used directory of pdf in the message template still it can read the pdf