I am using apsose.pdf v 17.2.0,
When I am using TextBuilder to add text to a page it is not working… but works when adding via a paragraph… What am I doing wrong following is my code…
<span style=“font-family: “Courier New”; font-size: 9pt;”>Document pdfDoc = <span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(0, 0, 128); font-weight: bold;”>new <span style=“font-family: “Courier New”; font-size: 9pt;”>Document();<pre style=“font-family: “Courier New”; font-size: 9pt;”>
DocumentInfo docInfo = pdfDoc.getInfo();
<span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(128, 128, 128); font-style: italic;”>//Meeting info
<span style=“font-family: “Courier New”; font-size: 9pt;”>Page page = pdfDoc.getPages().add();
TextFragment meetingNameLabel = <span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(0, 0, 128); font-weight: bold;”>new <span style=“font-family: “Courier New”; font-size: 9pt;”>TextFragment(<span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(0, 128, 0); font-weight: bold;”>“Name:”<span style=“font-family: “Courier New”; font-size: 9pt;”>);
meetingNameLabel.getTextState().setFont(FontRepository.<span style=“font-family: “Courier New”; font-size: 9pt; font-style: italic;”>findFont<span style=“font-family: “Courier New”; font-size: 9pt;”>(<span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(0, 128, 0); font-weight: bold;”>“Arial”<span style=“font-family: “Courier New”; font-size: 9pt;”>));
meetingNameLabel.getTextState().setFontSize(<span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(0, 0, 255);”>14<span style=“font-family: “Courier New”; font-size: 9pt;”>);
meetingNameLabel.getTextState().setFontStyle(FontStyles.<span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(102, 14, 122); font-weight: bold; font-style: italic;”>Bold<span style=“font-family: “Courier New”; font-size: 9pt;”>);
TextBuilder tb = <span style=“font-family: “Courier New”; font-size: 9pt; color: rgb(0, 0, 128); font-weight: bold;”>new <span style=“font-family: “Courier New”; font-size: 9pt;”>TextBuilder(page);
tb.appendText(meetingNameLabel);
<pre style=“font-family: “Courier New”; font-size: 9pt;”>pdfDoc.save(“D:/work/temp.pdf”);
But this works<span style=“font-family: “Courier New”; font-size: 9pt;”><pre style=“font-family: “Courier New”; font-size: 9pt;”>Document pdfDoc = new Document();
DocumentInfo docInfo = pdfDoc.getInfo();
//Meeting info
Page page = pdfDoc.getPages().add();
TextFragment meetingNameLabel = new TextFragment(“Name:”);
meetingNameLabel.getTextState().setFont(FontRepository.findFont(“Arial”));
meetingNameLabel.getTextState().setFontSize(14);
meetingNameLabel.getTextState().setFontStyle(FontStyles.Bold);<pre style=“font-family: “Courier New”; font-size: 9pt;”>page.getParagraphs().add(meetingNameLabel);<pre style=“font-family: “Courier New”; font-size: 9pt;”>pdfDoc.save(“D:/work/temp.pdf”);<span style=“font-family: “Courier New”;”>
What am I doing wrong in the first method ?