Welcome to LEAD Support Forum Login | Register | Faq  

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

Re: PDF to TIFF conversion with quality output with compression using .Net code (version 15)
Started by pvatkar at 06-19-2008 5:03. Topic has 5 replies.

Print Search « Previous Thread Next Thread »
  06-19-2008, 5:03
pvatkar is not online. Last active: 6/19/2008 10:01:51 AM pvatkar

Not Ranked
Joined on 06-19-2008
Posts 4
PDF to TIFF conversion with quality output with compression using .Net code (version 15)
Reply Quote

The code use for conversion is --

RasterSupport.Unlock(RasterSupportType.PdfRead, leadToolsKey);
   RasterCodecs.Startup();
   RasterCodecs codecs = new RasterCodecs();
   try
   {
    //RasterImage srcImage = codecs.Load(sourceFileName, 200, 300, 1 /* 1bit/pixel */, RasterSizeFlags.None, CodecsLoadByteOrder.BgrOrGray, 1, -1);
    codecs.Options.Pdf.Load.XResolution = 200;
    codecs.Options.Pdf.Load.YResolution = 300;
    codecs.Options.Load.Compressed = true;    
    RasterImage srcImage = codecs.Load(sourceFileName);    
    //codecs.Options.Save.OptimizedPalette = true;
    codecs.Save(srcImage, destinationFileName, RasterImageFormat.TifxFaxG4, 1, 1, -1, 1, CodecsSavePageMode.Overwrite);
    //codecs.Save(srcImage, destinationFileName, RasterImageFormat.Tif, 1, 1, -1, 1, CodecsSavePageMode.Overwrite);
    return true;
   }
   catch (Exception ex)
   {
    
    return false;
   }
   finally
   {
    codecs.Dispose();
    RasterCodecs.Shutdown();
   }

Then also the image quality is not proper. Please guide me.


   Report 
  06-19-2008, 11:35
Adam Boulad is not online. Last active: 7/23/2008 4:14:05 PM Adam Boulad



Top 10 Posts
Joined on 09-16-2007
Posts 403
Re: PDF to TIFF conversion with quality output with compression using .Net code (version 15)
Reply Quote
I checked your code and it seems to be correct, can you please send me the source image and the image save by our toolkits and attach them here in a ZIP or RAR file.
When you attach files here do not use the 'Preview' feature.


Adam Boulad
LEADTOOLS Technical Support

   Report 
  06-19-2008, 11:49
pvatkar is not online. Last active: 6/19/2008 10:01:51 AM pvatkar

Not Ranked
Joined on 06-19-2008
Posts 4
Re: PDF to TIFF conversion with quality output with compression using .Net code (version 15)

Attachment: ISMS.zip
Reply Quote

Hi,

Please find attached PDF document along with the output.

 

Regards,

Prashant Vatkar

 


   Report 
  06-19-2008, 12:03
pvatkar is not online. Last active: 6/19/2008 10:01:51 AM pvatkar

Not Ranked
Joined on 06-19-2008
Posts 4
Re: PDF to TIFF conversion with quality output with compression using .Net code (version 15)
Reply Quote

Hi,

We are planning to change the code to -

RasterSupport.Unlock(RasterSupportType.PdfRead, leadToolsKey);

RasterCodecs.Startup();

RasterCodecs codecs = new RasterCodecs();

try

{

codecs.ThrowExceptionsOnInvalidImages = true;

//codecs.Options.Load.Compressed = true;

CodecsImageInfo info = codecs.GetInformation(sourceFileName, true);

int pageCount = info.TotalPages;

for (int i = 1; info.TotalPages >= i; i++)

{

RasterImage image = codecs.Load(sourceFileName, info.Width, info.Height, 0, RasterSizeFlags.FavorBlack, CodecsLoadByteOrder.Bgr, i, i);

codecs.Save(image, destinationFileName, RasterImageFormat.Tif, 1, 1, -1, i, CodecsSavePageMode.Append);

}

return true;

}

catch (Exception ex)

{

//BPOpenBaseException bpEx = new BPOpenBaseException(ex.Message, ex);

//ExceptionManager.Publish(ServiceName, ServiceInstance, bpEx);

return false;

}

finally

{

codecs.Dispose();

RasterCodecs.Shutdown();

}

 

But we are getting the error at "RasterImage image = codecs.Load(sourceFileName, info.Width, info.Height, 0, RasterSizeFlags.FavorBlack, CodecsLoadByteOrder.Bgr, i, i);" as Invalid parameter passed.

Your help would appreciated.And does this change is better than the previous one.

Regards,

Prashant Vatkar


   Report 
  06-22-2008, 11:17
Adam Boulad is not online. Last active: 7/23/2008 4:14:05 PM Adam Boulad



Top 10 Posts
Joined on 09-16-2007
Posts 403
Re: PDF to TIFF conversion with quality output with compression using .Net code (version 15)
Reply Quote
Prashant,
The RasterSizeFlags.FavorBlack is only supported in Document/Medical only, so you will need to unlock Document/Medical features to use it.
Also this flag affects only 1-bit, black-and-white images and you are loading the file using the default BitsPerPixel. If you apply this flag to an image that has more than 1 bit per pixel, then the behavior is undefined and will give you an error message. If you try other flags, does it work with you?


Adam Boulad
LEADTOOLS Technical Support

   Report 
  06-23-2008, 9:02
pvatkar is not online. Last active: 6/19/2008 10:01:51 AM pvatkar

Not Ranked
Joined on 06-19-2008
Posts 4
Re: PDF to TIFF conversion with quality output with compression using .Net code (version 15)
Reply Quote

Hi,

Thanks for the reply and the code is finalized.

But we are still having issue with the quality of conversation of PDF document to TIFF. So it we are again and again changing the resolution. The quality has improved but it has increase the size. And secondly the viewer which we are using it is not viewing it properly due to the higher resolution. Please suggest us to have quality output with lesser size and proper resolution.

RasterSupport.Unlock(RasterSupportType.PdfRead, leadToolsKey);
RasterCodecs.Startup();
RasterCodecs codecs = new RasterCodecs();
try
{
codecs.ThrowExceptionsOnInvalidImages = true;
codecs.Options.Pdf.Load.XResolution = 600;
codecs.Options.Pdf.Load.YResolution = 600;
RasterImage image = codecs.Load(sourceFileName, 1, CodecsLoadByteOrder.Bgr, 1, -1);
codecs.Save(image, destinationFileName, RasterImageFormat.CcittGroup4, 1, 1, -1, 1, CodecsSavePageMode.Overwrite);    
return true;
}
catch (Exception ex)
{
 return false;
}
finally
{
codecs.Dispose();
RasterCodecs.Shutdown();
}


   Report 
Post
LEAD Support Fo... » Developer » PDF » Re: PDF to TIFF conversion with quality output with compression using .Net code (version 15)

Powered by Community Server, by Telligent Systems