andrwo
andrwo

Reputation: 63

CFDOCUMENT creates PDF with different MD5 hashes for same input

I am using CFDOCUMENT to create a PDF in CF9.0.1. However with the same input each time I generate a new PDF using CFDOCUMENT the MD5 hash seems to be different.

Test code is simple:

<cfdocument name=FileData1 format="PDF" localurl="yes" pagetype="A4"><h3>I am happy!</h3></cfdocument>
<cfdocument name=FileData2 format="PDF" localurl="yes" pagetype="A4"><h3>I am happy!</h3></cfdocument>
<cffile ACTION="write" FILE="C:\happy1.pdf" OUTPUT=#FileData1# ADDNEWLINE=NO NAMECONFLICT="Override">
<cffile ACTION="write" FILE="C:\happy2.pdf" OUTPUT=#FileData2# ADDNEWLINE=NO NAMECONFLICT="Override">

Both files produced have different MD5 file-hash although both PDF looks exactly the same. I have a user requirement where if the file is the same to ignore regeneration of PDF, so does anyone know how to force CF9 to generate the same PDF with same MD5 hash (bit similarity) if given the same input?

I ran a HxD Hex File Compare and found that the file differs in three sections:

Thanks for your help in advance!

Upvotes: 4

Views: 1034

Answers (1)

Dale Fraser
Dale Fraser

Reputation: 4748

They will never be the same.

The timestamp /CreationDate(D:20110927152929+08'00')

The creationDate is a timestamp of when it was created, thus unless you create it at the same second every time, it wont be the same.

You might be able to modify the pdf and remove or modify this bit.

Or use a different method to determine if you should create the pdf, creating it to md5 compare the results seems like a waste of processing power.

Upvotes: 5

Related Questions