This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Tuesday, December 29, 2009 12:19:25 AM(UTC)
Groups: Registered
Posts: 17
Hello, I'm trying to save a tif file in pdf format.
With the pdf plugin I'have'n any problem, the problem is the quality of the file.
When I save my tif file in pdf format i have a loss of quality picture.
Maybe I have an error of my code?
This is the code:
Leadtools.Codecs.RasterCodecs _codecs = new Leadtools.Codecs.RasterCodecs();
MemoryStream fStream = new MemoryStream(pFileBuf);
Leadtools.Codecs.CodecsImageInfo info = _codecs.GetInformation(fStream, true);
Leadtools.RasterImage _image = _codecs.Load(
fStream,
0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray,
1, info.TotalPages);
string imageName = "TEST"+ _Ext_Pdf_;
string imageLocalPath = _workPath + imageName;
RasterImageFormat _format = RasterImageFormat.RasPdfG4;
_codecs.Save(_image, imageLocalPath, _format, info.BitsPerPixel,
firstPage, lastPage, 1, Leadtools.Codecs.CodecsSavePageMode.Overwrite);
I have also tried with the lead tools demo program to write a datamatrix into a pdf file and save this pdf. Also in this case I have a lossy image quality to the pdf final file. Why?
thank you very much.
Andrea
#2
Posted
:
Tuesday, December 29, 2009 4:02:07 AM(UTC)
Groups: Registered, Tech Support
Posts: 1,326
Was thanked: 1 time(s) in 1 post(s)
Andrea,
To improve the quality of the result PDF image, try to set the codecs.Options.Pdf.Save.UseImageResolution property to true before saving the image.
Also, what is the exact raster PDF format that you use when you save the PDF image?
Thanks,
Maen Badwan
LEADTOOLS Technical Support
#3
Posted
:
Thursday, December 31, 2009 12:07:29 AM(UTC)
Groups: Registered
Posts: 17
Indeed my problem occours when I save a pdf from an image loaded from another pdf.
I use this portion of code:
Leadtools.RasterSupport.Unlock(RasterSupportType.PdfRead, "xxxxxxxx");
Leadtools.RasterSupport.Unlock(RasterSupportType.PdfSave, "xxxxxxxx");
Leadtools.Codecs.RasterCodecs.Startup();
Leadtools.Codecs.RasterCodecs _codecs = new Leadtools.Codecs.RasterCodecs();
Leadtools.Codecs.CodecsImageInfo info = _codecs.GetInformation(inputFileName1, true);//inputfilename1 is a PDF file with an image A4 size 300dpix300dpi
_codecs.Options.Load.Format = RasterImageFormat.RasPdfG4;
Leadtools.RasterImage bcImage = _codecs.Load(inputFileName1,0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray,1, info.TotalPages);
SizeF paperSize = new SizeF(bcImage.Width, bcImage.Height);
RasterImageGdiPlusGraphicsContainer gContainer = bcImage.CreateGdiPlusGraphics();
Graphics g = gContainer.Graphics;
SolidBrush labelBrush = new SolidBrush(Color.Black);
RectangleF labelBorder = new RectangleF(labelLocation, labelSize);
Pen p = new Pen(labelBrush);
g.DrawRectangle(p, Rectangle.Round(labelBorder));
labelBrush.Dispose();
gContainer.Dispose();
_codecs.Options.Pdf.Save.UseImageResolution = true;
_codecs.Save(bcImage, outputFileName1, info.Format, info.BitsPerPixel, 1, info.TotalPages, 1, CodecsSavePageMode.Overwrite);
The result is a pdf file with the original image that is ginned.
What can I do?
thank you very much!
Andrea
PS: In the previous post You ask me what is the exact format that I use when I save the pdf image, You intend the RasterImageFormat.RasPdfG4; ?
#4
Posted
:
Thursday, December 31, 2009 1:04:26 AM(UTC)
Groups: Registered, Tech Support
Posts: 1,326
Was thanked: 1 time(s) in 1 post(s)
The problem might be caused by low resolution used when loading the PDF file. To increase it to 300 DPI, set the RasterCodecs.Options.Pdf.Load.XResolution and RasterCodecs.Options.Pdf.Load.YResolution properties to 300 before you load the source image.
Thanks,
Maen Badwan
LEADTOOLS Technical Support
#5
Posted
:
Monday, January 18, 2010 3:50:29 AM(UTC)
Groups: Registered
Posts: 17
I have tried to set the image quality with:
_codecs.Options.Load.XResolution = 300;
_codecs.Options.Load.YResolution = 300;
but the result is the same.
The curious thing is that when i execute this part of code:
Leadtools.RasterImage bcImage = _codecs.Load(
inputFileName1,
0, Leadtools.Codecs.CodecsLoadByteOrder.BgrOrGray,
1, info.TotalPages);
SizeF paperSize = new SizeF(bcImage.Width, bcImage.Height);
I see that the bcImage width is 597 and bcImage.height is 841 but
the original width of image file is 1654 and original height is 2339.
The original pdf file size is 72KB but the final pdf converted with leadtools is 1472KB.
What's wrong???
Thanks.
Andrea
#6
Posted
:
Monday, January 18, 2010 4:41:48 AM(UTC)
Groups: Registered, Tech Support
Posts: 1,326
Was thanked: 1 time(s) in 1 post(s)
You are setting the wrong properties, which do not affect the PDF file.
Instead of _codecs.Options.Load.XResolution and _codecs.Options.Load.YResolution properties, you need to set the _codecs.Options.Pdf.Load.XResolution and _codecs.Options.Pdf.Load.YResolution properties to 300 before loading the PDF file.
About the size of the PDF file, please open a new thread and explain the issue. In the new thread, mention if the original file is an image PDF or a text document (searchable) PDF. If you're not sure, and attach a sample PDF in a ZIP or RAR file.
Thanks,
Maen Badwan
LEADTOOLS Technical Support
#7
Posted
:
Monday, January 18, 2010 5:10:15 AM(UTC)
Groups: Registered
Posts: 17
Yes with the option.pdf.lod.Xresolution = 300 the quality is ok, but I have the size problem.
I will open a new thread.
Thanks
Andrea
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.