Free Support Forum -

BaseParagraph is missing ID

The Paragraph class in Aspose.pdf.generator has the property ID.
I’m migrating the existing version to Aspose PDF 18.8 but can’t find the ID property in BaseParagraph class or classes that inherit from it. How can the Id be retrieved for a paragraph(BaseParagraph)?



Thanks for your inquiry.

Would please explain a bit more why you need to get an ID of BaseParagraph. It would be helpful if you can please share sample code snippet, so that we can check your actual requirements and suggest DOM based code snippet accordingly. Please also share any sample file if scenario requires it.

We have a xsl template to support adding of images using the image tag. The id is used to have the image type and details of the image. During creation of the pdf we loop through all the elements fetch and add images specified image to the document:

<Image Alignment="Left" ID="image:ReferenceParagraphID">
 <xsl:attribute name="ReferenceParagraphID">ImageChartMethod=PlotSchematic&amp;FixWidth=545&amp;Scale=0.9</xsl:attribute>


private void CheckForImage(Document pdf, Dictionary<string, byte[]> attachments, Page section, BaseParagraph p)
// recurse for floating boxes…
if (p is FloatingBox)
foreach (var pinner in (p as FloatingBox).Paragraphs)
CheckForImage(pdf, attachments, section, pinner);

            // now do image insert
            if (p.ID != null && (p.ID.StartsWith("attachment:") || p.ID.StartsWith("image:")))

Here is the image tag that we use in the xsl template:
<Image Alignment="Left" ID="image:ReferenceParagraphID"></image>


In order to retrieve values of element IDs in XSL/XML template using latest DOM approach, you can use Document.GetObjectById( ) method. Please check following example in API documentation where mentioned method is being used to get the image ID and set its path.

Set Image Path While Converting XML to PDF

In case if suggested solution does not work, please share a sample template along with complete sample code snippet. We will test the scenario in our environment and address it accordingly.