When backcolor is applied on a cell or range, any background image or data gets hidden behind it while exporting to PDF.
DsExcel allows you to make the cell's backcolor transparent when exported to PDF by using the setPrintTransparentCell method of the PdfSaveOptions class. The default value of this property is false. When set to true, it prints the transparency of the cell's background color which makes any background image or data visible.
Refer to the following example code to make cell's backcolor transparent to view the background image in PDF document.
Java |
Copy Code |
---|---|
// Initialize workbook Workbook workbook = new Workbook(); // Fetch default worksheet IWorksheet worksheet = workbook.getWorksheets().get(0); worksheet.getRange("A1:K20").getInterior().setColor(Color.FromArgb(50, 0, 255, 255)); // Add a background picture IBackgroundPicture picture = worksheet.getBackgroundPictures().addPictureInPixel("image.png", 0, 0, 300, 200); // Set the transparency of cell's background color, so the background picture will come out to the front PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); pdfSaveOptions.setPrintTransparentCell(true); // Save to pdf file workbook.save("PrintTransparentCell.pdf", pdfSaveOptions); |