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.

Mon Dec 06, 2021 5:54 am

Hi team, I updated version Spire to 9.9.7 it works well on localhost but I have an issue "Object reference not set to an instance of an object inline 'document.SaveToStream(outStream, ps);'" on Microsoft Azure, I have attached an image error on Microsoft Azure.

Code: Select all
var selections = document.FindAllString(key, true, true);
foreach (var selection in selections)
{
    var sdt = new StructureDocumentTagInline(document)
    {
        CharacterFormat = { FontSize = sizeCheckBox, TextColor = Color.FromArgb(argb) }
    };
    var range = selection.GetAsOneRange();
    var index = range.OwnerParagraph.ChildObjects.IndexOf(range);
    range.OwnerParagraph.ChildObjects.Insert(index, sdt);
    sdt.SDTProperties.SDTType = SdtType.CheckBox;
    var scb = new SdtCheckBox();
    sdt.SDTProperties.ControlProperties = scb;
    var tr = new TextRange(document)
    {
        CharacterFormat =
                    {
                        FontName = "MS Gothic",
                        FontSize = sizeCheckBox,
                        TextColor = Color.FromArgb(argb)
                    }
    };
    sdt.ChildObjects.Add(tr);
    scb.Checked = true;
    sdt.SDTProperties.Alias = "CheckoBox";
    sdt.SDTProperties.Tag = "Checkbox";
    range.OwnerParagraph.ChildObjects.Remove(range);
}

//Embed private font from font file into the document
document.PrivateFontList. Add(new PrivateFontPath("MS Gothic", @"..\fontFiles\MS Gothic.ttc"));

// PS method
ToPdfParameterList ps = new ToPdfParameterList();
ps.UsePSCoversion = true;
MemoryStream outStream = new MemoryStream();
document.SaveToStream(outStream, ps);
buffer = outStream.ToArray();

haunguyen
 
Posts: 1
Joined: Mon Dec 06, 2021 5:36 am

Mon Dec 06, 2021 9:04 am

Hello,

Thanks for your inquiry!

I tested your code on azure, but did not reproduce your issue. Here I also attached my project, you can try to deploy this on your side. If the issue still exists, please provide us with your input file and your target framework(E.g. .Netframework 4.8.0) for further investigate. Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Dec 20, 2021 9:49 am

Hello,

Hope you are doing well!

Has the issue been solved now? Could you please give us some feedback at your convenience?

Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.Doc