We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Convert PDF to template based Excel Format using Aspose.PDF for Java

Hi Aspose Team,

Thank you for your help, We had tried with below code

private void processExcel() {
String input = “E:\sample\9149.pdf”;
InputStream is = null;
try {
File licFile = new File(“E:\sample\GenerateExcel\src\Aspose_Total.lic”);
is = new FileInputStream(licFile);
License lic = new License();
lic.setLicense(is);
} catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
} finally {
try {
if (is != null)
is.close();
} catch (Exception ignored) {

                }
            }
            
    try
    {
        Document pdfDocument = new Document(input);          
        ExcelSaveOptions excelsave = new ExcelSaveOptions();          
        pdfDocument.save("E:\\sample\\test123.xls", excelsave);          
       
        
         Document doc = new Document(input);        
         ExcelSaveOptions options1 = new ExcelSaveOptions();         
         options1.setFormat(ExcelSaveOptions.ExcelFormat.XLSX);         
         doc.save("E:\\sample\\test1.xlsx", options1);
         
         
         System.out.println("end");
         } catch (Exception e) {
                System.out.println(e.toString());
                e.printStackTrace();
            }
    }

XLS format output was generated(attached generated output test123.xls) but it is like excel file not template format, we need excel output with given template format (like excel_template.xls attached)

and we are getting below error while executing the above code to generate xlsx format file. We are using aspose.pdf-18.6-java.jar

Exception in thread “main” java.lang.NoSuchMethodError: com.aspose.pdf.ExcelSaveOptions.setFormat(I)V
at com.javacodegeeks.example.HelloWorldApplication.processExcel(HelloWorldApplication.java:79)
at com.javacodegeeks.example.HelloWorldApplication.main(HelloWorldApplication.java:30)

Can you please provide sample code for generating an excel template file with input as a pdf or XML
Files.zip (107.8 KB)
file.

Thanks,
Durga


This Topic is created by Amjad_Sahi using Email to Topic tool.

@nishitha

Thanks for your inquiry.

Would you please try using Aspose.PDF for Java 20.3 at your end as we tested the scenario using this version and were unable to notice the exception.

Regarding your template based requirements, we have logged an investigation ticket as PDFJAVA-39302 in our issue tracking system. We will look into details of it and keep you posted with the status of its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi Aspose Team,
Thank you for your help, We had tried with below code using aspose.pdf-20.3-java.jar

private void processExcel() {
String input = “E:\sample\9149.pdf”;
InputStream is = null;
try {
File licFile = new File(“E:\sample\GenerateExcel\src\Aspose_Total.lic”);
is = new FileInputStream(licFile);
License lic = new License();
lic.setLicense(is);
} catch (Exception e) {
System.out.println(e.toString());
e.printStackTrace();
} finally {
try {
if (is != null)
is.close();
} catch (Exception ignored) {

            }
        }
        
try
{
    Document pdfDocument = new Document(input);          
    ExcelSaveOptions excelsave = new ExcelSaveOptions();          
    pdfDocument.save("E:\\sample\\test123.xls", excelsave);          
   
    
     Document doc = new Document(input);        
     ExcelSaveOptions options1 = new ExcelSaveOptions();         
     options1.setFormat(ExcelSaveOptions.ExcelFormat.XLSX);         
     doc.save("E:\\sample\\test1.xlsx", options1);
     
     
     System.out.println("end");
     } catch (Exception e) {
            System.out.println(e.toString());
            e.printStackTrace();
        }
}

we are getting below error while executing the above code

java.lang.IllegalStateException: The subscription included in this license allows free upgrades until 22 May 2019, but this version of the product was released on 18 Mar 2020. Please renew the subscription or use a previous version of the product.
at com.aspose.pdf.l9h.lI(Unknown Source)
at com.aspose.pdf.License.setLicense(Unknown Source)
at com.javacodegeeks.example.HelloWorldApplication.processExcel(HelloWorldApplication.java:42)
at com.javacodegeeks.example.HelloWorldApplication.main(HelloWorldApplication.java:26)

Can you please provide trail license code for aspose.pdf-20.3-java.jar for generating an excel template file

Thanks,
Durga

@nishitha

You can surely apply for a 30-days trial license over our website. In case you still face any issue, please feel free to let us know.

Hi Aspose Team,
Thank you for your help, We got the temporary license and tried with that license now excel file was generated with xlsx format using aspose.pdf-20.3-java.jar but in this RTF template format not applied just data was copied from pdf to excel file as like XLS format. attached sample RTF and XML.Test_pdf.pdf (26.9 KB)

We need template-based excel with the input of pdf / xml / rtf file.
Can we know the status of PDFJAVA-39302 ticket.

Thanks,
Durga

@nishitha

The ticket has already been logged in our issue tracking system to investigate your requirements. The ticket is logged under the free support model and will be resolved on a first come first serve basis. We will surely inform you as soon as we have additional updates in this regard. Please spare us some time.

We are sorry for the inconvenience.

The issues you have found earlier (filed as PDFJAVA-39302) have been fixed in Aspose.PDF for Java 20.5.

Hi Team,

Thank you for your help. Could you please provide trail license for aspose-pdf-20.5.jar for checking excel template file generation with above provided jar files.

Thanks,
Durga

@nishitha

We always recommend to use the latest version as all previous fixes and enhancements are part of the latest version. You can surely get a trial license in order to test the Aspose.PDF for Java 21.8 by clicking on the share link and following the wizard.

Hi Team,

Tried with latest version( Aspose.PDF for Java 21.8) and now also only data got copied to excel file from pdf template file but the excel file data is not displaying in a template format i.e. pdf data styles(like background color, alignments) are not displaying in excel. Could you please assist how can we achieve pdf template also along with data from pdf to excel ?

Thank you…

@nishitha

Could you please share your sample PDF document for our reference so that we can test the scenario in our environment and address it accordingly.

Hi Team,

Please find attached pdf template file and converted excel file.

sample files.zip (48.6 KB)

Thank you

@nishitha

We were able to replicate the issue in our environment. Therefore, a ticket has been logged as PDFJAVA-40869 in our issue tracking system for further investigation. We will look into its details and keep you posted with the status of its resolution. Please be patient and spare us some time.

We are sorry for the inconvenience.

Hi Team,

Thanks for the update. Getting one more issue as getting Java heap size issue while converting pdf template to excel template for 1lakh rows PDF input file(16MB file size) and for 50k rows(8MB) pdf input file takes 4 mins to generate excel file.
Could you please suggest how to overcome this Java heap size and generate in less time?
Thank you…

@nishitha

We may also need a sample source file for this case in order to test and observe the same issue in our environment. Would you please provide it so that we can further proceed to assist you accordingly.