Solved

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

Posted on 2013-06-20
3
969 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

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

777 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