How to set page width as per the table width

Hi ,


I am using Aspoe.pdf version-3.1.0 .

My table column can be from 10 to 100.
Right now I am setting section page width as A0(since it can accommodate large no of columns)
section.getPageInfo().setPageWidth(PageSize.A0Width);

Is there a way to set the width as per the table width so that if there are small no of column say 4 it Page Size should not be max which is currently A0

Any help will be appreciated.

Thanks and Best regards,
Ankit

Hi Ankit,


Please accept my apology for delayed response. You can achieve your desired results by setting table width as an argument for page width in addition to right left margins of page. Please find below the code snippet hopefully it would serve the purpose.


sec1.getPageInfo().setPageWidth(Table1.getWidth()+sec1.getPageInfo()

.getMargin().Right+sec1.getPageInfo().getMargin().Left);


Please feel free to contact us for any further assistance.

Best Regards

Hi Support Team,


I tried this but this time the page width was very small and its like width as margin width.

Is there any other way to make the page width auto-fit to content (as per table width )

Regards,
Ankt

Hi Ankt,


Sorry for the inconvenience faced. Can you please share your sample code and output document here? So we will test it at our end and suggest you the solution accordingly.

Best Regards,

My output pdf columns will be around 200, and I've horizontal scorll bar for it.

The issue is my table columns doesn't show up after 30.

My code is like below:

pdfDoc = new Pdf();

section = pdfDoc.getSections().add();

table = new Table(section);

section.getPageInfo().setPageWidth(PageSize.A0Width);

table.setDefaultCellBorder(new BorderInfo(BorderSide.All.getValue(),0.1F));

MarginInfo margin = new MarginInfo();

margin.Left = 5f;

margin.Right = 5f;

margin.Top = 5f;

margin.Bottom = 5f;

table.setDefaultCellPadding(margin);

this.table = this.setTableHeader();

Above code was showing the size about 33.06x11.69 in, I thought size is the issue. So I changed the above code as below, I see larger width now, but only same 30 columns shown, rest shows blank in width.

section.getPageInfo().setPageWidth(7200);

section.getPageInfo().setPageHeight(1000);

and I tried your example below, it shows very narrow window in width.

You help is appreciated to get all columns displayed in the table.

Regards

Rav

Hi there,


Thanks for your inquiry. Can you please share your sample code and output document here? So we will look into it and will provide you information accordingly.

Sorry for the inconvenience faced.

Best Regards,