Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Content render outside the table when page break

$
0
0
Hi,

I am facing a issue when rendering html content in a table. Please use the below code to reproduce the problem. I attached car.jpg which used in the html and the result file BrokenLine.pdf for your reference. Put the car.jpg image under c:\temp\.

As you can see from the result file, in the first page, the bottom border of the table went through the last second line while the last line is shown outside the table.

What am I missing here?

Thanks.
Iris.


Aspose.Pdf.Generator.MarginInfo _defaultCellMargin = new Aspose.Pdf.Generator.MarginInfo();
            _defaultCellMargin.Top = 2;
            _defaultCellMargin.Left = 5;
            _defaultCellMargin.Right = 5;
            _defaultCellMargin.Bottom = 2;

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

            sec.PageInfo.Margin.Left = 20;
            sec.PageInfo.Margin.Right = 20;
            sec.PageInfo.Margin.Top = 30;
            sec.PageInfo.Margin.Bottom = 30;

            //Instantiate a table object
            Aspose.Pdf.Generator.Table tab = new Aspose.Pdf.Generator.Table();
            sec.Paragraphs.Add(tab);

            tab.Border = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.1F, new Aspose.Pdf.Generator.Color("Black"));
            tab.Margin.Bottom = 10;

            int tabWidth = 555;
            int columnWidth = tabWidth / 2;
            tab.ColumnWidths = columnWidth.ToString() + " " + (tabWidth - columnWidth).ToString();

            //Create rows in the table and then cells in the rows
            Aspose.Pdf.Generator.Row rowTitle = tab.Rows.Add();
            rowTitle.FixedRowHeight = 35;
            rowTitle.DefaultRowCellPadding = _defaultCellMargin;
            rowTitle.VerticalAlignment = Aspose.Pdf.Generator.VerticalAlignmentType.Center;

            // set the background color for Row
            rowTitle.BackgroundColor = new Aspose.Pdf.Generator.Color("Gray");

            tab.DefaultCellBorder = new Aspose.Pdf.Generator.BorderInfo((int)Aspose.Pdf.Generator.BorderSide.All, 0.0F);
            Aspose.Pdf.Generator.TextInfo tiTitle = new Aspose.Pdf.Generator.TextInfo()
            {
                FontName = "Arial",
                FontSize = 10,
                IsTrueTypeFontBold = true,
                IsTrueTypeFontItalic = false,
                Color = new Aspose.Pdf.Generator.Color("Black")
            };
            Aspose.Pdf.Generator.Cell leftTitle = rowTitle.Cells.Add();
            leftTitle.Alignment = Aspose.Pdf.Generator.AlignmentType.Left;
            leftTitle.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Testing Left", tiTitle));

            Aspose.Pdf.Generator.Cell rightTitle = rowTitle.Cells.Add();
            rightTitle.Alignment = Aspose.Pdf.Generator.AlignmentType.Left;
            rightTitle.Paragraphs.Add(new Aspose.Pdf.Generator.Text("Testing Right", tiTitle));

            Aspose.Pdf.Generator.Row contentRow = tab.Rows.Add();
            contentRow.DefaultRowCellPadding = _defaultCellMargin;
            Aspose.Pdf.Generator.Cell contentCell = contentRow.Cells.Add();
            contentCell.ColumnsSpan = 2;

            contentCell.Border = new Aspose.Pdf.Generator.BorderInfo()
            {
                Right = new Aspose.Pdf.Generator.GraphInfo() { LineWidth = 0.1F, Color = new Aspose.Pdf.Generator.Color("Black") },
                Left = new Aspose.Pdf.Generator.GraphInfo() { LineWidth = 0.1F, Color = new Aspose.Pdf.Generator.Color("Black") },
                Bottom = new Aspose.Pdf.Generator.GraphInfo() { LineWidth = 0.1F, Color = new Aspose.Pdf.Generator.Color("Black") },
                Top = new Aspose.Pdf.Generator.GraphInfo() { LineWidth = 0.0F, Color = new Aspose.Pdf.Generator.Color("Black") }
            };


            string txt = "<font size=\"1\"><html>\r   \r   <body>\r <p><strong>Test Image</strong></p>\r <p> </p>\r <p><img src=\"c:\\temp\\car.jpg\" alt=\"\" /></p>\r <p> </p>\r <p> </p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">SQL Server 2008 (formerly codenamed \"Katmai\") [11][12] was released on August 6, 2008[13] and aims to make data management self-tuning, self organizing, and self maintaining with the development of SQL</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">Server Always On technologies, to provide near-zero downtime. SQL Server 2008 also includes support for structured and semi-structured data, including digital media formats for pictures, audio, video and other</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">multimedia data. In current versions, such multimedia data can be stored as BLOBs (binary large objects), but they are generic bitstreams. Intrinsic awareness of multimedia data will allow specialized functions to</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">be performed on them. According to Paul Flessner, senior Vice President, Server Applications, Microsoft Corp., SQL Server 2008 can be a data storage backend for different varieties of data: XML, email,</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">time/calendar, file, document, spatial, etc as well as perform search, query, analysis, sharing, and synchronization across all data types.[12]</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">Other new data types include specialized date and time types and a Spatial data type for location-dependent data.[14] Better support for unstructured and semi-structured data is provided using the new</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">FILESTREAM[15] data type, which can be used to reference any file stored on the file system.[16] Structured data and metadata about the file is stored in SQL Server database, whereas the unstructured</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">component is stored in the file system. Such files can be accessed both via Win32 file handling APIs as well as via SQL Server using T-SQL; doing the latter accesses the file data as a BLOB. Backing up and</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">restoring the database backs up or restores the referenced files as well.[17] SQL Server 2008 also natively supports hierarchical data, and includes T-SQL constructs to directly deal with them, without using</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">recursive queries.[17]</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">The Full-text search functionality has been integrated with the database engine. According to a Microsoft technical article, this simplifies management and improves performance.[18]</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">Spatial data will be stored in two types. A \"Flat Earth\" (GEOMETRY or planar) data type represents geospatial data which has been projected from its native, spherical, coordinate system into a plane. A \"Round</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">Earth\" data type (GEOGRAPHY) uses an ellipsoidal model in which the Earth is defined as a single continuous entity which does not suffer from the singularities such as the international dateline, poles, or map</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">projection zone \"edges\". Approximately 70 methods are available to represent spatial operations for the Open Geospatial Consortium Simple Features for SQL, Version 1.1.[19]</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">SQL Server includes better compression features, which also helps in improving scalability.[20] It enhanced the indexing algorithms and introduced the notion of filtered indexes. It also includes Resource Governor</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">that allows reserving resources for certain users or workflows. It also includes capabilities for transparent encryption of data (TDE) as well as compression of backups.[15] SQL Server 2008 supports the ADO.NET</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">Entity Framework and the reporting tools, replication, and data definition will be built around the Entity Data Model.[21] SQL Server Reporting Services will gain charting capabilities from the integration of the</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">data visualization products from Dundas Data Visualization, Inc., which was acquired by Microsoft.[22] On the management side, SQL Server 2008 includes the Declarative Management Framework which allows</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">configuring policies and constraints, on the entire database or certain tables, declaratively.[14] The version of SQL Server Management Studio included with SQL Server 2008 supports IntelliSense for SQL queries</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">against a SQL Server 2008 Database Engine.[23] SQL Server 2008 also makes the databases available via Windows PowerShell providers and management functionality available as Cmdlets, so that the server</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">and all the running instances can be managed from Windows PowerShell.[24]</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">----------</span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\"> </span></p>\r <p><span style=\"font-size: 10pt; font-family: arial, helvetica, sans-serif;\">  </span></p>\r </body>\r   </html></font>";

            Aspose.Pdf.Generator.Table tabContent = new Aspose.Pdf.Generator.Table();
            tab.DefaultCellPadding = _defaultCellMargin;

            contentCell.Paragraphs.Add(tabContent);
            int tableWidth = 545;

            tabContent.ColumnWidths = tableWidth.ToString();
            Aspose.Pdf.Generator.Row row1 = tabContent.Rows.Add();
            Aspose.Pdf.Generator.Cell cell1 = row1.Cells.Add();
            Aspose.Pdf.Generator.Text htmlTxt = new Aspose.Pdf.Generator.Text(txt);
            htmlTxt.IsHtmlTagSupported = true;
            cell1.Paragraphs.Add(htmlTxt);

            pdf.Save(@"C:\temp\BrokenLine.pdf");

Viewing all articles
Browse latest Browse all 3131