Issue with table of content


#21

Hi ,

I want to indent my table as per token indentation.but when i am doing contents of the table is not coming properly (half of the content is going out of the page). My requirement is get the table fit in the page with indentation of the token.

I have attached the sample code , input docx ainput_temp.zip (12.7 KB)output_temp (3).zip (11.5 KB)
SampleCode (2).zip (2.4 KB)

Thank you…


#22

@Pintutrnt

In your code, you are not setting the width of table and its cell. Please the width of table and cells and call the Table.autoFit(AutoFitBehavior.FIXED_COLUMN_WIDTHS) method to get the desired output. Hope this helps you.

Moreover, we suggest you please read the following article.
Specifying Table and Cell Widths


#23

Hi Tahir,

I tried your suggestion but when i am indenting the table as per my token’s indentation some of the contents of table is going out of the table.

FYR, attached the sample code and docx.

Thank you…
SampleCode (3).zip (2.4 KB)
input_temp.zip (12.7 KB)
output_temp (4).zip (11.5 KB)


#24

@Pintutrnt

We have tested the scenario using the latest version of Aspose.Words for Java 19.10 and have not found the shared issue. So, please use Aspose.Words for Java 19.10.


#25

Hi Tahir,

I tried your suggestion. but check my new sample code and please do let me know the fix or limitations. [input docx is same]
SampleCode (4).zip (2.5 KB)

Thank you…


#26

@Pintutrnt

Please set the paragraph’s right and left indent as shown below to get the desired output.

case "tableGen":
    Table table = builder.startTable();
    builder.insertCell();
    ParagraphFormat paragraphFormat = builder.getParagraphFormat();
    paragraphFormat.setLeftIndent(0.0);
    paragraphFormat.setRightIndent(0.0);
    paragraphFormat.setAlignment(ParagraphAlignment.CENTER);

#27

Hi Tahir,

I tried your suggestion and its working fine. but my requirement is to set the token’s left indentation in to table’s left indentation and am setting it but in output ,Table’s left indentation is coming as default value as 0.0. can you please guide me.

FYR, attaching the sample code and output docx.
SampleCode (5).zip (2.5 KB)
output_temp (5).zip (11.6 KB)


#28

@Pintutrnt

Please note that Aspose.Words mimics the behavior of MS Word. If you create the same table using MS Word, you will get the same output and behavior.


#29

Hi Tahir,

when we are increasing the number of columns as well as there value’s length then the cell value is getting shrink and wrap inside the column. Attaching the screen shot.[sample code is same]

Table with Larger Nos. _using template.png (9.2 KB)


#30

@Pintutrnt

You are facing the expected behavior of Aspose.Words. Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.


#31

Hi Tahir,

I am defining in “Different First Page” under design of MS docx template. and converting the template in PDF after all token replacement. but when i am parsing the generated PDF using different library (PDFBOX) then “Different First Page” properties is getting lost.
This is the code snippet for Converting in PDF using Aspose :

PdfSaveOptions options = new PdfSaveOptions();
options.getOutlineOptions().setDefaultBookmarksOutlineLevel(1);
options.getOutlineOptions().setHeadingsOutlineLevels(2);
document.save(“D:/output.pdf”,options);

What is the setting i have to do for PDFSaveOptions to get that properties in generated PDF file. Itried doing
options.setExportDocumentStructure(true);
but no luck. can you please help.

Thank you…


#32

@Pintutrnt

Please attach the following resources here for testing:

  • Your input Word document.
  • Please attach the output PDF that shows the undesired behavior.
  • Please attach the expected output PDF that shows the desired behavior.
  • Please create a simple Java application ( source code without compilation errors ) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.


#33

Hi Tahir,

I am attaching sample code and input- output file.While i am converting the file in PDF using Aspose it coming perfectly fine but at the time of loading the same file using PDFBox jar and saving(Note: apart from this i am not doing any changes in loaded file in attached sample code) , PDF is getting changed.

Please do let me know if you need any other info.

Thank you…
AsposeOutput_temp.zip (294.0 KB)
SampleCode (6).zip (2.6 KB)
Jars.zip (6.3 MB)


#34

@Pintutrnt

Could you please share the steps that you are using to generate the pdfBoxGen.pdf? Please share how you processed the generated PDF file using PDFBox. We will then investigate the issue and provide you more information on it.


#35

Below snippet is used to generate the PDF using PDFBOX jar :

PDDocument originalDocument = PDDocument.load(new File(“D:\AsposeOutput_temp.pdf”));
originalDocument.save(“D:\pdfBoxGen.pdf”);


#36

@Pintutrnt

We have tested the scenario using the latest version of Aspose.Words for Java 19.11 and have not found the shared issue. Please use Aspose.Words for Java 19.11.

We have attached the PDF files generated by Aspose.Words and PDFBOX with this post for your kind reference.
19.11.pdf (202.6 KB)
PDFBOX-19.11.pdf (200.3 KB)


#37

Hi Tahir,

I am attaching the new code , input (This one has first page different setting )and output documents. In code , i have introduced a new switch case named “agTitles”. in this case , i have to add some text with heading 1 title and its description as well as insert a new page with Heading 2 style vertically aligned and a empty page. this whole logic will execute in loop.

But after saving in PDF , Input doc setting (First page Different ) is not retaining and footer value is starting from first page. but as per requirement , page page setting should be retain. Can you please check and help ASAP…

Thank you…
Aspose_section_break_issue.zip (211.0 KB)


#38

@Pintutrnt

Unfortunately, your requirement is not clear to us. It would be great if you please share the screenshots of problematic sections of output document along with your expected output PDF/Word document. We will investigate the issue and provide you more information on your issue.


#39

Below is the requirement:

1.) I have to introduced a new HEADING 1 title and its description ,
2.) After that insert a new page break and add the HEADING 2 title with vertically centre aligned
3.) Insert more than one new empty page with same Header & footer
4.) Make sure all the Font style , size (HEADING 2 size will be bigger), color should be consistent.
5.) repeat the step 1 to 4 in a loop.

When i am implementing the requirement without making any design change in input template, its working fine. but issue is coming with input template having first page as “Different First Page” (Under Design tab of MS word ) setting.
There is no token in input_temp-3.docx template at first page’s header and footer(except light blue color). from second page onward in template, i have put the tokens in header and footer. But in generated AsposeOutput_temp.pdf file, first page footer’s color is lost and more over 2nd page onward replaced token value is coming. As per requirement, it should not happen means First page’s header and footer of the generated file should be matching with input template header footer.

Hope it will help you to understand now…


#40

@Pintutrnt

Thanks for sharing the detail. You are clearing the page setup formatting using PageSetup.ClearFormatting method. In your case, we suggest you please use the following modified code snippet to get the desired output.

//now i have to insert two empty pages - one with heading 2 title vertically aligned and one is empty page
Boolean firstPageHeaderFooter = builder.getPageSetup().getDifferentFirstPageHeaderFooter();
builder.getPageSetup().clearFormatting();
builder.getPageSetup().setDifferentFirstPageHeaderFooter(firstPageHeaderFooter);

Moreover, we suggest you please call the Document.updatePageLayout method before saving document to PDF.