11-18-2008, 10:23
|
PPCUBAN
Joined on 07-08-2008
Posts 10
|
Re: Invalid File Format when loading a PDF
|
 
 
|
|
|
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
|
|
|
|