SetTagAlternateDescription Method (GdPicturePDF)
In This Topic
Sets the alternate description of the structure element (tag) specified by its unique (tag's) identifier, that is a part of the document's tag structure tree related to the currently loaded PDF document.
It is a text string in the readable form providing for items, located in the PDF document, that do not translate naturally into the text, such as images, formulas, actual form field names or annotations displaying text and others.
Syntax
'Declaration
Public Function SetTagAlternateDescription( _
ByVal As Integer, _
ByVal As String _
) As GdPictureStatus
public GdPictureStatus SetTagAlternateDescription(
int ,
string
)
public function SetTagAlternateDescription(
: Integer;
: String
): GdPictureStatus;
public function SetTagAlternateDescription(
: int,
: String
) : GdPictureStatus;
public: GdPictureStatus SetTagAlternateDescription(
int ,
string*
)
public:
GdPictureStatus SetTagAlternateDescription(
int ,
String^
)
Parameters
- TagID
- A unique tag identifier of the tag's tree element.
- AlternateDescription
- The new alternate description of the specified tag's tree element.
Return Value
A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.
We strongly recommend always checking this status first.
Example
How to utilize an alternate description property of a newly created tag element.
Dim caption As String = "Example: SetTagAlternateDescription"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim image_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagImage As Integer = gdpicturePDF.NewTag(tagRootID, "Figure")
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagAlternateDescription(tagImage, "This is a picture of ...") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagAttribute(tagImage, "BBox", New Double() {0, 0, 612, 792}) = GdPictureStatus.OK) Then
If (gdpicturePDF.BeginMarkedContentSequence(tagImage, "Figure") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawImage(image_name, 0, 0, 612, 792) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your new PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Creating a tag's content has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Creating a tag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: SetTagAlternateDescription";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string image_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int tagRootID = gdpicturePDF.GetTagRootID();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLanguage("en-US") == GdPictureStatus.OK))
{
int tagImage = gdpicturePDF.NewTag(tagRootID, "Figure");
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagAlternateDescription(tagImage, "This is a picture of ...") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagAttribute(tagImage, "BBox", new double[] { 0, 0, 612, 792 }) == GdPictureStatus.OK))
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagImage, "Figure") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawImage(image_name, 0, 0, 612, 792) == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your new PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Creating a tag's content has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Creating a tag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddJpegImageFromFile has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Example
How to utilize an alternate description property of a newly created tag element.
Dim caption As String = "Example: SetTagAlternateDescription"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim image_name As String = gdpicturePDF.AddJpegImageFromFile("image.jpg")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagImage As Integer = gdpicturePDF.NewTag(tagRootID, "Figure")
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagAlternateDescription(tagImage, "This is a picture of ...") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTagAttribute(tagImage, "BBox", New Double() {0, 0, 612, 792}) = GdPictureStatus.OK) Then
If (gdpicturePDF.BeginMarkedContentSequence(tagImage, "Figure") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawImage(image_name, 0, 0, 612, 792) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your new PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Creating a tag's content has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Creating a tag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The AddJpegImageFromFile has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: SetTagAlternateDescription";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string image_name = gdpicturePDF.AddJpegImageFromFile("image.jpg");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int tagRootID = gdpicturePDF.GetTagRootID();
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetLanguage("en-US") == GdPictureStatus.OK))
{
int tagImage = gdpicturePDF.NewTag(tagRootID, "Figure");
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagAlternateDescription(tagImage, "This is a picture of ...") == GdPictureStatus.OK) &&
(gdpicturePDF.SetTagAttribute(tagImage, "BBox", new double[] { 0, 0, 612, 792 }) == GdPictureStatus.OK))
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagImage, "Figure") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawImage(image_name, 0, 0, 612, 792) == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your new PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Creating a tag's content has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Creating a tag has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The AddJpegImageFromFile has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
See Also