Rank: Advanced Member Groups: Member
Joined: 5/24/2012 Posts: 45
|
Hi, We have been using your product to convert an html document into a pdf file for over a year now. Today it started creating an empty pdf file. We are using version 4.0.18.2.
We haven't made any changes to our live site in the past week. Do you have any idea what could be causing this?
Thanks, Becky
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
We can not think of anything else other than the input is wrong.
Thanks!
|
Rank: Advanced Member Groups: Member
Joined: 5/24/2012 Posts: 45
|
The code creates an html file which is converted to pdf using eo.pdf - all the html docs seem to be fine, contain the correct text etc. At 12:04pm today everything worked fine - but at 12:27pm today - the html file was fine but the pdf contained roughly the same amount of pages as the html file but no text. table borders are there - the ...... in the table of contents is there as is the page number - but no text. The header underline is there but no text. The bullet points are there but no text. The page number is in the footer but no text. The vertical border line in the document is there but no text.
If you want to take a look at this you can login to our test site at pakatrak.ipower.com/testdirector/pfrmlogin1.aspx username and password are test2 - don't worry about the third box then click 'personalization' then click 'personalize' then click 'create policy manual' - this takes a couple minutes and produces a pdf empty of text
Very weird that it has been working fine, was working fine this morning then at some point in the 23 minutes between 12:04pm and 12:27pm this problem started happening.
It works fine on my local machine - can you think of anything our server could have installed or anything like that that could cause this?
Thanks! Becky
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
There isn't much we can tell you except that you have to debug your code. Things don't happen for no reason --- so something must have changed on your side. If you have reduced your application to nothing else but a few lines of codes that call our library and it still does not work, then we will take over and investigate. Before that you will have to do the debugging since you know your application and we do not.
Thanks!
|
Rank: Advanced Member Groups: Member
Joined: 5/24/2012 Posts: 45
|
Hi, thanks for your help. I don't think it is eo code per say that is causing this issue. I used your demo on our htm file and it converted just fine. I was hoping you could take a look at what is happening and let me know if you have ever experienced anything like this. I think it is related to something that was either added to or deleted from our server. But I am not in charge of our server and they are telling me they have not done anything. But like you say, something had to of changed in order for this to start happening. And one more thing - I am using this :
Code: Visual Basic.NET
Dim response As HttpResponse = HttpContext.Current.Response
response.Clear()
response.ClearHeaders()
response.AppendHeader("content-disposition", "attachment; filename=" & "PolicyManual" & txtaid.Text & ".pdf")
response.ContentType = "application/pdf"
response.WriteFile(outFilePath)
response.Flush()
response.End()
/code]
to display the pdf file. Chrome and firefox will display the file. IE asks if you would like to open or save the pdf file. It will save but nothing happens if you click open.
Anyway - the following url will display the problem. Please look at it and let me know if you have ever seen this sort of thing before.
http://pakatrak.com/hrdirector/html/job1002.htm - created by our code - works find
http://pakatrak.com/hrdirector/html/job1002.pdf - converted by eo.pdf - worked fine until 12:27pm yesterday - now it creates a file with no text
As you asked, I have been troubleshooting this issue.
The preceding code creates the htm file which works fine. This is what happens next (this used to work fine)
[code=vb] ''***************'''''''''''''''''''''
' now convert html to pdf document
'''''''**********************************
'Create a PdfDocument object and convert
'the Url into the PdfDocument object
HtmlToPdf.Options.PageSize = New SizeF(8.5F, 11.0F)
' create a PDF document
Dim TOC_ENTRIES_COUNT As Integer = PolicyCount
Dim TOC_HEADINGS_COUNT As Integer = 10
Dim PAGE_NUMBER_FONT_SIZE As Integer = 10
' optional settings for the PDF document like margins, compression level,
' security options, viewer preferences, document information, etc
'get url of htm file created above
thisPageURL = HttpContext.Current.Request.Url.AbsoluteUri
Dim baseURL As String = ""
Dim UrltoConvert As String = thisPageURL.Substring(0, thisPageURL.LastIndexOf("/")) + "/html/PolicyManual" & txtaid.Text & ".htm"
'get starting header
currentHeading = "ManualHeader0 before convert"
'Create a PdfDocument object and convert
'the Url into the PdfDocument object
Dim doc As New PdfDocument()
' HtmlToPdf.Options.AutoFitX = HtmlToPdfAutoFitMode.None
' HtmlToPdf.Options.PageSize = New SizeF(8.5F, 11.0F)
HtmlToPdf.Options.PageSize = New SizeF(8.5F, 11.0F)
HtmlToPdf.Options.OutputArea = New RectangleF(0.5F, 0.975F, 7.5F, 9.3F)
HtmlToPdf.Options.AutoAdjustForDPI = False
HtmlToPdf.Options.AutoFitX = HtmlToPdfAutoFitMode.None
' HtmlToPdf.Options.OutputArea = New RectangleF(0.5F, 0.5F, 7.5F, 9.0F)
' HtmlToPdf.Options.HeaderHtmlFormat = myHeader
' HtmlToPdf.Options.FooterHtmlFormat = myFooter
'''' HtmlToPdf.Options.AfterRenderPage = New EO.Pdf.PdfPageEventHandler(AddressOf On_AfterRenderPage)
Dim result As HtmlToPdfResult = HtmlToPdf.ConvertUrl(UrltoConvert, doc)
Dim arrTOC(TOC_ENTRIES_COUNT - 1, 4) 'array containing all entries in the TOC
'arrTOC(0,0) = x location of toc entry
'arrTOC(0,1) = y location of toc entry
'arrTOC(0,2) = page number of the TOC entry
'arrTOC(0,3) = page number of target - where entry is located in the document + 100
'arrTOC(0,4) = length of TOC entry
Dim arrPages(TOC_HEADINGS_COUNT - 1, 1) As Object 'array containing 10 headings
'arrPages(0,0) = text of each Heading
'arrPages(0,1) = actual page number in document where heading is found
Dim refDiv As HtmlElement
Dim refDivT As HtmlElement
Dim headingsCount As Integer = 0
'now for each TOC entry, find its location on the page and its page number plus the length
'and the page number in the document where the target can be found
For n As Integer = 1 To TOC_ENTRIES_COUNT
Dim tocEntryID As String = String.Format("TOCEntry_{0}_ID", n)
Dim tocTargetID As String = String.Format("TOCEntry_{0}_Target_ID", n)
Dim str As String
Dim sb As New System.Text.StringBuilder
refDiv = result.HtmlDocument.GetElementById(tocEntryID)
refDivT = result.HtmlDocument.GetElementById(tocTargetID)
str = refDiv.InnerText
'clean the string of strange characters
sb = New System.Text.StringBuilder
For Each ch As Char In str
If Char.IsLetterOrDigit(ch) OrElse ch = " "c Then
sb.Append(ch)
End If
Next
If sb.ToString = "INTRODUCTION TO MANUAL" _
Or sb.ToString = "EMPLOYMENT PRACTICES" _
Or sb.ToString = "HOURS OF EMPLOYMENT" _
Or sb.ToString = "WAGES AND SALARIES" _
Or sb.ToString = "EMPLOYEE BENEFITS" _
Or sb.ToString = "POLICIES" _
Or sb.ToString = "EMPLOYEE RELATIONS" _
Or sb.ToString = "TERMINATION OF EMPLOYMENT" _
Or sb.ToString = "ACKNOWLEDGEMENT FORM" _
Or sb.ToString = "DESIGNATED NAMES" Then
'this TOC entry is a heading, put info into arrPages
arrPages(headingsCount, 0) = sb.ToString
If sb.ToString = "ACKNOWLEDGEMENT FORM" Then
arrPages(headingsCount, 1) = doc.Pages.Count - 2
ElseIf sb.ToString = "DESIGNATED NAMES" Then
arrPages(headingsCount, 1) = doc.Pages.Count - 1
Else
arrPages(headingsCount, 1) = refDivT.Location.Page.Index
End If
headingsCount = headingsCount + 1
End If
arrTOC(n - 1, 0) = refDiv.Location.X
arrTOC(n - 1, 1) = refDiv.Location.Y
arrTOC(n - 1, 2) = refDiv.Location.Page.Index '0 start, ok -this is actual page
arrTOC(n - 1, 3) = refDivT.Location.Page.Index + 100 - arrPages(0, 1) 'page numbering starts at 100
arrTOC(n - 1, 4) = Len(refDiv.InnerText)
Next
'Add page number and header and footer to each page if not part of the TOC
For I As Integer = 0 To doc.Pages.Count - 1
Dim pageNumber As Acm.AcmText
Dim pageNumRender As Acm.AcmRender
If I >= arrPages(0, 1) Then
'Create an AcmText representing the page number
pageNumber = New Acm.AcmText((I + 100) - arrPages(0, 1).ToString())
'Create an AcmRender to render the page number.
'The arguments are:
' First argument: the target page
' Second argument: the "Y" position
' Third argument: The paper margins in left, top, right, bottom order
pageNumRender = New Acm.AcmRender(doc.Pages(I), 10.395, _
New Acm.AcmPageLayout( _
New Acm.AcmPadding(7.5, -0.075, 1, 0)))
'Render the page number
pageNumber.Style.FontName = "Arial"
pageNumber.Style.FontSize = 10.5F
pageNumRender.Render(pageNumber)
End If
Dim header As New Acm.AcmBlock(New Acm.AcmText(String.Format(" ", doc.Pages(I).Index)))
Dim footer As New Acm.AcmBlock(New Acm.AcmText(String.Format(" ", doc.Pages(I).Index)))
'header.Style.Border.Bottom = New Acm.AcmLineInfo(Acm.AcmLineStyle.Solid, Color.Black, 0.01F)
header.Style.Top = 0.6F
Dim j As Integer
Dim thisHeading As String = " "
For j = 0 To TOC_HEADINGS_COUNT - 1 'Decide which heading goes on this page
If arrPages(j, 1) >= doc.Pages(I).Index Then
'heading is either current j (=) or j-1 (>)
If arrPages(j, 1) = doc.Pages(I).Index Then
thisHeading = arrPages(j, 0)
Exit For
ElseIf doc.Pages(I).Index < arrPages(0, 1) Then
'tocpages do not need heading, set with blank heading
thisHeading = "Blank"
Exit For
ElseIf j > 0 Then 'we have not found the next heading so keep
'displaying previous heading
thisHeading = arrPages(j - 1, 0)
Exit For
' Else
' thisHeading = arrPages(j, 0)
' Exit For
End If
End If
Next j
Select Case Trim(thisHeading) 'select text of heading from the header_footer_content table
Case "INTRODUCTION TO MANUAL"
currentHeading = GetHeaderFooterContent("ManualHeader1")
Case "EMPLOYMENT PRACTICES"
currentHeading = GetHeaderFooterContent("ManualHeader2")
Case "HOURS OF EMPLOYMENT"
currentHeading = GetHeaderFooterContent("ManualHeader3")
Case "WAGES AND SALARIES"
currentHeading = GetHeaderFooterContent("ManualHeader4")
Case "EMPLOYEE BENEFITS"
currentHeading = GetHeaderFooterContent("ManualHeader5")
Case "POLICIES"
currentHeading = GetHeaderFooterContent("ManualHeader6")
Case "EMPLOYEE RELATIONS"
currentHeading = GetHeaderFooterContent("ManualHeader7")
Case "TERMINATION OF EMPLOYMENT"
currentHeading = GetHeaderFooterContent("ManualHeader8")
Case "ACKNOWLEDGEMENT FORM"
currentHeading = GetHeaderFooterContent("ManualHeader9")
Case "DESIGNATED NAMES"
currentHeading = GetHeaderFooterContent("ManualHeader10")
End Select
If thisHeading <> "Blank" Then 'this page needs a header and footer
' header.Style.HorizontalAlign = Acm.AcmHorizontalAlign.Right
' header.Style.Border.Bottom = New Acm.AcmLineInfo(Acm.AcmLineStyle.Solid, Color.Black, 0.01F)
' header.Style.Top = 0.6F
' header.Style.FontName = "Arial Narrow"
'first draw the header line
EO.Pdf.HtmlToPdf.Options.OutputArea = New RectangleF(0, 0.5, 7.85F, 1.0F)
'Render an image and a horizontal line. Note the
'second argument is the PdfPage object
EO.Pdf.HtmlToPdf.ConvertHtml(currentHeading, _
doc.Pages(I))
'now create the line underneath the header
'get current page
Dim TOCpage As EO.Pdf.PdfPage = doc.Pages(I)
'Create a new PdfPathContent
Dim content As New EO.Pdf.Contents.PdfPathContent()
'Create a new sub path and set the sub path's starting point
Dim subPath As New EO.Pdf.Drawing.PdfSubPath()
subPath.From = New EO.Pdf.Drawing.PdfPoint(47, 726)
'Draw a line from the current position to the right edge
Dim line As New EO.Pdf.Drawing.PdfPathLineSegment(New EO.Pdf.Drawing.PdfPoint(565, 726))
subPath.Segments.Add(line)
'Add the sub path into the path
content.Path.SubPaths.Add(subPath)
'Stroke the path
content.LineWidth = 1.0F
' If K Mod 2 = 0 Then
' content.StrokingColor = New EO.Pdf.Drawing.PdfColor(Color.Red)
' Else
content.StrokingColor = New EO.Pdf.Drawing.PdfColor(Color.Black)
' End If
content.Action = EO.Pdf.Contents.PdfPathPaintAction.Stroke
'Add the path into the page
TOCpage.Contents.Add(content)
'if there is a header, add a footer too
Dim myFooter As String = ""
Select Case txtType.Text 'Session("type")
Case "1" 'dental client
myFooter = GetHeaderFooterContent("ManualFooterDental")
Case "2" 'veterinarian client
myFooter = GetHeaderFooterContent("ManualFooterVeterinarian")
Case "3" 'medical client
myFooter = GetHeaderFooterContent("ManualFooterMedical")
Case "4" 'commercial client
myFooter = GetHeaderFooterContent("ManualFooterCommercial")
Case Else 'default is always dental
myFooter = GetHeaderFooterContent("ManualFooterDental")
End Select
EO.Pdf.HtmlToPdf.Options.OutputArea = New RectangleF(0, 10.2, 8.5F, 1.0F)
'Render the footer
EO.Pdf.HtmlToPdf.ConvertHtml(myFooter, _
doc.Pages(I))
End If
Next
For K As Integer = 0 To TOC_ENTRIES_COUNT - 1
'for each toc entry, create a horizontal line from entry to page number
'and put in page number
'get page
Dim TOCpage As EO.Pdf.PdfPage = doc.Pages(arrTOC(K, 2))
'create text layer
Dim txtLayer As EO.Pdf.Contents.PdfTextLayer = New EO.Pdf.Contents.PdfTextLayer
txtLayer.Font = New EO.Pdf.Drawing.PdfFont("Arial Narrow, Arial, sans-serif", 10.5)
'create the text
Dim content1 As EO.Pdf.Contents.PdfTextContent = New EO.Pdf.Contents.PdfTextContent(arrTOC(K, 3).ToString)
content1.PositionMode = EO.Pdf.Contents.PdfTextPositionMode.Offset
content1.Offset = New EO.Pdf.Drawing.PdfPoint(534, 785 - (arrTOC(K, 1)) * 72)
'add content objects into pdfTextLayer objec
txtLayer.Contents.Add(content1)
'add the text layer to the page
TOCpage.Contents.Add(txtLayer)
'now create the line between the toc entry and the page number
'Create a new PdfPathContent
Dim content As New EO.Pdf.Contents.PdfPathContent()
'Create a new sub path and set the sub path's starting point
Dim subPath As New EO.Pdf.Drawing.PdfSubPath()
'subPath.From = New EO.Pdf.Drawing.PdfPoint((arrTOC(K, 0) * 72) + (arrTOC(K, 4) * 7.8), 785 - (arrTOC(K, 1) * 72))
If arrTOC(K, 4) >= 69 Then
subPath.From = New EO.Pdf.Drawing.PdfPoint(528, 785.6 - (arrTOC(K, 1) * 72))
ElseIf arrTOC(K, 4) > 55 And arrTOC(K, 4) < 69 Then
subPath.From = New EO.Pdf.Drawing.PdfPoint((arrTOC(K, 4) * 7.0) + 62, 785.6 - (arrTOC(K, 1) * 72))
content.StrokingColor = New EO.Pdf.Drawing.PdfColor(Color.Green)
ElseIf arrTOC(K, 4) > 52 And arrTOC(K, 4) <= 55 Then
subPath.From = New EO.Pdf.Drawing.PdfPoint((arrTOC(K, 4) * 7.02) + 38, 785.6 - (arrTOC(K, 1) * 72))
content.StrokingColor = New EO.Pdf.Drawing.PdfColor(Color.Blue)
ElseIf arrTOC(K, 4) > 32 And arrTOC(K, 4) <= 52 Then
subPath.From = New EO.Pdf.Drawing.PdfPoint((arrTOC(K, 4) * 7.7) + 38, 785.6 - (arrTOC(K, 1) * 72))
content.StrokingColor = New EO.Pdf.Drawing.PdfColor(Color.LightGreen)
ElseIf arrTOC(K, 4) > 22 And arrTOC(K, 4) <= 32 Then
subPath.From = New EO.Pdf.Drawing.PdfPoint((arrTOC(K, 4) * 7.9) + 49, 785.6 - (arrTOC(K, 1) * 72))
content.StrokingColor = New EO.Pdf.Drawing.PdfColor(Color.Red)
ElseIf arrTOC(K, 4) > 14 And arrTOC(K, 4) <= 22 Then
subPath.From = New EO.Pdf.Drawing.PdfPoint((arrTOC(K, 4) * 7.9) + 56, 785.6 - (arrTOC(K, 1) * 72))
content.StrokingColor = New EO.Pdf.Drawing.PdfColor(Color.CornflowerBlue)
ElseIf arrTOC(K, 4) > 8 And arrTOC(K, 4) <= 14 Then
subPath.From = New EO.Pdf.Drawing.PdfPoint((arrTOC(K, 4) * 8.2) + 60, 785.6 - (arrTOC(K, 1) * 72))
content.StrokingColor = New EO.Pdf.Drawing.PdfColor(Color.DarkMagenta)
Else
subPath.From = New EO.Pdf.Drawing.PdfPoint((arrTOC(K, 4) * 8.3) + 60, 785.6 - (arrTOC(K, 1) * 72))
End If
'Draw a line from the current position to the right edge
Dim line As New EO.Pdf.Drawing.PdfPathLineSegment(New EO.Pdf.Drawing.PdfPoint(529, 785.6 - (arrTOC(K, 1)) * 72))
subPath.Segments.Add(line)
'Add the sub path into the path
content.Path.SubPaths.Add(subPath)
'Stroke the path
content.LineWidth = 0.5F
content.LineDashStyle = New EO.Pdf.Drawing.PdfDashStyle(New Single() {1, 2}, 0)
content.StrokingColor = New EO.Pdf.Drawing.PdfColor(Color.Black)
content.Action = EO.Pdf.Contents.PdfPathPaintAction.Stroke
'Add the path into the page
TOCpage.Contents.Add(content)
Next
then we save the pdf to our html folder on the server and ask if the user wants to open or save the pdf to their local machine Thanks for any insights you might have on this issue. Becky
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi Becky,
We really do not review or debug your code. You have to do that yourself.
Another thing that's very very important is, NEVER post your license key publicly in the forum. You just posted your code with your license key in the forum that is publicly accessible to the whole world. We have modified your post and removed that. If you do that again, we will have no option but to revoke your license key.
Simply put, you can not just post your whole code and let us to find the error for you. We have thousands of customers, if everyone just send their code to us when anything goes wrong we would have been completely overwhelmed. As a result, we do not do that, hope you understand.
Thanks!
|