Document Solutions for Excel, Java Edition | Document Solutions
File Operations / Export to PDF / Export Picture
In This Topic
    Export Picture
    In This Topic

    DsExcel Java allows users to save worksheets with pictures while exporting to a PDF file.

    In order to export an excel file with pictures to PDF format, refer to the following example code.

    Java
    Copy Code
    // Create a new workbook and access the default worksheet
    Workbook workbook = new Workbook();
    IWorksheet worksheet = workbook.getWorksheets().get(0);
    worksheet.getPageSetup().setOrientation(PageOrientation.Landscape);
            
    FileInputStream stream = null;
    try 
    {
        stream = new FileInputStream("Pictures/logo.png");
    } 
            
    catch (FileNotFoundException e) 
    {
        e.printStackTrace();
    }
            
    System.out.println(stream.toString());
    IShape picture = null;
    try 
    {
       picture = worksheet.getShapes().addPicture(stream, ImageType.PNG, 20, 20, 690, 100);
    } 
    catch (IOException ioe) 
    {
    }
            
    // Save to a pdf file
    workbook.save("ExportPicture.pdf", SaveFileFormat.Pdf);