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

Free Support Forum - aspose.com

My html does not fit to aspose pdf page

my html does not fit to aspose pdf page. i want a pdf page where all of my html would fit in. it now has 9 columns but it may have more columns in future. please provide back an answer asap. thank you
i can also be reached via email. my email address is: taylanozgur78@hotmail.com
thank you

here is my c# code

Aspose.Pdf.Generator.Pdf pdf = new Aspose.Pdf.Generator.Pdf();
pdf.PageSetup.PageBorderMargin.Top = 0;
pdf.PageSetup.PageBorderMargin.Bottom = 0;
pdf.PageSetup.PageBorderMargin.Left = 0;
pdf.PageSetup.PageBorderMargin.Right = 0;
Aspose.Pdf.Generator.Section section = pdf.Sections.Add();
pdf.IsAutoFontAdjusted = true;
pdf.PageSetup.PageWidth = Aspose.Pdf.Generator.PageSize.LetterWidth;
pdf.PageSetup.PageHeight = Aspose.Pdf.Generator.PageSize.LetterHeight;
pdf.HtmlInfo.IsLandScape = true;
pdf.HtmlInfo.Margin.Top = 0;
pdf.HtmlInfo.Margin.Bottom = 0;
pdf.HtmlInfo.Margin.Left = 0;
pdf.HtmlInfo.Margin.Right = 0;
pdf.IsLandscape = true;
pdf.HtmlInfo.ImgUrl = "D:/pdftest/MemoryStream/";
Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text(section, contents);
section.IsLandscape = true;
text.Margin.Top = 0;
text.Margin.Bottom = 0;
text.Margin.Left = 0;
text.Margin.Right = 0;
text.IsFitToPage = true;
text.IsHtmlTagSupported = true;
text.IfHtmlTagSupportedOverwrightHtmlFontNames = true;
text.IfHtmlTagSupportedOverwrightHtmlFontSizes = true;
section.Paragraphs.Add(text);
pdf.Save("ReportResult.pdf",Aspose.Pdf.Generator.SaveType.OpenInAcrobat,Response);

and here below is my html

Trouble Ticket Report
Complaint No Workflow Status Current Department Ticket Type Ticket Sub Type Trouble MSISDN Ticket Title Urgency Degree Create Time
RUNNING CUSTOMER_REPRESENTATIVE 17.05.2013 16:27:05
RUNNING CUSTOMER_REPRESENTATIVE 17.05.2013 16:27:44
RUNNING CUSTOMER_REPRESENTATIVE 28.05.2013 15:56:47
RUNNING CUSTOMER_REPRESENTATIVE 28.05.2013 16:14:00
RUNNING CUSTOMER_REPRESENTATIVE 28.05.2013 16:52:01
RUNNING CUSTOMER_REPRESENTATIVE 29.05.2013 15:12:52
RUNNING CUSTOMER_REPRESENTATIVE 29.05.2013 15:31:40
RUNNING CUSTOMER_REPRESENTATIVE 29.05.2013 15:37:57
RUNNING CUSTOMER_REPRESENTATIVE 29.05.2013 16:04:08
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 14:58:19
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 15:07:47
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 15:10:30
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 15:14:30
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 15:16:00
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 15:20:13
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 15:25:51
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 15:36:54
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 15:41:01
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 15:43:11
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 15:47:34
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 15:59:24
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 16:02:42
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 16:06:27
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 16:08:17
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 16:32:58
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 16:37:31
RUNNING CUSTOMER_REPRESENTATIVE 30.05.2013 16:46:28
RUNNING CUSTOMER_REPRESENTATIVE 31.05.2013 10:11:52
RUNNING CUSTOMER_REPRESENTATIVE 31.05.2013 10:19:58
RUNNING CUSTOMER_REPRESENTATIVE 31.05.2013 10:21:59
RUNNING CUSTOMER_REPRESENTATIVE 03.06.2013 13:53:36
RUNNING CUSTOMER_REPRESENTATIVE 03.06.2013 14:40:45
RUNNING CUSTOMER_REPRESENTATIVE 03.06.2013 15:48:25
RUNNING CUSTOMER_REPRESENTATIVE 03.06.2013 15:49:53
RUNNING CUSTOMER_REPRESENTATIVE 03.06.2013 15:51:42
RUNNING CUSTOMER_REPRESENTATIVE 04.06.2013 08:33:40
RUNNING CUSTOMER_REPRESENTATIVE 04.06.2013 09:31:41
RUNNING CUSTOMER_REPRESENTATIVE 04.06.2013 10:30:42
RUNNING CUSTOMER_REPRESENTATIVE 04.06.2013 10:33:22
RUNNING CUSTOMER_REPRESENTATIVE 04.06.2013 10:39:48
RUNNING CUSTOMER_REPRESENTATIVE 04.06.2013 10:58:12
RUNNING CUSTOMER_REPRESENTATIVE 04.06.2013 13:36:13
RUNNING CUSTOMER_REPRESENTATIVE 04.06.2013 13:38:44
RUNNING CUSTOMER_REPRESENTATIVE 04.06.2013 14:44:52
RUNNING BRANCH_MANAGER 04.06.2013 15:03:59
RUNNING CUSTOMER_REPRESENTATIVE 04.06.2013 15:08:37
RUNNING CUSTOMER_REPRESENTATIVE 04.06.2013 15:13:50
RUNNING CUSTOMER_REPRESENTATIVE 17.06.2013 10:59:06
RUNNING CUSTOMER_REPRESENTATIVE 17.06.2013 11:11:30
RUNNING CUSTOMER_REPRESENTATIVE 17.06.2013 11:34:12
RUNNING CUSTOMER_REPRESENTATIVE 17.06.2013 11:45:32



Hi Taylan,


Thanks for using our products and sorry for the delayed response.

As per my understanding, you need to accommodate/display all the columns on a single page and in order to accomplish this requirement, you need to set the width and margin information for section object in which HTML contents are being placed. Instead of setting the margin/dimensions for Pdf object, it’s recommended to set the information for individual Section object containing text element. Please try using the following code snippet to accomplish your requirement.

For your reference, I have also attached the resultant PDF generated over my end using latest release of Aspose.Pdf for .NET 8.2.0.

[C#]

Aspose.Pdf.Generator.Pdf
pdf = new Aspose.Pdf.Generator.Pdf();<o:p></o:p>

// instantiate Section object

Aspose.Pdf.Generator.Section section = pdf.Sections.Add();

// set the margin for section object

section.PageInfo.Margin.Top = 0;

section.PageInfo.Margin.Left= 0;

// set the page width information for section object

section.PageInfo.PageWidth = 1000F;

// set the page Height information for section object

section.PageInfo.PageHeight= 800F;

// adjust font automatically

pdf.IsAutoFontAdjusted = true;

// Read the contents of HTML file into StreamReader object

StreamReader r = File.OpenText(@"c:/pdftest/sample.html");

// instantiate Text object with HTML file contents

Aspose.Pdf.Generator.Text text = new Aspose.Pdf.Generator.Text(section, r.ReadToEnd());

// set the section orientation as Landscape

section.IsLandscape = true;

text.IsFitToPage = true;

text.IsHtmlTagSupported = true;

text.IfHtmlTagSupportedOverwrightHtmlFontNames = true;

text.IfHtmlTagSupportedOverwrightHtmlFontSizes = true;

section.Paragraphs.Add(text);

pdf.Save("c:/pdftest/HTML+ReportResult.pdf");