Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Aug 18, 2021 4:59 am

Hi

When I try to save to stream in XLSX format (from Pdf) ti returns 0 bytes. The same document saves fine to a file (which I can then read in and convert to a stream so I have a workaround but it is messy).

Has this been seen before.

Code: Select all
   
    InputStream is = dataContext.getStream(i);
    Properties props = dataContext.getProperties(i);
   
    PdfDocument pdf = new PdfDocument(is);
     
    os = new ByteArrayOutputStream();
   
    pdf.saveToStream(os, FileFormat.XLSX);   // this doesn't work
    pdf.saveToFile("work/yyy.xlsx", FileFormat.XLSX)   // this does work
   
    DataFormatter formatter = new DataFormatter(Locale.default);
    File file = new File("work/yyy.xlsx");
    Workbook wb = WorkbookFactory.create(file);
    List sheetList = wb.sheets;
    StringBuilder sb = new StringBuilder();

andrew.waites
 
Posts: 1
Joined: Sun Aug 15, 2021 11:58 pm

Wed Aug 18, 2021 9:26 am

Hello,

Thank you for your inquiry.
I did an initial test with your code, but did not reproduce your problem (return 0 byte). The version I used is the latest version(Spire.PDF for Java Version:4.7.8). If you were not using the latest version, please first give it a try. If the issue still exists after trying, please provide your sample PDF file for further investigation. You could attach it here or send to us via email ([email protected]). Thanks in advance.

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF