Rank: Newbie
Groups: Registered
Joined: 3/31/2016(UTC) Posts: 1  Location: London
|
Here is my code:
PdfCommon.Initialize();
var doc = PdfDocument.Load("ct600-2008.pdf");
PdfPageCollection pageCollection = doc.Pages; int count = pageCollection.Count;
PdfPage pdfPage = pageCollection.ElementAt(0);
PdfPageObjectsCollection pageObjects = pdfPage.PageObjects; count = pageObjects.Count;
PdfTextObject txtObj = PdfTextObject.Create(); txtObj.Location = new PointF(50, 50);
txtObj.TextAscii = "Hello"; pageObjects.InsertObject(txtObj);
when the line "txtObj.TextAscii = "Hello";" is executed I get a 'System.AccessViolationException" occurred in "Patagames.Pdf.dll".
Any help here would be appreciated as without this functionality the SDK is of no use to me.
P.S. same exception occurs when setting TextUnicode.
|
|
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 1/5/2016(UTC) Posts: 1,138
Thanks: 10 times Was thanked: 132 time(s) in 129 post(s)
|
Please look at following: Code:
PdfCommon.Initialize();
var doc = PdfDocument.Load("ct600-2008.pdf");
PdfPageCollection pageCollection = doc.Pages;
int count = pageCollection.Count;
PdfPage pdfPage = pageCollection.ElementAt(0);
PdfPageObjectsCollection pageObjects = pdfPage.PageObjects;
count = pageObjects.Count;
PdfTextObject txtObj = PdfTextObject.Create();
//Firstly you need to set the font to this text object
txtObj.Font = PdfFont.CreateStock(doc, FontStockNames.Arial);
//Next you need to set the text's color
txtObj.StrokeColor = Color.Black;
//After that you need to set the text's size
txtObj.Transform(50, 0, 0, 50, 0, 0);
//and then you can set the location
txtObj.Location = new PointF(50, 50);
//Now this line will be executed without any errors
txtObj.TextAscii = "Hello";
pageObjects.InsertObject(txtObj);
if you use PdfViewer, finally you need to redraw the page.
|
|
|
|
|
|
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.
Important Information:
The Patagames Software Support Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close