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.

pdf generation issue( initial part of text is missing when page is breaking to new page)

Thread ID:

Created:

Updated:

Platform:

Replies:

97741 Jan 4,2011 06:09 AM Jan 5,2011 08:21 AM ASP.NET Web Forms (Classic) 1
loading
Tags: PDF
Vijay Raja
Asked On January 4, 2011 06:09 AM

Hi,

we are using the Syncfusion PDF dll (version 4.402.0.51) in our ASP.NET application to generate a PDF document.
we are looping through a datatable to generate the pdf by using graphics.drawmultitext method.
However we are facing issue, whenever the text is breaking to a new page, we are missing initial part of the text in the newpage.
Is it possible to find when the text is going to the new page. Else please provide a way to fix the issue.
Please find the code and sample file attached.,please reply ASAP.

Public Sub Generatepdfdoc(ByVal datatable As DataTable)

Dim LetterHeight, ReferenceHeight, DescriptionHeight As Single
Dim AcronymWidth As Single
Dim x As Single = 5
Dim y As Single = 15
Dim HorizantalWidth As Single = 5
Dim filePath As String


Dim PdfDoc As Syncfusion.Pdf.PDFDocument = New Syncfusion.Pdf.PDFDocument()
PdfDoc.AutoCreatePages = True

AddFooter(PdfDoc)
Dim font As IPDFFont = PdfDoc.Fonts.Add(New Font("Arial", 8))
Dim GraphicState As IPDFGraphicState = PdfDoc.CreateGraphicState()
GraphicState.BreakBehavior = AutoBreakBehavior.MultiLineTextBreak
Dim page As IPDFPage = PdfDoc.CreatePage()

Dim graphic As IPDFGraphics = PdfDoc.Graphics()
Dim pageWidth As Single = page.DrawingWidth
Dim heightinline As Integer = 0


For i As Integer = 0 To datatable.Rows.Count - 1


LetterHeight = ReferenceHeight = DescriptionHeight = 0
LetterHeight = PdfDoc.Graphics.MeasureString(datatable.Rows(i)("LETTER_REFERENCE").ToString.Trim(), font).Height
ReferenceHeight = PdfDoc.Graphics.MeasureString(datatable.Rows(i)("REFERENCE").ToString.Trim(), font).Height
DescriptionHeight = PdfDoc.Graphics.MeasureString(datatable.Rows(i)("DESCRIPTION").ToString.Trim(), font, pageWidth, GraphicState).Height
AcronymWidth = PdfDoc.Graphics.MeasureString(datatable.Rows(i)("ACRONYM").ToString.Trim(), font).Width


graphic.DrawMultiText(New RectangleF(x, y, pageWidth, LetterHeight), datatable.Rows(i)("LETTER_REFERENCE").ToString.Trim(), font)
y = y + LetterHeight + HorizantalWidth

If Not String.IsNullOrEmpty(datatable.Rows(i)("ACRONYM").ToString) Then
graphic.DrawMultiText(New RectangleF(x, y, pageWidth, ReferenceHeight), datatable.Rows(i)("ACRONYM").ToString.Trim(), font)
x = x + AcronymWidth + HorizantalWidth
End If
heightinline = PdfDoc.Graphics.ClientRectangle.Bottom
graphic.DrawMultiText(New RectangleF(x, y, pageWidth, ReferenceHeight), datatable.Rows(i)("REFERENCE").ToString.Trim(), font)
x = 5
y = y + ReferenceHeight + HorizantalWidth


graphic.DrawMultiText(New RectangleF(x, y, pageWidth, DescriptionHeight), datatable.Rows(i)("DESCRIPTION").ToString.Trim(), font, GraphicState)

y = y + DescriptionHeight + HorizantalWidth + HorizantalWidth

Next

filePath = Server.MapPath("temp/" & "Glossary" & DateTime.Now.ToString("ddMMyyyyhhmmss") & ".pdf")
PdfDoc.Save(filePath)
PdfDoc.Close()
Context.Response.ContentType = "application/pdf"
Context.Response.Charset = ""
Context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + "Glossary" & DateTime.Now.ToString("ddMMyyyyhhmmss") + ".pdf")
Context.Response.TransmitFile(filePath)
Context.Response.End()
End Sub

Public Sub AddFooter(ByVal pdfdoc As PDFDocument)

Dim font As IPDFFont
Dim footer As PDFTemplateArea = pdfdoc.Templates.Add(New SizeF(pdfdoc.LastPage.DrawingWidth, 40))
font = pdfdoc.Fonts.Add(New Font("Arial", 10, System.Drawing.FontStyle.Regular))
Dim FooterText As String = System.DateTime.Now.ToString("MMMM-yyyy")
Dim pagenumber As String = "Page #p; of #P;"

Dim bounds As RectangleF = New RectangleF(0, 30, footer.Size.Width, footer.Size.Height)
Dim FooterTextGraphicState As IPDFGraphicState = pdfdoc.CreateGraphicState()
FooterTextGraphicState.TextAlignment = TextAlignment.Right
FooterTextGraphicState.BreakBehavior = AutoBreakBehavior.MultiLineTextBreak
footer.Graphics.DrawMultiText(bounds, FooterText, font, FooterTextGraphicState, bounds)
FooterTextGraphicState = pdfdoc.CreateGraphicState()
Dim PageNumberGraphicState As IPDFGraphicState = pdfdoc.CreateGraphicState()
PageNumberGraphicState.TextAlignment = TextAlignment.Center
PageNumberGraphicState.BreakBehavior = AutoBreakBehavior.MultiLineTextBreak
footer.Graphics.DrawMultiText(bounds, pagenumber, font, PageNumberGraphicState, bounds)
PageNumberGraphicState = pdfdoc.CreateGraphicState()
pdfdoc.Templates.Footer = footer

End Sub



Priyadharshini J [Syncfusion]
Replied On January 5, 2011 08:21 AM

Hi Vijay,

Thank you for your interest in syncfusion products.

Currently we do not provide support for version 4.402.0.51, as we have changed our code base completely. The mentioned issue is fixed in our current version. Could you please upgrade to 8.4.0.10 version, you can download the same from the link below.
http://www.syncfusion.com/support/forums/general/97146/Essential-Studio-2010-Volume-4-Final-Release-v84010-available-for-download

Sample for the same is placed in the location below:
forum97741189349904.zip

Kindly try this and let us know if you have any queries.

Regards,
Priyadharshini


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.

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.

;