Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active March 24, 2022 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/77ffea3f2a23f7a5e93f78dfdf90114f to your computer and use it in GitHub Desktop.
Save aspose-com-gists/77ffea3f2a23f7a5e93f78dfdf90114f to your computer and use it in GitHub Desktop.
Create Survey Form from JSON Markup using C#
// This code example demonstrates how to generate Survey OMR and Save as PDF from JSON markup.
// Path to the JSON file with Template Markup
string markupPath = @"C:\Files\OMR\SimpleSurvey.json";
// Initialize OMR engine
OmrEngine engine = new OmrEngine();
// Generate Template
GenerationResult res = engine.GenerateJSONTemplate(markupPath);
// Save to the local disk
res.SaveAsPdf(@"C:\Files\OMR\", "SimpleSurvey");
// This code example demonstrates how to generate Survey image and OMR from JSON markup.
// Path to the JSON file with Template Markup
string markupPath = @"C:\Files\OMR\SimpleSurvey.json";
// Initialize OMR engine
OmrEngine engine = new OmrEngine();
// Generate Template
GenerationResult res = engine.GenerateJSONTemplate(markupPath);
// Save to the local disk
res.Save(@"C:\Files\OMR\", "SimpleSurvey");
{
"element_type": "template",
"children": [
{
"element_type": "page",
"children": [
{
"name": "Welcome to Sample Survey",
"element_type": "text",
"font_style": "bold",
"font_size": 16,
"align": "center"
},
{
"element_type": "emptyLine"
},
{
"element_type": "text",
"name": "February 25, 2022",
"font_style": "italic",
"align": "right"
},
{
"element_type": "emptyLine"
},
{
"name": "Section - I",
"element_type": "text",
"font_style": "bold",
"font_size": 14,
"align": "Left"
},
{
"font_family": "Segoe UI",
"font_style": "Regular",
"font_size": 12,
"align": "Left",
"answers_string": "(() Yes, indeed! () No",
"question_text": "Can Aspose.OMR process not only scans, but also photos?\r\n",
"element_type": "ChoiceBox"
},
{
"font_family": "Segoe UI",
"font_style": "Regular",
"font_size": 12,
"align": "Left",
"answers_string": "((Yes) Yes, indeed! (No) No",
"question_text": "Aspose.OMR works with any kind of OMR forms: tests, exams, questionnaires, surveys, etc.\r\n",
"element_type": "ChoiceBox"
},
{
"font_family": "Segoe UI",
"font_style": "Regular",
"font_size": 12,
"align": "Left",
"answers_string": "(() Very high quality () High quality\r\n() Average quality () Low quality",
"question_text": "How would you rate the quality of the product:\r\n",
"element_type": "ChoiceBox"
},
{
"font_family": "Segoe UI",
"font_style": "Regular",
"font_size": 12,
"align": "Left",
"answers_string": "(1) (2) (3) (4) (5) (6) (7) (8) (9)",
"question_text": "How likely is it that you would recommend our company to a friend or colleague?\r\n",
"element_type": "ChoiceBox"
},
{
"element_type": "emptyLine"
},
{
"children": [
{
"name": "Section - II",
"font_style": "Bold",
"font_size": 14,
"align": "Left",
"element_type": "Text"
},
{
"name": "main_container",
"children": [
{
"name": "main_block",
"children": [
{
"name": "product survey",
"children": [
{
"font_family": "Segoe UI",
"font_style": "Bold",
"font_size": 12,
"row_proportions": [
60,
20,
10,
10
],
"name": "How would you rate your total experience?",
"children": [
{
"name": "Score",
"header_type": "Amount",
"element_type": "ScoreHeader"
},
{
"name": "Yes",
"header_type": "Positive",
"element_type": "ScoreHeader"
},
{
"name": "No",
"header_type": "Negative",
"element_type": "ScoreHeader"
},
{
"Score": 5,
"element_type": "ScoreAnswer",
"name": "I am enjoy the product."
},
{
"Score": 10,
"element_type": "ScoreAnswer",
"name": "I will recommend it to my friends."
}
],
"element_type": "ScoreQuestion"
}
],
"score_group_type": "Table",
"element_type": "ScoreGroup"
}
],
"column": 1,
"element_type": "Block"
}
],
"columns_count": 1,
"element_type": "Container"
},
{
"element_type": "page",
"children": [
{
"name": "1-st",
"children": [
{
"name": "Process",
"children": [
{
"name": "Process",
"element_type": "writeIn"
}
],
"element_type": "block"
}
],
"element_type": "container"
}
]
}
],
"element_type": "Page"
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment