Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Oct 08, 2024 1:11 pm

I've been using Spire doc to convert .rtf to .pdf, I have the license as an embedded recourse in the solution.

I am facing the problem that the license is not being applied correctly. Here I have some test code:
Code: Select all
public static void Main(string[] args)
{
    var fileMemoryStream =
        new MemoryStream(File.ReadAllBytes("C:\\Users\\cjosse\\Downloads\\MIL-KBOS-00163_OFF_DIR_ALG_UG1_N_2146.rtf"));

    Document doc = new Document();
    doc.LoadFromStream(fileMemoryStream, FileFormat.Rtf);
    MemoryStream pdfMemoryStream = new MemoryStream();
    doc.SaveToStream(pdfMemoryStream, FileFormat.PDF);


    File.WriteAllBytes("DDDDD.pdf", pdfMemoryStream.ToArray());

    fileMemoryStream =
        new MemoryStream(File.ReadAllBytes("C:\\Users\\cjosse\\Downloads\\815_SNapp_bestelling_243605_ - Copy.rtf"));

    //doc = new Document();
    doc.LoadFromStream(fileMemoryStream, FileFormat.Rtf);
    doc.SaveToStream(pdfMemoryStream, FileFormat.PDF);

    File.WriteAllBytes("EEEE.pdf", pdfMemoryStream.ToArray());
}



If I uncomment the line "//doc = new Document();" the second converted pdf will have a limit of 10 pages and the "Evaluation Warning: The document was created with Spire.Doc for .NET." on all pages.

Our actual project is of course not this simple, as I need to convert multiple files asynchronously. Which should work because example like this has no problem detecting the license correctly:
Code: Select all
public static async Task Main(string[] args)
{
    var files = new List<string>
    {
        "C:\\Users\\cjosse\\Downloads\\MIL-KBOS-00163_OFF_DIR_ALG_UG1_N_2146.rtf",
        "C:\\Users\\cjosse\\Downloads\\AnotherFile.rtf"
    };

    var tasks = new List<Task>();

    foreach (var file in files)
    {
        tasks.Add(ConvertFileAsync(file));
    }

    await Task.WhenAll(tasks);
}

private static async Task ConvertFileAsync(string filePath)
{
    await Task.Run(() =>
    {
        var fileMemoryStream = new MemoryStream(File.ReadAllBytes(filePath));

        Document doc = new Document();
        doc.LoadFromStream(fileMemoryStream, FileFormat.Rtf);
        MemoryStream pdfMemoryStream = new MemoryStream();
        doc.SaveToStream(pdfMemoryStream, FileFormat.PDF);

        string outputFileName = Path.GetFileNameWithoutExtension(filePath) + ".pdf";
        File.WriteAllBytes(outputFileName, pdfMemoryStream.ToArray());
    });
}


But again our project is not as simple, the conversion is called from different classes. Is there a way to set up de project so that the license will get detected correctly?

Here are all the functions where the library is called:
Code: Select all
public void ConvertRtfToPdf(MemoryStream fileMemoryStream, string pdfFilePath)
{
    Document doc = new Document();
    doc.LoadFromStream(fileMemoryStream, FileFormat.Rtf);
    doc.SaveToFile(pdfFilePath, FileFormat.PDF);
}

public MemoryStream ConvertRtfToPdf(Stream fileMemoryStream)
{
    Document doc = new Document();
    doc.LoadFromStream(fileMemoryStream, FileFormat.Rtf);
    MemoryStream pdfMemoryStream = new MemoryStream();
    doc.SaveToStream(pdfMemoryStream, FileFormat.PDF);
    return pdfMemoryStream;
}

public async Task<MemoryStream> ConvertRtfToPdf(string rtfFilePath)
{
    var fileMemoryStream = await getMemoryStreamHttpsAsync(rtfFilePath);
    fileMemoryStream.Position = 0;
    return ConvertRtfToPdf(fileMemoryStream);
}

public async Task ConvertRtfToPdf(string rtfFilePath, string pdfOutputFilePath)
{
    ConvertRtfToPdf(await getMemoryStreamHttpsAsync(rtfFilePath), pdfOutputFilePath);
}
public async Task<(MemoryStream convertedPdf, int pageCount)> ConvertRtfToPdf_andPageCount(string rtfFilePath)
{
    Document doc = new Document();
    var fileMemoryStream = await getMemoryStreamHttpsAsync(rtfFilePath);
    fileMemoryStream.Position = 0;
    doc.LoadFromStream(fileMemoryStream, FileFormat.Rtf);
    var pageCount = doc.PageCount;
    MemoryStream pdfMemoryStream = new MemoryStream();
    doc.SaveToStream(pdfMemoryStream, FileFormat.PDF);
    return (pdfMemoryStream, pageCount);
}

Cjoskeee
 
Posts: 3
Joined: Tue Oct 08, 2024 12:54 pm

Wed Oct 09, 2024 6:22 am

Hello,

Thanks for your inquiry. Please note that the Developer Small Business license you have chosen 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. We have sent a new license file of Spire.Doc Pro edition Developer OEM to you.

Sincerely,
Amin
E-iceblue support team
User avatar

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

Mon Oct 14, 2024 6:26 am

Hi

The problem still arises when using the first two locations where the license was used first, so it is not a matter of deployment location as a colleague has assured me that the first two MAC addresses that the licenses has been used still should work fine.

The problem arises when more than one instance of the library is being used on the same program after each other as I have displayed in the test code. This displays the warning message the second time when the license was applied for the first one, so we know that the license is getting detected correctly and that the location does have the license rights.

I have also tested the Developer OEM temporary license, and this does not have the same problem.
The only thing it can be is that there is a limit of instances applied to the Developer Small Business license or something similar that is not being disclosed to me.

Regards

Cjoskeee
 
Posts: 3
Joined: Tue Oct 08, 2024 12:54 pm

Mon Oct 14, 2024 10:16 am

Hello,

Thanks for your inquiry.
When verifying the license, our server obtained the batch information, it is not fixed every time. Therefore, once the limit is exceeded, there may be watermarks if some verifications fail. The Developer OEM license has no any restrictions on deployment location, You can use it freely.

Sincerely,
Amin
E-iceblue support team
User avatar

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

Return to Spire.Doc

cron