# Check corrupt PDF file

**URL:** <https://rubytalk.org/t/check-corrupt-pdf-file/44011>\
**Category:** ruby-talk\
**Created:** [24 January 2008 09:01 UTC](https://rubytalk.org/t/check-corrupt-pdf-file/44011 "2008-01-24T09:01:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Flaming\_Flamingo](https://avatars.discourse-cdn.com/v4/letter/f/6bbea6/32.png) [@Flaming\_Flamingo](https://rubytalk.org/u/Flaming_Flamingo)\
**Post date:** [24 January 2008 09:01 UTC](https://rubytalk.org/t/check-corrupt-pdf-file/44011/1 "2008-01-24T09:01:55Z")

</div>

Hi,  
I'm making a script that check's if a pdf file is corrupt or not.

require 'watir'  
require 'win32ole'  
require 'pdf/writer'

oPDF = WIN32OLE.new('AcroExch.App')  
oPDFDoc = WIN32OLE.new('AcroExch.AVDoc')

if (oPDFDoc.Open("c:\\tempcor.pdf","") !=true)  
&nbsp;&nbsp;&nbsp;puts "false" #problem...press enter  
else  
&nbsp;&nbsp;&nbsp;puts "true"  
end

Now, the problem is, when opening a corrupt pdf, a message appears in  
Adobe.  
Does anyone know how to check it without the message or get the message  
out of the way?

cheers.  
FF

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

---

<div class="post-metadata">

**Author:** ![Flaming\_Flamingo](https://avatars.discourse-cdn.com/v4/letter/f/6bbea6/32.png) [@Flaming\_Flamingo](https://rubytalk.org/u/Flaming_Flamingo)\
**Post date:** [24 January 2008 09:36 UTC](https://rubytalk.org/t/check-corrupt-pdf-file/44011/2 "2008-01-24T09:36:56Z")

</div>

oke, fixed it with this:

Before opening the pdf I call this def:

def startClicker(waitTime = 3)  
&nbsp;&nbsp;sleepTime = waitTime  
&nbsp;&nbsp;puts "in clicker"  
&nbsp;&nbsp;@wsh = WIN32OLE.new('Wscript.Shell')  
&nbsp;&nbsp;@wsh.SendKeys('{enter}')  
end

Any better idea's are welcom (don't like sendkeys solutions that  
much...)

> **···**
>
> --  
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
