Quotes .....

There never was, there never will be, a man who is always praised, or a man who is always blamed....

Thursday, August 9, 2012

LoadFile() Method of the object AxAcroPDFLib.AxAcroPDF can't use to load already open PDF files

The Question:

I have made a Windows desktop application(in C#) where I use the AxAcroPDF control to display a pdf-file on a form when user give the path of the pdf and click a button. Pdf-file is located in one network shared file folder where multiple users can access it.
(I use the LoadFile() Method of the object AxAcroPDFLib.AxAcroPDF)

This is working fine. But when the same pdf file which my applications try to open is already opened using Adobe Reader then my application can’t open the same pdf file.

If the PC my application installed has Adobe reader 7 then application throw the error message as "System.ApplicationException Failed Loading PDF Template" and application freeze.

And if the application running PC’s having Adobe Reader X installed then no error will appear but the loading screen appears for ever.

But opening the same pdf simultaneously in two or more PC using my application works perfect.

The Answer:

Solution01 - Not recommended (this sometimes not work)

After desperate search on forums I couldn't find a proper solution as I was expecting to find. But to avoid the program get crash, I put a check before loading the pdf.

bool PDFAvailable = axAcroPDF1.LoadFile(PDFPath.ToString());

If the Boolean variable 'PDFAvailable' return true I'll load the PDF like below. Else a proper message is thrown.
bool PDFAvailable = axAcroPDF1.LoadFile(PDFPath.ToString());                                                if (PDFAvailable == true)                        {                            axAcroPDF1.LoadFile(PDFPath.ToString());                            axAcroPDF1.setShowToolbar(false); //disable pdf toolbar.                            axAcroPDF1.Enabled = true;                                                    }                        else                        {                            MessageBox.Show("Selected PDF Template Is Locked By Another Application.", ""Test Application"", MessageBoxButtons.OK, MessageBoxIcon.Information);                                                    }
Solution02 - Recommended (Work fine for Adobe Acrobat Reader X)

I found a workaround in this
Rather than LoadFile() we can use the "src" property of the control.
The drawback is Adobe acrobat Reader 7 doesn't support src property.

Solution03 - Recommended for any version

Copy the pdf file to client PC temp folder and then read :-)


Anonymous said...

Great beat ! I would like to apprentice while you amend
your web site, how can i subscribe for a blog website?
The account aided me a acceptable deal. I had been
tiny bit acquainted of this your broadcast offered bright clear concept
Also visit my homepage ebook writing

Anonymous said...

This excellent website truly has all the information I needed about this subject
and didn't know who to ask.
Have a look at my web page ; cheap reborns

Anonymous said...

Great blog here! Also your site loads up very fast! What
web host are you using? Can I get your affiliate link
to your host? I wish my site loaded up as fast as yours lol
Also visit my blog - funnymariogames

Anonymous said...

It's difficult to find educated people about this subject, however, you seem like you know what you're talking about!

Feel free to surf my site social media

Anonymous said...

I have been surfing on-line more than 3 hours nowadays, yet I by no means found any attention-grabbing article like yours.
It is pretty price sufficient for me. In my opinion,
if all site owners and bloggers made good content
as you probably did, the internet might be a lot more helpful than ever before.
my webpage - Hesperia Victorville

Anonymous said...

Malaysia & Singapore & brunei best online blogshop
for wholesale & quantity korean add-ons, earrings, earstuds, locket, rings, bangle, hair & trinket accessories.
Promotion 35 % wholesale price cut. Ship Worldwide
Also visit my web-site :: validição científica

Anonymous said...

I wanted to thank you for this excellent read!! I definitely enjoyed
every little bit of it. I have you saved as a favorite to check out new things you post…
my web site > ikea furniture assembly service

Anonymous said...

I enjoy reading through an article that can make people think.
Also, thanks for allowing for me to comment!

My weblog free weights

Anonymous said...

I get pleasure from, cause I found just what I used to be having a look for.

You have ended my four day lengthy hunt! God Bless you man.
Have a nice day. Bye

Feel free to visit my site :: Natural Anxiety Remedies Tips

Anonymous said...

you are in reality a excellent webmaster. The web site loading pace is amazing.

It sort of feels that you are doing any unique trick.
Furthermore, The contents are masterwork. you've performed a fantastic task in this subject!

Here is my web page :: Vexxhost Testimonials

Anonymous said...

Peculiar article, just what I wanted to find.

Check out my blog minecraft vps hosting cheap

Anonymous said...

I've been surfing online more than three hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my opinion, if all web owners and bloggers made good content as you did, the internet will be much more useful than ever before.

Here is my site: http://www.69videosporno.net/horny-blondie-fucking-into-both-vaginas/