converting TIFF to PDF & JPG to PDF

Questions, comments and suggestions concerning VintaSoft PDF .NET Plug-in.

Moderator: Alex

Post Reply
mylenesia
Posts: 3
Joined: Tue Oct 29, 2013 12:47 pm

converting TIFF to PDF & JPG to PDF

Post by mylenesia »

Hi,

Our company is currently evaluating the product whether it will cater to our needs.

Our requirements are as follows:
1) Convert TIFF file to PDF using JBIG2 Compression
2) Convert JPG file to PDF using JPEG2000 Compression

When I tried, I get an error message stating that the compression (Jpeg2000 and Jbig2) is not supported now.

Basing on the documentation provided, below is the code for converting TIFF to PDF (using JBIG2):
ImageCollection imageCollection = new ImageCollection();
imageCollection.Add(tiffFileName);

PdfEncoder pdfEncoder = new PdfEncoder(true);
pdfEncoder.Settings.Compression = PdfImageCompression.Jbig2;
pdfEncoder.Settings.Jbig2Settings.Lossy = false;
imageCollection.SaveSync(pdfFileName, pdfEncoder);

pdfEncoder.Dispose();
imageCollection.Dispose();

Below is the code for converting JPG to PDF (using JPEG2000):
ImageCollection imageCollection = new ImageCollection();
imageCollection.Add(jpgFileName);

PdfEncoder pdfEncoder = new PdfEncoder(true);
pdfEncoder.Settings.Compression = PdfImageCompression.Jpeg2000;
pdfEncoder.Settings.Jpeg2000Settings.CompressionType = Vintasoft.Imaging.Codecs.Jpeg2000.Jpeg2000CompressionType.Lossy;
imageCollection.SaveSync(pdfFileName, pdfEncoder);

pdfEncoder.Dispose();
imageCollection.Dispose();

Is there something I should be doing to make this work or is this feature only supported in future versions? Please note that I'm currently using version 7.0.1.1.

Please advise asap.

Thanks.

Best Regards,
Mylene
Alex
Site Admin
Posts: 2305
Joined: Thu Jul 10, 2008 2:21 pm

Re: converting TIFF to PDF & JPG to PDF

Post by Alex »

Hello Mylene,

What files do you have in your output bin directory? I think you have only Vintasoft.Imaging.dll and Vintasoft.Pdf.dll.

Please add reference to Vintasoft.Imaging.Jbig2Codec.dll and Vintasoft.Imaging.Jpeg2000Codec.dll in your project or place these 2 files into your output bin directory.

Best regards, Alexander
mylenesia
Posts: 3
Joined: Tue Oct 29, 2013 12:47 pm

Re: converting TIFF to PDF & JPG to PDF

Post by mylenesia »

Hi Alex,

Thanks! Figured it out. Although I added them as references, they weren't copied to output folder in my test project as they weren't actually called.

The JPG to PDF with JPEG2000 compression is now working fine. But I'm getting this error for the TIFF to PDF (JBIG2):

Vintasoft.Imaging.Codecs.PdfEncoderException: Index must be within the bounds of the List.

The error is thrown by this line of code:

imageCollection.SaveSync(pdfFileName, pdfEncoder);

Found the examples for this and experimented with some settings. I tried to follow what works on the Imaging Converter example by doing this:

pdfEncoder.Settings.Jbig2Settings.Lossy = false;
pdfEncoder.Settings.Jbig2Settings.Inaccuracy = 50;
pdfEncoder.Settings.Jbig2Settings.UseSymbolDictionary = true;
pdfEncoder.Settings.Jbig2Settings.SymbolDictionarySize = 6500;
pdfEncoder.Settings.Jbig2Settings.UseMmr = false;

But I still get the same error Index must be within the bounds of the List.

Am I missing something again?

Best Regards,
Mylene
mylenesia
Posts: 3
Joined: Tue Oct 29, 2013 12:47 pm

Re: converting TIFF to PDF & JPG to PDF

Post by mylenesia »

Oh. Never mind. Finally figured it out. I missed this line of code:

pdfEncoder.Settings.Jbig2UseGlobals = false;

Thanks again Alex!
Post Reply