How to add comments to PDF header programmatically?

User Case: Has anyone had any success with adding additional information to a PDF file? We have an electronic medical record system which produces medical documents for our users. In the past, those documents have been Print-To-File (.prn) files which we have fed to a system that displayed them as part of an enterprise medical record.Now the hospital's enterprise medical record vendor wants to receive the documents as PDF, but still wants all of the same information stored in the header.Honestly, we can't figure out how to put information into a PDF file that doesn't break the PDF file.Here is the start of one of our PDF...

6 0 obj  
   /Type /XObject  
   /Subtype /Image  
   /BitsPerComponent 8  
   /Width 854  
   /Height 130  
   /ColorSpace /DeviceRGB  
   /Filter /DCTDecode  
   /Length 17734>>  

In our PRN files, we would insert information like this:

%MRN% TEST000001
%ACCT% TEST0000000000001
%DATE% 01/01/2009^16:44
%DOC_TYPE% Clinical
%DOC_NUM% 192837475

My question is, can I insert this information into a PDF in a manner which allows the document server to perform post-processing, yet is NOT visible to the doctor who views the PDF?

Suggestion: Actually you can insert this information into a PDF. Any line in a PDF file that starts with a percent sign is a comment and as such ignored (the first two lines of the PDF actually are comments as well). So you can pretty much insert your information into the PDF as you did into the PRN. However, PDF format works with byte position references, so if you insert data into a finished PDF file, this will push the rest of the data away from their original position and thus break the file. You can also not append it to the file, because a PDF file has to end with specific information.


You could insert your data right before these three lines. The byte position of the "startxref" part is never referenced anywhere, so you won't break anything if you push this final part towards the end. Please note there is no check summing, signing or encryption going on of those PDF or else adding comment will fail. That would make things more complicated.As Javier pointed out correctly, you can also just add your data to the end and just add a copy of the three lines to the end of that. Boils down to the same thing, but it's a little easier.

When you need to use some toolkit to add comment or some additional information to PDF file, maybe you can have a free trial of this software PDF Editor OCX Control (ActiveX). By this software, you can add comment, annotation casually. During the using, if you have any question, please contact us as soon as possible.

VN:F [1.9.20_1166]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: 0 (from 0 votes)

Random Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Verify Code   If you cannot see the CheckCode image,please refresh the page again!