Hi,
Hi Saurabh,
Thanks for using our API’s.
The reason SVG image appears outside of table cell is because it has large margin around all corners. However when I have tested the scenario using one of my sample SVG images, the image appears properly in table cell.
[Java]
com.aspose.pdf.Document doc = new com.aspose.pdf.Document();
// Add a page to the document
doc.getPages().add();
// Define border information
BorderInfo info = new BorderInfo(BorderSide.All, com.aspose.pdf.Color.getAqua());
// Create a table and set default cell border
Table table = new Table();
table.setDefaultCellBorder(info);
// Add a row to the table
com.aspose.pdf.Row row = table.getRows().add();
// Add a cell with text
row.getCells().add("Just some text");
// Create a cell to hold an image
Cell cell = new Cell();
cell.setBorder(info);
// Create and configure the image
com.aspose.pdf.Image img = new com.aspose.pdf.Image();
img.setFile("C:\\pdftest\\svg\\test.svg");
img.setFileType(com.aspose.pdf.ImageFileType.Svg);
// Add the image to the cell
cell.getParagraphs().add(img);
// Add the cell to the row
row.getCells().add(cell);
// Set the column widths for the table
table.setColumnWidths("200 200");
// Add the table to the page
doc.getPages().get_Item(1).getParagraphs().add(table);
// Save the document
doc.save("c:/pdftest/TableBorderIssue.pdf");
Hi,
Hi Saurabh,
Hi Saurabh,
Hi,
Is this issue fixed now? If it is which version of ASPOSE PDF API should I use?
Thanks,
Balakumar
@BalakumarSeethapathy,
The linked ticket ID PDFJAVA-35601 is not resolved yet and dependent on an internal enhancement. It is a complex task and can take more time than usual. We will notify you once it is fixed.
Best Regards,
Imran Rafique
Thanks Imran, What is usal turn around in fixing such bugs? Above bug has not fixed for more than one and half year. we are exploring feasibility to use Aspose in our application, and this is key feature we are looking for.
@mitulraul,
The linked ticket ID PDFJAVA-35601 is dependent on an internal feature. We have recorded your concern of the time span. We would like to add here that we do our best to incorporate the bug fixes reported by the clients as soon as possible, but in fewer cases it becomes difficult for us due to the complexity of the scenario. We will let you know once an update is available.
@SaurabhMayekar, @BalakumarSeethapathy, @mitulraul
Thanks for your patience.
We are pleased to inform you that earlier logged issue PDFJAVA-35601 has been resolved in Aspose.PDF for Java 18.1. In order to set fixed height/width of the image, please use following code snippet:
img.setFixWidth(250); // or any other value
img.setFixHeight(250); // or any other value
Furthermore, please note that in some cases the above code is not necessary as the cells normally grow bigger if the image fits the page. And only if it is not, the image should be scaled. The snippet below demonstrates how (with using Aspose.Imaging library) can be determined, whether there is a need for scaling or not.
com.aspose.pdf.Image img = new com.aspose.pdf.Image();
img.setFile("C:\\pdftest\\geomap.svg");
com.aspose.imaging.fileformats.svg.SvgImage svg = (com.aspose.imaging.fileformats.svg.SvgImage) com.aspose.imaging.Image.load(img.setFile("C:\\pdftest\\geomap.svg");
if (svg.getWidth() > (page.getPageInfo().getWidth() / 2)) {
double scaleFactor = svg.getWidth() / (page.getPageInfo().getWidth() / 2 );
img.setFixHeight(svg.getWidth() / scaleFactor);
img.setFixWidth(svg.getHeight() / scaleFactor);
}
svg.close();
Please try using latest version of the API and in case you still face any issue, please feel free to let us know.