Welcome to LEAD Support Forum Login | Register | Faq  

    LEAD Support Forum
  Resource to find answers and post technical questions about LEAD products.
Search    
   

Invalid File Format when loading a PDF
Started by PPCUBAN at 11-13-2008 18:47. Topic has 12 replies.

Print Search « Previous Thread Next Thread »
  11-13-2008, 18:47
PPCUBAN is not online. Last active: 11/13/2008 11:41:53 PM PPCUBAN

Top 500 Posts
Joined on 07-08-2008
Posts 10
Invalid File Format when loading a PDF
Reply Quote
hello.

I have an app that loads a PDF.

here the steps

if (file.Contains(".pdf"))
{
//// set codecs load options
rasterCodecs.Options.Load.XResolution = 150;
rasterCodecs.Options.Load.YResolution = 150;
rasterCodecs.Options.Pdf.Load.XResolution = 150;
rasterCodecs.Options.Pdf.Load.YResolution = 150;
rasterCodecs.Options.Pdf.Load.GraphicsAlpha = 1;
rasterCodecs.Options.Pdf.Load.TextAlpha = 1;

mainImage = rasterCodecs.Load(file,0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, -1);
//mainImage = rasterCodecs.Load(file);

}

Here is the problem. it worked at the beginning. Then it stopped working for no reason and throws that exception. it's actually frustrating. I haven't changed any line of code in my app.
Any help?

Thank you
   Report 
  11-13-2008, 18:53
PPCUBAN is not online. Last active: 11/13/2008 11:41:53 PM PPCUBAN

Top 500 Posts
Joined on 07-08-2008
Posts 10
Re: Invalid File Format when loading a PDF
Reply Quote
I couldnt edit my post. Im adding some extra notes.

this is my using section.

using Leadtools;
using Leadtools.Codecs;
using Leadtools.WinForms;
using Leadtools.Codecs.Tif;
using Leadtools.Codecs.Cmp;
   Report 
  11-14-2008, 13:54
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: Invalid File Format when loading a PDF
Reply Quote
What is the file version of Leadtools.dll that you are using?

Which DLLs do you have referenced/copied into your Application directory?

Is this your development machine or deployment machine?

Greg Ross
LEADTOOLS Technical Support
   Report 
  11-17-2008, 15:36
PPCUBAN is not online. Last active: 11/13/2008 11:41:53 PM PPCUBAN

Top 500 Posts
Joined on 07-08-2008
Posts 10
Re: Invalid File Format when loading a PDF
Reply Quote
1. Leadtools.dll version is 15.0.0.0. Runtime Version is v2.0.50727.

2. Leadtools.dll
Leadtools.Codecs.Cmp
Leadtools.Codecs.Fax
Leadtools.Codecs.Tif
Leadtools.ImageProcessing.Color
Leadtools.Winforms
Leadtools.Twain

3. My working environment is
- Windows Vista
- Framework 3.5 SP1
- Visual Studio 2008
This is a development machine.

   Report 
  11-18-2008, 8:48
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: Invalid File Format when loading a PDF
Reply Quote
In the v15/16 .NET libraries, Invalid File Format means one of three things:

1.
The file is actually invalid or there's a problem with the codec.  If you can load the same file in one of our pre-compiled demos that ship with the toolkit, then this is not the case.

2.
You did not call RasterCodecs.StartUp

3.
You are not including as a reference or copying to your EXE's directory the necessary codecs dll for the file format.  These dlls follow the naming convention of Leadtools.Codecs.???.dll (e.g. Leadtools.Codecs.Tif.dll).  To learn which dlls are necessary for a particular file format, please read the help file article "Files to be Included With Your Application" and find the row for the file format in question.

If you have any more questions or problems, please let me know.
Greg Ross
LEADTOOLS Technical Support
   Report 
  11-18-2008, 10:05
PPCUBAN is not online. Last active: 11/13/2008 11:41:53 PM PPCUBAN

Top 500 Posts
Joined on 07-08-2008
Posts 10
Re: Invalid File Format when loading a PDF
Reply Quote
Hello.
thank you for your response.

OK. I went to
C:\Program Files\LEAD Technologies\LEADTOOLS 15\Examples\DotNet\CS\PdfCompDemo

I ran the sample. The i tried to open the pdf document we are dealing with. it throw me a different error.
PDF Capability is required.

I remember when i added in my project Leadtools.Codecs.Pdf i started having the same error.

What's next step?


   Report 
  11-18-2008, 10:23
PPCUBAN is not online. Last active: 11/13/2008 11:41:53 PM PPCUBAN

Top 500 Posts
Joined on 07-08-2008
Posts 10
Re: Invalid File Format when loading a PDF
Reply Quote
I am gonna send you the whole piece of code.

Just so you know. We are creating a viewer/processor for pdf, tiff and jpeg. These three types of file are those we mainly use in our office. They are save in bulk to an unified processing folder so we iterate thru every file in our folder and depending on the format (file type) we load it differently.

here is the code.


////PDF VERSION
File.SetAttributes(file, FileAttributes.ReadOnly);
File.GetCreationTime(file);
if (file.Contains(".pdf"))
{
//// set codecs load options
rasterCodecs.Options.Load.XResolution = 150;
rasterCodecs.Options.Load.YResolution = 150;
rasterCodecs.Options.Pdf.Load.XResolution = 150;
rasterCodecs.Options.Pdf.Load.YResolution = 150;
rasterCodecs.Options.Pdf.Load.GraphicsAlpha = 1;
rasterCodecs.Options.Pdf.Load.TextAlpha = 1;
//mainImage = rasterCodecs.Load(file,0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray, 1, -1);
mainImage = rasterCodecs.Load(file);
}

////TIFF VERSION
if (file.Contains(".tif") || file.Contains(".tiff"))
mainImage = rasterCodecs.Load(file, 2, 0, 1, -1);

////JPG VERSION
if (file.Contains(".jpg") || file.Contains(".jpeg"))
{
rasterCodecs.Options.Load.XResolution = 300;
rasterCodecs.Options.Load.YResolution = 300;
mainImage = rasterCodecs.Load(file, 8, CodecsLoadByteOrder.BgrOrGray, 1, -1);
}

   Report 
  11-18-2008, 10:42
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: Invalid File Format when loading a PDF
Reply Quote
The other error, PDF Capability Required, means that you need to unlock support for PdfRead.  If you do not have this unlock code, please contact our sales department.

Greg Ross
LEADTOOLS Technical Support
   Report 
  11-18-2008, 11:09
PPCUBAN is not online. Last active: 11/13/2008 11:41:53 PM PPCUBAN

Top 500 Posts
Joined on 07-08-2008
Posts 10
Re: Invalid File Format when loading a PDF
Reply Quote
Wow. Well, honestly i thought we had purchased the full license with all the toys since PDF is one of the most used file type in our company.

The funny thing is that i would bet my house and car that last week i worked with PDF files in my system. not to mention that i never used Leadtools.Codecs.Pdf before in those days.

Any possible reason or explanation why this happened please? before i go crazy and start strongly to believe i was taken by Aliens last week and all that happened in a dream :)


   Report 
  11-18-2008, 11:17
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: Invalid File Format when loading a PDF
Reply Quote
You may have purchased the PDF plugin, but you still have to sign licensing agreements in order to get the unlock codes.  When you first install the licensed version of the SDK, it uses a NAG kernel which displays a nag message but doesn't require anything to be unlocked so that you can develop the application and sign the agreements later.  Perhaps you unknowingly started using the NONAG version which requires unlocking.

Greg Ross
LEADTOOLS Technical Support
   Report 
  11-18-2008, 11:47
PPCUBAN is not online. Last active: 11/13/2008 11:41:53 PM PPCUBAN

Top 500 Posts
Joined on 07-08-2008
Posts 10
Re: Invalid File Format when loading a PDF
Reply Quote
Ok. our Tech Support department is going to call your sales department to find out about this. i remember we purchased the full package version 1.4 and then we upgraded. That's my recollection.

Aside from that, is there any reasonable explanation to why i was able to see PDF documents before. Now you got me confused. I am 99.9% sure that i tested last week several PDFs.

Thank You
   Report 
  11-18-2008, 11:50
PPCUBAN is not online. Last active: 11/13/2008 11:41:53 PM PPCUBAN

Top 500 Posts
Joined on 07-08-2008
Posts 10
Re: Invalid File Format when loading a PDF
Reply Quote
I have another problem related to memory use of the RasterImage and RasterImageViewer object. Where is the best section to post this?

Thank you
   Report 
  11-18-2008, 11:53
GregR is not online. Last active: 1/2/2009 9:03:27 AM GregR



Top 10 Posts
Joined on 05-31-2006
In House
Posts 1,811
Re: Invalid File Format when loading a PDF
Reply Quote
 PPCUBAN wrote:
Ok. our Tech Support department is going to call your sales department to find out about this. i remember we purchased the full package version 1.4 and then we upgraded. That's my recollection. Aside from that, is there any reasonable explanation to why i was able to see PDF documents before. Now you got me confused. I am 99.9% sure that i tested last week several PDFs.

There's only two possible reasons that you used to be able to load PDF files before (assuming you were always using the same version of the SDK):

1.
You were unlocking support for PdfRead

2.
You were using either the NAG or Evaluation version of Leadtools.dll.

 PPCUBAN wrote:
I have another problem related to memory use of the RasterImage and RasterImageViewer object. Where is the best section to post this?

Either the .NET or the Image Display forums would be appropriate.  As long as you make a new post for new issues, that's all we really care about =).

Greg Ross
LEADTOOLS Technical Support
   Report 
Post
LEAD Support Fo... » Developer » PDF » Invalid File Format when loading a PDF

Powered by Community Server, by Telligent Systems