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

Free Support Forum - aspose.com

PdfFileEditor.Concatenate not working in Docker

Hi.

I’m using aspose for .NET to try to concatenate 2 PDF files, but when I run my code in windows it works correctly, but when I change to run in docker I get a 0 bytes PDF or if I set AllowConcatenateExceptions to true, I got this NullReferenceException:

at #=z2FQPfzHGdiZfRYrJwMZ0nK$sTN91.#=zPT2Ot3g=(#=zOWH0esf1NUl0qFZixoj2_DGR8r49 #=znybI$7oO5srv)
   at #=zm4njWmBfnhXcV7Zqax27qyM=.#=zjq$GEPI=(#=zOWH0esf1NUl0qFZixoj2_DGR8r49 #=znybI$7oO5srv)
   at #=qAPeHTVJJWbx2hGWGRgpDDzzlwqMrRaNOig8aorE03AA=.#=z$NsE5yEuN7aiYyxJsQ7fLQ_WXhPYm5rt2m270Ug=(Object #=zsVIZ3L4=)
   at #=qAPeHTVJJWbx2hGWGRgpDDzzlwqMrRaNOig8aorE03AA=.#=zCz8ExqCAZLKQY9QFXyriQeqSszFcaHgEkIGWrow=(MethodBase #=zsVIZ3L4=, Boolean #=zo1DU7AA=)
   at #=qAPeHTVJJWbx2hGWGRgpDDzzlwqMrRaNOig8aorE03AA=.#=z8L0qG9LBxbWH4fheVcCy1Qs=(#=qAPeHTVJJWbx2hGWGRgpDDzzlwqMrRaNOig8aorE03AA= #=zsVIZ3L4=, #=qlXudrc64bMkSzUgeeGJWD3joQlfmxVRwqNk8hMs9REI= #=zo1DU7AA=)
   at #=qAPeHTVJJWbx2hGWGRgpDDzzlwqMrRaNOig8aorE03AA=.#=zDJtJSdvoa6srzEDWMR1BxRZVgdRO9DhesA==()
   at #=qAPeHTVJJWbx2hGWGRgpDDzzlwqMrRaNOig8aorE03AA=.#=zU8TpxrJvPkag_hsTatj9gHErbYk_9JyyzQ==(Boolean #=zsVIZ3L4=)
   at #=qAPeHTVJJWbx2hGWGRgpDDzzlwqMrRaNOig8aorE03AA=.#=z$NsE5yEuN7aiYyxJsQ7fLQ_WXhPYm5rt2m270Ug=(Object #=zsVIZ3L4=)
   at #=qAPeHTVJJWbx2hGWGRgpDDzzlwqMrRaNOig8aorE03AA=.#=zD23IhMOYnLkFjrQtvzlBqeU7kP4RYgMYeinaQ_9uzxJI()
   at #=qAPeHTVJJWbx2hGWGRgpDDzzlwqMrRaNOig8aorE03AA=.#=zPfgIrYVfOnY4wpL503UoQ59WD6VIQhhf1A==(#=qAPeHTVJJWbx2hGWGRgpDDzzlwqMrRaNOig8aorE03AA= #=zsVIZ3L4=, #=qlXudrc64bMkSzUgeeGJWD3joQlfmxVRwqNk8hMs9REI= #=zo1DU7AA=)
   at #=qAPeHTVJJWbx2hGWGRgpDDzzlwqMrRaNOig8aorE03AA=.#=zDJtJSdvoa6srzEDWMR1BxRZVgdRO9DhesA==()
   at #=qAPeHTVJJWbx2hGWGRgpDDzzlwqMrRaNOig8aorE03AA=.#=zU8TpxrJvPkag_hsTatj9gHErbYk_9JyyzQ==(Boolean #=zsVIZ3L4=)
   at Aspose.Pdf.Facades.PdfFileEditor.#=zpb6DkVM=(Exception #=zm45FFdQ=)
   at Aspose.Pdf.Facades.PdfFileEditor.Concatenate(String[] inputFiles, String outputFile)
   at Aspose.Pdf.Facades.PdfFileEditor.Concatenate(String firstInputFile, String secInputFile, String outputFile)
   at SEPDFConverter.Controllers.ConverterDebugController.ConvertDebug(IFormFile file1, IFormFile file2) in C:\Users\jean.heidemann\Documents\se-documento\desktop-apps\src\pdfconverter\SEPDFConverter\SEPDFConverter\Controllers\ConverterDebugController.cs:line 66

I have a .NET 5 Web Api project and this is my sample code:

[HttpPost]
        [DisableRequestSizeLimit]
        public IActionResult ConvertDebug([FromForm] IFormFile file1, [FromForm] IFormFile file2)
        {
            string filepath1 = Path.GetTempPath() + Guid.NewGuid().ToString() + Path.GetExtension(file1.FileName);
            using (FileStream fileStream = new FileStream(filepath1, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                file1.CopyTo(fileStream);
            }

            string filepath2 = Path.GetTempPath() + Guid.NewGuid().ToString() + Path.GetExtension(file2.FileName);
            using (FileStream fileStream = new FileStream(filepath2, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                file2.CopyTo(fileStream);
            }

            string output = Path.GetTempPath() + Guid.NewGuid().ToString() + ".pdf";

            PdfFileEditor editor = new PdfFileEditor();
            editor.AllowConcatenateExceptions = true;

            editor.Concatenate(filepath1, filepath2, output);

            FileStream stream = new FileStream(output, FileMode.Open);
            return File(stream, "application/pdf", new FileInfo(output).Name);
        }

And here is my PDF files to concatenate

pdf1.pdf (441.2 KB)
pdf2.pdf (13.1 KB)

@jean.heidemann

Could you please make sure that libgdiplus and msttcorefonts packages are installed properly in the environment? Please let us know in case issue is still persisting despite of these packages installed.

@asad.ali

libgdiplus I had installed but msttcorefonts not. After installing it worked correctly

Thank you!

1 Like