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

Free Support Forum - aspose.com

CSV to PDF Crops Words in Java

I noticed CSV to PDF crops words in Java. I am converting CSV to PDF but some cell have 50+ characters but showing output file have only 20 character approx.
I used below code:

Workbook book = new Workbook(Filename);
book.save(Pathdata + File.separator+ Fname + ".pdf", SaveFormat.PDF); 

I also attached file Excel Test.zip (363.9 KB)

I also attached screen shot Screenshot (18).png (68.2 KB)


Aspose.Cells works as MS Excel.If you open the csv file in MS Excel, you will view the same result as generated pdf.
If you want to show all character, please auto fit width of the columns as the following codes before saving:
Workbook book = new Workbook( “Excel Test.csv”);
book.getWorksheets().get(0).autoFitColumns();//auto fit width of the columns

Hello @simon.zhao
thx for solution
one file is not converted by the above code showing exception Invalid end row index.
I attached file csvFile.zip (4.5 MB)

please check this file.

It’s the limitation of MS Excel. If you do not want to check the limitation of MS Excel,please set TxtLoadOptions .CheckExcelRestriction as the following codes:
TxtLoadOptions loadOptions = new TxtLoadOptions(LoadFormat.Csv);
loadOptions.CheckExcelRestriction = false;
Workbook wb = new Workbook(dir + “Main_types_of_fuel_long_updated_16-7-20.csv”, loadOptions);

Hello @simon.zhao
i used below code in java using aspose cell 21.10
TxtLoadOptions loadOptions = new TxtLoadOptions(LoadFormat.CSV);
Workbook book = new Workbook(Filename,loadOptions);
book.save(Pathdata + File.separator + Fname + “.pdf”, SaveFormat.PDF);

your code not valid
loadOptions.CheckExcelRestriction = false;
so i used loadOptions.setCheckExcelRestriction(false);
but same error (Invalid end row index.) in same file (Main_types_of_fuel_long_updated_16-7-20.csv) upload earlier
one more file have same issue i attached file issue.zip (8.7 MB)

so my issue not resolved plz suggest


We noticed this issue as you mentioned. Do you need to export all the rows of CSV file (even that are beyond the limitation of MS Excel (1,048,576 rows by 16,384 columns)), please confirm? After your confirmation, we will log appropriate ticket for your issue/requirements.

yes we need this , so please resolve this as soon as possible

Can we add watermark / image in all pages of pdf while using above code in this thread . If yes please suggest code for java.


Thanks for your confirmation.

We have logged a ticket with an id “CELLSJAVA-44070” for your issue. The issue is logged as following:
CELLSJAVA-44070 - Exception “Invalid end row index” in CSV to PDF rendering

Once we have an update on it, we will let you know.

See the document with example code on how to add watermark to the worksheet for your reference. You need to embed such a code before rendering to PDF file format.


See the document with example code on how to add watermark to the worksheet for your reference. You need to embed such a code before rendering to PDF file format.
This work only on 1st page other pages not showing watermark as i mentioned i need all pages watermark
I attached output file and input file file.zip (51.6 KB)


Yes, in that case, you need to insert watermark to each and every page in the worksheet.

(RE: csv to pdf watermark not set in every pages of pdf )
can know how it possible in java.
i Am searching code put every page water mark but not found so plz suggest .

And one more question can we blur few pages of pdf? or any restriction can apply to pdf


You should write your own code and logic to paste word art watermark to every page of the worksheet. I have written a sample code to accomplish the task for your reference. Please refer to it for reference and write/update your own code accordingly:
Sample code:

TxtLoadOptions loadOptions = new TxtLoadOptions(LoadFormat.CSV);
        Workbook workbook = new Workbook("f:\\files\\mid1234.csv",loadOptions);

        Worksheet worksheet = workbook.getWorksheets().get(0);
        ImageOrPrintOptions printoption = new ImageOrPrintOptions();
        SheetRender sr = new SheetRender(worksheet, printoption);
        int pageCount = sr.getPageCount();
        CellArea [] area = worksheet.getPrintingPageBreaks(printoption);
        int strow = 0;
        int stcol = 0;
        for(int i =0 ;i<area.length;i++)
            //Get each page range/area.
            strow = area[i].StartRow;
            stcol = area[i].StartColumn;

            // Add Watermark
            com.aspose.cells.Shape wordart = worksheet.getShapes().addTextEffect(MsoPresetTextEffect.TEXT_EFFECT_1, "CONFIDENTIAL",
                    "Arial Black", 50, false, true, strow + 18, 8, stcol+ 1, 0, 130, 800);
            // Get the fill format of the word art
            FillFormat wordArtFormat = wordart.getFill();
            // Set the color
            wordArtFormat.setOneColorGradient(com.aspose.cells.Color.getRed(), 0.2, GradientStyleType.HORIZONTAL, 2);
            // Set the transparency

            // Make the line invisible
            LineFormat lineFormat = wordart.getLine();

        workbook.save("f:\\files\\out1.pdf", SaveFormat.PDF);

You cannot blur PDF pages as Aspose.Cells is spreadsheet file format APIs and not PDF manipulation API. Aspose.Cells for Java only provides some security options that you may apply but it will be applied to the PDF document as a whole.

Please try the lastest fix 21.11.7.
(https://forum.aspose.com/uploads/discourse_instance3/57690) (7.5 MB)
We have fixed the issue of throwing Exception, but the data beyond the limitation of MS Excel is lost in generated pdf file. We are still working on it.