We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

content (html) repeated in pdf

Thread ID:

Created:

Updated:

Platform:

Replies:

110841 Aug 27,2013 01:22 PM UTC Aug 30,2013 04:10 AM UTC ASP.NET Web Forms (Classic) 1
loading
Tags: PDF
Jimmy Escherich
Asked On August 27, 2013 01:22 PM UTC

Hi,
We have an issue with a static html page when converting it to a pdf-file.
This is a simplified version of the html that we experience the same problem with:
http://2013gc.t2w.dk/pdftest.htm

After 42 pages the first page reappears in the pdf - and again at page 82 (pdf attached)

Below I have pasted our code.
Any help in this regard would be greatly appreciated.



Dim filename as String = ""
filename=(request("filename"))
Dim urltoparse as String = ""
urltoparse=(request("urltoparse"))

urltoparse=Replace(urltoparse,"_0OG0_","&")

If InStr(urltoparse,"?")>0 Then
urltoparse=urltoparse+"&tid"+server.urlencode(now())
Else
urltoparse=urltoparse+"?tid"+server.urlencode(now())
End if

Dim margins As String = ""
margins = (request("margins"))
If Not isnumeric(margins) Or Len(margins)=0 Then margins="10"

Dim doc As PdfDocument
doc = New PdfDocument()

doc.PageSettings.SetMargins(CInt(margins))

Dim Orientation As String = ""
Orientation = LCase((request("Orientation")))

If Orientation="landscape"  Then 
doc.PageSettings.Orientation = PdfPageOrientation.Landscape
else
doc.PageSettings.Orientation = PdfPageOrientation.Portrait
End if

doc.PageSettings.Rotate = CType(System.Enum.Parse(GetType(PdfPageRotateAngle), "RotateAngle0"), PdfPageRotateAngle)

Dim page As PdfPage = Nothing
Dim pageSize As SizeF = SizeF.Empty
Dim convertor As New PdfUnitConvertor()
Dim width As Single = -1
Dim height As Single = -1

page = doc.Pages.Add()

pageSize = page.GetClientSize()

'Calculates the height and width of the pdf image.
width = convertor.ConvertToPixels(page.GetClientSize().Width, PdfGraphicsUnit.Point)

dim html As HtmlConverter = New HtmlConverter()

html.EnableHyperlinks = True 
html.AutoDetectPageBreak = True
html.EnableJavaScript = True

Dim result As HtmlToPdfResult = html.Convert(urltoparse, ImageType.Metafile, CInt(Fix(width)), CInt(Fix(height)), AspectRatio.KeepWidth)

If Not result Is Nothing Then
Dim mf As PdfMetafile = New PdfMetafile(TryCast(result.RenderedImage, Metafile))
mf.Quality = 100

Dim format As PdfMetafileLayoutFormat = New PdfMetafileLayoutFormat()
format.Break = PdfLayoutBreakType.FitPage
format.Layout = PdfLayoutType.Paginate
doc.PageSettings.Height = result.RenderedImage.Size.Height
format.SplitTextLines = false
format.SplitImages = false

result.Render(page, format)
Else
Response.Write("Warning ! Please check the HTML link")
End If

Dim rect As RectangleF = New RectangleF(0, 0, doc.Pages(0).GetClientSize().Width, 50)
Dim footer As PdfPageTemplateElement = New PdfPageTemplateElement(rect)
Dim font As PdfStandardFont = New PdfStandardFont(PdfFontFamily.Helvetica, 10.5F)
Dim brush As PdfSolidBrush = New PdfSolidBrush(Color.Black)

'Create page number field
Dim pageNumber As PdfPageNumberField = New PdfPageNumberField(font, brush)

'Create page count field
Dim count As PdfPageCountField = New PdfPageCountField(font, brush)

'Add the fields in composite fields
Dim compositeField As PdfCompositeField = New PdfCompositeField(font, brush, "Side {0} af {1}", pageNumber, count)
compositeField.Bounds = footer.Bounds

'Draw the composite field in footer
compositeField.Draw(footer.Graphics, New PointF(470, 40))

'Add the footer template at the bottom
doc.Template.Bottom = footer


doc.Save(filename, Response, HttpReadType.Save)



GCaarsrapportdemo.pdf_f355c296.zip

Praveenkumar H [Syncfusion]
Replied On August 30, 2013 04:10 AM UTC

Hi Jimmy,

Thank you for your interest in Syncfusion products.

We are able to reproduce the mentioned issue.

Could you please report this issue through Direct Trac Developer Support System (https://www.syncfusion.com/account/login?ReturnUrl=%2fsupport%2fdirecttrac%2fincidents because you can take the advantage of the expertise of a dedicated support engineer and a guaranteed response time and we hope you will take advantage of this system as well. If you have already reported, please ignore this.

Regards,
Praveen


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;