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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Error before the PDF generates

Thread ID:





54591 Jan 12,2007 12:01 AM UTC Jan 19,2007 09:16 AM UTC ASP.NET Web Forms (Classic) 13
Tags: PDF
Mirza Javed
Asked On January 12, 2007 12:01 AM UTC


I am getting a strange error when I try to generate a PDF document. What happens is the PDF file generates absolutely fine with no errors at all, and I can see all the data in the file, save it and print it.

But at the same time, just before it generates the PDF it gives an error saying this "error: cannot obtain value".

Any thoughts....

Mirza Javed
Replied On January 12, 2007 12:05 AM UTC

Just to give a few more details on the issue. The error happens after the following statement executes

pdfDoc.Save("Sample.pdf", Response, HttpReadType.Save)

Dhivya K [Syncfusion]
Replied On January 12, 2007 01:23 PM UTC

Hi Mirza,

Thank you for your interest in Essential PDF.

Could you please ellobrate the issue like what manipulations you are doing? Could you please provide me some code snippet or sample in which you are able to reproduce the issue? Also can you please mention the Essential studio version that you are currently using?
These will help me investigating further on this issue.


Mirza Javed
Replied On January 12, 2007 04:01 PM UTC

The version is

What I am basically trying to do is read the data from a database and draw the text in the pdf document.

Here is the code...

I use a stored procedure to populate the Data Reader and then use the values in the Data Reader to draw the text in the PDF document.

DataReader = sqlCommand.ExecuteReader()
While DataReader.Read()
'******** Create a new PDF Document. The pdfDoc object represents the PDF document.
'******** This document has one page by default and additional pages have to be added.
Dim pdfDoc As PDFDocument = New PDFDocument
pdfDoc.AutoCreatePages = True
Dim props As IPDFGraphicState = pdfDoc.CreateGraphicState()
props.BreakBehavior = AutoBreakBehavior.MultiLineTextBreak

'******** Adding a font that can be used to draw Text inside the PDF document.
'******** Using the Predefined fonts to draw the text.
Dim pdfFont As IPDFFont = pdfDoc.Fonts.Add(FontBaseFamily.TimesRoman)
Dim pdfBold As IPDFFont = pdfDoc.Fonts.Add(FontBaseFamily.TimesBold)
Dim pdfHeader As IPDFFont = pdfDoc.Fonts.Add(FontBaseFamily.TimesBold)
pdfHeader.Size = "20"

'******** Draw text at the specified Location.
pdfDoc.Graphics.DrawImage(New PointF(0, 0), Server.MapPath("images/strategiclogodla.jpg"))
pdfDoc.Graphics.DrawText(200, 10, "SFI Coaching & Training Record", pdfHeader)
pdfDoc.Graphics.DrawText(0, 75, "Agent being Evaluated:", pdfBold)
pdfDoc.Graphics.DrawText(300, 75, DataReader("TSR Name"), pdfFont)
pdfDoc.Graphics.DrawLine(New PointF(300, 90), New PointF(500, 90))
pdfDoc.Graphics.DrawText(0, 110, "Date Evaluated:", pdfBold)
pdfDoc.Graphics.DrawText(300, 110, DataReader("lastchangeddate"), pdfFont)
pdfDoc.Graphics.DrawLine(New PointF(300, 125), New PointF(500, 125))
pdfDoc.Graphics.DrawText(0, 145, "Team Leader / Manager performing Evaluation:", pdfBold)
pdfDoc.Graphics.DrawText(300, 145, DataReader("Evaluator"), pdfFont)
pdfDoc.Graphics.DrawLine(New PointF(300, 160), New PointF(500, 160))
pdfDoc.Graphics.DrawText(0, 180, "Type of Evaluation:", pdfBold)
pdfDoc.Graphics.DrawText(300, 180, DataReader("evaltype"), pdfFont)
pdfDoc.Graphics.DrawLine(New PointF(300, 195), New PointF(500, 195))
pdfDoc.Graphics.DrawText(0, 215, "Reason for Session:", pdfBold)
pdfDoc.Graphics.DrawText(300, 215, DataReader("evalreason"), pdfFont)
pdfDoc.Graphics.DrawLine(New PointF(300, 230), New PointF(500, 230))
pdfDoc.Graphics.DrawText(0, 250, "Project:", pdfBold)
pdfDoc.Graphics.DrawText(300, 250, DataReader("project"), pdfFont)
pdfDoc.Graphics.DrawLine(New PointF(300, 265), New PointF(500, 265))
pdfDoc.Graphics.DrawText(0, 285, "Position Evaluated:", pdfBold)
pdfDoc.Graphics.DrawText(300, 285, DataReader("evalposition"), pdfFont)
pdfDoc.Graphics.DrawLine(New PointF(300, 300), New PointF(500, 300))
pdfDoc.Graphics.DrawText(0, 320, "Call Index:", pdfBold)
pdfDoc.Graphics.DrawText(300, 320, DataReader("callindex"), pdfFont)
pdfDoc.Graphics.DrawLine(New PointF(300, 335), New PointF(500, 335))
pdfDoc.Graphics.DrawText(0, 355, "Comments:", pdfBold)
pdfDoc.Graphics.DrawMultiText(0, 375, 500, 250, DataReader("evalcomments"), pdfFont, props)
pdfDoc.Graphics.DrawText(0, 650, "I have given/received this feedback and" & _
" understand the importance of the points made.", pdfFont)
pdfDoc.Graphics.DrawText(0, 720, "_________________________________", pdfFont)
pdfDoc.Graphics.DrawText(300, 720, "_________________________________", pdfFont)
pdfDoc.Graphics.DrawText(0, 740, DataReader("Evaluator"), pdfFont)
pdfDoc.Graphics.DrawText(300, 740, DataReader("TSR Name"), pdfFont)

'******** Display the PDF file on the screen
pdfDoc.Save(DataReader("TSR Name") & ".pdf", Response, HttpReadType.Save)
End While
End Using
Catch x As Exception
lblError.Text = x.Message
lblError.Visible = True
End Try

As I said earlier, everything seems to work great, and I can't notice any error with the pdf document or the application itself, but when it executes the statement

pdfDoc.Save(DataReader("TSR Name") & ".pdf", Response, HttpReadType.Save)

It jumps into the catch block and I can read the error by placing a break point on the statement

lblError.Text = x.Message

But, because it throws an error and goes to the catch block, it never executes any code that I place after the pdfdoc.save statement

Hopefully this is not too overwhelming

Mirza Javed
Replied On January 15, 2007 08:15 PM UTC

Any luck Dhivya

Dhivya K [Syncfusion]
Replied On January 16, 2007 10:54 AM UTC

Hi Mirza,

Sorry for the delay in getting back to you.

Thanks for the code. I tried testing this issue. I am afraid, I am unable to reproduce the issue.
Here is a sample for your reference:

Here is a PDF file generated using your code:

I guess,the problem must be in retrieving the value from the database.
Could you please verify if the values are retrieved correctly from the database or could you please modify my sample so that I can reproduce the issue?


Mirza Javed
Replied On January 16, 2007 04:37 PM UTC

Thanks Dhivya,

I tried your code, and just like it does for me, everything works fine.

But, the error is hidden and is not displayed. Here is what I want you to do to see the error. Put a break point on the statement "Try", so that while executing the application the code stops here. Then walk through the code until you reach the statement "pdfDoc.Save....". Now, if you keep going you will notice that it will ignore/skip the "Label1.text = "Success" statement after that and jump right into catch block

If you keep going further, when the statment "label1.text = x.message" is highlighted, individually hightlight the "x" and put your mouse on top of it, this is where you will see the error description

'******** Display the PDF file on the screen
pdfDoc.Save("TSR Name" & ".pdf", Response, HttpReadType.Save) -- THIS THROWS AN ERROR
Label1.Text = "Success" -- THIS LINE IS SKIPPED
Catch x As exception
Label1.text = x.message -- SHOWS AN ERROR DESCRIPTION
End Try



Mirza Javed
Replied On January 16, 2007 04:38 PM UTC

I attached a file Defulat.zip that will produce the error in the catch block that I explained in my previous message

Dhivya K [Syncfusion]
Replied On January 17, 2007 12:42 PM UTC

Hi Mirza,

Thank you for the sample and steps to reproduce the issue. I tried testing this issue as stated and was able to reproduce the issue. Whenever, it executes the "Save" statement with HttpType overload, it executes the catch statement. However, it doesn't display any error message. I will consult with development team and provide you with an update regarding this issue.

Could you please consider using "pdfDoc.Save("TSR Name" & ".pdf")" overload if you would like to save the PDF document in some location? This doesn't execute the catch statement. Or you can open the thid PDF document in the seperate browser window and execute the lines below.

Here is a sample to open a PDF document in a seperate window.

Please take a look into it and let me know if it helps.


Mirza Javed
Replied On January 17, 2007 03:36 PM UTC

hey Dhivya

Thanks for the quick reply and looking forward to know what your developers say. But, the attached zip file to your previous message did not have an example of opening up a pdf document in a seperate window. Can you please try that again


Dhivya K [Syncfusion]
Replied On January 18, 2007 06:53 AM UTC

Hi Mirza,

My apologies. I uploaded wrong sample.
Here is a sample to open a PDF document in a seperate window.

Please take a look into it and let me know it helps.


Mirza Javed
Replied On January 18, 2007 04:39 PM UTC

hey Dhivya

Is there a chance you may have the sample available in vb.net instead of c#


Mirza Javed
Replied On January 18, 2007 04:50 PM UTC

Never mind, I figured it out

Dhivya K [Syncfusion]
Replied On January 19, 2007 09:16 AM UTC

Hi Mirza,

Thanks for the update. Please let me know if you have any other queries.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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