We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

ParagraphAbsorber.Visit throwing exception in .NetCore

I am using the last version of Aspose.Pdf for .NET (22.5.0) in my .NetCore 3.1 project, but as soon as I start looping the pdfs pages I get the exception “System.NullReferenceException: ‘Object reference not set to an instance of an object.’” when calling “paragraphAbsorber.Visit(page)” for the second page of the pdf.

I also uploaded the file I am struggling with.

Document pdfDocument = new Document(filePath);

// Iterates over the pages
foreach (Page page in pdfDocument.Pages)
{
	ParagraphAbsorber paragraphAbsorber = new ParagraphAbsorber();
	paragraphAbsorber.Visit(page);
	foreach (PageMarkup markup in paragraphAbsorber.PageMarkups)
	{
		...
	}
}

tjpb_20220607.pdf (610.5 KB)

@fcprd

Would you please share your environment details as well e.g. OS Name and Version, Application Type, etc.? Also, please make sure that all Windows Fonts are installed in the system and try again before sharing the requested details.

Thank you for the quick response!

I have checked and all Windows Fonts are installed in the system. I forgot to mention before, but I am also using the same code in the same environment on a .Net Framework (4.5.2) project with Aspose.PDF (18.3.0) and it works as expected.

As you requested me to check all Windows Fonts are installed, a concern showed up in my mind. How am I supposed to run this application on Linux if I need to install all Microsoft Fonts?

My environment details are:
OS: Microsoft Windows 10
IDE: Microsoft Visual Studio 2019. It’s a C# console application.
Aspose.Pdf version: 22.5.0

@fcprd

In case of Linux or Non Windows environment, it is recommended to install msttcorefonts package so that all Microsoft essential fonts are present in the system. * These fonts should be placed in “/usr/share/fonts/truetype/msttcorefonts” directory as Aspose.PDF for .NET scans this folder on Linux like operating systems. In case operating system has other default folder/directory for fonts, you should use following line of code before performing any operation using Aspose.PDF.

Aspose.Pdf.Text.FontRepository.Sources.Add(new FolderFontSource("<user's path to ms fonts>"));

Furthermore, we tested the scenario in our environment and were unable to notice any issue. Can you kindly share a sample console application in .zip format which can reproduce the same exception that you are facing? Also, please confirm if you are using the API with a valid license. We will further proceed to assist you accordingly.

Thank you for your elucidation!

I confirm I am using a valid license.

I have uploaded my console application. Inside you will find the AsposeTest.NetCore.exe, the source code “Program.cs”, the pdf and also some .dll. But I have removed my “Aspose.Pdf.lic” and it will cause the following error “Something went wrong! Cannot find license ‘Aspose.Pdf.lic’.” if there isn’t any license inside the folder.

In this application, I attempt to remove some texts from the pdf’s tables, but I get an error when I call “tableFinder.Visit(page);”. If I skip that, I got the same error at paragraphAbsorber.Visit(page) as I mentioned before.

The following link has the .zip.

Let me know if you need anything else.

@fcprd

We are checking it and will get back to you shortly.

Hello.

Any news on this issue? Were you able to reproduce the exception from the console application I have shared?

@fcprd

We are afraid that we could not perform an initial investigation against your case due to other issues in the queue. Nevertheless, we will contact you soon after performing complete testing. Please spare us little time.

@fcprd

We have been able to reproduce the issue in our environment while using the latest version of the API. Therefore, we have logged it as PDFNET-52217 in our issue tracking system. We will further look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.

I really appreciate your effort to reproduce the issue and I hope you are able to fix that as soon as possible.

Thanks for your reply!