Docs created with 22.10 trigger antivirus false positive

A document we’ve created with 22.10 triggers at least some antivirus scanners. The same exact document created with 22.9 does not.

For instance, see how Google treats the two different files:

image.png (21.9 KB)

And VirusTotal:

image.png (31.8 KB)

This is resulting in some very important emailed documents being rejected by folks’ email systems.

The two files are attached. Any suggestions?

FWIW, I’ve also submitted a “false positive” report to ClamAV.

TestApplication_AL_ClearBlue_22.10.0.0.pdf (297.9 KB)

TestApplication_AL_ClearBlue_22.9.0.0.pdf (272.2 KB)

@smithkl42

We need to investigate this case further. Would you please also share sample code snippet that you are using to perform conversion at your end? We will log a ticket in our issue tracking system and share the ID with you.

This is the method in question. Let me know if that’s sufficient.

    protected async Task<byte[]> GenerateApplicationDefault(
    EFHomeownerQuote hoQuote,
    CarrierCode carrierCode,
    string carrierName,
    string templateName)
{
    if (hoQuote.QuoteProperty.StateCode != State)
    {
        throw new InvalidQuoteException(
            $"Quote {hoQuote.QuoteId} for state {hoQuote.QuoteProperty.StateCode} passed to application generator for state {State}");
    }

    var policyNumber = hoQuote.GetPolicyNumber();

    if (!hoQuote.Quote.ImsQuoteGuid.HasValue)
    {
        throw new InvalidQuoteException(
            $"Missing IMS quote for {hoQuote.QuoteId}/{policyNumber}. Must have IMS quote to generation state homeowner application.");
    }

    var imsQuote = await _source.GetImsQuoteByPolicyNumberOrDefault(hoQuote.GetPolicyNumber())
                   ?? throw new QuoteNotFoundException($"Could not find IMS quote for policy number{hoQuote.GetPolicyNumber()}.");
    var imsProdContact = await _source.GetProducerContactByPolicyNumberOrDefault(policyNumber);
    var imsInsured = await _source.GetInsuredOrDefault(policyNumber);
    var imsInsuredLocation = await _source.GetInsuredLocationOrDefault(policyNumber);
    var additionalInsured = await _source.GetAdditionalInsuredOrDefault(policyNumber);
    var minimumReplacementCost = await _source.GetMinimumReplacementCost(hoQuote);
    var imsPolicyFee = await _source.GetPolicyFee(policyNumber);

    var values = await GetPdfAttachmentTokenDictionary(
        new ApplicationPdfModel(
            HoQuote: hoQuote,
            ImsQuote: imsQuote,
            ImsProducerContact: imsProdContact,
            Insured: imsInsured,
            ImsInsuredLocation: imsInsuredLocation,
            AdditionalInsured: additionalInsured,
            MinimumReplacementCost: minimumReplacementCost,
            CarrierCode: carrierCode,
            ImsPolicyFee: imsPolicyFee) { CarrierName = carrierName });

    var template = ResourceLoader.GetResourceAsString(templateName);
    template = TemplateHelper.RemoveHtmlComments(template);
    var applicationHtml = TemplateHelper.ApplyValues(template, values, templateName);

    var pdfOptions = new PdfRenderingOptions();
    pdfOptions.PageSetup.AdjustToWidestPage = true;

    await using var htmlStream = new MemoryStream();
    await using var writer = new StreamWriter(htmlStream);
    await writer.WriteAsync(applicationHtml.Html);
    await writer.FlushAsync();
    htmlStream.Position = 0;
    var options = new HtmlLoadOptions();
    options.PageInfo.Margin = new MarginInfo(0, 45, 0, 45);
    options.PageInfo.Width = PageSize.PageLetter.Width;
    options.PageInfo.Height = PageSize.PageLetter.Height;

    using var pdfDocument = new Document(htmlStream, options);
    await using var pdfStream = new MemoryStream();
    pdfDocument.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
    pdfDocument.PageInfo.Margin = new MarginInfo(0, 0, 0, 0);
    pdfDocument.PageInfo.Width = PageSize.PageLetter.Width;
    pdfDocument.PageInfo.Height = PageSize.PageLetter.Height;

    // Create header and footer text
    var nameTextStamp = new TextStamp(values[PdfTemplateDocumentKey.InsuredName]);
    nameTextStamp.HorizontalAlignment = HorizontalAlignment.Left;
    nameTextStamp.VerticalAlignment = VerticalAlignment.Top;
    nameTextStamp.TopMargin = 30;
    nameTextStamp.LeftMargin = 60;

    var policyTextStamp = new TextStamp(values[PdfTemplateDocumentKey.PolicyNumber]);
    policyTextStamp.HorizontalAlignment = HorizontalAlignment.Right;
    policyTextStamp.VerticalAlignment = VerticalAlignment.Top;
    policyTextStamp.TopMargin = 30;
    policyTextStamp.RightMargin = 60;

    var formTextStamp = new TextStamp(FormName);
    formTextStamp.HorizontalAlignment = HorizontalAlignment.Left;
    formTextStamp.VerticalAlignment = VerticalAlignment.Bottom;
    formTextStamp.BottomMargin = 30;
    formTextStamp.LeftMargin = 60;

    var pageNumberTextStamp = new TextStamp("");
    pageNumberTextStamp.HorizontalAlignment = HorizontalAlignment.Right;
    pageNumberTextStamp.VerticalAlignment = VerticalAlignment.Bottom;
    pageNumberTextStamp.BottomMargin = 30;
    pageNumberTextStamp.RightMargin = 60;

    var counter = 1;
    foreach (var page in pdfDocument.Pages)
    {
        pageNumberTextStamp.Value = $"Page {counter} of {pdfDocument.Pages.Count}";
        page.AddStamp(nameTextStamp);
        page.AddStamp(policyTextStamp);
        page.AddStamp(formTextStamp);
        page.AddStamp(pageNumberTextStamp);
        counter++;
    }

    pdfDocument.Save(pdfStream);
    var applicationBytes = pdfStream.ToArray();

    return applicationBytes;
}

It’s basically taking an HTML template like the one I’ve attached, transforming some of the tags, and then turning it into a PDF.

AL.zip (6.1 KB)

@smithkl42

An investigation ticket as PDFNET-52842 has been logged in our issue tracking system for further analysis. We will further look into its details and keep you posted with the status of its correction. Please be patient and spare us some time.

We are sorry for the inconvenience.