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

Free Support Forum - aspose.com

Pdf having issue until saved in Adobe

I am encounter an issue in Aspsoe.PDF for .net where a pdf generate with our CAD tool NX does not contain any forms. If I open the PDF in adobe and save as the new PDF shows forms when opened with Aspose.

Further I was getting exceptions trying to use the TextFragmentAbsorber. If I open and save with adobe the exceptions are gone. I have tried using the Document.Check method to check and repair the document but it does not make a difference. I have also tried opening the document with aspose, saving, closing and reopening. No luck there either. Are there any other repair functions I am missing?

I attached a sample pdf. It should recognize 1 form.

model1.pdf (373.9 KB)

@Alexander96856

Using the latest version of Aspose.PDF for .NET 22.2, we have not found the shared issue. Please use the latest version of Aspose.PDF for .NET.
To test this case, we used the example shared in following article.
Search and Get Text from Pages of PDF

Could you please share some detail about this issue? We will investigate it and provide you more information on it.

Here is the basic example I am using to try to debug this issue. It uses the latest Nuget package.
I attached a zip to with the 2 sample pdfs using in the code below.
PdfTest.7z (799.6 KB)

  • model1.pdf - Raw output from our CAD system
  • model1_saved.pdf - The model1.pdf opened with adobe for editing and saved
using System;
using System.IO;
using Aspose.Pdf;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            var assyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
            FileInfo fileInfo = new FileInfo(assyPath);
            DirectoryInfo dirInfo = fileInfo.Directory;

            //set license               
            License license = new License();
            using (FileStream licenseStream = new FileStream($"{dirInfo.FullName}\\Aspose.PDF.NET.lic", FileMode.Open))
            {
                try
                {
                    license.SetLicense(licenseStream);
                    Console.WriteLine("License set successfully.\n");
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Unable to set aspose pdf license.\n");
                    throw ex;
                }
            }

            //This is the pdf directly exported from the cad program.
            string docPath = $"{dirInfo.FullName}\\model1.pdf";
            using (Document doc = new Document(docPath))
            {
                Console.WriteLine($"There are {doc.Form.Count} forms in {docPath}.");
                foreach (var form in doc.Form)
                    Console.WriteLine(form.ToString());
            }
            Console.WriteLine("");

            //this is the pdf after opening with adobe and saving. nothing else
            string docSavedPath = $"{dirInfo.FullName}\\model1_saved.pdf";
            using (Document docSaved = new Document(docSavedPath))
            {
                Console.WriteLine($"There are {docSaved.Form.Count} forms in {docSavedPath}.");
                foreach (var form in docSaved.Form)
                    Console.WriteLine(form.ToString());
            }
            Console.WriteLine("");
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.ToString());
        }
        Console.WriteLine("Press enter to exit.");
        Console.ReadLine();
    }
}

When I run the program Aspose finds 0 forms for the original pdf and 8 for the saved pdf. The output is

License set successfully.

There are 0 forms in C:\Temp\PdfTest\model1.pdf.

There are 8 forms in C:\Temp\PdfTest\model1_saved.pdf.
Aspose.Pdf.Forms.ButtonField
Aspose.Pdf.Forms.ButtonField
Aspose.Pdf.Forms.ButtonField
Aspose.Pdf.Forms.ButtonField
Aspose.Pdf.Forms.ButtonField
Aspose.Pdf.Forms.ButtonField
Aspose.Pdf.Forms.TextBoxField
Aspose.Pdf.Forms.TextBoxField

Press enter to exit.

@Alexander96856

We have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as PDFNET-51488. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.