Generating PDF Partially with Aspose.PDF

Hello Team,

We are seeing that some html files content is missing in the output PDF. It is not fully exported into output PDF. You can see some part of Reference section is missing in the output PDF.

We even tried with the latest versions (24.4.0/24.3.0) of Aspose.PDF.Drawing, but no luck.

We also tried with downgrade version (23.4.0), but no luck.

I have attached the input html and output pdf files here.
example.zip (1.2 MB)

Could you please check and advise to fix it?

Regards,
Prashant

Also, please find the attached stylesheet(CSS) file.
article_style.zip (10.0 KB)

@pps2794
Could you also provide the code you’re using, please?

@ilyazhuykov
Application written in C# (.NET 6)
Env: Clound Foundary (Linux based container)
Code:
try
{
Aspose.Pdf.License license = new Aspose.Pdf.License();
string licensepath = AppContext.BaseDirectory + “Aspose.Total.NET.lic”;
inputFile = $“{Constants.HEADERTEXT} {inputFile}”;
license.SetLicense(licensepath);
FontRepository.Sources.Add(new FolderFontSource(AppContext.BaseDirectory));
byte[] byteArray = Encoding.ASCII.GetBytes(inputFile);
using (MemoryStream stream = new MemoryStream(byteArray))
{
// Set page size A3 and Landscape orientation;
HtmlLoadOptions options = new HtmlLoadOptions()
{
PageInfo = { Width = 1200, Height = 1191, IsLandscape = true }
};

		using (Aspose.Pdf.Document pdfDocument = new Aspose.Pdf.Document(stream, options))
		{
			pdfDocument.Save(outputFile);
		}
}
break; // success!

}
catch(Exception ex)
{
Console.WriteLine($“GeneratePDF: Failed, inputFile={inputFile} Attempt={retry}, error= {ex.ToString()}”);
}

@pps2794
In your code css file usage is absent
How do you apply it do PDF document?
I tried your variant, the result document seems to be correctly converted but lacks style application, seems that there could be something wrong with that
example.pdf (1.4 MB)

@ilyazhuykov In order to apply styles, you need to keep both html and style file the same folder as it linked like below in the input html file:

@pps2794 , thank you, I’ll try with you suggestion

@pps2794
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): PDFNET-57082

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.

I replicated issue, for now I found no workaround
I added new task for development team, I’ll contact you in case I find some workaround solution

@ilyazhuykov any updates on this?

@pps2794
There’s no updates on this task
However I tried to run your code on Aspose Pdf 24.5 and it seems that issue was fixed
Current result looks like this:
example.pdf (1.0 MB)

@ilyazhuykov I just tried with upgrading the Aspose.PDF.Drawing to latest version (24.5.0), but no luck.
See the attached input html and output pdf
Example_3005.zip (862.3 KB)

.

@pps2794
Do I understand correctly that css file changed?
For now it seems that previous one is not recognized by mentioned html input

@ilyazhuykov No CSS file is not changed.
PFA
article_style.zip (10.0 KB)

1 Like

@pps2794
For now I run into peculiar problem that style does not apply
During experimentation I found out that modification of original html with explicit mentioning of css helps and resulting file seems OK, but I’m not sure if it will suit you
I’ll try to contact development team, maybe they will explain why it works this way
Files that I used are here
css.zip (1.3 MB)
To clarify, did version 24.5 Drawing fix issue with previous document?
For now it seems to me that these two are a bit separate cases

@ilyazhuykov
Please place css file in the same folder where you put html file.
PFA and refer it.
example_3005.zip (872.4 KB)

Example_3005.pdf (1.6 MB)

Now style is applied but result still it differs from result you shared
Maybe it has something to do with environment and version of framework, could you share details about it, please?
Also, could you double check that version is correctly updated and is indeed Aspose Pdf 24.5 Drawing ?
I also note that html for Example_3005 is a bit different now
Code didn’t change, I suppose

@ilyazhuykov Sorry for the inconvenience.

Try this html file now
Example_3005_2.zip (873.0 KB)

System details:
Framework: .NET 6
Aspose.PDF.Drawing: 24.5.0
OS: Windows OS

1 Like

@pps2794
thank you for feedback
yes, issue is replicated with this version of html file
I’ll add it to the task then

Could you please check, if issue replicates with file from your original post which is example.html?