-1

I have some PDF files. All the PDFs contain single page. But, it will have a very large collection. I want to show them as JP2 image in Universal Viewer from my .NET application. The entire process (from conversion of PDFs to JP2 images and showing those JP2 images in Universal Viewer) will have to be done dynamically from my .Net application. Also, the Universal Viewer will have the autocomplete, search and hit-highlight feature, cropping, clipping etc.

Please guide me the implementation process in details.

Thanks.

B Roy
  • 37
  • 5

1 Answers1

1

I do not know free fully managed solutions for PDF to JP2 conversion in .NET.

You can split the task to 2 parts:

  1. Convert PDF to PNG / TIFF image There are free C++ libraries that can do that - look at muPDF, xpdf, Ghostscript. There are .NET bindings for some of them.

  2. Convert PNG / TIFF to JPEG 2000. There is free CSJ2K library. It looks frozen, though.

Vitaliy Shibaev
  • 1,420
  • 10
  • 24
  • Please let me know how I can convert PNG to JPEG 2000 using CSJ2K library in C#. Thanks. – B Roy Jul 03 '20 at 16:18
  • You need 2 steps here too: a. Load PNG to System.Drawing.Bitmap b. Pass the bitmap to J2kImage.ToBytes(object) method. Alternatively, you can convert System.Drawing.Bitmap to PPM [like that](http://rosettacode.org/wiki/Bitmap/Write_a_PPM_file#C.23), then create BlkImageDataSrc object for PPM data and pass to J2kImage.ToBytes(BlkImgDataSrc) overload. Read for more detail: https://github.com/cureos/csj2k#encoding – Vitaliy Shibaev Jul 05 '20 at 08:10
  • I tried to make the conversion in following way: string file = @"D:\JPG\scan_0003.jpeg"; System.Drawing.Image image = System.Drawing.Bitmap.FromFile(file); byte[] j2kArray = CSJ2K.J2kImage.ToBytes(image); System.IO.File.WriteAllBytes(@"D:\JP2\0009.jp2", j2kArray); But, I am getting this error: "Object reference not set to an instance of an object" In this line: byte[] j2kArray = CSJ2K.J2kImage.ToBytes(image); I am working on web application. Please help me. Thanks. – B Roy Jul 06 '20 at 07:45
  • I fixed that. But, it's taking too much time in JP2 conversion. – B Roy Jul 06 '20 at 11:14
  • Is there any way to make this conversion faster please? – B Roy Jul 06 '20 at 12:08
  • I am not related to CSJ2K so cannot help you with that. You can use CSJ2K from sources and run your decoding with a profiler to find and fix performance bottlenecks. – Vitaliy Shibaev Jul 07 '20 at 02:45
  • Hello, Is there any other free version tool available for PNG to JP2 conversion in .Net/C#. Thanks. – B Roy Jul 07 '20 at 06:32
  • No. There are free C++ libraries like [openjpeg](https://www.openjpeg.org/) that you can use via .NET bindings. If you decide to use paid libraries then take a look at [Jpeg2000.Net](https://bitmiracle.com/jpeg2000/), I am one of the authors. – Vitaliy Shibaev Jul 07 '20 at 12:19
  • Hello, I have the JP2 images and now showing them using IIPServer in Universal Viewer. Now, I want to implement the search and autocomplete functionality on those JP2 images in Universal Viewer. I have a very large number of JP2 images. The search and autocomplete functionality will have to be worked for all text inside the image. Please guide me the implementation details. Thanks – B Roy Jul 07 '20 at 13:48
  • You should post separate question. Be more specific. Too broad questions like this one will be closed and unanswered. – Vitaliy Shibaev Jul 08 '20 at 03:12
  • Hello, Some more details about my application. I have converted PDF to JP2 images using ImageMagick and showing them in Universal Viewer. I have text with positions info. I want to implement search with hit highlight on it and want to show on the JP2 image in Universal Viewer. How can I generate annotations dynamically from it and link it to manifest.json? Please help me. Thanks. – B Roy Jul 10 '20 at 13:48