а

Export to pdf - wrap text


#1

Hi,

I am using export pdf (java) functionality. I would like to know how can I wrap the text for column headers as well as for column cells.

I did try using the latest grid-to-pdf java version, also used mygrid.enableMultiline(true); code in my loadGrid() method, however the pdf was still not wrapping the text.

Please advise.

Thanks,
Sam


#2

Hi,
you should modify method printColumn in file PDFWriter.java like here:

String label = textWrap(column.getName(), width - 2*cellOffset, f1);

#3

Could you please provide the code or working example. I am not able to wrap the text into column header and cells.

Thanks,
Sam


#4

Never mind, I figure out a way to fix it.

Thanks


#5

Hi Radyno,

I was able to wrap text for column headers, however I would like to know how can wrap text for row cells.

For instance, row 1 has 13 columns, each column’s text length is less that its column width - so in this case text will appear fine, however in row 2 where couple of columns has text length which exceeds its column width they are truncated as text…(i.e. text truncated until text length is less than column’s width and it is printed as text…, i.e. with 3 dots)

I will really appreciate if you can help by providing a solution which can increase the row height of cell/column, where cell text length exceeds its column width and value is not truncated at all.

Please advise.

Thanks,
Sam


#6

Hi,
unfortunately there is no way to do that for java.


#7

We already built a big project using dhtmlxgrid and the users are loving it, however the text wrapping in pdf columns is now becoming a major concern as pdf’s are exchanged and sent along in emails for various purposes.

I read somewhere on the forum, that PHP export to pdf version takes care of wrapping text in the columns? Is that correct? Then why not java?

Will export to pdf(java) version include this enhancement in near future?

Thanks,
Sam


#8

Hi,
yes, php version supports text wrapping. Unfortunately java-library for producing PDF (PDFJet) doesn’t provide some important methods for getting sizes and precalculating row height. So there is no way to do that in java for now.


#9

Radyno,

I believe there should be note or some information on dhtmlxgrid pdf page that JAVA version of export to pdf does not supports text wrapping in column cells where as PHP does.

I hope you and dhtmlxgrid support should understand that there is NO USE of having a pdf if the text is truncated and not shown in the columns of pdf, this means the user has to come to webpage every time when he wants to read the description. Really frustrating.

May i please know when the fix will be ready for export to pdf java version???

Thanks,
Sam


#10

Thanks for your feedback.
Unfortunately there is no way to implement text wrapping for now.
We will do it as soon as PDFJet will provide required functionality.


#11

Hi,
Can you try increasing the page size to the width and height of the grid ? It may help.

In PDFXMlParser.java setXML method , add the bold lines to the code.

if (orientation_string != “”) {
if (orientation_string.equalsIgnoreCase(“landscape”)) {
orientation = A4.LANDSCAPE;
} else {
orientation = A4.PORTRAIT;
}
} else {
double sum_width = 0;
for (int i = 0; i < widths.length; i++)
sum_width += widths[i];
if (sum_width/widths.length < 80)
orientation = Letter.LANDSCAPE;
else
orientation = Letter.PORTRAIT;

//RA: changed the orientation when columns are too many.
orientation[0] = 1.2sum_width;
orientation[1] = 792
(orientation[0]/612);

}

It worked for me.


#12

Good work!


#13

I read the thread. I need to know, is there any feature to wrap the text in (Export->PDF) .NET version.


#14

Hi Dhivya,
can you specify, what do you mean by wrapping the text?
You may also try latest version of export tool, to see if feature implemented there
s3.amazonaws.com/uploads.hipcha … 130208.zip


#15

Hi,

I am able to export as PDF using the those libraries, which you have attached in the email. Is this wrapping the column values, for e.g. if the column value is more than 10 characters, its not wrapping, its hiding. I want to display those values with wrapping.


#16

I used which you have sent, it is not wrapping the text. Please find the attachment for your reference.


#17

hello,
unfortunatelly this feature is not implemented in current version


#18

Ok Thanks for your reply!

Please get back to us once this feature is added.


#19

ranan2 - Thanks for your inputs, it did help a bit for some of my grids, however the page zoom level becomes 45%. I know we can increase it and set as we want but when I want to print the pdf, it’s divided into 4 pages, i.e. I have 15 columns then 1st page will have 1-3 columns, 2nd page - 3-6, 3rd page - 6-9 and so on…

DHTMLX Support,

As of now, I have decided to implement export-to-pdf grid functionality using php, i.e. by using grid-pdf-php code and now text is being wrapped in columns, however how can I implement text wrapping in column HEADERS.

Please suggest.

Thanks,
Sam


#20

I have also asked this question in http://forum.dhtmlx.com/viewtopic.php?f=23&t=31228, if anyone can help, then please reply to either of the two posts.

Thanks,
Sam