How do you set the AltText on a SElement?

197 views
Skip to first unread message

Seth Goldstein

unread,
Nov 11, 2010, 4:12:51 PM11/11/10
to PDFTron PDFNet SDK

When reviewing the documentation for SElement here:

http://www.pdftron.com/pdfnet/html/classpdftron_1_1PDF_1_1Struct_1_1SElement.html

I see and can use HasAlt and GetAlt just fine to get the Alt text for
the element.

However, how would I set the Alt text on the element? What would be
the equivalent of SetAlt?

Support

unread,
Nov 12, 2010, 4:44:20 PM11/12/10
to PDFTron PDFNet SDK

You could use:

Obj se = selement.GetSDFObj();
if (se != null && se.IsDict()) se.PutText("Alt", "My Alt text");



On Nov 11, 1:12 pm, Seth Goldstein <seth.d.goldst...@gmail.com> wrote:
> When reviewing the documentation for SElement here:
>
> http://www.pdftron.com/pdfnet/html/classpdftron_1_1PDF_1_1Struct_1_1S...

Support

unread,
Nov 29, 2010, 5:28:29 PM11/29/10
to PDFTron PDFNet SDK
Q: We’re still trying to get the structure tree worked out in our
PDF. We have used your example to create a structure tree but are
still confused how to reference our existing Image as Marked Content.
We’ve implemented the code below and additionally see a structure tree
being added when viewing the resulting PDF in CosEdit. Yet, we don’t
see association between the image and the STree. When we spoke
earlier you mentioned using ObjectRef to create the reference,
additionally you referenced section 14.7.4.2. Unfortunately we are
unable to track down any more information about these items.

I’ve attached the pdf file we’ve created the structure tree for
although we assume the image isn’t “Marked Content”.

Here is the method we use to create the structure tree, how do we
associate the image?

Public Function CreateTree(ByVal doc As pdftron.PDF.PDFDoc, ByVal page
As pdftron.PDF.Page) As SElement
Dim SRoot As STree = STree_Create(doc)
Dim p1 As SElement = SElement_Create(doc, "P")
STree_Insert(SRoot, p1, 0)
Return p1

Dim mcid1 As Integer = ContentItem_Create(doc, p1,
page.GetSDFObj())
Dim prop1 As Obj = doc.CreateIndirectDict()
prop1.PutNumber("MCID", mcid1)
End Function

Thanks for your time, we are happy to investigate the pdf spec in more
detail but aren’t too familiar with the file formats. If you have
advice on specific sections we’re happy to dig at that also.

----------------------
A: We were hoping that Acrobat would display alternate text from the
OBJR (object reference). The OBJR is recognized, however for some
reason the tooltip is not show. In case you need to compatible with
Acrobat you will probably need to use MCID reference. This means that
you would need to edit the page content stream (similar to ElementEdit
sample - http://www.pdftron.com/pdfnet/samplecode.html#ElementEdit)
and inject the following string just before image element is written
out:

element_writer.WriteString("/Figure <</MCID 0 >> BDC");
element_writer.WriteElement(image_element);
element_writer.WriteString("EMC");

This way you will surround a given image element in a 'marked content
block', which will be linked to your SElement with alternate text.
> > the equivalent of SetAlt?- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages