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

Free Support Forum - aspose.com

Issue in page size of PDF after converting from PPT

Hi Team,

I am converting PPTX to PDF and from PDF to HTML …

now I require PDF back with same page size as slide size of PPT,

I am getting A4 size of PDF from HTML when regenerated back.

using following code…

Aspose.Pdf.HtmlLoadOptions objLoadOptions = new Aspose.Pdf.HtmlLoadOptions();
Console.WriteLine(“Slide Height:-” + slide.SlideSize.Size.Height + " Slide Width:- " + slide.SlideSize.Size.Width);
objLoadOptions.PageInfo.Margin.Bottom = 0;
objLoadOptions.PageInfo.Margin.Top = 0;
objLoadOptions.PageInfo.Margin.Right = 0;
objLoadOptions.PageInfo.Margin.Left = 0;
Aspose.Pdf.Document pdf2 = new Aspose.Pdf.Document(Root+"//pdf_generated.html", objLoadOptions);
Aspose.Pdf.PdfSaveOptions options = new Aspose.Pdf.PdfSaveOptions();
pdf2.Save(Root + “//Regenerated_Pdf.pdf”);

even tried with …

objLoadOptions.PageInfo.Height= Presentation.Slide.SlideSize.Height;
objLoadOptions.PageInfo.Width =Presentation.Slide.SlideSize.Width;

but still not getting same size as pptx slide…

Thanks in advance.

@kotharib2

Thanks for contacting support.

Would you please share the sample HTML file with us i.e. pdf_generated.html. We will test the scenario in our environment and address it accordingly.

Hi @asad.ali,

I attached three files

  1. Demo.pdf <- Original PDF File.
  2. pdf_generated.html <- HTML generated from PDF
    3)Regenerated_PDF.pdf <- PDF regenerated from pdf_generated.html

Document.zip (7.2 MB)

any updates…?

@kotharib2

We have checked original PDF (Demo.pdf) and tried to generate an output with similar dimensions using your input HTML and Aspose.PDF for .NET 18.8. Generated PDF looked fine and rendered with applied dimensions. Please check following code snippet and attached resultant file for your reference.

Aspose.Pdf.HtmlLoadOptions objLoadOptions = new Aspose.Pdf.HtmlLoadOptions();
objLoadOptions.PageInfo.Margin.Bottom = 0;
objLoadOptions.PageInfo.Margin.Top = 0;
objLoadOptions.PageInfo.Margin.Right = 0;
objLoadOptions.PageInfo.Margin.Left = 0;
objLoadOptions.PageInfo.Height = 540; // 7.50 * 72
objLoadOptions.PageInfo.Width = 720; // 10 * 72
objLoadOptions.PageInfo.IsLandscape = true;
Aspose.Pdf.Document doc = new Aspose.Pdf.Document(dataDir + "pdf_generated.html", objLoadOptions);
doc.Save(dataDir + "RegeneratedPDF.pdf");

RegeneratedPDF.pdf (965.8 KB)

Would you please use latest version of the API in your environment and if you still face any issue, please feel free to let us know.

Thanks a lot got idea…issue resolved :slight_smile: