Use Aspose.PDF for .NET in Linux - ArgumentNullException - Value cannot be null

Hello,

I am trying to run a console application onto linux platform . The project uses Aspose.Pdf and runs fine on windows machine.
When I run the same project on linux it throws me an exception “value cannot be null’”. Here is the trace output -

at System.Collections.Generic.Dictionary2.FindEntry(TKey key) at System.Collections.Generic.Dictionary2.TryGetValue(TKey key, TValue& value)
at #=zTy8JYEq94vIoTFVTXxW_8hAWBv25y0fwAA==.#=zb2gSaHo=(#=zgBaXOuo= #=zu7Btii8=)
at #=zrCoAmbKuBy2AdCeRk0_w0KAI4jCjN7yjKA==.#=zyiIwR8O8_PPX.#=zV9yCNOhiHINE(#=zgBaXOuo= #=zu7Btii8=, #=zJ4qWz8o=& #=z4MuNd_4=)
at #=zAbvnhnk80gAJQzXhu05FHJo5X2IGlGM$V$NuNV4=.#=zPHd2d8YcJkSD(#=zsi89OAvfaEppiCj$F2Qc9SVZIZ2q #=z4UFu2BMT2ZU4)
at #=zp3LBmtWs7q19$FY8Nr_x4So5IREA.#=zdnqhxDs=(#=zivHMpuGKu7N7gWkY4coAwpsee2rVUxpu0xfAshFihL1S& #=zJ2EQwkE=)
at #=zp3LBmtWs7q19$FY8Nr_x4So5IREA.#=zdnqhxDs=()
at Aspose.Pdf.Devices.ImageDevice.#=zdnqhxDs=(Page #=zAd34nB8=)
at Aspose.Pdf.Devices.PngDevice.Process(Page page, Stream output)
at Aspose.Pdf.Facades.PdfConverter.#=zvRvA6LHJW5GWkaqpvg==(Page #=zAd34nB8=)
at Aspose.Pdf.Document.ConvertPageToPNGMemoryStream(Page page)

I am having hard time solving this. Any help on this would be appreciated.

@swapnilp18

Can you please share source files along with sample code and environment details so that we may further investigate to help you out.

Hello ,
PFB the sample source code.

using System;
using System.IO;
using Aspose;
using Tesseract;

namespace OCRService
{
class Program
{
static void Main(string[] args)
{
var inputFile = new Aspose.Pdf.Document(args[0]);
var outputFile = args[1];
string texttowrite = string.Empty;
int pageNumber = 1;
foreach (var page in inputFile.Pages)
{
using (var memorystream = inputFile.ConvertPageToPNGMemoryStream(page))
{
StreamWriter writer = new StreamWriter(memorystream);
writer.Flush();
//Rewind the MemoryStream before copying
memorystream.Seek(0, SeekOrigin.Begin);
using (FileStream fs = new FileStream($“{pageNumber}.png”, FileMode.OpenOrCreate))
{
memorystream.CopyTo(fs);
fs.Flush();
texttowrite += ProcessFile($“{pageNumber}.png”);
}
}
pageNumber++;
}

        //File.AppendAllText("1.txt", texttowrite);  
        Console.Read();
    }

    private static string ProcessFile(string file)
    {
        string trainedDataFolderName = "tessdata";
        string tessPath = Path.Combine(trainedDataFolderName, "");
        Console.WriteLine(Environment.CurrentDirectory);
        using (TesseractEngine engine = new TesseractEngine(tessPath, "eng", EngineMode.Default))
        {
            using (var img = Pix.LoadFromFile(file))
            {
                var page = engine.Process(img);
                string result = page.GetText();
                Console.WriteLine($"Result for Page {file} :");
                Console.WriteLine(result);
                return result;
            }
        }
    }
}

}

@swapnilp18

Your code snippet is referring to a method i.e. ConvertPageToPNGMemoryStream. Would you kindly share definition of this method as well. Also as shared earlier, please share your sample PDF document with us as well. Furthermore, would you please make sure following:

  • libgdiplus package is installed
  • All MS Core Fonts are installed

Please try using DOM approach to convert PDF Pages into images and in case issue still persists, please share complete environment details i.e. OS Name and Version, .NET Framework, etc. We will further proceed to assist you accordingly.

Hello ,

ConvertPageToPNGMemoryStream is a method defined in Aspose PDF. Here is the link for that convertpagetopngmemorystream .

I have tried instaliing libgdiplus and ms core fonts but the issue still persists.

@swapnilp18

Thanks for your response.

Would you kindly share above information with us. We will log an investigation ticket and share the ID with you.

Hi ,
Here are the details -

OS name - CentOS Linux
version - 7(Core)

Thanks

@swapnilp18,

Can you please share source PDF with us so that we may further investigate to help you out.

testpdf.Pdf (59.9 KB)

@swapnilp18,

Thanks for contacting support.

We have tested this scenario in our environment and have been able to observe the issue that you have mentioned. We have logged issue with ID PDFNET-47515 in our issue tracking system. We will share with you as soon as logged issue is fixed.

Have this bug fixed? I have the same issue on my Ubuntu 20.04.1 LTS

@lamhiep16

Sadly, the earlier logged ticket is not yet resolved. We will surely investigate and fix it on first come first serve basis and let you know once it is rectified. Please give us some time.

We are sorry for the inconvenience.

Hello colleagues! Looks like we have the same issue in our project with Aspose.
Could you please answer, do you have any progress with this issue?

@Aleksandr_Kuznetsov

We are afraid that earlier logged ticket is not yet resolved due to other issues logged prior to it. We will surely provide an update in this forum thread as soon as we have some regarding ticket resolution. Your patience is highly appreciated in this matter.

We apologize for the inconvenience.

@asad.ali any ETA? Our company is working on migration to AWS hosting where we plan to use linux based dockers. Our plan was to upgrade our existing license to new as soon as we are ready for migration. However it sounds like we cannot do that. I would really appreciate with any meaningful response and ETA.

@sergey_mosyakov

We really regret to share that we cannot share any ETA at the moment as the ticket is not yet fully investigated. We have updated the ticket information as per your concerns and will surely provide you an update as soon as the investigation against this issue is complete. We highly appreciate your patience and comprehension in this regard.

We apologize for your inconvenience.

We still need to know ETA. It is not something minor to us and I believe to many other teams. What can be done to escalate this issue with highest priority? It is small issue on your side probably but it is real cost to us if we need to use different instance which is windows based just because this issue is still there.

@sergey_mosyakov

We humbly apologize for the inconvenience and the trouble caused by this issue. Please note that we are investigating this issue and trying to come up with an ETA as soon as possible. We will surely inform you once the investigation is done. Please also note that the issue was logged under the normal support model where issues are resolved on a first come first serve basis and have normal priority unlike priority support where they are dealt with high precedence. Nevertheless, we will inform you as soon as any news about the ETA is available. Please give us little time.

We again apologize for the inconvenience caused.

Any updates?

@sergey_mosyakov

The issue is currently under the phase of investigation and due to other issues which were logged prior to it, the investigation could not get completed. Please note that we have already raised your concerns and escalated the ticket to the next level. We will surely share an ETA or fix updates with you as soon as the ticket is analyzed. We greatly appreciate your patience and cooperation in this matter.

We apologize for the inconvenience being caused.