dvplayltd
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.Sl eep(500);
System.Diagnostics.Process myProc = null;
try
{
myProc = System.Diagnostics.Process .Start(@sF ile);
// 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.eSy sIcons.Err or);
}
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.Sl
System.Diagnostics.Process
try
{
myProc = System.Diagnostics.Process
// 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.eSy
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I found a solution on my own.
can u post the code that download the pdf url?