Hi Ankit,
Hi Nayyer ,
Hi Ankit,
Pdf pdf = new Pdf();<o:p></o:p>
//create a Section object and add it to PDF document
Section sec1 = pdf.getSections().add();
// create a sample text object as heading for PDF document
Text text = new Text(sec1, "This Demo shows how to create simple Table!\n");
// specify that heading should be Bold
text.getTextInfo().setIsTrueTypeFontBold(true);
// set the font face information as Arial
text.getTextInfo().setFontName("Arial");
// set the font size for text object
text.getTextInfo().setFontSize(14);
// specify font color information as Green
text.getTextInfo().setColor(new aspose.pdf.Color("Green"));
// add the text object to paragraphs collection of section
sec1.getParagraphs().add(text);
// ======= In following code we will create a Table =======//
// create a new Table object
Table Table1 = new Table(sec1);
// specify the Column width information for Table object
// Table1.setColumnWidths("70 70");
// specify the Border information for Table
Table1.setDefaultCellBorder(new BorderInfo(BorderSide.All.getValue(), 0.9F, new aspose.pdf.Color("Black")));
// Set the BackGround color information for Tabel as Yellow
Table1.setBackgroundColor(new aspose.pdf.Color("White"));
Table1.setIsFirstRowRepeated(true);
Table1.setIsVerticalBroken(true);
int rowCount = 0;
for (int i = 1; i < 100; i++)
{
Row row21 = Table1.getRows().add();
row21.setFixedRowHeight(15);
for (int j = 0; j < 10; j++)
{
row21.getCells().add("Col" + rowCount + j);
}
// add a cell to first row of Table
rowCount++;
}
// add table to paragraphs collection of section object
sec1.getParagraphs().add(Table1);
sec1.getPageInfo().setPageHeight(PageSize.A5Height);
MarginInfo info = new MarginInfo();
info.Left = 60;
info.Right = 20;
info.Top = 30;
info.Bottom = 20;
sec1.getPageInfo().setMargin(info);
Section imageSection = pdf.getSections().add();
ImageInfo imgInfo = new ImageInfo();
imgInfo.setFile("c:/pdftest/Map.png");
imgInfo.setFixWidth(imageSection.getPageInfo().getPageWidth() - 10);
imgInfo.setAlignment(AlignmentType.Center);
aspose.pdf.Image pdfImg = new aspose.pdf.Image();
pdfImg.setImageInfo(imgInfo);
imageSection.getParagraphs().add(pdfImg);
//Save the resultant PDF
pdf.save(“c:\pdftest\ResultantTable.pdf”);
Hi Nayyer,
I tried same piece of code with same image on my machine as well.
And I am able to generate PDF.
But when I just replaced image path with url of image deployed on local tomcat(same image ) I am able to reproduce this issue.
only below part is changed
imgInfo.setFile(“http://localhost:84/img/Map.png”
);
Is there any way to avoid this issue.
Although when I tried with different image (imag is attached)which is also deployed on tomcat
imgInfo.setFile(“http://localhost:84/img/google-map-large.jpg”
);
I was able to generate pdf.
Exception-
Exception in thread “main” java.lang.OutOfMemoryError: Java heap space
at aspose.pdf.figure.Aab.a(SourceFile:351)
at aspose.pdf.figure.Aab.a(SourceFile:96)
at aspose.pdf.figure.Aab.(SourceFile:83)
at aspose.pdf.figure.Aab.(SourceFile:174)
at aspose.pdf.figure.Abi.a(SourceFile:222)
at aspose.pdf.figure.Abi.a(SourceFile:93)
at aspose.pdf.figure.Abi.a(SourceFile:182)
at aspose.pdf.figure.Aba.a(SourceFile:156)
at aspose.pdf.xml.Abi.a(SourceFile:212)
at aspose.pdf.xml.Abi.a(SourceFile:618)
at aspose.pdf.xml.Abj.a(SourceFile:578)
at aspose.pdf.xml.Acd.a(SourceFile:804)
at aspose.pdf.xml.Aar.a(SourceFile:104)
at aspose.pdf.xml.Aba.a(SourceFile:113)
at aspose.pdf.Pdf.save(SourceFile:929)
at examples.samples.table.MapExportTest.main(MapExportTest.java:78)
Regards,
Ankit
Hi Ankit,