Logo, ReportName and Report Generation Time Not adding on top of the PDF first page

Hi Team,

My pdf file is generated using excel to pdf conversion. After that my code is trying to add Logo image, Report name and report generation time on the top of the first page of the generated pdf but it is not adding. FYI, The same code worked fine in 18.5 older aspose jar version. Below is the code snippet i am using to add the said details. Please check and suggest.

Java code to add Logo, Report Name and time.

public void addLogoAndFilters(String pdfFilePath, String title, String requestedDate, boolean showFilters,
Map<String, OutputFilter> reportFilters, Font font) {
setAsposePdfLicense();
Document pdfDocument = new Document(pdfFilePath);
Page page = pdfDocument.getPages().get_Item(1);
Table table = new Table();
table.setColumnWidths(“25 125”);
// Add an image to the header
Image image = new Image();
image.setImageStream(Thread.currentThread().getContextClassLoader()
.getResourceAsStream(“images/”.concat(PdfOutputConstants.SPLASH_ICON_IMAGE_FILE_NAME)));
image.setFixWidth(20); // Set the image width
image.setFixHeight(20); // Set the image height

	Row imageRow = table.getRows().add();
	Row hrRow = table.getRows().add();
	Row executedOn = table.getRows().add();

	Cell imageCell = imageRow.getCells().add();
	imageCell.setRowSpan(3);
	// imageCell.setAlignment(HorizontalAlignment.Right);
	imageCell.getParagraphs().add(image);
	imageCell.setWidth(50);

	Cell titleCell = imageRow.getCells().add();
	titleCell.getParagraphs().add(new TextFragment(replaceCharactersNotSupportedByFontFile(title, " ", font)));
	// titleCell.setAlignment(HorizontalAlignment.Left);
	titleCell.setWidth(300);

	TextState tState = titleCell.getDefaultCellTextState();
	tState.setForegroundColor(Color.getBlue());
	// tState.setFont(font);
	tState.setFontSize(6);

	Cell hrCell = hrRow.getCells().add();
	// hrCell.setAlignment(HorizontalAlignment.Left);
	hrCell.setWidth(300);
	hrCell.getParagraphs().add(new HtmlFragment("<HR>"));

	Cell executedOncell = executedOn.getCells().add();
	// executedOncell.setAlignment(HorizontalAlignment.Left);
	executedOncell.getParagraphs().add(new TextFragment("Report Executed On : " + requestedDate));
	executedOncell.setWidth(300);

	tState = executedOncell.getDefaultCellTextState();
	tState.setForegroundColor(Color.getGray());
	// tState.setFont(font);
	tState.setFontSize(6);

	page.getParagraphs().add(table);

	addFilters(page, showFilters, reportFilters);
	
	savePdfDocument(pdfDocument, pdfFilePath);
}

Expected result - actual pdf gen file.pdf
Actual result - expected pdf gen file.pdf

test pdf gen files.zip (133.5 KB)

@koteswaragunda

Can you please share the sample source PDF document that you obtained from the Excel file? We will test the scenario in our environment and address it accordingly.

@asad.ali enclosed the pdf file generated from excel
excel-to-pdf-Data.zip (115.6 KB)

@koteswaragunda

We were able to notice that the image was not rendered in the output PDF document generated by 24.10 version of the API. We would need to investigate this issue in further details. Can you also share the file generated using 18.5 or older version of the API from your side in which image is visible using the same code? It will help us in investigation.

32373.pdf (154.8 KB)
Plase find the enclosed file

@koteswaragunda

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFJAVA-44495

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Hi @asad.ali
Thank you for taking care of the issue.
One observation wanted to share is,
I have observed that even i have set the System.setProperty(“java.awt.headless”, “true”); i was getting HeadLessException, When i further debug, found that it was caused due to HtmlFragment class used in the code, i.e. hrCell.getParagraphs().add(new HtmlFragment("<HR>")); And when i commented, the image got rendered.

So please check in those lines as well for early resolution.

Also please let me know alternative approaches to set the HTML text.

@koteswaragunda

Thanks for sharing further information. We have updated the ticket details accordingly and will investigate from this perspective as well.

We are afraid that there is no alternate approach to add HTML text other than using HtmlFragment in DOM approach. We will however investigate the issue and let you know as soon as it is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.

Sure @asad.ali will wait for your reply. Thank you.