Hi,
How can we add custom headers and footers to the pdf document?
And how to create a bold text using TextFragment?
Thanks
Mamatha
Hi,
How can we add custom headers and footers to the pdf document?
And how to create a bold text using TextFragment?
Thanks
Mamatha
Hi Mamatha,
Document doc = new Document();<o:p></o:p>
Page page = doc.getPages().add();
TextFragment boldtext= new TextFragment("bold text");
boldtext.getTextState().setFontStyle(com.aspose.pdf.FontStyles.Bold);
page.getParagraphs().add(boldtext);
com.aspose.pdf.Table table = new com.aspose.pdf.Table();
table.setColumnWidths("50 100");
for (int i = 1; i <= 200; i++)
{
com.aspose.pdf.Row row = table.getRows().add();
row.setFixedRowHeight(15);
com.aspose.pdf.Cell cell1 = row.getCells().add();
cell1.getParagraphs().add(new TextFragment("Content 1 "+i));
com.aspose.pdf.Cell cell2 = row.getCells().add();
cell2.getParagraphs().add(new TextFragment("Content 2 "+i));
}
page.getParagraphs().add(table);
//header table
com.aspose.pdf.Table table1 = new com.aspose.pdf.Table();
table1.setColumnWidths("150 150");
com.aspose.pdf.Row row1 = table1.getRows().add();
//add table cells
row1.getCells().add("Column 1");
row1.getCells().add("Column 2");
row1.setBorder(new com.aspose.pdf.BorderInfo(BorderSide.Bottom, .5f, com.aspose.pdf.Color.getLightGray()));
com.aspose.pdf.HeaderFooter header = new com.aspose.pdf.HeaderFooter();
header.getParagraphs().add(table1);
page.setHeader(header);
doc.save(myDir+"HeaderFooter.pdf");
Hi,
Thanks for the sample program. Bold text and header worked. But when I set header top margin or table top margin is set then header is overlapping with the content. Can you please look into this.
header.getMargin().setTop(72);
One more thing, when I tried to add image into table cell Acrobat reader complains.
Image img = new com.aspose.pdf.Image();
img.setFile("d:/pdf/logo.png");
img.setFixHeight(85);
img.setFixWidth(100);
row1.getCells().add().getParagraphs().add(img);
What is the right way for adding image into a table cell?
Thanks
Mamatha
Hi Mamatha,mamatha:Thanks for the sample program. Bold text and header worked. But when I set header top margin or table top margin is set then header is overlapping with the content. Can you please look into this.header.getMargin().setTop(72);
Thanks
for using our API’s.
I
have tested the scenario and I am able to notice the same problem. For the sake
of correction, I have logged this problem as PDFNEWJAVA-35390 in
our issue tracking system. We will further look into the details of this
problem and will keep you updated on the status of correction. Please be
patient and spare us little time. We are sorry for this inconvenience.
Hi Mamatha,mamatha:One more thing, when I tried to add image into table cell Acrobat reader complains.
Image img = new com.aspose.pdf.Image();
img.setFile(“d:/pdf/logo.png”);
img.setFixHeight(85);
img.setFixWidth(100);
row1.getCells().add().getParagraphs().add(img);What is the right way for adding image into a table cell?
Thanks for your patience.
I have tested the above stated scenario and I am unable to notice any issue. Can you please share which version of API which you are using.
[C#]
Document doc = new Document();<o:p></o:p>
Page page = doc.getPages().add();<o:p></o:p>
TextFragment boldtext= new TextFragment(“bold
text”);<o:p></o:p>
boldtext.getTextState().setFontStyle(com.aspose.pdf.FontStyles.Bold);<o:p></o:p>
page.getParagraphs().add(boldtext);<o:p></o:p>
com.aspose.pdf.Table table = new
com.aspose.pdf.Table();<o:p></o:p>
table.setColumnWidths(“50 100”);<o:p></o:p>
for (int i = 1; i <= 200;
i++)<o:p></o:p>
{<o:p></o:p>
com.aspose.pdf.Row row =
table.getRows().add();<o:p></o:p>
row.setFixedRowHeight(15);<o:p></o:p>
com.aspose.pdf.Cell cell1 =
row.getCells().add();<o:p></o:p>
cell1.getParagraphs().add(new TextFragment("Content 1
"+i));<o:p></o:p>
com.aspose.pdf.Cell cell2 =
row.getCells().add();<o:p></o:p>
cell2.getParagraphs().add(new TextFragment("Content 2
"+i));<o:p></o:p>
}<o:p></o:p>
page.getParagraphs().add(table);<o:p></o:p>
//header table<o:p></o:p>
com.aspose.pdf.Table table1 = new
com.aspose.pdf.Table();<o:p></o:p>
table1.setColumnWidths(“150 150”);<o:p></o:p>
com.aspose.pdf.Row row1 =
table1.getRows().add();<o:p></o:p>
//add table cells<o:p></o:p>
// row1.getCells().add(“Column
1”);<o:p></o:p>
com.aspose.pdf.Image img = new com.aspose.pdf.Image();<o:p></o:p>
img.setFile(“c:/pdftest/12-15-2015+11-07-36+AM.jpg”);<o:p></o:p>
img.setFixHeight(85);<o:p></o:p>
img.setFixWidth(100);<o:p></o:p>
row1.getCells().add().getParagraphs().add(img);<o:p></o:p>
row1.getCells().add(“Column
2”);<o:p></o:p>
row1.setBorder(new
com.aspose.pdf.BorderInfo(BorderSide.Bottom, .5f, com.aspose.pdf.Color.getLightGray()));<o:p></o:p>
com.aspose.pdf.HeaderFooter header = new
com.aspose.pdf.HeaderFooter();<o:p></o:p>
header.getParagraphs().add(table1);<o:p></o:p>
header.getMargin().setTop(72);<o:p></o:p>
page.setHeader(header);<o:p></o:p>
doc.save(“c:/pdftest/HeaderFooter_with_Margin.pdf”);
Hi,
I am using Aspose-pdf-10.9 version for java. And here is the sample code.
com.aspose.pdf.Table table1 = new com.aspose.pdf.Table();
table1.setColumnWidths("4.0inch 2.5inch");
com.aspose.pdf.Row row1 = table1.getRows().add();
row1.getCells().add("First image);
Image img = new com.aspose.pdf.Image();
img.setFile("d:/pdf/logo.png");
img.setFixHeight(85);
img.setFixWidth(100);
row1.getCells().add(img);
com.aspose.pdf.Row row2 = table1.getRows().add();
row2.getCells().add("Second image);
img = new com.aspose.pdf.Image();
img.setFile("d:/pdf/logo.png");
img.setFixHeight(85);
img.setFixWidth(100);
row2.getCells().add(img);
Thanks
Mamatha
Hi Mamatha,
com.aspose.pdf.Document doc = new
com.aspose.pdf.Document();<o:p></o:p>
doc.getPages().add();
com.aspose.pdf.Table table1 = new com.aspose.pdf.Table();
table1.setColumnWidths("4.0inch 2.5inch");
com.aspose.pdf.Row row1 = table1.getRows().add();
row1.getCells().add("First image");
com.aspose.pdf.Image img = new com.aspose.pdf.Image();
img.setFile("c:/pdftest/logoSpin.png");
img.setFixHeight(85);
img.setFixWidth(100);
row1.getCells().add();
row1.getCells().get_Item(1).getParagraphs().add(img);
com.aspose.pdf.Row row2 = table1.getRows().add();
row2.getCells().add("Second image");
img = new com.aspose.pdf.Image();
img.setFile("c:/pdftest/logoSpin.png");
img.setFixHeight(85);
img.setFixWidth(100);
row2.getCells().add();
row2.getCells().get_Item(1).getParagraphs().add(img);
doc.getPages().get_Item(1).getParagraphs().add(table1);
doc.save(“c:/pdftest/ImageInTableIssue.pdf”);
Nayyer,
Thank you. That did work. Somehow I am still getting error when trying to insert image. I will look into it. I have noticed that free trial version message on the top of the document looks messed up. I have attached screen shot of it. Do you know when do we encounter that issue. I tried generating other reports and they seem to be fine. Is it based on the content of the document?
Thanks
Mamatha
Nayyer,
I was able to reproduce the image issue. I have included image and the sample program. Can you please look into it.
Thanks
Mamatha
Hi Mamatha,
Hi Mamatha,mamatha:I was able to reproduce the image issue. I have included image and the sample program. Can you please look into it.
Hi Mamatha,mamatha:I have noticed that free trial version message on the top of the document looks messed up. I have attached screen shot of it. Do you know when do we encounter that issue. I tried generating other reports and they seem to be fine. Is it based on the content of the document?
Hi,
Is there any update on this?
Thanks
Mamatha
Hi Mamatha,
The issues you have found earlier (filed as PDFNEWJAVA-35404) have been fixed in Aspose.Pdf for Java 16.11.0.
The issues you have found earlier (filed as PDFJAVA-35405) have been fixed in Aspose.Pdf for Java 17.4.