Link to home
Start Free TrialLog in
Avatar of dvplayltd
dvplayltdFlag for Bulgaria

asked on

I have a problem with programmatically open a PDF file with C# with my WinForm

Dear experts

I have a problem with programmatically open a PDF file with C# with my WinForm application. Please help.

 First – all has been fine 2 years, the problem is NOW appear. My application download a PDF file and open it to help the user faster review it. Today I get the error  Insufficient data for image from PDF , and the title image is missing, also some text. I understand, that the problem is with adobe Reader, however my application will be used from many customers and I want to avoid ask them to update to latest reader. I even try to change the image with PNG (I read that the problem is with J2PG, I have such image but the error is still here.
 What is strange, that on my computer if I open manually the downloaded PDF file all is OK. So my question is – what is different when I open my file with code? How to change code, so the open to be the same as the manually? It is something with starting environment…

Here you my code for open the file:
                System.Threading.Thread.Sleep(500);
                System.Diagnostics.Process myProc = null;
                try
                {
                    myProc = System.Diagnostics.Process.Start(@sFile);
// myProc.Close(); - DO I NEED THIS CODE ?
                }
                catch (Exception ex)
                {
                    g.Msg("The file has been downloaded, but can't be open!\r\nPlease make sure that you have the needed software installed on your computer /Word, Excel or Addobe PDF Reader/ to open this file!\n\\n\rr" + ex.Message, "Error in the file opening!",PSTaskDialog.eSysIcons.Error);
                }
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

no need to call myProc.Close().
can u post the code that download the pdf url?
ASKER CERTIFIED SOLUTION
Avatar of dvplayltd
dvplayltd
Flag of Bulgaria image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dvplayltd

ASKER

I found a solution on my own.