LEADTOOLS Support
Document
Document SDK Questions
"Feature not supported", PdfCompressor.Write
This topic and its replies were posted before the current version of LEADTOOLS was released and may no longer be applicable.
#1
Posted
:
Wednesday, June 4, 2008 10:26:29 PM(UTC)
Groups: Registered
Posts: 5
Hi.
I'm evaluating the LT15 PDF plugin for C# within a WPF application and I'm having trouble writing out a PDF document. I've read elsewhere that this can be due to missing assembly references, however I am sure I've included all that are relevant. Because I am adding JPG images to the PDF, I have referenced:
- Leadtools.dll
- Leadtools.Codecs.dll
- Leadtools.Codecs.Cmp.dll
- Leadtools.Codecs.Pdf.dll
- Leadtools.Pdf.dll
My code is:
RasterSupport.Unlock(RasterSupportType.PdfAdvanced, "");
RasterSupport.Unlock(RasterSupportType.PdfRead, "");
RasterSupport.Unlock(RasterSupportType.PdfSave, "");
// Load an image RasterCodecs.Startup(); RasterCodecs codecs = new RasterCodecs(); codecs.ThrowExceptionsOnInvalidImages = true; PdfCompressor pdfCompressor = new PdfCompressor(); PdfCompressorOptions pdfCompressorOptions = new PdfCompressorOptions(); PdfCompressorCompressionTypes compressionTypes = new PdfCompressorCompressionTypes(); //Sets compression types needed for each segment compressionTypes.Comp1Bit = PdfCompressor1BitCompression.Zip1Bit; compressionTypes.Comp2Bit = PdfCompressor2BitCompression.Lzw2Bit; compressionTypes.CompPicture = PdfCompressorPictureCompression.JpgPic; compressionTypes.QFactor = 2; //Flags for used compression types should be set compressionTypes.Flags = EnabledCompressionsFlags.EnableOneBit | EnabledCompressionsFlags.EnableTwoBit | EnabledCompressionsFlags.EnablePicture; pdfCompressor.SetCompression(compressionTypes); int pageNum = 1; DirectoryInfo dInfo = Directory.CreateDirectory(InfoProvider.OutputPath); FileInfo[] jpgFiles = dInfo.GetFiles(Path.GetFileNameWithoutExtension(InfoProvider.OutputFile) + "_*.jpg"); foreach (FileInfo jpgFile in jpgFiles) { using (RasterImage image = codecs.Load(jpgFile.FullName)) { pdfCompressor.Insert(image); //pdfCompressor.SegmentImage += new EventHandler<PdfCompressorSegmentImageEventArgs>(pdfCompressor_SegmentImage_PdfDocument); } jpgFile.Delete(); } string filePath = InfoProvider.OutputPath + Path.GetFileNameWithoutExtension(InfoProvider.OutputFile) + ".pdf"; pdfCompressor.Write(filePath); pdfCompressor.Dispose(); RasterCodecs.Shutdown();
#2
Posted
:
Thursday, June 5, 2008 7:29:21 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
You are
correct that normally, 'Feature not supported' exceptions are generated when
your application is missing some DLLs.
Please
check 2 things:
1. If
you run our pre-built C# Main demo shipped with the toolkit and open any image,
can you save it as PDF using the File => Save menu?
2. If
you use codecs.Save() instead of pdfCompressor.Write() to save the image as
PDF, does it work?
#3
Posted
:
Thursday, June 5, 2008 3:22:34 PM(UTC)
Groups: Registered
Posts: 5
Hi Adnan
- The CSPdfComp demo app works correctly, and I've looked at the code but I can't find anything I've missed - except that I have a WPF application and the demo is a WinForms app. This isn't likely to cause a problem is it?
- Codecs.Save also works correctly, however these is a huge difference in file size, even using RasterImageFormat.RasPdfJpeg.
Regards, Andrew
#4
Posted
:
Monday, June 9, 2008 4:22:57 AM(UTC)
Groups: Guests
Posts: 3,022
Was thanked: 2 time(s) in 2 post(s)
Can you
try to isolate the exception "Feature not supported" that you get in
a small test project (not your full application) so I can reproduce this issue
here. If you want to send the project, please put it in a ZIP or RAR file.
About
file size, you can use RasPdfLzw format instead of RasPdfJpeg to reduce the
file size.
#5
Posted
:
Wednesday, July 29, 2009 10:10:07 AM(UTC)
Groups: Registered
Posts: 25
I fixed this issue by removing the LeadTools.Codecs.Pdf dll from the project.
#6
Posted
:
Thursday, July 30, 2009 6:52:23 AM(UTC)
Groups: Registered
Posts: 25
Scratch my last response...the trick for me was
1. Unlocking the PDFAdvanced
2. Adding the following filters to my project (since the PDFCompressor uses those types)
Normal
0
false
false
false
EN-US
ZH-CN
AR-SA
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Table Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-qformat:yes;
mso-style-parent:"";
mso-padding-alt:0in 5.4pt 0in 5.4pt;
mso-para-margin:0in;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;}
- leadtools.codecs.jbg
- leadtools.codecs.jb2
- leadtools.codecs.cmp
- leadtools.codecs.fax
- leadtools.codecs.tif
LEADTOOLS Support
Document
Document SDK Questions
"Feature not supported", PdfCompressor.Write
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.