Error in generated PDF viewed by Adobe Reader 8 ( no Error with Foxit )

Hey Everybody,

I am trying to generate a simple PDF with PDFNet.
Heres my testing Code:

PDFNet.Initialize();
PDFNet.SetResourcesPath(@“C:\dotnet\PSPPortal”);

PDFDoc doc = new PDFDoc();
Page p = doc.PageCreate();
ElementBuilder b = new ElementBuilder();
ElementWriter w = new ElementWriter();
Element element = b.CreateTextBegin(Font.Create(doc, Font.StandardType1Font.e_times_roman), 12);

w.Begin§;

string data = “Hello World!”;
element = b.CreateTextRun(data);
element.SetTextMatrix(10, 0, 0, 10, 0, 600);
element.GetGState().SetLeading(15); // Set the spacing between lines
w.WriteElement(element);
w.WriteElement(b.CreateTextNewLine());
b.CreateTextEnd();
w.End();
doc.PagePushBack§;
doc.Save(@“c:\output\t.pdf”, SDFDoc.SaveOptions.e_remove_unused);
doc.Close();

So, if I open the “t.pdf” with Foxit all is fine but with Adobe Reader 8 the Text isn’t there and Error pops up.

Thank You for your help,
Marc Eilhard

You fotgot to output the start of the text block (i.e.
CreateTextBegin). To fix this add the following line after w.Begin(p):

w.WriteElement(element);