Hello!
I have a problem creating a PDF file with Aspose.Words (v. 18.9.0) in .Net.
I have the following code:
var streamOut = new MemoryStream();
Aspose.Words.Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Aspose.Words.Font font = builder.Font;
font.Size = 16;
font.Bold = true;
font.Name = "Arial";
ParagraphFormat paragraph = builder.ParagraphFormat;
paragraph.Alignment = ParagraphAlignment.Left;
paragraph.KeepTogether = true;
builder.MoveTo(doc.FirstSection.Body.LastParagraph);
// Shows how to move a cursor position to the beginning or end of a document.
builder.MoveToDocumentStart();
builder.Writeln("Title");
font.Size = 12;
font.Name = "Arial";
font.Bold = false;
builder.InsertBreak(BreakType.ParagraphBreak);
builder.Writeln("Test line 1");
builder.Writeln("Test line 2");
builder.InsertBreak(BreakType.ParagraphBreak);
font.Size = 14;
font.Bold = true;
builder.Writeln("Undertitle");
builder.InsertBreak(BreakType.LineBreak);
font.Size = 12;
var counter = 1;
foreach (var object in objects)
{
if (object.Type != "pageBreak")
{
builder.Writeln(counter + ". " + object.Title);
builder.InsertBreak(BreakType.LineBreak);
counter++;
switch (object.Type)
{
case "checkBox":
foreach (var answer in object.Answers)
{
builder.InsertCheckBox("", false, false, 0);
builder.Writeln(answer.Description);
}
break;
case "radioButton":
foreach (var answer in object.Answers)
{
builder.Writeln(answer.Description);
}
builder.InsertBreak(BreakType.LineBreak);
break;
case "dropDown":
foreach (var answer in object.Answers)
{
builder.Writeln(answer.Description);
}
builder.InsertBreak(BreakType.LineBreak);
break;
}
}
}
doc.Save(streamOut, Aspose.Words.SaveFormat.Pdf);
streamOut.Position = 0;
return File(streamOut, "application/pdf", "Export.pdf");
When I save the file as Word, the content is present. If I save it as PDF, it is defective or empty.
I think I’ve considered everything in your documentation.
Can you help me?