Hi support,
I’m creating headings and then I’m trying to get the label, but I get “null”, although I see in the output the labels : 1.1 ; 3.2.2 etc.
Please advice,
Milan
Hi Milan,
Please share the code with us so we could have a look at it.
Regards,
Hi shahzad.latif,
Here is a code that prints null strings instead of :“1”, “1.1”, “1.1.1” etc. :
Pdf pdf1 = new Pdf();
Section sec1 = pdf1.getSections().add();
for(int i=1; i < 10 ; ++i)
{
Heading heading1 = new Heading(pdf1,sec1, i);
heading1.getSegments().add(“Heading_” + i);
heading1.setLabelWidth(i*10);
sec1.getParagraphs().add(heading1);
System.out.println(heading1.getUserLabel());
}
FileOutputStream out = new FileOutputStream(new File(“C:/Temp/HeadingNumbering.pdf”));
pdf1.save(out);
Regards,
Milan
Hi Milan,
I wonder why you're using System.out.println in the code to show the label. I would rather suggest to change the code like below in blue:
Pdf pdf1 = new Pdf();
Section sec1 = pdf1.getSections().add();
for(int i=1; i < 10 ; ++i)
{
Heading heading1 = new Heading(pdf1,sec1, i);
heading1.getSegments().add("Heading_" + i);
heading1.setLabelWidth(i*10);
heading1.setIsAutoSequence(true);
heading1.setLevel(i);
sec1.getParagraphs().add(heading1);
}
FileOutputStream out = new FileOutputStream(new File("C:/Temp/HeadingNumbering.pdf"));
pdf1.save(out);
You can find more help at the following link:
If you still have some issues please do let us know.
Regards,
Hi,
I’m using System.out.println to show you that although the label for heading is set, I cannot get it. I want to write that label in some other section in my pdf document. Use this line "sec1.getParagraphs().add(new Text(sec1, “Label = " + heading1.getUserLabel()));” instead of the one with System.out.println, and you’ll note what I’m pointing to.
Thanks for looking into this,
Milan
<![endif]–>
Hi milan,
The method: Heading.getUserLabel() can only retrieve the vale you set through the method: Heading.setUserLabel(String). As you have not called Heading.setUserLabel(String), it’s not strange you get a “null”.
You can not get the Heading label when it is generated automatically. Maybe we will provide this function in the future release.
Thank you for using our product.