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

Free Support Forum - aspose.com

Not able to set page height and width while doing html to pdf conversion

Hi Team,

We are doing HTML to PDF conversion. While doing the conversion, the width and height of the generated pdf is much more than A4 size. We have tried passing width and height using code below

var loadoptions = new HtmlLoadOptions();
loadoptions.PageInfo.IsLandscape = false;
loadoptions.PageInfo.Width = PageSize.A4.Height;
loadoptions.PageInfo.Height = PageSize.A4.Width;
loadoptions.PageInfo.Margin = new MarginInfo(15, 50, 15, 50);

But is is not working as expected. Can you help us out here.
Moreover can you let us know, what is the unit type (px, inch etc) for width, height and margin. There is no documentation for the same.

Regards,
Nipun Jain

@nipunjainindia

Thanks for contacting support.

Please try setting IsLandscape Property to true and if it does not help, please share your sample HTML file in ZIP format with us. We will test the scenario in our environment and address it accordingly.

The basic unit of measurement in Aspose.PDF is point where 72 Points = 1 inch. You can set desired value in points per inch.

Hi team,

The IsLandscape value as true is also not working.Aspose.zip (475.5 KB)

The zip files contains

  1. header.html
  2. footer.html
  3. report.html
  4. code.txt: The code used to convert report, header and footer html files to a pdf file.
  5. resulting_report.pdf: The resulting pdf file.

Please have a look at it asap.

Regards,
Nipun Jain

@nipunjainindia

Thanks for sharing sample files.

We managed to replicate the issue in our environment and logged it as PDFNET-45372 in our issue tracking system for further investigation. We will look into details of the issue and keep you posted with the status of its correction. Please be patient and spare us little time.

We are sorry for the inconvenience.

Hi team,

By when are we expecting this issue to be fixed.

Regards,
Nipun Jain

@nipunjainindia

We just have logged the issue in our issue tracking system and it is pending for investigation. Please note that the issue has been logged under free support model where issues are resolved on first come first serve basis. I regret to share that we cannot share any reliable ETA as resolution of the issue depends upon how long is the queue of previously logged issue. However, we will surely let you know when we make some progress towards resolution of your issue.

Furthermore, we also offer paid support option to our customers where issues are resolved on urgent basis. If your issue is a blocker, you may please consider using priority support option.

We are sorry for the inconvenience.