Announcement

Collapse
No announcement yet.

Read a PDF Write a PDF with Encryption

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Read a PDF Write a PDF with Encryption

    We're trying to get around a specific limitation of SQL Reporting Services not being able to generate an encrypted PDF report through a subscription.

    So I thought I might turn to my favorite tool, Mirth to see if I can bridge the gap.

    Wanted to see if anyone is doing anything like this before I go digging in...

    I have a File Reader looking for a PDF file. That file is NOT encrypted. I'd like to read the PDF, then using a Document Writer, write the PDF back out with encryption, then grab the encrypted file and email it.

    I don't think it will be too difficult.

    Any thoughts or suggestions would be appreciated

  • #2
    I think the only issue that I might have is going from a File Reader to the Document Writer.

    All data types are set to Delimited Text (source and destination)

    Source, File Reader, File Type is Binary

    Destination, Document Writer, PDF, Encrypted.

    I'm using the Document Writer instead of File Writer in order to leverage the Encrypted function.


    Here is the only thing I need advice on... The File Reader is reading the PDF file as a binary, which I assume is encoded. The Document Writer is expecting text, so I have to decode/transform it.

    I don't have a good grip on file types/data streams/PDF formats, etc so I'm not sure which direction I need to encode/decode.

    Comment


    • #3
      PDFs are just XMLs. I would suggest googling how to encode XML in javascript.

      Here is one that might work...

      http://www.w3schools.com/jsref/jsref...icomponent.asp

      Comment


      • #4
        I'll take a look at that.

        Isn't the issue though, that the File Reader isn't reading the PDF as an encodable format first? It's reading it as a binary file, so shouldn't I first have to address that?

        Comment


        • #5
          You can set the File Reader to read as text.

          Comment


          • #6
            Yeah, that doesn't actually read the contents in.

            The File Reader reads the file itself NOT the contents inside the file.

            It is possible, using iText, to read the PDF file contents, but it's tricky and doesn't always work well with formatting.

            I don't think the Document Writer is going to work, which really sucks.

            I'm just trying to find a way to take an existing PDF and put a password on it for protection during email.

            Comment


            • #7
              http://www.evermap.com/javascriptsecurity.asp

              Comment


              • #8
                Since you did not specify, I will assume you're working with the latest version (3.1.0), which includes PDFBox for PDF encryption.

                The Document Writer takes in HTML to generate a PDF; it doesn't take in an existing PDF and write it back out. You could use iText or something to convert the existing PDF into HTML and then use the Document Writer from that point. But that is a lot of work, and would be prone to inconsistencies in formatting, etc.

                I've created a code template for this however: http://www.mirthcorp.com/community/f...3440#post43440
                Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

                Nicholas Rupley
                Work: 949-237-6069
                Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


                - How do I foo?
                - You just bar.

                Comment


                • #9
                  Originally posted by briandhuff View Post
                  The File Reader reads the file itself NOT the contents inside the file.
                  That is incorrect. The File Reader reads the contents of a file. The Text vs. Binary options merely tells the receiver to either encode the contents with a specific charset, or to encode it into a Base64 string. Either way, the encoded data is the contents of that file.
                  Step 1: JAVA CACHE...DID YOU CLEAR ...wait, ding dong the witch is dead?

                  Nicholas Rupley
                  Work: 949-237-6069
                  Always include what Mirth Connect version you're working with. Also include (if applicable) the code you're using and full stacktraces for errors (use CODE tags). Posting your entire channel is helpful as well; make sure to scrub any PHI/passwords first.


                  - How do I foo?
                  - You just bar.

                  Comment


                  • #10
                    That's what I need.

                    I was actually heading down this path: http://itextpdf.com/examples/iia.php?id=219

                    and going to build my own, but yours is so much nicer.

                    Thank you!

                    Comment

                    Working...
                    X