Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert check box in document #136

Open
geraluca opened this issue Mar 31, 2023 · 1 comment
Open

Insert check box in document #136

geraluca opened this issue Mar 31, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@geraluca
Copy link

Is it possible to insert a series of check boxes in the document ?

@PrzemyslawKlys
Copy link
Member

It's not yet supported. Something to add in the future. Unless you want to play with OpenXML directly

public Paragraph GenerateParagraph()
        {
            Paragraph paragraph1 = new Paragraph(){ RsidParagraphAddition = "00612BFE", RsidRunAdditionDefault = "00C314BB", ParagraphId = "3ECD5C4A", TextId = "77777777" };

            SdtRun sdtRun1 = new SdtRun();

            SdtProperties sdtProperties1 = new SdtProperties();
            SdtId sdtId1 = new SdtId(){ Val = -857119503 };

            W14.SdtContentCheckBox sdtContentCheckBox1 = new W14.SdtContentCheckBox();
            W14.Checked checked1 = new W14.Checked(){ Val = W14.OnOffValues.One };
            W14.CheckedState checkedState1 = new W14.CheckedState(){ Font = "MS Gothic", Val = "2612" };
            W14.UncheckedState uncheckedState1 = new W14.UncheckedState(){ Font = "MS Gothic", Val = "2610" };

            sdtContentCheckBox1.Append(checked1);
            sdtContentCheckBox1.Append(checkedState1);
            sdtContentCheckBox1.Append(uncheckedState1);

            sdtProperties1.Append(sdtId1);
            sdtProperties1.Append(sdtContentCheckBox1);

            SdtContentRun sdtContentRun1 = new SdtContentRun();

            Run run1 = new Run();

            RunProperties runProperties1 = new RunProperties();
            RunFonts runFonts1 = new RunFonts(){ Hint = FontTypeHintValues.EastAsia, Ascii = "MS Gothic", HighAnsi = "MS Gothic", EastAsia = "MS Gothic" };

            runProperties1.Append(runFonts1);
            Text text1 = new Text();
            text1.Text = "";

            run1.Append(runProperties1);
            run1.Append(text1);

            sdtContentRun1.Append(run1);

            sdtRun1.Append(sdtProperties1);
            sdtRun1.Append(sdtContentRun1);

            Run run2 = new Run();
            Text text2 = new Text(){ Space = SpaceProcessingModeValues.Preserve };
            text2.Text = "This is a ";

            run2.Append(text2);
            ProofError proofError1 = new ProofError(){ Type = ProofingErrorValues.GrammarStart };

            Run run3 = new Run();
            Text text3 = new Text();
            text3.Text = "checkbox";

            run3.Append(text3);
            ProofError proofError2 = new ProofError(){ Type = ProofingErrorValues.GrammarEnd };

            paragraph1.Append(sdtRun1);
            paragraph1.Append(run2);
            paragraph1.Append(proofError1);
            paragraph1.Append(run3);
            paragraph1.Append(proofError2);
            return paragraph1;
        }

@PrzemyslawKlys PrzemyslawKlys added the enhancement New feature or request label Mar 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants