Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Thu May 28, 2026 10:02 am

Hi,

I'm using spire.pdf 12.5.8 in my .net 8 AWS lambda function to extract text from a pdf like below.

Code: Select all
var pdf = new PdfDocument();
 
     pdf.LoadFromStream(stream);

     if (pdf != null)
     {
         var builder = new StringBuilder();
         var totalPages = pdf.Pages.Count;

         var options = new PdfTextExtractOptions
         {
             IsExtractAllText = true,
             IsShowHiddenText = false
         };

         for (int pageNo = 0; pageNo < totalPages; pageNo++)
         {
             var page = pdf.Pages[pageNo];

             var pdfTextExtractor = new PdfTextExtractor(page);
             var rawText = pdfTextExtractor.ExtractText(options);           

             var textLines = rawText.Replace("copy", "    ", StringComparison.InvariantCultureIgnoreCase).Split("\r\n", StringSplitOptions.RemoveEmptyEntries);

             builder.AppendLine(string.Join("\r\n", textLines));
         }
         
       var extractedText = builder.ToString();
     }


This code works as expected when I run it locally on windows but when I deploy it to AWS I get this error.

Exception 'The type initializer for 'Gdip' threw an exception.', Stack trace ' at System.Drawing.SafeNativeMethods.Gdip.GdipCreatePath(FillMode brushMode, IntPtr& path)
at System.Drawing.Drawing2D.GraphicsPath..ctor()
at spr届..ctor()
at spr뗀.㓡(spr椵 A_0, FillMode A_1)
at spr뗀.㾪()
at spr뗀.㾪()
at spr랶.㓡(spr樰 A_0)
at spr랶.㓡()
at spr냙.㺯()
at Spire.Pdf.Texts.PdfTextExtractor.㓡(PdfTextExtractOptions A_0)
at Spire.Pdf.Texts.PdfTextExtractor.ExtractText(PdfTextExtractOptions options)
at Lambdas.Services.PDFProcessingService.ProcessPDF(String message) in C:\source\app\Lambdas\Services\PDFProcessingService.cs:line 101
at Lambdas.Services.PDFProcessingService.ProcessPDF(String message) in C:\source\app\Lambdas\Services\PDFProcessingService.cs:line 119
at Lambdas.Functions.ProcessPDFInvoice(SQSEvent ev, ILambdaContext lambdaContext) in C:\source\app\Lambdas\Functions.cs:line 74', Source 'System.Drawing.Common'


I don't actually need anything image related from the pdf. Just need to extract all the text from the pdf. Not sure why Spire throws this error when extracting text. Could you please advise if there is a way to extract the text I need, without causing this error in AWS Lambda function (Linux environment)?

Regards,
Swathi

swathi.chetla
 
Posts: 5
Joined: Thu May 28, 2026 9:40 am

Fri May 29, 2026 2:55 am

Dear Swathi,

Thank you for contacting us.
Please note the .NETCore8 dlls of our Spire.PDF has dependency Spire.Drawing.Common, which is no longer supported in non-windows systems from the .NET6. Please refer to Microsoft's official documentation for instructions: https://learn.microsoft.com/en-us/dotnet/core/compatibility/core-libraries/6.0/system-drawing-common-windows-only

That's the reason why you got 'Gdip' exception on your AWS lambda function. Please use use the NETStandard dll rather than the NETCore dll as it uses the SkiaSharp to replace the Spire.Drawing.Common. Please install the Spire.PDFfor.NETStandardV12.5.8 from Nuget to try again. Please note:
1. It's best for you to also install this dependency (SkiaSharp.NativeAssets.Linux.NoDependencies) to avoid the problem of not being able to find SkiaSharp after deploying to AWS.
2. The .NETStandard DLL depends on SkiaSharp version 3.116.1, which requires the GLIBC version on your system to be 2.29 or higher. We recommend verifying your deployment environment’s GLIBC version before installation. You can check it on your AWS using this command: ldd –version

If there is any question, please feel free to write back.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1379
Joined: Tue Sep 27, 2016 1:06 am

Wed Jun 03, 2026 10:11 pm

Hi Nina,

Thanks for the quick response. I've updated my .net 8 lambda function to use 'Spire.pdf for .NetStandard' and installed the dependency 'SkiaSharp.NativeAssets.Linux.NoDependencies' as you suggested. After deploying my lambda function on AWS(Amazon Linux release 2023.11.20260413), got the below error with the same code as before. Could you please advise if I need to install any other dependencies?

2026-06-03T21:59:59.430Z b7889033-8b56-5e41-98b6-f2a92d585f94 fail Message id 45daa294-9ca4-42fd-8320-57a7e55c195d failed processing. Exception 'The type initializer for 'SkiaSharp.SKObject' threw an exception.', Stack trace ' at SkiaSharp.SKPath..ctor()
at spr堄..ctor()
at spr펪.▯(spr榹 A_0, sprㅼ A_1)
at spr펪.⚀()
at spr펪.⚀()
at spr폐.▯()
at spr퍋.♭()
at Spire.Pdf.Texts.PdfTextExtractor.▯(PdfTextExtractOptions A_0)
at Spire.Pdf.Texts.PdfTextExtractor.ExtractText(PdfTextExtractOptions options)
at Lambdas.Services.PDFProcessingService.ProcessPDF(String message) in C:\source\app\Lambdas\Services\PDFProcessingService.cs:line 98
at Lambdas.Services.PDFProcessingService.ProcessPDF(String message) in C:\source\app\Lambdas\Services\PDFProcessingService.cs:line 116
at Lambdas.Functions.ProcessPDFInvoice(SQSEvent ev, ILambdaContext lambdaContext) in C:\source\app\Lambdas\Functions.cs:line 75', Source 'SkiaSharp'



Regards,
Swathi

swathi.chetla
 
Posts: 5
Joined: Thu May 28, 2026 9:40 am

Thu Jun 04, 2026 8:16 am

Dear Swathi,

Thanks for your feedback.
Could you please confirm if the installed version of SkiaSharp.NativeAssets.Linux.NoDependencies matches your SkiaSharp version (both at 3.116.1)? Additionally, please use the ldd --version command and tell us the GLIBC version on your server.

Or maybe you can install the SkiaSharp.NativeAssets.Linux 3.116.1 rather than the NoDependencies to try again.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1379
Joined: Tue Sep 27, 2016 1:06 am

Fri Jun 05, 2026 9:11 am

Dear Nina,

Thanks for the solution. I got it working on my AWS lambda.

Just noticed that spire is only extracting text from first 10 pages of a pdf. Can I request for a trial license which will help evaluate our requirements without any restrictions please? Also I didn't find any license info specific to 'Spire.pdf for .NetStandard' on your website. In the request for temporary license which product should I choose. Could you please advise?


Regards,
Swathi

swathi.chetla
 
Posts: 5
Joined: Thu May 28, 2026 9:40 am

Fri Jun 05, 2026 9:48 am

Dear Swathi,

Thanks for your feedback.
We just sent a temporary license (one month free) to your email ([email protected]), please refer to this tutorial to apply the license by license key. If there is any question, please feel free to let us know.
https://www.e-iceblue.com/Tutorials/Licensing/Licensing.html#Apply_by_Key

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1379
Joined: Tue Sep 27, 2016 1:06 am

Fri Jun 05, 2026 1:27 pm

Dear Nina,

Thanks for arranging the temporary license. So I received the license for 'Spire.Office for .Net'. Just wondered if 'Spire.pdf for .NetStandard' license not available on its own and do we need to take the whole package of spire.office? Please clarify.


Regards,
Swathi

swathi.chetla
 
Posts: 5
Joined: Thu May 28, 2026 9:40 am

Mon Jun 08, 2026 8:14 am

Dear Swathi,

Apologies for the delayed response over the weekend.
To clarify your questions: The Spire.Office license you received is a bundle license that covers all our .NET products. This means you can also use it to try out our other products like Word (Doc) and Excel (XLS) if needed.
However, for your development, you do not need to reference the entire Spire.Office package. You can simply use the Spire.PDF package alone, and the license will work perfectly.
Please let me know if you need any further assistance.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1379
Joined: Tue Sep 27, 2016 1:06 am

Mon Jun 08, 2026 11:19 am

Hi Nina,

Thanks for the clarification. Could you please provide the link with license cost information for 'Spire.pdf for .NetStandard'.


Regards,
Swathi

swathi.chetla
 
Posts: 5
Joined: Thu May 28, 2026 9:40 am

Tue Jun 09, 2026 1:58 am

Hi Swathi,

This is the cost link for Spire.PDF: https://www.e-iceblue.com/Buy/Spire.PDF.html

We offer four types of license subscription. Please select the one that best suits your actual business needs. Should you have any questions, please feel free to contact us.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1379
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF

cron