PDFsharp & MigraDoc Forum
https://forum.pdfsharp.net/

How to read Tag string from Paragraphs after Document render
https://forum.pdfsharp.net/viewtopic.php?f=2&t=2227
Page 1 of 1

Author:  brad [ Mon Nov 19, 2012 2:44 pm ]
Post subject:  How to read Tag string from Paragraphs after Document render

Hi,
When building a Document, I set the Tag and Comment properties of paragraphs like this:

myParagraph01.Tag = "Para01";
myParagraph01.Comment = "Para01";
myParagraph02.Tag = "Para02";
myParagraph02.Comment = "Para02";

Then I send the Document to the viewer like this:

string ddl = DdlWriter.WriteToString(myDocument);
myDocumentPreview.Ddl = ddl;

which works fine.

Now I would like to get the tag values, but I cant seem to get them:

DocumentRenderer renderer = this.myDocumentPreview.Renderer;
DocumentObject[] documentObjects = renderer.GetDocumentObjectsFromPage(1); // Get all page 1 DOM elements
MigraDoc.DocumentObjectModel.Paragraph p = (MigraDoc.DocumentObjectModel.Paragraph)documentObjects[0];

It seems to 'see' the single paragraph I have added to the single Section, but not the Tag or Comment properties as they are empty.

How can I achieve this?
Thanks,
Brad.

Author:  Thomas Hoevel [ Mon Nov 19, 2012 3:46 pm ]
Post subject:  Re: How to read Tag string from Paragraphs after Document re

Hi!

Tag is of type object. It could be that tags do not persist the WriteToString call.

Try "myDocumentPreview.Document = myDocument;" instead.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/