Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting a .txt file to a .tif or pdf to not allow editing.

Status
Not open for further replies.

strangeryet

Programmer
Jul 8, 2004
159
US
I have an application that creates invoices in a .txt file format that can be emailed. Is there away to create this file in a format that can not be edited, like a .tif or .pdf in VB? Or is there away to convert these files to .tif or pdf files? Thanks for you help.
 
Yes but you don't want to write the filter yourself. Go to Adobe's site and take a look at their Acrobat SDK. You need an ActiveX/COM object that you can manipulate with VB.

Another option is to create a digital sig of the text file... that won't prevent changes but you will be able to KNOW if they've been changed.

If someone is trying to cheat you then they can change a PDF or TIFF... by converting it to one of those formats you just get rid of the low hanging fruit.
 
Hi Strangeryet:

I agree with Sheco, but would like to make an additional suggestion.

Have you considered creating your own file viewer, especially for the invoices? The invoice creating program could use encryption (with one key) to store the invoice image. Then, using a file viewer that you supply, the client can view and print the invoice, but not edit the invoice. The file viewer would use the matching encryption key to decode the invoice image.


For the keys, do not encode them hard anywhere. Instead, have each program calculate the keys. This makes it harder, but not impossible, to break the viewer.

Sorry, but I don't have any sample code, but a search on encryption techniques should help. Also, store the file as a binary file, not an TIF, PDF, TXT or similar format.

Cassandra
[shadeshappy]
 
Thanks for the input.
I'm not familar with writing filters. When you say 'filter'
is this like creating my own file type?
 
Maybe filter wasn't the correct word. What I meant was that, unless you have a LOT of time on your hands its better not to write your own file conversion code if there is something already available that accomplishes the same task.

For example you could learn the internal file structure of a PDF file and then construct it yourself, byte by byte... or you could use the tools available from Adobe.

Anyone with access to Adobe Acrobat could still edit your PDF files... the full version I mean, not just the reader.

So it depends on how secure you need to be. Creating your own file format and distributing your own reader is good because you control how your documents are viewed... but this is still subject to reverse engineering.

You could kick it up a notch and do your own format under public key encryption but really before you do encryption of any sort you have to figure out if it might not be easier to go at authentication in anotehr way.

What I mean is that you could go all "Fort Knox Mode" on your data files but if your invoice can be spoofed with a Xerox machine and a bottle of "white-out" then you've got to get a handle on the human element first. The chain is only as strong as the weakest link yada yada.
 
strangeryet,

If your users have MS Office you may try;

Create a PictureBox (could be invisible) the same size as the paper used to print the invoice on, AutoRedraw = True

Print the invoice on the picturebox.

Copy the image property of the PictureBox to the ClipBoard.

Startup an instance of Ms Word

Paste the contents of the ClipBoard into a waiting Word doc.

Make the Word doc Readonly and Password protect it if you need to.

Email the Word doc

The initial image of the (A4) report will be over 1MB but Word automatically compresses embedded images, so a doc wrapping a single A4 page comes down to about 50k.

regards Hugh,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top