We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Remove unwanted spaces in pdf

Hi,

I converted a .html file to pdf using the below code,when I view the converted file lot of spaces and empty pages also merged in between.CAN U PLEASE HELP IN THIS...

HTML File contains :4 tables ,bulleted listing

Inbetween tables and bulleted listing unwanted spaces was merged...

public void HTMLFiletoPDF(string strInputFile)
{
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Total.lic");

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
StreamReader r = File.OpenText(strInputFile);
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());
text2.Segments.Clear();
section.Paragraphs.Clear();
if (section.PageInfo.PageWidth > 180)
section.IsLandscape = true;
text2.IsHtmlTagSupported = true;
section.Paragraphs.Add(text2);
pdf.Save(strInputFile + "out.pdf");

}

Hi Chokkass,

Thanks for your interest in our products.

Can you please share the source HTML file so that we can test the scenario at our end. This will help us to figure out the issue and reply back to you soon.

We apologize for your inconvenience.

Thanks & Regards,

Hi,

Please take the below code snippet,previous one is wrong...

and also I attached the HTML Sample file...

public void HTMLFiletoPDF(string strInputFile)
{
Aspose.Pdf.License license = new Aspose.Pdf.License();
license.SetLicense("Aspose.Total.lic");

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
StreamReader r = File.OpenText(strInputFile);
Aspose.Pdf.Generator.Text text2 = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());
if (section.PageInfo.PageWidth > 180)
section.IsLandscape = true;
text2.IsHtmlTagSupported = true;
section.Paragraphs.Add(text2);
pdf.Save(strInputFile + "out.pdf");

}

Hi Chokkalingam,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

<o:p> </o:p>

Thank
you for sharing the template file and sample code.<o:p></o:p>

<o:p> </o:p>

We
have found your mentioned issue after an initial test. Your issue has been
registered in our issue tracking system with issue id: PDFNEWNET-32895
.
You will be notified via this forum thread regarding any updates against
your issue.<o:p></o:p>

<o:p> </o:p>

Sorry
for the inconvenience, <o:p></o:p>

Hi Chokkass,

Thank you for sharing the template file and source code.

I have tested your scenario and able to notice that there is no issue in the generated PDF file using Aspose.Pdf for .NET v6.5. Extra spaces are available in your source HTML file, I have removed the tags from your template file which were creating problems. For your reference updated HTML and resultant PDF documents are attached.

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,

Hi,

Thanks for the effort and my requirement is,whether it is possible with that html file what I sent before,since it is the file generated from one of my interface ~ I cant change the tags/edit anything in that.

Can u please help me in this...

Thanks.

Hi Chokkalingham, <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for the feedback.

As we have already registered the issue in our issue tracking system (as mentioned in my previous post), our development team will look into your reported issue and once we get any feedback, we will share that with you.

Thank You & Best Regards,

Hi Chokkalingham,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for being patient.

Please download and try the latest version of Aspose.Pdf for .NET v6.8 as your reported issue regarding empty spaces and extra pages while converting HTML2PDF has been fixed. Please do let us know in case you face any issue.

Sorry for the inconvenience,

The issues you have found earlier (filed as PDFNEWNET-32895) have been fixed in Aspose.Pdf for .NET 9.5.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Hi Chokkalingham,


Thanks for your patience. Your reported issue has been fixed in new DOM approach of HTML to PDF conversion. Please check following documentation link for code snippet and details.


Please feel free to contact us for any further assistance.

Best Regards,