PdfFileEditor ResizeContents does not abide by set width and height

Aspose Version: 22.2.0
We are unable to upgrade to the latest version. We tried to do that already and it has other issues where it does not process HTML in the same way causing another portion of this process to fail.

We have a use case for our customers that they are required to perform by law where we take lots of pdf documents and turn all of them into a single pdf document.

The issue that we have is that we cannot control the height, width, or rotation of those documents. At times we get documents that are Plat sized or even certain pages that are different heights and widths. These documents or pages within a document can be 36 inches x 42 inches. We have seen in the past when trying to add these documents directly to the single pdf that we create it causes a failure OR it actually makes it into the PDF but then our customers attempt to print that pdf and that fails because of the large discrepancies in page size.

To correct this we initially were converting the pdf to docx which recently we found it began cutting off content from the document and more often than not it doesn’t actually convert when you have the really large size files.

To correct this now we are attempting to use the following code.

public void ProcessBadPages(string filePath, int counter)
{
    var pdfFilePath = Path.Combine(_savePath, $"{counter}.pdf");
    var tempPdfFilePath = Path.Combine(_savePath, $"Temp_{counter}.pdf");
    var tempRotated = Path.Combine(_savePath, $"TempRotated_{counter}.pdf");

    try
    {
        var document = new Aspose.Pdf.Document(pdfFilePath);
        var heightWithoutRotation = document.Pages[1].PageInfo.Height;
        var widthWithoutRotation = document.Pages[1].PageInfo.Width;
        var rectHeight = document.Pages[1].GetPageRect(true).Height;
        var rectWidth = document.Pages[1].GetPageRect(true).Width;

        var ppe = new PdfPageEditor();
        ppe.BindPdf(document);

        if (rectWidth > rectHeight)
        {
            if (ppe.Document.Pages[1].Rotate == Rotation.on90)
            {
                ppe.Document.Pages[1].Rotate = Rotation.None;
            }
            else if (ppe.Document.Pages[1].Rotate == Rotation.on180)
            {
                ppe.Document.Pages[1].Rotate = Rotation.None;
            }
            else if (ppe.Document.Pages[1].Rotate == Rotation.on270)
            {
                ppe.Document.Pages[1].Rotate = Rotation.on180;
            }
        }

        ppe.VerticalAlignmentType = VerticalAlignment.Bottom;
        ppe.HorizontalAlignment = HorizontalAlignment.Left;
        ppe.Save(tempPdfFilePath);
        ppe.Document.FreeMemory();
        ppe.Document.Dispose();
        ppe.Dispose();

        if (heightWithoutRotation != PageSize.A4.Height || widthWithoutRotation != PageSize.A4.Width)
        {
            var fileEditor = new PdfFileEditor();
            var feParams = new PdfFileEditor.ContentsResizeParameters(
                PdfFileEditor.ContentsResizeValue.Units(36),
                PdfFileEditor.ContentsResizeValue.Units(Aspose.Pdf.PageSize.A4.Width),
                PdfFileEditor.ContentsResizeValue.Units(36),
                PdfFileEditor.ContentsResizeValue.Units(72),
                PdfFileEditor.ContentsResizeValue.Units(Aspose.Pdf.PageSize.A4.Height),
                PdfFileEditor.ContentsResizeValue.Units(72)
            );
            fileEditor.CloseConcatenatedStreams = true;
            fileEditor.ResizeContents(tempPdfFilePath, tempRotated, new int[1] { 1 }, feParams);
            fileEditor = null;
        }
    }
    catch (Exception ex)
    {
        GC.Collect();
        GC.WaitForPendingFinalizers();

        throw;
    }
    finally
    {
        GC.Collect();
        GC.WaitForPendingFinalizers();
    }
}

This code will fix the rotation of the page and then we use PdfFileEditor to resize the file. The problem occurs during this process. When resizing the file we want it to be 8.5x11 in but once the document is resized with a margin at the top, sides, and bottom it comes out 9.26x13.69 in.

We have also tried removing the margins (which isn’t really an option because we place headers and footers dynamically on the document specific to our customers) but this still results in a
8.26x11.69 in file.

At the end of all of this we need the pages to all be 8.5x11 in.

Original Document
OriginalDocument.pdf (845.0 KB)

Document after rotation
File after rotation.pdf (1.2 MB)

Size with margins
Size 8.26x11.69 without margins.pdf (1.2 MB)

Size without margins
Size 9.26x13.69 with margins.pdf (1.2 MB)

Here are tye types of files that we are processsing. The page referenced above is actually coming from the document “022024-Ordinance-24-attachment” located in the folder below.
Typs of attachments being processed

@ST2YKE2

Would you please confirm if the latest version is able to do the Resize Content process as per expectations at your end even if it is failing to process the HTML in other portion of the routine? We are asking because we can only log an issue in our system if it is happening with the latest version of the API.

There is a few problems I’m having with the newer version maybe you can provide a bit of direction with it.

  1. StructuredDocumentTag no longer contains a definition for “ChildNodes”.
private void AddNode(string key, string value)
{
    StructuredDocumentTag control = new StructuredDocumentTag(_Document, SdtType.RichText, MarkupLevel.Block);
    control.IsShowingPlaceholderText = false;
    control.Title = key;
    control.Tag = key;
    control.LockContentControl = true;
    control.LockContents = true;
    Paragraph para = new Paragraph(_Document);
    Run run = new Run(_Document);
    run.Text = value;
    run.Font.Color = Color.Green;
    para.Runs.Add(run);
    control.RemoveAllChildren();
    control.ChildNodes.Add(para);

    var shape = new Shape(_Document, ShapeType.TextBox);
    shape.RelativeHorizontalPosition = RelativeHorizontalPosition.RightMargin;
    shape.HorizontalAlignment = HorizontalAlignment.Right;
    shape.VerticalAlignment = VerticalAlignment.Bottom;
    shape.RelativeVerticalPosition = RelativeVerticalPosition.BottomMargin;
    shape.Left = 2000;
    shape.Width = 1;
    shape.Height = 1;

    shape.AppendChild(control);

    _DocumentBuilder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
    _DocumentBuilder.InsertNode(shape);
}
  1. HtmlSaveOptions no longer contains a definition for “ExportTextBoxAsSvg”
/// <summary>
/// This method will take a docx template/uploaded docx and convert it into HTML
/// </summary>
/// <param name="docxDocument"></param>
/// <param name="data"></param>
/// <param name="compiledMeetingDoc"></param>
/// <param name="permFilePath"></param>
/// <returns></returns>
public async Task ShouldCreateHTMLFromDocxCompile(Document docxDocument, CompileMeetingContentModel data, CompiledMeetingDocument compiledMeetingDoc = null, string permFilePath = null)
{
    if (bc.AutoCreateHtmlFromDocxSetting != true)
    {
        return;
    }

    if (data == null)
    {
        data = await bc.GetMeetingData(compiledMeetingDoc);
        await bc.CompileUpdates.SendCompileUpdates(
            bc.AzureQueueCompileModel,
            CompileEvents.Started,
            new int[1] { 3 },
            null
        );
    }

    var compiledDoc = await bc.StartCompile(data.Meeting.Id, data.MeetingTemplate.Id, new List<CompileOutputTypes>() { CompileOutputTypes.Html }, DateTime.UtcNow);
    var file = compiledDoc.CompiledMeetingDocumentFiles.FirstOrDefault(x => x.CompileOutputType == CompileOutputTypes.Html);
    file.CompiledMeetingDocumentHtml = new CompiledMeetingDocumentHtml();

    string tempPath = Path.Combine(bc.SavePath, $"{Guid.NewGuid().ToString()}.html");
    Aspose.Words.Saving.HtmlSaveOptions htmlSaveOptions = new Aspose.Words.Saving.HtmlSaveOptions();
    htmlSaveOptions.ExportImagesAsBase64 = true;
    htmlSaveOptions.SaveFormat = SaveFormat.Html;
    htmlSaveOptions.ExportFontsAsBase64 = true;
    htmlSaveOptions.ExportFontResources = true;
    htmlSaveOptions.ExportTextBoxAsSvg = true;
    htmlSaveOptions.ExportRoundtripInformation = true;
    htmlSaveOptions.Encoding = Encoding.UTF8;

    if (docxDocument == null)
    {
        using (var docStream = bc.AzureProvider.DownloadToStream(permFilePath))
        {
            docxDocument = new Aspose.Words.Document(docStream);
            ELSLogHelper.InsertInfoLog(ELSLogHelper.AsposeLogMessage("Load"), MethodBase.GetCurrentMethod()?.Name, MethodBase.GetCurrentMethod().DeclaringType?.Name, Environment.StackTrace);
            docxDocument.Save(tempPath, htmlSaveOptions);
            ELSLogHelper.InsertInfoLog(ELSLogHelper.AsposeLogMessage("Save"), MethodBase.GetCurrentMethod()?.Name, MethodBase.GetCurrentMethod().DeclaringType?.Name, Environment.StackTrace);
        }
    }
    else
    {
        docxDocument.Save(tempPath, htmlSaveOptions);
        ELSLogHelper.InsertInfoLog(ELSLogHelper.AsposeLogMessage("Save"), MethodBase.GetCurrentMethod()?.Name, MethodBase.GetCurrentMethod().DeclaringType?.Name, Environment.StackTrace);
    }

    var decodedHtmlDoc = await ProcessHTMLSectionsAndItems(tempPath, data);

    file.PublishStatus = PublishStatuses.Unpublish;
    file.Language = Localizer_i18n.CurrentLanguage.Value;

    var insertSQLObj = new
    {
        CompiledHtml = decodedHtmlDoc.DocumentNode.OuterHtml
    };

    var insertSQL = "INSERT INTO CompiledMeetingDocumentHtmls " +
        "(CompiledHtml) " +
        "OUTPUT INSERTED.Id " +
        "VALUES " +
        "(@CompiledHtml)";

    file.CompiledMeetingDocumentHtml.Id = await bc.CustomerCallContext.SystemContext.CommitAsync<int>(insertSQL, insertSQLObj);
    file.CompiledMeetingDocumentHtml.CompiledHtml = decodedHtmlDoc.DocumentNode.OuterHtml;
    file.CompileFinishedDate = DateTime.UtcNow;

    await bc.CustomerCallContext.SystemContext.UpdateFileAsync(file);

    if (File.Exists(tempPath))
    {
        File.Delete(tempPath);
    }

    //integration of compile document history 
    ICreateCompileAttachmentHistory createCompileAttachmentHistory = new CompileMeetingAttachmentHistoryService(bc.CustomerCallContext);
    var compileHistory = await createCompileAttachmentHistory.CreateInMemoryCompileAttachmentHistory(data.Content, file.CompiledMeetingDocumentId);
    await createCompileAttachmentHistory.SaveCompileAttachmentHistory(compileHistory);

    decodedHtmlDoc = null;
    docxDocument = null;

    GC.Collect();
    GC.WaitForPendingFinalizers();

    bc.ThrowIfTaskCancelled(bc.CancellationToken);
    await bc.SaveCompile(compiledDoc);

    var logManagerModel = new LogManagerModel
    {
        Exception = null,
        ExceptionData = new Dictionary<string, string>()
        {
            { "Message", $"HTML Compiled Successfully." }
        }
    };
    bc.CustomerCallContext.LogManager.Info(logManagerModel);
}
  1. CompositeNode no longer contains a definition for “ChildNodes”
/// <summary>
/// This will allow pulling of content between specific document nodes passed in
/// </summary>
/// <param name="cloneNode"></param>
/// <param name="nodes"></param>
/// <param name="node"></param>
/// <param name="isInclusive"></param>
/// <param name="isStartMarker"></param>
/// <param name="isEndMarker"></param>
private static void ProcessMarker(CompositeNode cloneNode, ArrayList nodes, Node node, bool isInclusive, bool isStartMarker, bool isEndMarker)
{
    // If we are dealing with a block level node just see if it should be included and add it to the list.
    if (!IsInline(node))
    {
        // Don't add the node twice if the markers are the same node
        if (!(isStartMarker && isEndMarker))
        {
            if (isInclusive)
            {
                nodes.Add(cloneNode);
            }
        }
        return;
    }

    // If a marker is a FieldStart node check if it's to be included or not.
    // We assume for simplicity that the FieldStart and FieldEnd appear in the same paragraph.
    if (node.NodeType == NodeType.FieldStart)
    {
        // If the marker is a start node and is not be included then skip to the end of the field.
        // If the marker is an end node and it is to be included then move to the end field so the field will not be removed.
        if ((isStartMarker && !isInclusive) || (!isStartMarker && isInclusive))
        {
            while (node.NextSibling != null && node.NodeType != NodeType.FieldEnd)
                node = node.NextSibling;
        }
    }

    // If either marker is part of a comment then to include the comment itself we need to move the pointer forward to the Comment
    // Node found after the CommentRangeEnd node.
    if (node.NodeType == NodeType.CommentRangeEnd)
    {
        while (node.NextSibling != null && node.NodeType != NodeType.Comment)
            node = node.NextSibling;
    }

    // Find the corresponding node in our cloned node by index and return it.
    // If the start and end node are the same some child nodes might already have been removed. Subtract the
    // Difference to get the right index.
    int indexDiff = node.ParentNode.ChildNodes.Count - cloneNode.ChildNodes.Count;

    // Child node count identical.
    if (indexDiff == 0)
        node = cloneNode.ChildNodes[node.ParentNode.IndexOf(node)];
    else
        node = cloneNode.ChildNodes[node.ParentNode.IndexOf(node) - indexDiff];

    // Remove the nodes up to/from the marker.
    bool isSkip = false;
    bool isProcessing = true;
    bool isRemoving = isStartMarker;
    Node nextNode = cloneNode.FirstChild;

    while (isProcessing && nextNode != null)
    {
        Node currentNode = nextNode;
        isSkip = false;

        if (currentNode.Equals(node))
        {
            if (isStartMarker)
            {
                isProcessing = false;
                if (isInclusive)
                    isRemoving = false;
            }
            else
            {
                isRemoving = true;
                if (isInclusive)
                    isSkip = true;
            }
        }

        nextNode = nextNode.NextSibling;
        if (isRemoving && !isSkip)
            currentNode.Remove();
    }

    // After processing the composite node may become empty. If it has don't include it.
    if (!(isStartMarker && isEndMarker))
    {
        if (cloneNode.HasChildNodes)
        {
            nodes.Add(cloneNode);
        }
    }
}
  1. Newest version of aspose no longer includes the “-aw-” or “-aw-headerfooter-type:” when converting Docx to HTML which is something we were relying on to ensure that we are finding the correct sections of our HTML.

OuterHtml = "<table cellspacing="0" cellpadding="0"><td style="width:489.6pt; padding-right:5.4pt; padding-left:5.4pt; vertical-align:top"><p style="margin-top:0pt; margin-bottom:0pt; font-size:12pt"><span style="font-weight:bold">ACTIVE AGENDA:<a …

/// <summary>
/// This method will take a docx template/uploaded docx and convert it into HTML
/// </summary>
/// <param name="docxDocument"></param>
/// <param name="data"></param>
/// <param name="compiledMeetingDoc"></param>
/// <param name="permFilePath"></param>
/// <returns></returns>
public async Task ShouldCreateHTMLFromDocxCompile(Document docxDocument, CompileMeetingContentModel data, CompiledMeetingDocument compiledMeetingDoc = null, string permFilePath = null)
{
    if (bc.AutoCreateHtmlFromDocxSetting != true)
    {
        return;
    }

    if (data == null)
    {
        data = await bc.GetMeetingData(compiledMeetingDoc);
        await bc.CompileUpdates.SendCompileUpdates(
            bc.AzureQueueCompileModel,
            CompileEvents.Started,
            new int[1] { 3 },
            null
        );
    }

    var compiledDoc = await bc.StartCompile(data.Meeting.Id, data.MeetingTemplate.Id, new List<CompileOutputTypes>() { CompileOutputTypes.Html }, DateTime.UtcNow);
    var file = compiledDoc.CompiledMeetingDocumentFiles.FirstOrDefault(x => x.CompileOutputType == CompileOutputTypes.Html);
    file.CompiledMeetingDocumentHtml = new CompiledMeetingDocumentHtml();

    string tempPath = Path.Combine(bc.SavePath, $"{Guid.NewGuid().ToString()}.html");
    Aspose.Words.Saving.HtmlSaveOptions htmlSaveOptions = new Aspose.Words.Saving.HtmlSaveOptions();
    htmlSaveOptions.ExportImagesAsBase64 = true;
    htmlSaveOptions.SaveFormat = SaveFormat.Html;
    htmlSaveOptions.ExportFontsAsBase64 = true;
    htmlSaveOptions.ExportFontResources = true;
    htmlSaveOptions.ExportRoundtripInformation = true;
    htmlSaveOptions.Encoding = Encoding.UTF8;

    if (docxDocument == null)
    {
        using (var docStream = bc.AzureProvider.DownloadToStream(permFilePath))
        {
            docxDocument = new Aspose.Words.Document(docStream);
            ELSLogHelper.InsertInfoLog(ELSLogHelper.AsposeLogMessage("Load"), MethodBase.GetCurrentMethod()?.Name, MethodBase.GetCurrentMethod().DeclaringType?.Name, Environment.StackTrace);
            docxDocument.Save(tempPath, htmlSaveOptions);
            ELSLogHelper.InsertInfoLog(ELSLogHelper.AsposeLogMessage("Save"), MethodBase.GetCurrentMethod()?.Name, MethodBase.GetCurrentMethod().DeclaringType?.Name, Environment.StackTrace);
        }
    }
    else
    {
        docxDocument.Save(tempPath, htmlSaveOptions);
        ELSLogHelper.InsertInfoLog(ELSLogHelper.AsposeLogMessage("Save"), MethodBase.GetCurrentMethod()?.Name, MethodBase.GetCurrentMethod().DeclaringType?.Name, Environment.StackTrace);
    }

    var decodedHtmlDoc = await ProcessHTMLSectionsAndItems(tempPath, data);

    file.PublishStatus = PublishStatuses.Unpublish;
    file.Language = Localizer_i18n.CurrentLanguage.Value;

    var insertSQLObj = new
    {
        CompiledHtml = decodedHtmlDoc.DocumentNode.OuterHtml
    };

    var insertSQL = "INSERT INTO CompiledMeetingDocumentHtmls " +
        "(CompiledHtml) " +
        "OUTPUT INSERTED.Id " +
        "VALUES " +
        "(@CompiledHtml)";

    file.CompiledMeetingDocumentHtml.Id = await bc.CustomerCallContext.SystemContext.CommitAsync<int>(insertSQL, insertSQLObj);
    file.CompiledMeetingDocumentHtml.CompiledHtml = decodedHtmlDoc.DocumentNode.OuterHtml;
    file.CompileFinishedDate = DateTime.UtcNow;

    await bc.CustomerCallContext.SystemContext.UpdateFileAsync(file);

    if (File.Exists(tempPath))
    {
        File.Delete(tempPath);
    }

    //integration of compile document history 
    ICreateCompileAttachmentHistory createCompileAttachmentHistory = new CompileMeetingAttachmentHistoryService(bc.CustomerCallContext);
    var compileHistory = await createCompileAttachmentHistory.CreateInMemoryCompileAttachmentHistory(data.Content, file.CompiledMeetingDocumentId);
    await createCompileAttachmentHistory.SaveCompileAttachmentHistory(compileHistory);

    decodedHtmlDoc = null;
    docxDocument = null;

    GC.Collect();
    GC.WaitForPendingFinalizers();

    bc.ThrowIfTaskCancelled(bc.CancellationToken);
    await bc.SaveCompile(compiledDoc);

    var logManagerModel = new LogManagerModel
    {
        Exception = null,
        ExceptionData = new Dictionary<string, string>()
        {
            { "Message", $"HTML Compiled Successfully." }
        }
    };
    bc.CustomerCallContext.LogManager.Info(logManagerModel);
}

/// <summary>
/// This method will process the sections and attachments and build the public HTML.
/// </summary>
/// <param name="tempPath"></param>
/// <param name="data"></param>
private async Task<HtmlDocument> ProcessHTMLSectionsAndItems(string tempPath, CompileMeetingContentModel data)
{
    var tempHtmlDoc = new HtmlDocument() { OptionUseIdAttribute = true };
    tempHtmlDoc.Load(tempPath);
    var htmlDoc = new HtmlDocument();
    htmlDoc.LoadHtml(System.Net.WebUtility.HtmlDecode(tempHtmlDoc.DocumentNode.OuterHtml));

    var hasMiniPacket = new MeetingTemplate(bc.CustomerCallContext).HasMiniPacketTemplate(data.Meeting.Id);
    var miniPacketEnabled = bc.SystemSettingsLogic.IsMiniPacketEnabled();
    var itemSearchEnabled = new BaseSettingLogic(bc.CustomerCallContext).GetItemSearchFeatureFlagValue();
    var facebookEnabled = bc.SystemSettingsLogic.IsFacebookShareEnabled();
    var twitterEnabled = bc.SystemSettingsLogic.IsTwitterShareEnabled();
    var isVideoLocationButtonEnabled = await bc.SystemSettingsLogic.IsVideoLocationButtonEnabled();

    var headerFooterNodesToBeRemoved = htmlDoc.DocumentNode
            .Descendants("div")
            .Where(node => (node.GetAttributeValue("style", "").Trim().ToLower().Contains("header") || node.GetAttributeValue("style", "").Trim().ToLower().Contains("footer")) && node.GetAttributeValue("style", "").Trim().ToLower().Contains("-aw-headerfooter-type:")).ToList();

    foreach (var headerFooter in headerFooterNodesToBeRemoved)
    {
        headerFooter.Remove();
    }

    var sectionCounter = 0;
    var itemCounter = 0;
    HtmlNodeCollection itemHtmlNodeCollection = new HtmlNodeCollection(null);
    HtmlNodeCollection sectionHtmlNodeCollection = new HtmlNodeCollection(null);
    foreach (var section in data.Content)
    {
        if (sectionHtmlNodeCollection == null || sectionHtmlNodeCollection.Count == 0)
        {
            var sectionHtmlNodeCollectionList = htmlDoc.DocumentNode.SelectNodes($"//*").Where(x => x.Name.ToLower() == "a" && x.GetAttributeValue("name", "").Contains($"SectionBookmark_"));
            sectionHtmlNodeCollectionList.ForEach(x =>
            {
                sectionHtmlNodeCollection.Add(x);
            });
        }

        var fSection = htmlDoc.DocumentNode.SelectSingleNode($"//html/body/div/table/tr/td/p/a[@name[contains(., 'SectionBookmark_{section.Id}')]]");
        //var fSection = htmlDoc.DocumentNode.Descendants().FirstOrDefault(x => x.Name.ToLower() == "a" && x.GetAttributeValue("name", "").Contains($"SectionBookmark_{section.Id}") && x.InnerText.Contains(System.Net.WebUtility.HtmlDecode(section.Name)));
        if (fSection == null)
        {
            //fSection = htmlDoc.DocumentNode.SelectNodes($"//html/body/div/table/tr/td/p/*").FirstOrDefault(x => x.Name.ToLower() == "a" && x.InnerText.Contains(System.Net.WebUtility.HtmlDecode(section.Name)));
            fSection = htmlDoc.DocumentNode.SelectNodes($"//*").FirstOrDefault(x => x.Name.ToLower() == "a" && x.GetAttributeValue("name", "").Contains($"SectionBookmark_{section.Id}") && x.InnerText.Contains(System.Net.WebUtility.HtmlDecode(section.Name)));
        }

        if (fSection != null)
        {
            var parentNode = fSection;
            if (parentNode.Name.ToLower() == "a")
            {
                foreach (var childrenNodes in parentNode.ChildNodes)
                {
                    parentNode.ParentNode.InsertBefore(childrenNodes, parentNode);
                }
            }

            var parentTableNode = fSection.ParentNode;
            HtmlNode parentCellNode = null;
            var foundParentTableNode = false;
            while (foundParentTableNode == false && parentTableNode.Name.ToLower() != "body")
            {
                if (parentTableNode.PreviousSibling != null &&
                    (parentTableNode.PreviousSibling.Name.ToLower() == "p" || parentTableNode.PreviousSibling.Name.ToLower() == "table") &&
                    parentTableNode.ParentNode.Name.ToLower() == "div" &&
                    parentTableNode.GetAttributeValue("style", null).ToLower().Contains("-aw-"))
                {
                    foundParentTableNode = true;
                    parentTableNode.AddClass("item-table-fromdocx");
                    parentTableNode.Attributes.Add(htmlDoc.CreateAttribute("data-id", $"{section.Id}"));
                    parentTableNode.Attributes.Add(htmlDoc.CreateAttribute("data-sectionid", $"{section.MeetingSectionId}"));
                    parentCellNode = parentTableNode.SelectNodes("*/td").LastOrDefault();
                }
                else
                {
                    parentTableNode = parentTableNode.ParentNode;
                }
            }

            if (section.AttachmentCount > 0)
            {
                parentCellNode.AddClass("section-item-attachments-fromdocx");
                parentCellNode.Attributes.Add(htmlDoc.CreateAttribute("id", $"sectionattachment_{section.Id}"));
                parentCellNode.Attributes.Add(htmlDoc.CreateAttribute("data-createdfromdocx", $"True"));
                parentCellNode.Attributes.Add(htmlDoc.CreateAttribute("data-hasattachments", $"True"));
                parentCellNode.Attributes.Add(htmlDoc.CreateAttribute("data-sectiontemplateid", $"{section.Id}"));

                var attachmentHtmlNode = HtmlNode.CreateNode($@"<td class=""attachmentCell""><div><span class=""glyphicon glyphicon-paperclip"" title=""Has Attachments"" style=""color:#aaa;""></span></div></td>");
                parentTableNode.FirstChild.PrependChild(attachmentHtmlNode);
            }
            else
            {
                var attachmentHtmlNode = HtmlNode.CreateNode($@"<td class=""attachmentCell""><div></span></div></td>");
                parentTableNode.FirstChild.PrependChild(attachmentHtmlNode);

                parentTableNode.Attributes.Add(htmlDoc.CreateAttribute("data-hasattachments", $"False"));
            }

            var optionsButtons = $@"<td id=""sharebuttons_{section.Id}"" class=""optionalButtonsCell"">";
            if (hasMiniPacket && miniPacketEnabled)
            {
                optionsButtons += $@"                                
                            <div id=""miniPacket_{section.Id}"" data-loaded=""Loaded"" class=""flex-parent shareButtons_display pull-right optionalButtons shareItemBtns_{section.Id}"">
                                <a href=""/meetings/sectionminipacket?id={section.Id}"" onclick=""event.stopPropagation();"" tabindex=""0"">
                                    <svg width=""38"" height=""20"" viewBox=""0 0 38 20"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
                                        <title>Combine item's attachments into one PDF and view</title>
                                        <rect class=""svgPdfShareButtons"" width=""37.5"" height=""20"" rx=""2"" fill=""currentColor"" ></rect>
                                        <path d=""M9.80078 8.32031L8.375 9.74609V6.25C8.375 5.91797 8.08203 5.625 7.75 5.625C7.39844 5.625 7.125 5.91797 7.125 6.25V9.74609L5.67969 8.32031C5.5625 8.20312 5.40625 8.125 5.25 8.125C5.07422 8.125 4.91797 8.20312 4.80078 8.32031C4.54688 8.55469 4.54688 8.96484 4.80078 9.19922L7.30078 11.6992C7.53516 11.9531 7.94531 11.9531 8.17969 11.6992L10.6797 9.19922C10.9336 8.96484 10.9336 8.55469 10.6797 8.32031C10.4453 8.06641 10.0352 8.06641 9.80078 8.32031ZM10.875 13.125H4.625C4.27344 13.125 4 13.418 4 13.75C4 14.1016 4.27344 14.375 4.625 14.375H10.875C11.207 14.375 11.5 14.1016 11.5 13.75C11.5 13.418 11.207 13.125 10.875 13.125Z"" fill=""white""></path><path d=""M16.21 6.86133C16.9456 6.86133 17.4974 7.05827 17.8652 7.45215C18.2363 7.84603 18.4219 8.40592 18.4219 9.13184C18.4219 9.48665 18.3763 9.81706 18.2852 10.123C18.194 10.4258 18.054 10.6911 17.8652 10.9189C17.6764 11.1436 17.4372 11.3193 17.1475 11.4463C16.8577 11.57 16.516 11.6318 16.1221 11.6318H15.79V14H14.0908V6.86133H16.21ZM16.0488 8.30176H15.79V10.1914H15.9414C16.0977 10.1914 16.2344 10.1572 16.3516 10.0889C16.4688 10.0173 16.5583 9.90495 16.6201 9.75195C16.6852 9.5957 16.7178 9.39225 16.7178 9.1416C16.7178 8.86165 16.6624 8.65169 16.5518 8.51172C16.4411 8.37174 16.2734 8.30176 16.0488 8.30176ZM24.1836 10.2793C24.1836 11.0703 24.0632 11.7425 23.8223 12.2959C23.5846 12.8493 23.2396 13.2725 22.7871 13.5654C22.3346 13.8551 21.7845 14 21.1367 14H19.2959V6.86133H21.2539C21.8789 6.86133 22.4095 6.99316 22.8457 7.25684C23.2819 7.52051 23.6139 7.90625 23.8418 8.41406C24.0697 8.92188 24.1836 9.54362 24.1836 10.2793ZM22.4258 10.3477C22.4258 9.86589 22.3802 9.47689 22.2891 9.18066C22.2012 8.88444 22.0677 8.6696 21.8887 8.53613C21.7129 8.39941 21.4915 8.33105 21.2246 8.33105H20.9951V12.5205H21.127C21.5762 12.5205 21.9049 12.3447 22.1133 11.9932C22.3216 11.6416 22.4258 11.0931 22.4258 10.3477ZM26.8643 14H25.165V6.86133H28.583V8.30176H26.8643V9.83008H28.4561V11.2705H26.8643V14ZM32.6602 12.3008C32.6602 12.6979 32.5853 13.0299 32.4355 13.2969C32.2858 13.5638 32.0693 13.764 31.7861 13.8975C31.5062 14.0309 31.1676 14.0977 30.7705 14.0977C30.5003 14.0977 30.235 14.0749 29.9746 14.0293C29.7142 13.9837 29.4554 13.904 29.1982 13.79V12.2617C29.4001 12.3822 29.6214 12.488 29.8623 12.5791C30.1064 12.667 30.3522 12.7109 30.5996 12.7109C30.7493 12.7109 30.8617 12.6865 30.9365 12.6377C31.0114 12.5856 31.0488 12.5026 31.0488 12.3887C31.0488 12.3268 31.0326 12.2682 31 12.2129C30.9707 12.1543 30.8975 12.0843 30.7803 12.0029C30.6631 11.9215 30.4759 11.8174 30.2188 11.6904C29.9941 11.5765 29.8053 11.4382 29.6523 11.2754C29.4993 11.1094 29.3838 10.9206 29.3057 10.709C29.2275 10.4974 29.1885 10.2614 29.1885 10.001C29.1885 9.48665 29.3447 9.08626 29.6572 8.7998C29.9697 8.51335 30.4141 8.37012 30.9902 8.37012C31.2767 8.37012 31.5469 8.41081 31.8008 8.49219C32.0547 8.57031 32.3135 8.68587 32.5771 8.83887L32.1816 10.0693C32.0156 9.95866 31.8398 9.86263 31.6543 9.78125C31.4688 9.69987 31.2799 9.65918 31.0879 9.65918C30.974 9.65918 30.8893 9.68034 30.834 9.72266C30.7786 9.76497 30.751 9.83008 30.751 9.91797C30.751 9.97656 30.7656 10.0303 30.7949 10.0791C30.8275 10.1279 30.8991 10.1898 31.0098 10.2646C31.1204 10.3363 31.293 10.4421 31.5273 10.582C31.752 10.7057 31.9489 10.8473 32.1182 11.0068C32.2874 11.1663 32.4193 11.3519 32.5137 11.5635C32.6113 11.7718 32.6602 12.0176 32.6602 12.3008Z"" fill=""white""></path>
                                    </svg>
                                </a>
                            </div>";
            }
            else if (section.AttachmentCount > 0)
            {
                optionsButtons += $@"
                            <div id=""miniPacket_{section.Id}"" data-loaded=""Loaded"" class=""flex-parent shareButtons_display pull-right optionalButtons shareItemBtns_{section.Id}"">
                                <a href=""/meetings/sectionattachments?id={section.Id}"" onclick=""event.stopPropagation();"" tabindex=""0"">
                                    <svg width=""38"" height=""20"" viewBox=""0 0 38 20"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
                                        <title>Combine item's attachments into one PDF and view</title>
                                        <rect class=""svgPdfShareButtons"" width=""37.5"" height=""20"" rx=""2"" fill=""currentColor"" ></rect>
                                        <path d=""M9.80078 8.32031L8.375 9.74609V6.25C8.375 5.91797 8.08203 5.625 7.75 5.625C7.39844 5.625 7.125 5.91797 7.125 6.25V9.74609L5.67969 8.32031C5.5625 8.20312 5.40625 8.125 5.25 8.125C5.07422 8.125 4.91797 8.20312 4.80078 8.32031C4.54688 8.55469 4.54688 8.96484 4.80078 9.19922L7.30078 11.6992C7.53516 11.9531 7.94531 11.9531 8.17969 11.6992L10.6797 9.19922C10.9336 8.96484 10.9336 8.55469 10.6797 8.32031C10.4453 8.06641 10.0352 8.06641 9.80078 8.32031ZM10.875 13.125H4.625C4.27344 13.125 4 13.418 4 13.75C4 14.1016 4.27344 14.375 4.625 14.375H10.875C11.207 14.375 11.5 14.1016 11.5 13.75C11.5 13.418 11.207 13.125 10.875 13.125Z"" fill=""white""></path><path d=""M16.21 6.86133C16.9456 6.86133 17.4974 7.05827 17.8652 7.45215C18.2363 7.84603 18.4219 8.40592 18.4219 9.13184C18.4219 9.48665 18.3763 9.81706 18.2852 10.123C18.194 10.4258 18.054 10.6911 17.8652 10.9189C17.6764 11.1436 17.4372 11.3193 17.1475 11.4463C16.8577 11.57 16.516 11.6318 16.1221 11.6318H15.79V14H14.0908V6.86133H16.21ZM16.0488 8.30176H15.79V10.1914H15.9414C16.0977 10.1914 16.2344 10.1572 16.3516 10.0889C16.4688 10.0173 16.5583 9.90495 16.6201 9.75195C16.6852 9.5957 16.7178 9.39225 16.7178 9.1416C16.7178 8.86165 16.6624 8.65169 16.5518 8.51172C16.4411 8.37174 16.2734 8.30176 16.0488 8.30176ZM24.1836 10.2793C24.1836 11.0703 24.0632 11.7425 23.8223 12.2959C23.5846 12.8493 23.2396 13.2725 22.7871 13.5654C22.3346 13.8551 21.7845 14 21.1367 14H19.2959V6.86133H21.2539C21.8789 6.86133 22.4095 6.99316 22.8457 7.25684C23.2819 7.52051 23.6139 7.90625 23.8418 8.41406C24.0697 8.92188 24.1836 9.54362 24.1836 10.2793ZM22.4258 10.3477C22.4258 9.86589 22.3802 9.47689 22.2891 9.18066C22.2012 8.88444 22.0677 8.6696 21.8887 8.53613C21.7129 8.39941 21.4915 8.33105 21.2246 8.33105H20.9951V12.5205H21.127C21.5762 12.5205 21.9049 12.3447 22.1133 11.9932C22.3216 11.6416 22.4258 11.0931 22.4258 10.3477ZM26.8643 14H25.165V6.86133H28.583V8.30176H26.8643V9.83008H28.4561V11.2705H26.8643V14ZM32.6602 12.3008C32.6602 12.6979 32.5853 13.0299 32.4355 13.2969C32.2858 13.5638 32.0693 13.764 31.7861 13.8975C31.5062 14.0309 31.1676 14.0977 30.7705 14.0977C30.5003 14.0977 30.235 14.0749 29.9746 14.0293C29.7142 13.9837 29.4554 13.904 29.1982 13.79V12.2617C29.4001 12.3822 29.6214 12.488 29.8623 12.5791C30.1064 12.667 30.3522 12.7109 30.5996 12.7109C30.7493 12.7109 30.8617 12.6865 30.9365 12.6377C31.0114 12.5856 31.0488 12.5026 31.0488 12.3887C31.0488 12.3268 31.0326 12.2682 31 12.2129C30.9707 12.1543 30.8975 12.0843 30.7803 12.0029C30.6631 11.9215 30.4759 11.8174 30.2188 11.6904C29.9941 11.5765 29.8053 11.4382 29.6523 11.2754C29.4993 11.1094 29.3838 10.9206 29.3057 10.709C29.2275 10.4974 29.1885 10.2614 29.1885 10.001C29.1885 9.48665 29.3447 9.08626 29.6572 8.7998C29.9697 8.51335 30.4141 8.37012 30.9902 8.37012C31.2767 8.37012 31.5469 8.41081 31.8008 8.49219C32.0547 8.57031 32.3135 8.68587 32.5771 8.83887L32.1816 10.0693C32.0156 9.95866 31.8398 9.86263 31.6543 9.78125C31.4688 9.69987 31.2799 9.65918 31.0879 9.65918C30.974 9.65918 30.8893 9.68034 30.834 9.72266C30.7786 9.76497 30.751 9.83008 30.751 9.91797C30.751 9.97656 30.7656 10.0303 30.7949 10.0791C30.8275 10.1279 30.8991 10.1898 31.0098 10.2646C31.1204 10.3363 31.293 10.4421 31.5273 10.582C31.752 10.7057 31.9489 10.8473 32.1182 11.0068C32.2874 11.1663 32.4193 11.3519 32.5137 11.5635C32.6113 11.7718 32.6602 12.0176 32.6602 12.3008Z"" fill=""white""></path>
                                    </svg>
                                </a>
                            </div>";
            }

            if (isVideoLocationButtonEnabled && section.VideoLocation > 0)
            {
                optionsButtons += $@"
                            <div id=""playButton_{section.Id}"" data-loaded=""Loaded"" class=""flex-parent shareButtons_display pull-right optionalButtons shareItemBtns_{section.Id}"">
                                <a onclick=""jumpToVideoLocation()"" tabindex=""0"">
                                    <svg width=""20"" height=""20"" viewBox=""0 0 20 20"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
                                        <title>Jump to location on video</title>
                                        <rect class=""svgPlayButton"" width=""20"" height=""20"" rx=""2"" fill=""currentColor"" />
                                        <path d=""M7.5 6.5359C7.5 6.151 7.91667 5.91044 8.25 6.10289L14.25 9.56699C14.5833 9.75944 14.5833 10.2406 14.25 10.433L8.25 13.8971C7.91667 14.0896 7.5 13.849 7.5 13.4641L7.5 6.5359Z"" fill=""white"" />
                                    </svg>
                                </a>
                            </div>";
            }

            if (optionsButtons != $@"<td id=""sharebuttons_{section.Id}"" class=""optionalButtonsCell"">")
            {
                optionsButtons += $@"
                            <div data-id=""{section.Id}"" class=""flex-parent shareButtons_display pull-right elipsisMenu elipsis_{section.Id}"">
                                <svg width=""20"" height=""20"" viewBox=""0 0 20 20"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
                                    <path class=""svgElipsisMenu"" fill-rule=""evenodd"" clip-rule=""evenodd"" d=""M15.2351 8.11582C16.0091 8.4364 16.3766 9.3237 16.056 10.0977C15.7354 10.8716 14.8481 11.2391 14.0742 10.9186C13.3002 10.598 12.9327 9.71068 13.2533 8.93672C13.5738 8.16277 14.4611 7.79523 15.2351 8.11582ZM10.0851 11.0337C10.9228 11.0337 11.6019 10.3546 11.6019 9.51686C11.6019 8.67913 10.9228 8.00002 10.0851 8.00002C9.24737 8.00002 8.56826 8.67913 8.56826 9.51686C8.56826 10.3546 9.24737 11.0337 10.0851 11.0337ZM5.51686 11.0339C6.35458 11.0339 7.03369 10.3548 7.03369 9.5171C7.03369 8.67937 6.35458 8.00026 5.51686 8.00026C4.67913 8.00026 4.00002 8.67937 4.00002 9.5171C4.00002 10.3548 4.67913 11.0339 5.51686 11.0339Z"" fill=""currentColor"" />
                                </svg>
                            </div>";
            }

            optionsButtons += "</td>";

            var htmlNode = HtmlNode.CreateNode(optionsButtons);
            parentTableNode.FirstChild.AppendChild(htmlNode);

            var parentTableStyles = parentTableNode.GetAttributeValue("style", "").Split(';');
            if (parentTableStyles.Any(x => x.ToLower().Contains("margin-left")))
            {
                var marginLeft = parentTableStyles.FirstOrDefault(x => x.ToLower().Contains("margin-left")).Split(':')[1];
                parentTableNode.FirstChild.FirstChild.SetAttributeValue("style", $@"{parentTableNode.FirstChild.FirstChild.GetAttributeValue("style", "")} padding-left:{marginLeft}");

                parentTableNode.SetAttributeValue("style", $@"{parentTableNode.GetAttributeValue("style", "").ToLower().Replace($@"margin-left:{marginLeft}", "")}");
            }

            if (parentNode.Name.ToLower() == "a")
            {
                parentNode.Remove();
            }
        }

        foreach (var item in section.Items)
        {
            if (itemHtmlNodeCollection == null || itemHtmlNodeCollection.Count == 0)
            {
                var itemHtmlNodeCollectionList = htmlDoc.DocumentNode.SelectNodes($"//*").Where(x => x.Name.ToLower() == "a" && x.GetAttributeValue("name", "").Contains($"ItemBookmark_"));
                itemHtmlNodeCollectionList.ForEach(x =>
                {
                    itemHtmlNodeCollection.Add(x);
                });
            }

            var fItem = htmlDoc.DocumentNode.SelectSingleNode($"//html/body/div/table/tr/td/p/a[@name[contains(., 'ItemBookmark_{item.MeetingItemId}')]]");
            if (fItem == null)
            {
                fItem = htmlDoc.DocumentNode.SelectNodes($"//*").FirstOrDefault(x => x.Name.ToLower() == "a" && x.GetAttributeValue("name", "").Contains($"ItemBookmark_{item.MeetingItemId}") && x.InnerText.Contains(System.Net.WebUtility.HtmlDecode(item.Title)));
            }

            if (fItem != null)
            {
                HtmlNode parentNode = null;

                if (fItem.Name.ToLower() == "a")
                {
                    parentNode = fItem;

                    foreach (var childrenNodes in fItem.ChildNodes)
                    {
                        parentNode.ParentNode.InsertBefore(childrenNodes, parentNode);
                    }
                }
                else
                {
                    parentNode = fItem.ParentNode;

                    while (!item.Title.Trim().ToLower().Contains(parentNode.GetAttributeValue("name", "").Replace("_", " ").Trim().ToLower()) && parentNode.Name.ToLower() != "body")
                    {
                        parentNode = parentNode.ParentNode;
                    }

                    foreach (var childrenNodes in fItem.ParentNode.ChildNodes)
                    {
                        parentNode.ParentNode.InsertBefore(childrenNodes, parentNode);
                    }
                }

                var parentTableNode = fItem.ParentNode;
                HtmlNode parentCellNode = null;
                var foundParentTableNode = false;
                while (foundParentTableNode == false && parentTableNode.Name.ToLower() != "body")
                {
                    if (parentTableNode.PreviousSibling != null &&
                        (parentTableNode.PreviousSibling.Name.ToLower() == "p" || parentTableNode.PreviousSibling.Name.ToLower() == "table") &&
                        parentTableNode.ParentNode.Name.ToLower() == "div" &&
                        parentTableNode.GetAttributeValue("style", null).ToLower().Contains("-aw-"))
                    {
                        foundParentTableNode = true;
                        parentTableNode.AddClass("item-table-fromdocx");
                        parentTableNode.Attributes.Add(htmlDoc.CreateAttribute("data-id", $"{item.MeetingItemId}"));
                        parentTableNode.Attributes.Add(htmlDoc.CreateAttribute("data-itemid", $"{item.MeetingItemId}"));
                        parentCellNode = parentTableNode.SelectNodes("*/td").LastOrDefault();
                    }
                    else
                    {
                        parentTableNode = parentTableNode.ParentNode;
                    }
                }

                if (item.AttachmentCount > 0 || new SystemItemAttachedDocument(bc.CustomerCallContext).HasDocuments(item.SystemItemId))
                {
                    parentCellNode.AddClass("agenda-item");
                    parentCellNode.Attributes.Add(htmlDoc.CreateAttribute("id", $"AgendaItem_{item.MeetingItemId}"));
                    parentCellNode.Attributes.Add(htmlDoc.CreateAttribute("data-itemid", $"{item.MeetingItemId}"));
                    parentCellNode.Attributes.Add(htmlDoc.CreateAttribute("data-createdfromdocx", $"True"));
                    parentCellNode.Attributes.Add(htmlDoc.CreateAttribute("data-hasattachments", $"True"));
                    parentCellNode.SetAttributeValue("style", $@"cursor:pointer;{parentCellNode.GetAttributeValue("style", null)}");

                    var attachmentHtmlNode = HtmlNode.CreateNode($@"<td class=""attachmentCell"" id=""AgendaItem_{item.MeetingItemId}"" class=""agenda-item"" id=""attachment-icon-{item.MeetingItemId}""><div><span class=""glyphicon glyphicon-paperclip"" title=""Has Attachments"" style=""color:#aaa;""></span></div></td>");
                    parentTableNode.FirstChild.PrependChild(attachmentHtmlNode);
                }
                else
                {
                    parentTableNode.Attributes.Add(htmlDoc.CreateAttribute("data-hasattachments", $"False"));
                    var attachmentHtmlNode = HtmlNode.CreateNode($@"<td class=""attachmentCell"" id=""AgendaItem_{item.MeetingItemId}"" class=""agenda-item"" id=""attachment-icon-{item.MeetingItemId}""><div style=""width:16px;height:23.84px;""></div></td>");
                    parentTableNode.FirstChild.PrependChild(attachmentHtmlNode);
                }

                var htmlExtrasNodeString = $@"<td class=""optionalButtonsCell"">";

                if (hasMiniPacket && miniPacketEnabled)
                {
                    htmlExtrasNodeString += $@"
                            <div id=""sharebuttons_{item.MeetingItemId}"" data-loaded=""Loaded"" class=""flex-parent shareButtons_display pull-right optionalButtons shareItemBtns_{item.MeetingItemId}"">
                                <a href=""/meetings/ItemWithTemplateType?id={item.MeetingItemId}&meetingTemplateType=2"" onclick=""event.stopPropagation();"" tabindex=""0"">
                                    <svg width=""38"" height=""20"" viewBox=""0 0 38 20"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
                                        <title>Combine item's attachments into one PDF and view</title>
                                        <rect class=""svgPdfShareButtons"" width=""37.5"" height=""20"" rx=""2"" fill=""currentColor"" ></rect>
                                        <path d=""M9.80078 8.32031L8.375 9.74609V6.25C8.375 5.91797 8.08203 5.625 7.75 5.625C7.39844 5.625 7.125 5.91797 7.125 6.25V9.74609L5.67969 8.32031C5.5625 8.20312 5.40625 8.125 5.25 8.125C5.07422 8.125 4.91797 8.20312 4.80078 8.32031C4.54688 8.55469 4.54688 8.96484 4.80078 9.19922L7.30078 11.6992C7.53516 11.9531 7.94531 11.9531 8.17969 11.6992L10.6797 9.19922C10.9336 8.96484 10.9336 8.55469 10.6797 8.32031C10.4453 8.06641 10.0352 8.06641 9.80078 8.32031ZM10.875 13.125H4.625C4.27344 13.125 4 13.418 4 13.75C4 14.1016 4.27344 14.375 4.625 14.375H10.875C11.207 14.375 11.5 14.1016 11.5 13.75C11.5 13.418 11.207 13.125 10.875 13.125Z"" fill=""white""></path><path d=""M16.21 6.86133C16.9456 6.86133 17.4974 7.05827 17.8652 7.45215C18.2363 7.84603 18.4219 8.40592 18.4219 9.13184C18.4219 9.48665 18.3763 9.81706 18.2852 10.123C18.194 10.4258 18.054 10.6911 17.8652 10.9189C17.6764 11.1436 17.4372 11.3193 17.1475 11.4463C16.8577 11.57 16.516 11.6318 16.1221 11.6318H15.79V14H14.0908V6.86133H16.21ZM16.0488 8.30176H15.79V10.1914H15.9414C16.0977 10.1914 16.2344 10.1572 16.3516 10.0889C16.4688 10.0173 16.5583 9.90495 16.6201 9.75195C16.6852 9.5957 16.7178 9.39225 16.7178 9.1416C16.7178 8.86165 16.6624 8.65169 16.5518 8.51172C16.4411 8.37174 16.2734 8.30176 16.0488 8.30176ZM24.1836 10.2793C24.1836 11.0703 24.0632 11.7425 23.8223 12.2959C23.5846 12.8493 23.2396 13.2725 22.7871 13.5654C22.3346 13.8551 21.7845 14 21.1367 14H19.2959V6.86133H21.2539C21.8789 6.86133 22.4095 6.99316 22.8457 7.25684C23.2819 7.52051 23.6139 7.90625 23.8418 8.41406C24.0697 8.92188 24.1836 9.54362 24.1836 10.2793ZM22.4258 10.3477C22.4258 9.86589 22.3802 9.47689 22.2891 9.18066C22.2012 8.88444 22.0677 8.6696 21.8887 8.53613C21.7129 8.39941 21.4915 8.33105 21.2246 8.33105H20.9951V12.5205H21.127C21.5762 12.5205 21.9049 12.3447 22.1133 11.9932C22.3216 11.6416 22.4258 11.0931 22.4258 10.3477ZM26.8643 14H25.165V6.86133H28.583V8.30176H26.8643V9.83008H28.4561V11.2705H26.8643V14ZM32.6602 12.3008C32.6602 12.6979 32.5853 13.0299 32.4355 13.2969C32.2858 13.5638 32.0693 13.764 31.7861 13.8975C31.5062 14.0309 31.1676 14.0977 30.7705 14.0977C30.5003 14.0977 30.235 14.0749 29.9746 14.0293C29.7142 13.9837 29.4554 13.904 29.1982 13.79V12.2617C29.4001 12.3822 29.6214 12.488 29.8623 12.5791C30.1064 12.667 30.3522 12.7109 30.5996 12.7109C30.7493 12.7109 30.8617 12.6865 30.9365 12.6377C31.0114 12.5856 31.0488 12.5026 31.0488 12.3887C31.0488 12.3268 31.0326 12.2682 31 12.2129C30.9707 12.1543 30.8975 12.0843 30.7803 12.0029C30.6631 11.9215 30.4759 11.8174 30.2188 11.6904C29.9941 11.5765 29.8053 11.4382 29.6523 11.2754C29.4993 11.1094 29.3838 10.9206 29.3057 10.709C29.2275 10.4974 29.1885 10.2614 29.1885 10.001C29.1885 9.48665 29.3447 9.08626 29.6572 8.7998C29.9697 8.51335 30.4141 8.37012 30.9902 8.37012C31.2767 8.37012 31.5469 8.41081 31.8008 8.49219C32.0547 8.57031 32.3135 8.68587 32.5771 8.83887L32.1816 10.0693C32.0156 9.95866 31.8398 9.86263 31.6543 9.78125C31.4688 9.69987 31.2799 9.65918 31.0879 9.65918C30.974 9.65918 30.8893 9.68034 30.834 9.72266C30.7786 9.76497 30.751 9.83008 30.751 9.91797C30.751 9.97656 30.7656 10.0303 30.7949 10.0791C30.8275 10.1279 30.8991 10.1898 31.0098 10.2646C31.1204 10.3363 31.293 10.4421 31.5273 10.582C31.752 10.7057 31.9489 10.8473 32.1182 11.0068C32.2874 11.1663 32.4193 11.3519 32.5137 11.5635C32.6113 11.7718 32.6602 12.0176 32.6602 12.3008Z"" fill=""white""></path>
                                    </svg>
                                </a>
                            </div>";
                }
                else if (item.AttachmentCount > 0 || new SystemItemAttachedDocument(bc.CustomerCallContext).HasDocuments(item.SystemItemId))
                {
                    htmlExtrasNodeString += $@"
                            <div id=""sharebuttons_{item.MeetingItemId}"" data-loaded=""Loaded"" class=""flex-parent shareButtons_display pull-right optionalButtons shareItemBtns_{item.MeetingItemId}"">
                                <a href=""/meetings/item/{item.MeetingItemId}"" tabindex=""0"">
                                    <svg width=""38"" height=""20"" viewBox=""0 0 38 20"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
                                        <title>Combine item's attachments into one PDF and view</title>
                                        <rect class=""svgPdfShareButtons"" width=""37.5"" height=""20"" rx=""2"" fill=""currentColor"" ></rect>
                                        <path d=""M9.80078 8.32031L8.375 9.74609V6.25C8.375 5.91797 8.08203 5.625 7.75 5.625C7.39844 5.625 7.125 5.91797 7.125 6.25V9.74609L5.67969 8.32031C5.5625 8.20312 5.40625 8.125 5.25 8.125C5.07422 8.125 4.91797 8.20312 4.80078 8.32031C4.54688 8.55469 4.54688 8.96484 4.80078 9.19922L7.30078 11.6992C7.53516 11.9531 7.94531 11.9531 8.17969 11.6992L10.6797 9.19922C10.9336 8.96484 10.9336 8.55469 10.6797 8.32031C10.4453 8.06641 10.0352 8.06641 9.80078 8.32031ZM10.875 13.125H4.625C4.27344 13.125 4 13.418 4 13.75C4 14.1016 4.27344 14.375 4.625 14.375H10.875C11.207 14.375 11.5 14.1016 11.5 13.75C11.5 13.418 11.207 13.125 10.875 13.125Z"" fill=""white""></path><path d=""M16.21 6.86133C16.9456 6.86133 17.4974 7.05827 17.8652 7.45215C18.2363 7.84603 18.4219 8.40592 18.4219 9.13184C18.4219 9.48665 18.3763 9.81706 18.2852 10.123C18.194 10.4258 18.054 10.6911 17.8652 10.9189C17.6764 11.1436 17.4372 11.3193 17.1475 11.4463C16.8577 11.57 16.516 11.6318 16.1221 11.6318H15.79V14H14.0908V6.86133H16.21ZM16.0488 8.30176H15.79V10.1914H15.9414C16.0977 10.1914 16.2344 10.1572 16.3516 10.0889C16.4688 10.0173 16.5583 9.90495 16.6201 9.75195C16.6852 9.5957 16.7178 9.39225 16.7178 9.1416C16.7178 8.86165 16.6624 8.65169 16.5518 8.51172C16.4411 8.37174 16.2734 8.30176 16.0488 8.30176ZM24.1836 10.2793C24.1836 11.0703 24.0632 11.7425 23.8223 12.2959C23.5846 12.8493 23.2396 13.2725 22.7871 13.5654C22.3346 13.8551 21.7845 14 21.1367 14H19.2959V6.86133H21.2539C21.8789 6.86133 22.4095 6.99316 22.8457 7.25684C23.2819 7.52051 23.6139 7.90625 23.8418 8.41406C24.0697 8.92188 24.1836 9.54362 24.1836 10.2793ZM22.4258 10.3477C22.4258 9.86589 22.3802 9.47689 22.2891 9.18066C22.2012 8.88444 22.0677 8.6696 21.8887 8.53613C21.7129 8.39941 21.4915 8.33105 21.2246 8.33105H20.9951V12.5205H21.127C21.5762 12.5205 21.9049 12.3447 22.1133 11.9932C22.3216 11.6416 22.4258 11.0931 22.4258 10.3477ZM26.8643 14H25.165V6.86133H28.583V8.30176H26.8643V9.83008H28.4561V11.2705H26.8643V14ZM32.6602 12.3008C32.6602 12.6979 32.5853 13.0299 32.4355 13.2969C32.2858 13.5638 32.0693 13.764 31.7861 13.8975C31.5062 14.0309 31.1676 14.0977 30.7705 14.0977C30.5003 14.0977 30.235 14.0749 29.9746 14.0293C29.7142 13.9837 29.4554 13.904 29.1982 13.79V12.2617C29.4001 12.3822 29.6214 12.488 29.8623 12.5791C30.1064 12.667 30.3522 12.7109 30.5996 12.7109C30.7493 12.7109 30.8617 12.6865 30.9365 12.6377C31.0114 12.5856 31.0488 12.5026 31.0488 12.3887C31.0488 12.3268 31.0326 12.2682 31 12.2129C30.9707 12.1543 30.8975 12.0843 30.7803 12.0029C30.6631 11.9215 30.4759 11.8174 30.2188 11.6904C29.9941 11.5765 29.8053 11.4382 29.6523 11.2754C29.4993 11.1094 29.3838 10.9206 29.3057 10.709C29.2275 10.4974 29.1885 10.2614 29.1885 10.001C29.1885 9.48665 29.3447 9.08626 29.6572 8.7998C29.9697 8.51335 30.4141 8.37012 30.9902 8.37012C31.2767 8.37012 31.5469 8.41081 31.8008 8.49219C32.0547 8.57031 32.3135 8.68587 32.5771 8.83887L32.1816 10.0693C32.0156 9.95866 31.8398 9.86263 31.6543 9.78125C31.4688 9.69987 31.2799 9.65918 31.0879 9.65918C30.974 9.65918 30.8893 9.68034 30.834 9.72266C30.7786 9.76497 30.751 9.83008 30.751 9.91797C30.751 9.97656 30.7656 10.0303 30.7949 10.0791C30.8275 10.1279 30.8991 10.1898 31.0098 10.2646C31.1204 10.3363 31.293 10.4421 31.5273 10.582C31.752 10.7057 31.9489 10.8473 32.1182 11.0068C32.2874 11.1663 32.4193 11.3519 32.5137 11.5635C32.6113 11.7718 32.6602 12.0176 32.6602 12.3008Z"" fill=""white""></path>
                                    </svg>
                                </a>
                            </div>";
                }

                var itemUrl = $"{bc.CustomerCallContext.BaseUrl}/portal/item?id={item.SystemItemId}";
                if (itemSearchEnabled)
                {
                    itemUrl = $"{bc.CustomerCallContext.BaseUrl}/search/itemsearch?searchItemId={item.SystemItemId}";

                    htmlExtrasNodeString += $@"
                            <div id=""itemsearch-{item.MeetingItemId}"" data-loaded=""Loaded"" class=""flex-parent shareButtons_display pull-right optionalButtons shareItemBtns_{item.MeetingItemId}"">
                                <a href=""{itemUrl}"" target=""_blank"" onclick=""event.stopPropagation();"" tabindex=""0"">
                                    <svg width=""20"" height=""20"" viewBox=""0 0 20 20"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
                                        <title>View Item Details</title>
                                        <rect class=""svgSquareInfoShareButtons"" width=""20"" height=""20"" rx=""2"" fill=""currentColor""/>
                                        <path d=""M11.7859 13.5714H11.0716V9.64279C11.0716 9.06243 10.5806 8.57136 10.0002 8.57136H8.57164C7.94664 8.57136 7.50021 9.06243 7.50021 9.64279C7.50021 10.2678 7.94664 10.7142 8.57164 10.7142H8.92878V13.5714H8.21449C7.58949 13.5714 7.14307 14.0624 7.14307 14.6428C7.14307 15.2678 7.58949 15.7142 8.21449 15.7142H11.7859C12.3663 15.7142 12.8574 15.2678 12.8574 14.6428C12.8574 14.0624 12.3663 13.5714 11.7859 13.5714ZM10.0002 7.14279C10.7591 7.14279 11.4288 6.51779 11.4288 5.71422C11.4288 4.95529 10.7591 4.28564 10.0002 4.28564C9.19664 4.28564 8.57164 4.95529 8.57164 5.71422C8.57164 6.51779 9.19664 7.14279 10.0002 7.14279Z"" fill=""white""/>
                                    </svg>
                                </a>
                            </div>";
                }

                if (facebookEnabled)
                {
                    htmlExtrasNodeString += $@"
                            <div class=""flex-parent shareButtons_display pull-right optionalButtons shareItemBtns_{item.MeetingItemId}"">
                                <a target=""_blank"" onclick=""Share.facebook('{itemUrl}', 'Item Share', '/content/images/svg/Portal_Facebook_Share.svg', 'Share Item on Facebook')"">
                                    <svg width=""20"" height=""20"" viewBox=""0 0 20 20"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
                                        <title>Share on Facebook</title>
                                        <rect class=""svgFacebookShareButtons"" width=""20"" height=""20"" rx=""2"" fill=""currentColor""/>
                                        <path d=""M16 10.0365C16 6.70183 13.3145 4 10 4C6.68548 4 4 6.70183 4 10.0365C4 13.0548 6.17742 15.5619 9.05645 16V11.789H7.53226V10.0365H9.05645V8.72211C9.05645 7.21298 9.95161 6.36105 11.3065 6.36105C11.9839 6.36105 12.6613 6.48276 12.6613 6.48276V7.96755H11.9113C11.1613 7.96755 10.9194 8.43002 10.9194 8.91684V10.0365H12.5887L12.3226 11.789H10.9194V16C13.7984 15.5619 16 13.0548 16 10.0365Z"" fill=""white""/>
                                    </svg>
                                </a>
                            </div>";
                }

                if (twitterEnabled)
                {
                    htmlExtrasNodeString += $@"
                            <div class=""flex-parent shareButtons_display pull-right optionalButtons shareItemBtns_{item.MeetingItemId}"">
                                <a onclick=""Share.twitter('{itemUrl}', 'Item Share')"">
                                    <svg width=""20"" height=""20"" viewBox=""0 0 20 20"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
                                        <title>Share on Twitter</title>
                                        <rect class=""svgTwitterShareButtons"" width=""20"" height=""20"" rx=""2"" fill=""currentColor""/>
                                        <path d=""M14.7789 7.73374C14.7789 7.84217 14.7789 7.92892 14.7789 8.03735C14.7789 11.0518 12.3131 14.5 7.78082 14.5C6.37182 14.5 5.08023 14.1313 4 13.4807C4.18787 13.5024 4.37573 13.5241 4.58708 13.5241C5.73777 13.5241 6.79452 13.1554 7.63992 12.5482C6.55969 12.5265 5.64384 11.8759 5.33855 10.9651C5.50294 10.9867 5.64384 11.0084 5.80822 11.0084C6.01957 11.0084 6.2544 10.9651 6.44227 10.9217C5.31507 10.7048 4.46967 9.79398 4.46967 8.68795V8.66627C4.79843 8.83976 5.19765 8.92651 5.59687 8.94819C4.91585 8.53614 4.49315 7.84217 4.49315 7.06145C4.49315 6.62771 4.61057 6.23735 4.82192 5.91205C6.04305 7.27831 7.87476 8.18916 9.91781 8.29759C9.87084 8.1241 9.84736 7.9506 9.84736 7.77711C9.84736 6.51928 10.9511 5.5 12.3131 5.5C13.0176 5.5 13.6517 5.76024 14.1213 6.21566C14.6614 6.10723 15.2016 5.91205 15.6712 5.65181C15.4834 6.19398 15.1076 6.62771 14.591 6.90964C15.0841 6.86627 15.5773 6.73614 16 6.56265C15.6712 7.01807 15.2485 7.40843 14.7789 7.73374Z"" fill=""white""/>
                                    </svg>
                                </a>
                            </div>";
                }

                if (isVideoLocationButtonEnabled && item.VideoLocation > 0)
                {
                    htmlExtrasNodeString += $@"
                            <div id=""playButton_{item.MeetingItemId}"" data-loaded=""Loaded"" class=""flex-parent shareButtons_display pull-right optionalButtons shareItemBtns_{item.MeetingItemId}"">
                                <a onclick=""jumpToVideoLocation()"" tabindex=""0"">
                                    <svg width=""20"" height=""20"" viewBox=""0 0 20 20"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
                                        <title>Jump to location on video</title>
                                        <rect class=""svgPlayButton"" width=""20"" height=""20"" rx=""2"" fill=""currentColor"" />
                                        <path d=""M7.5 6.5359C7.5 6.151 7.91667 5.91044 8.25 6.10289L14.25 9.56699C14.5833 9.75944 14.5833 10.2406 14.25 10.433L8.25 13.8971C7.91667 14.0896 7.5 13.849 7.5 13.4641L7.5 6.5359Z"" fill=""white"" />
                                    </svg>
                                </a>
                            </div>";
                }

                if (htmlExtrasNodeString != $@"<td class=""optionalButtonsCell"">")
                {
                    htmlExtrasNodeString += $@"
                        <div data-id=""{item.MeetingItemId}"" class=""flex-parent shareButtons_display pull-right elipsis_{item.MeetingItemId}"">
                            <svg width=""20"" height=""20"" viewBox=""0 0 20 20"" fill=""none"" xmlns=""http://www.w3.org/2000/svg"">
                                <path class=""svgElipsisMenu"" fill-rule=""evenodd"" clip-rule=""evenodd"" d=""M15.2351 8.11582C16.0091 8.4364 16.3766 9.3237 16.056 10.0977C15.7354 10.8716 14.8481 11.2391 14.0742 10.9186C13.3002 10.598 12.9327 9.71068 13.2533 8.93672C13.5738 8.16277 14.4611 7.79523 15.2351 8.11582ZM10.0851 11.0337C10.9228 11.0337 11.6019 10.3546 11.6019 9.51686C11.6019 8.67913 10.9228 8.00002 10.0851 8.00002C9.24737 8.00002 8.56826 8.67913 8.56826 9.51686C8.56826 10.3546 9.24737 11.0337 10.0851 11.0337ZM5.51686 11.0339C6.35458 11.0339 7.03369 10.3548 7.03369 9.5171C7.03369 8.67937 6.35458 8.00026 5.51686 8.00026C4.67913 8.00026 4.00002 8.67937 4.00002 9.5171C4.00002 10.3548 4.67913 11.0339 5.51686 11.0339Z"" fill=""currentColor"" />
                            </svg>
                        </div>";
                }

                htmlExtrasNodeString += "</td>";

                var htmlNode = HtmlNode.CreateNode(htmlExtrasNodeString);
                parentTableNode.FirstChild.AppendChild(htmlNode);

                var parentTableStyles = parentTableNode.GetAttributeValue("style", "").Split(';');
                if (parentTableStyles.Any(x => x.ToLower().Contains("margin-left")))
                {
                    var marginLeft = parentTableStyles.FirstOrDefault(x => x.ToLower().Contains("margin-left")).Split(':')[1];
                    parentTableNode.FirstChild.FirstChild.SetAttributeValue("style", $@"{parentTableNode.FirstChild.FirstChild.GetAttributeValue("style", "")} padding-left:{marginLeft}");

                    parentTableNode.SetAttributeValue("style", $@"{parentTableNode.GetAttributeValue("style", "").ToLower().Replace($@"margin-left:{marginLeft}", "")}");
                }

                if (parentNode.Name.ToLower() == "a")
                {
                    parentNode.Remove();
                }
            }

            itemCounter++;
        }

        sectionCounter++;
    }

    tempHtmlDoc = null;

    return htmlDoc;
}

What are my options to correct these methods in the newest version?

@asad.ali

I was able to get all of the errors worked out on the most recent version of Aspose but the same issue still exists.

image.png (146.1 KB)

@ST2YKE2

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-56969

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

@asad.ali

Another thing to add to this issue is that when using ResizeContents it is cutting content off on pages that have the following data:

var heightWithoutRotation = document.Pages[1].PageInfo.Height (842)
var widthWithoutRotation = document.Pages[1].PageInfo.Width (595)
var rectHeight = document.Pages[1].GetPageRect(true).Height (2160)
var rectWidth = document.Pages[1].GetPageRect(true).Width (3024)

Original Document
75.pdf (496.3 KB)

Updated document after rotating it to Portrait
75.pdf (821.6 KB)

Updated document after using PdfFileEditor.ResizeContents()
75.pdf (822.7 KB)

Can you give me any update on this issue? It is a major problem with how Aspose is handling resizing content on PDF files. At this point I’ll even take a work around or anything pretty please!

@ST2YKE2

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-57006

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.