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

Free Support Forum - aspose.com

HTML to PDF conversion resulting in PDF with 2 pages rather than one

Hi,



We have a release version of Aspose .Net 10.8 and are getting an issue when converting HTML to PDF whereby the PDF is rendered across 2 pages whereas we need it on a single page.





A code sample of what we are doing is :

string licenseFile = string.Format("{0}.Aspose.Total.lic", “TestImageTransform”);

Aspose.Pdf.License AsposePDF = new Aspose.Pdf.License();

AsposePDF.SetLicense(licenseFile);

AsposePDF.Embedded = true;

byte[] chartHtml = File.ReadAllBytes(“html filelocation”);



HtmlLoadOptions options = new HtmlLoadOptions();



Aspose.Pdf.Document doc = new Aspose.Pdf.Document(new MemoryStream(chartHtml), options);



var pageSize = Aspose.Pdf.PageSize.A4;

pageSize.IsLandscape = true;



var pEdit = new Aspose.Pdf.Facades.PdfPageEditor();

pEdit.BindPdf(doc);



MemoryStream fitPageStream = new MemoryStream();





var origPageSize = pEdit.GetPageSize(1);

var zoom = 1f;



if (origPageSize.Height > origPageSize.Width)

zoom = pageSize.Height / origPageSize.Height;

else

zoom = pageSize.Width / origPageSize.Width;

pEdit.PageSize = pageSize;

pEdit.Zoom = zoom;

pEdit.VerticalAlignmentType = VerticalAlignment.Center;

pEdit.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Left;



pEdit.Save(fitPageStream);





doc = new Aspose.Pdf.Document(fitPageStream);

MemoryStream stream = new MemoryStream();

doc.Save(stream);

byte[] content = stream.ToArray();



File.WriteAllBytes(@“c:\temp\chart.pdf”, content);





Please note we are doing the double conversion due to another issue in Aspose whereby the Export results in a blank PDF with the following Code:



string licenseFile = string.Format("{0}.Aspose.Total.lic", “TestImageTransform”);

Aspose.Pdf.License AsposePDF = new Aspose.Pdf.License();

AsposePDF.SetLicense(licenseFile);

AsposePDF.Embedded = true;

byte[] chartHtml = File.ReadAllBytes(“html filelocation”);



HtmlLoadOptions options = new HtmlLoadOptions();



Aspose.Pdf.Document doc = new Aspose.Pdf.Document(new MemoryStream(chartHtml), options);





MemoryStream stream = new MemoryStream();

doc.Save(stream);

byte[] content = stream.ToArray();



File.WriteAllBytes(@“c:\temp\chart.pdf”, content);







I have attached the HTML file and generated PDF file.



Regards,

Barry

Hi Barry,

Thanks for contacting support.

We are currently looking into this matter and will get back to you soon. We are sorry for this delay and inconvenience.

CGSTech:
Hi,

We have a release version of Aspose .Net 10.8 and are getting an issue when converting HTML to PDF whereby the PDF is rendered across 2 pages whereas we need it on a single page.

A code sample of what we are doing is :
string licenseFile = string.Format("{0}.Aspose.Total.lic", “TestImageTransform”);
Aspose.Pdf.License AsposePDF = new Aspose.Pdf.License();
AsposePDF.SetLicense(licenseFile);
AsposePDF.Embedded = true;
byte[] chartHtml = File.ReadAllBytes(“html filelocation”);

        HtmlLoadOptions options = new HtmlLoadOptions();
      
        Aspose.Pdf.Document doc = new Aspose.Pdf.Document(new MemoryStream(chartHtml), options);

        var pageSize = Aspose.Pdf.PageSize.A4;
         pageSize.IsLandscape = true;

        var pEdit = new Aspose.Pdf.Facades.PdfPageEditor();
        pEdit.BindPdf(doc);

        MemoryStream fitPageStream = new MemoryStream();


        var origPageSize = pEdit.GetPageSize(1);
        var zoom = 1f;

        if (origPageSize.Height > origPageSize.Width)
            zoom = pageSize.Height / origPageSize.Height;
        else
            zoom = pageSize.Width / origPageSize.Width;
        pEdit.PageSize = pageSize;
        pEdit.Zoom = zoom;
        pEdit.VerticalAlignmentType = VerticalAlignment.Center;
        pEdit.HorizontalAlignment = Aspose.Pdf.HorizontalAlignment.Left;

        pEdit.Save(fitPageStream);

 
        doc = new Aspose.Pdf.Document(fitPageStream);
        MemoryStream stream = new MemoryStream();
        doc.Save(stream);
        byte[] content = stream.ToArray();

        File.WriteAllBytes(@"c:\temp\chart.pdf", content); </div></BLOCKQUOTE></font><div><font face="Arial" size="2">Hi <span style="background-color: rgb(255, 255, 255);">Barry,</span></font></div><div><font face="Arial" size="2"><br></font></div><div><font face="Arial" size="2">Thanks for contacting support.</font></div><div><font face="Arial" size="2"><br></font></div><div><font face="Arial" size="2">I have tested the scenario using latest release of <a href="http://www.aspose.com/downloads/pdf-family/net/new-releases/aspose.pdf-for-.net-11.5.0/">Aspose.Pdf for .NET 11.5.0</a> and I am unable to notice any issue. For your reference, I have also attached the output generated over my end.</font></div>

Hi,

I am trying to test this with a trial version of 11.5 but am getting the following error.
“At most 4 text fragments can be added in evaluation mode”

Is there a way around this?

Kind Regards,
Barry

Hi Bary,

Thanks for your inquiry. Please note Aspose.Pdf evaluation version has two limitations, evaluation watermark and at most four elements of any collection can be viewed. Please make a request for 30 days temporary license to evaluate our product without any limitation. It will resolve the issue.

Please feel free to contact us for any further assistance.

Best Regards,