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.

Tue Jul 30, 2024 10:44 am

We have a valid Spire.PDF license and with this valid Spire.PDF license we created a .NET 8 console application.
This production application has a strange problem, only on some virtual machines.

To reproduce the problem I created a small console application and the whole project (excluding the spire license) is attached to this post.

The application will unlock the spire license, then generates a document without the evaluation warning.
After "sleeping" for more then 1 second, a second document is create which will contain the evaluation warning.
If the second document is created after 500 ms, the second document will not contain the evaluation warning.

I tested the application on several Azure virtual machines and this problem only occurs on some of the virtual machines.
As far as I know these machines are all configured the same.

I also tried to unlock the license every time a document is created, but that did not fix the problem.
I know it has to do something with the specific machines, because the same executables are used, but have different results on different machines, but I can't seem to find the setting(s) that are different between de machines that might cause this problem to occur.

Some additional system information
We are using Spire.PDF v10.7.21 on a .NET 8 console application
Microsoft Windows Server 2019 Standard Version 10.0.17763 Build 17763 (Azure virtual machine)
Country settings: Netherlands
Regional format: Dutch (Netherlands)
Windows display language: English (United States)

Can you please help us with this problem?


Code: Select all
// This application is created to analyze a problem with the spire licensing.
using Spire.Pdf;
using System.Xml.Linq;

static void CreatePdfFile(int sleepCount)
{
    Console.WriteLine($"Sleep for {sleepCount}ms.");
    Task.Delay(sleepCount).Wait();
    byte[] fileBytes = File.ReadAllBytes("Test.pdf");
    byte[] fileBytesWithoutMetaData = RemoveMetadataFromPdf(fileBytes);

    string resultFileName = $"Test-Without-Meta-Data-{sleepCount}.pdf";
    if (File.Exists(resultFileName))
    {
        File.Delete(resultFileName);
    }
    File.WriteAllBytes(resultFileName, fileBytesWithoutMetaData);
}

static byte[] RemoveMetadataFromPdf(byte[] pdfdocument)
{
    // NOTE: Document information properties are set to an empty string and NOT null, to prevent exceptions.
    using (PdfDocument document = new PdfDocument(pdfdocument))
    {
        document.DocumentInformation.Author = string.Empty;
        document.DocumentInformation.Creator = string.Empty;
        document.DocumentInformation.Keywords = string.Empty;
        document.DocumentInformation.Producer = string.Empty;
        document.DocumentInformation.Subject = string.Empty;
        document.DocumentInformation.Title = string.Empty;

        Dictionary<string, string> customerDefined = document.DocumentInformation.GetAllCustomProperties();
        foreach (string key in customerDefined.Keys)
        {
            document.DocumentInformation.RemoveCustomProperty(key);
        }

        using (MemoryStream stream = new MemoryStream())
        {
            document.SaveToStream(stream);
            return stream.ToArray();
        }
    }
}

static void UnlockLicenses()
{
    // Unlock Spire.
    XDocument xDocument = XDocument.Load(new MemoryStream(SpirePoc.Properties.Resources.Spire_pdf_license));
    string? key = xDocument.Element("License")?.Attribute("Key")?.Value.ToString();
    if (string.IsNullOrWhiteSpace(key))
    {
        throw new Exception("Spire pdf license not found.");
    }

    Spire.Pdf.License.LicenseProvider.SetLicenseKey(key);
    Spire.Pdf.License.LicenseProvider.LoadLicense();
}

Console.WriteLine("Unlock spire license.");
UnlockLicenses();

CreatePdfFile(0);
CreatePdfFile(1000);

Console.WriteLine("Press ENTER to close the application.");
Console.ReadLine();

DigitallHealth
 
Posts: 3
Joined: Fri Oct 08, 2021 2:56 pm

Wed Jul 31, 2024 3:03 am

Hi,

Thank you for inquiry.
Please note that the Developer Small Business license you have purchased allows 1 developer and 1 deployment location (identified by a unique machine ID/MAC address) to use it. When the license is used on machines beyond this limit, it will not be effective, the output file will have the warning messages. We have checked that your license usage had exceeded this limit. If you want more deployment locations, please upgrade to the Developer OEM specification, which has no limit on deployment locations.
https://www.e-iceblue.com/Buy/Spire.PDF.html
If you have any other questions, you can write email to sales@e-iceblue.com.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 277
Joined: Mon Jul 15, 2024 5:40 am

Wed Sep 18, 2024 8:00 pm

I believe I may be having the same issue. Could you please check what license was purchased for my account?

vfarrell@maydaymfg.com

vfarrell
 
Posts: 1
Joined: Wed Sep 18, 2024 7:40 pm

Thu Sep 19, 2024 2:41 am

Hello,vfarrell

Thanks for your inquiry. Our records show that the product you purchased is Developer Small Business license, which allows for one developer and one publishing address (identified by a unique machine ID/MAC address). If your license exceeds this limit, you will also see a warning message on the output file. If you want more deployment locations, please upgrade to the Developer OEM specification, which has no limit on deployment locations.
https://www.e-iceblue.com/Buy/Spire.PDF.html
If you have any other questions, you can write email to sales@e-iceblue.com.

Sincerely,
Amin
E-iceblue support team
User avatar

Amin.Gan
 
Posts: 277
Joined: Mon Jul 15, 2024 5:40 am

Return to Spire.PDF