Document Solutions for Excel, Java Edition | Document Solutions
File Operations / Export to PDF / Support Background Color Transparency
In This Topic
    Support Background Color Transparency
    In This Topic

    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.

    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();
    // Save to pdf file"PrintTransparentCell.pdf", pdfSaveOptions);