Rank: Newbie Groups: Member
Joined: 7/13/2015 Posts: 7
|
Hi, I am trying to create a simple test PDF but i keep getting an out of memory exception. I believe i am missing something obvious. Any help would be appreciated. ============== .NET 4.5 EO.Pdf.dll (From EO.Total 2015) ==============
Code: C#
using EO.Pdf;
using EO.Pdf.Acm;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace pdftest
{
class Program
{
static void Main(string[] args)
{
//AddLicence Omitted
CreatePDF();
}
static void CreatePDF()
{
//Create a new PdfDocument
PdfDocument doc = new PdfDocument();
//Create a new AcmRender object
AcmRender render = new AcmRender(doc);
AcmBlock container = new AcmBlock();
addFormTitle(ref container, "Some Title");
for (int i = 0; i < 9; i++)
{
addSection(ref container, "Section " + i);
}
//Render the text
//Errors Here: "System.OutOfMemoryException was unhandled"
render.Render(container);
//Save the PDF file
doc.Save("tmp.pdf");
}
private static void addFormTitle(ref AcmBlock Parent, String Title)
{
AcmText title = new AcmText(Title);
SetTitleFont(ref title);
Parent.Children.Add(title);
}
private static void addSection(ref AcmBlock Parent, String SectionTitle)
{
AcmBlock SectionContainer = new AcmBlock();
AcmBlock SectionContent = new AcmBlock();
SectionContainer.Style.Margin.Top = 10.0f;
AcmParagraph Paragraph = new AcmParagraph();
SetSubtitleFont(ref Paragraph);
Paragraph.Children.Add(new AcmText(SectionTitle));
SectionContent.Children.Add(Paragraph);
SectionContent.Style.Padding = new AcmPadding(5.0f);
SectionContent.Style.BackgroundColor = Color.FromArgb(230, 230, 230);
SectionContainer.Children.Add(SectionContent);
AcmBlock SectionContent2 = new AcmBlock();
SectionContent2.Style.Padding = new AcmPadding(5.0f);
SectionContent2.Children.Add(new AcmText(TEXT));
SectionContainer.Children.Add(SectionContent2);
Parent.Children.Add(SectionContainer);
}
private static void SetSubtitleFont(ref AcmParagraph obj)
{
obj.Style.FontName = "Helvetica";
obj.Style.FontSize = 10;
obj.Style.FontStyle = FontStyle.Bold;
}
private static void SetTitleFont(ref AcmText obj)
{
obj.Style.FontName = "Helvetica";
obj.Style.FontSize = 14;
obj.Style.FontStyle = FontStyle.Bold;
}
const string TEXT = "Facin exeraessisit la consenim iureet dignibh eu facilluptat vercil dunt autpat. " +
"Ecte magna faccum dolor sequisc iliquat, quat, quipiss equipit accummy niate magna " +
"facil iure eraesequis am velit, quat atis dolore dolent luptat nulla adio odipissectet " +
"lan venis do essequatio conulla facillandrem zzriusci bla ad minim inis nim velit eugait " +
"aut aut lor at ilit ut nulla ate te eugait alit augiamet ad magnim iurem il eu feuissi.\n" +
"Guer sequis duis eu feugait luptat lum adiamet, si tate dolore mod eu facidunt adignisl in " +
"henim dolorem nulla faccum vel inis dolutpatum iusto od min ex euis adio exer sed del " +
"dolor ing enit veniamcon vullutat praestrud molenis ciduisim doloborem ipit nulla consequisi.\n" +
"Nos adit pratetu eriurem delestie del ut lumsandreet nis exerilisit wis nos alit venit praestrud " +
"dolor sum volore facidui blaor erillaortis ad ea augue corem dunt nis iustinciduis euisi.\n" +
"Ut ulputate volore min ut nulpute dolobor sequism olorperilit autatie modit wisl illuptat dolore " +
"min ut in ute doloboreet ip ex et am dunt at.";
}
}
|
Rank: Newbie Groups: Member
Joined: 7/13/2015 Posts: 7
|
After some more debugging, it seems it is an issue caused by the huge padding styles.
I changed the paddings to 0.1f and it all seems to work fine
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,229
|
Great. Thanks for the update!
|