Solved

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

Posted on 2013-06-20
3
973 Views
Last Modified: 2013-06-25
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);
                }
0
Comment
Question by:dvplayltd
  • 2
3 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 39261936
no need to call myProc.Close().
can u post the code that download the pdf url?
0
 

Accepted Solution

by:
dvplayltd earned 0 total points
ID: 39262253
The C# code that make FTP download is rather complicated and use external library. Anyway, the problem is not with it, I change the picture in PDF with .GIF and the problem is not show. Look like this will be the solution ..the bug is due to Addobe Error, but I need clear solution as it will work on 100+ computers ...
0
 

Author Closing Comment

by:dvplayltd
ID: 39274140
I found a solution on my own.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question