Thanks for your patience. As stated above that your reported issue has been resolved in Aspose.Pdf for .NET 8.9.0. release. Please note issue has been fixed in new Generator i.e. Aspose.Pdf.Document class. Please check sample code snippet as following. Hopefully it will help you to accomplish your task.
Please note Aspose.Pdf.Generator is obsolete now and we are fixing issues and making enhancements in new Generator as it follows DOM approach and is more efficient than old Generator. Moreover it can be used to create a new PDF from scratch or manipulate existing PDF document as well.
string outFile = “34045.pdf”;<o:p></o:p>
string inFile = @"NAB Logo.bmp";
Document doc = new Document();
Page page =
doc.Pages.Add();
//LOGO
Aspose.Pdf.Image logo = new
Aspose.Pdf.Image();
logo.File = inFile;
page.Paragraphs.Add(logo);
//TITLE
TextFragment pdfHeadTitle
= new TextFragment(string.Format("{0}",
"internalTest.TestTemplate.Name"));
pdfHeadTitle.HorizontalAlignment
= Aspose.Pdf.HorizontalAlignment.Center;
pdfHeadTitle.TextState.Font = FontRepository.FindFont("Arial");
pdfHeadTitle.TextState.FontStyle
= FontStyles.Bold;
pdfHeadTitle.TextState.FontSize
= 16;
pdfHeadTitle.TextState.LineSpacing
= 5;
page.Paragraphs.Add(pdfHeadTitle);
String date_new;
int count = 1;
date_new = string.Format("Test
creato il: {0}", DateTime.Now.ToString("dd/MM/yyyy"));
//Counter
TextFragment pdfHeadCount
= new TextFragment(count.ToString());
pdfHeadCount.TextState.Font = FontRepository.FindFont("Arial");
pdfHeadCount.TextState.FontStyle
= FontStyles.Bold;
pdfHeadCount.TextState.FontSize
= 12;
pdfHeadCount.HorizontalAlignment
= Aspose.Pdf.HorizontalAlignment.Right;
pdfHeadCount.TextState.LineSpacing
= 5;
page.Paragraphs.Add(pdfHeadCount);
//Date
TextFragment pdfHeadDate
= new TextFragment(date_new);
pdfHeadDate.TextState.Font = FontRepository.FindFont("Arial");
pdfHeadDate.TextState.FontStyle
= FontStyles.Bold;
pdfHeadDate.TextState.FontSize
= 12;
pdfHeadDate.HorizontalAlignment
= Aspose.Pdf.HorizontalAlignment.Right;
pdfHeadDate.TextState.LineSpacing
= 5;
page.Paragraphs.Add(pdfHeadDate);
for (int question = 0; question <= 5; question++)
{
Aspose.Pdf.Heading
headingQ = new Aspose.Pdf.Heading(1);
headingQ.Text = "pulisci(question.Text)";
headingQ.TextState.Font = FontRepository.FindFont("Arial");
headingQ.TextState.FontSize = 10;
headingQ.TextState.FontStyle = FontStyles.Bold;
headingQ.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Justify;
headingQ.TextState.LineSpacing = 3;
headingQ.Margin = new
Aspose.Pdf.MarginInfo();
headingQ.Margin.Top = 10;
headingQ.IsAutoSequence = true;
page.Paragraphs.Add(headingQ);
for (int internalAnswer = 0; internalAnswer <= 5;
internalAnswer++)
{
Aspose.Pdf.Heading
headingA = new Aspose.Pdf.Heading(2);
headingA.Text = "(internalAnswer.Text)";
headingA.TextState.Font = FontRepository.FindFont("Arial");
headingA.TextState.FontSize = 10;
headingA.TextState.FontStyle = FontStyles.Bold;
headingA.HorizontalAlignment =
Aspose.Pdf.HorizontalAlignment.Justify;
headingA.TextState.LineSpacing = 3;
headingA.Margin = new Aspose.Pdf.MarginInfo();
headingA.Margin.Left = 12;
headingA.Margin.Top = 5;
page.Paragraphs.Add(headingA);
}
}
doc.Save(outFile);
Please feel free to contact us for any further assistance.
Best Regards,