Skip to content

Commit eea67f8

Browse files
committed
docs(scheduler): Improve PDF Troubleshooting article
1 parent 68c1ff7 commit eea67f8

File tree

1 file changed

+267
-58
lines changed

1 file changed

+267
-58
lines changed

controls/scheduler/troubleshooting/pdf-export.md

Lines changed: 267 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -8,99 +8,308 @@ published: True
88
position: 1
99
---
1010

11-
# PDF Export
11+
# PDF Export Troubleshooting
1212

1313

1414

15-
This article shows some of the known RadScheduler PDF Export issues and solutions.
15+
This article shows some of the known RadScheduler PDF Export issues and their solutions.
1616

17-
## Troubleshooting
1817

19-
* Problem:
18+
* [Invalid XHTML Scheduler output](#invalid-xhtml-scheduler-output)
2019

21-
**Invalid XHTML Scheduler output**
20+
* ['div' start tag on line 96 position 15 does not match the end tag of 'li'. Line 102, position 13.](#div-start-tag-on-line-96-position-15-does-not-match-the-end-tag-of-li-line-102-position-13)
2221

23-
Suggested solution:
22+
* [System.SystemException: Error while creating area : Encountered web exception while fetching image from](#systemsystemexception-error-while-creating-area--encountered-web-exception-while-fetching-image-from)
2423

25-
The rendered scheduler output should be valid XHTML. If it is not, you will receive exceptions on export. The most common cause for bad XHTML are symbols like **<**,**>**,**&** that need to be replaced by the correct *XHTML* entity: **& l t ;**, **& g t ;**, **& a m p ;** respectively. Another frequent problem is unclosed tags.
24+
* [System.ArgumentException: Parameter is not valid. at System.Drawing.Bitmap..ctor(Stream stream)](#systemargumentexception-parameter-is-not-valid-at-systemdrawingbitmapctorstream-stream)
2625

27-
* Problem:
26+
* [An error occurred while parsing EntityName. Line 1246, position 58 or '' is an unexpected token.](#an-error-occurred-while-parsing-entityname-line-1246-position-58-or--is-an-unexpected-token)
2827

29-
**'div' start tag on line 96 position 15 does not match the end tag of 'li'. Line 102, position 13.**
28+
* [System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host](#systemnetsocketssocketexception-an-existing-connection-was-forcibly-closed-by-the-remote-host)
3029

31-
Suggested solution:
3230

33-
Most likely it is caused by not closed html tags declared in scheduler templates for example.Please [validate](http://validator.w3.org/) the page output.
31+
## Invalid XHTML Scheduler output
32+
The rendered scheduler output should be valid XHTML. If it is not, you will receive exceptions on export. Here are some common causes for bad XHTML:
3433

35-
* Problem:
34+
* Special symbols like `<`,`>`,`&`.
3635

37-
**System.SystemException: Error while creating area : Encountered web exception while fetching image from**
36+
They should be replaced by the correct *XHTML* entity: `&lt;`, `&gt;`, `&amp;`
37+
38+
* Unclosed tags
3839

39-
**http://localhost:51300/Telerik.Web.UI.WebResource.axd?imgid=324e7fbdeca947c2b9a6c7ca14c88e87&type=rbi:**
4040

41-
**The remote server returned an error: (500) Internal Server Error.**
41+
## 'div' start tag on line 96 position 15 does not match the end tag of 'li'. Line 102, position 13.
42+
Most likely it is caused by not closed html tags declared in scheduler templates for example.
43+
Please [validate](http://validator.w3.org/) the page output.
4244

43-
Suggested solution:
4445

45-
To troubleshoot the issue, please open the url, specified in the error details. In the above example it is:
4646

47-
http://localhost:51300/Telerik.Web.UI.WebResource.axd?imgid=324e7fbdeca947c2b9a6c7ca14c88e87&type=rbi:
47+
## System.SystemException: Error while creating area : Encountered web exception while fetching image from
48+
````ExceptionMessage
49+
System.SystemException: Error while creating area :
50+
Encountered web exception while fetching image from
51+
http://localhost:51300/Telerik.Web.UI.WebResource.axd?imgid=324e7fbdeca947c2b9a6c7ca14c88e87&type=rbi
52+
The remote server returned an error: (500) Internal Server Error.
53+
````
54+
55+
To troubleshoot the issue, please open the url, specified in the error details. In the above example it is:
56+
`http://localhost:51300/Telerik.Web.UI.WebResource.axd?imgid=324e7fbdeca947c2b9a6c7ca14c88e87&type=rbi`
4857

49-
The most probable cause of this issue is incorrect web resource handler registration when the Telerik.Web.UI.dll is referenced trough the GAC. For more details refer to the [General TroubleShooting help topic](http://www.telerik.com/help/aspnet-ajax/introduction-troubleshooting.html) .
58+
The most probable cause of this issue is incorrect web resource handler registration when the Telerik.Web.UI.dll is referenced trough the GAC. For more details refer to the [General TroubleShooting help topic](http://www.telerik.com/help/aspnet-ajax/introduction-troubleshooting.html).
5059

51-
* Problem:
60+
## System.ArgumentException: Parameter is not valid. at System.Drawing.Bitmap..ctor(Stream stream)
5261

53-
**System.ArgumentException: Parameter is not valid. at System.Drawing.Bitmap..ctor(Stream stream) at Telerik.Web.Apoc.Image.ApocImage..ctor(String href, Byte[] imageData) at Telerik.Web.Apoc.Image.ApocImageFactory.Make(String href) at Telerik.Web.Apoc.Fo.Flow.ExternalGraphic.Layout(Area area) at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area) at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area, Region region) at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area) at Telerik.Web.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree) at Telerik.Web.Apoc.StreamRenderer.Render(PageSequence pageSequence) at Telerik.Web.Apoc.Fo.FOTreeBuilder.EndElement() at Telerik.Web.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)**
62+
````StackTrace
63+
System.ArgumentException: Parameter is not valid.
64+
at System.Drawing.Bitmap..ctor(Stream stream)
65+
at Telerik.Web.Apoc.Image.ApocImage..ctor(String href, Byte[] imageData)
66+
at Telerik.Web.Apoc.Image.ApocImageFactory.Make(String href)
67+
at Telerik.Web.Apoc.Fo.Flow.ExternalGraphic.Layout(Area area)
68+
at Telerik.Web.Apoc.Fo.Flow.Block.Layout(Area area)
69+
at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area, Region region)
70+
at Telerik.Web.Apoc.Fo.Flow.Flow.Layout(Area area)
71+
at Telerik.Web.Apoc.Fo.Pagination.PageSequence.Format(AreaTree areaTree)
72+
at Telerik.Web.Apoc.StreamRenderer.Render(PageSequence pageSequence)
73+
at Telerik.Web.Apoc.Fo.FOTreeBuilder.EndElement()
74+
at Telerik.Web.Apoc.Fo.FOTreeBuilder.Parse(XmlReader reader)
75+
````
5476

55-
Suggested solution:
77+
This problem appears on export when the Telerik.Web.UI.dll is referenced trough the GAC and the assembly version is different from the WebResource.axd version registered in the web.config file. Please check you web.config for proper handler registration in the following section:
5678

57-
1. This problem appears on export when the Telerik.Web.UI.dll is referenced trough the GAC and the assembly version is different from the WebResource.axdversion registered in the web.config file. Please check you web.configfor proper handler registration in the following section:
79+
````web.config
80+
<system.webServer>
81+
<handlers>
82+
<add name="Telerik.Web.UI.WebResource" path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=[ASSEMBLY_VERSION], Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
83+
</handlers>
84+
</system.webServer>
85+
````
5886

59-
**ASP.NET**
60-
61-
<system.webServer>
62-
<handlers>
63-
<add name="Telerik.Web.UI.WebResource" path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=[ASSEMBLY_VERSION], Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
64-
</handlers>
65-
</system.webServer>
66-
87+
Where [ASSEMBLY_VERSION] is the exact version of your Telerik.Web.UI.dll.
6788

68-
Where [ASSEMBLY_VERSION] is the exact version of your Telerik.Web.UI.dll.
69-
70-
2. If you are using Forms authentication please add the following section to your web.config file:
71-
72-
In case you are using RadScriptManager:
89+
If you are using Forms authentication please add the following section to your web.config file:
7390

74-
**ASPNET**
91+
- In case you are using **RadScriptManager**:
7592

76-
<location path="Telerik.Web.UI.WebResource.axd">
77-
<system.web>
78-
<authorization>
79-
<allow users="?"/>
80-
</authorization>
81-
</system.web>
82-
</location>
93+
**web.config**
94+
95+
<location path="Telerik.Web.UI.WebResource.axd">
96+
<system.web>
97+
<authorization>
98+
<allow users="?"/>
99+
</authorization>
100+
</system.web>
101+
</location>
83102
84103
85-
In case you are using asp:ScriptManager:
104+
- In case you are using **asp:ScriptManager**:
86105

87-
**ASPNET**
106+
**web.config**
107+
108+
<location path="WebResource.axd">
109+
<system.web>
110+
<authorization>
111+
<allow users="?"/>
112+
</authorization>
113+
</system.web>
114+
</location>
88115
89-
<location path="WebResource.axd">
90-
<system.web>
91-
<authorization>
92-
<allow users="?"/>
93-
</authorization>
94-
</system.web>
95-
</location>
96116
117+
## An error occurred while parsing EntityName. Line 1246, position 58 or '' is an unexpected token.
118+
119+
````ExceptionMessage
120+
An error occurred while parsing EntityName.
121+
Line 1246, position 58 or '' is an unexpected token.
122+
The expected token is ';'. Line 131, position 10.
123+
````
124+
125+
If special characters are used, replace them by valid HTML equivalents: `&` - `&amp;`, `<` - `&lt;`, `>` - `&gt;`, etc.
126+
127+
You can use this article for reference - [Special Characters in HTML](http://www.degraeve.com/reference/specialcharacters.php).
128+
129+
130+
## System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
131+
<span></span>
132+
### Description
133+
134+
Such problems are usually caused by an incorrectly configured server and some generic connection issues.
135+
136+
The Stack trace sometimes says that the GetStyleSheet method is failing. The said method only executes a standard HttpWebRequest. The observed error most probably is related to a general connection issue rather than an issue with the control itself.
137+
138+
Below you can find some exception messages that you might encounter:
139+
140+
### Exception messages
141+
142+
* [SocketException (0x2746): An existing connection was forcibly closed by the remote host]
143+
144+
**ExceptionMessage**
145+
146+
[SocketException (0x2746): An existing connection was forcibly closed by the remote host]
147+
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +249
148+
149+
[IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.]
150+
System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +8442161
151+
System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) +57
152+
System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +243
153+
System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) +470
154+
System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) +8572686
155+
System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) +230
156+
System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) +645
157+
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) +9
158+
System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) +87
159+
System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) +1467
160+
System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) +84
161+
System.Net.ConnectStream.WriteHeaders(Boolean async) +816
162+
163+
[WebException: The underlying connection was closed: An unexpected error occurred on a send.]
164+
System.Net.HttpWebRequest.GetResponse() +8442708
165+
Telerik.Web.UI.Scheduler.SchedulerExporter.GetStyleSheet(String url) +120
166+
Telerik.Web.UI.Scheduler.SchedulerExporter.GetStyleSheetFor(String controlName, Type controlType, Page page, String pathFormatString, String defaultPathFormatString) +318
167+
Telerik.Web.UI.Scheduler.SchedulerExporter.GetStyleSheets(Page page) +99
168+
Telerik.Web.UI.Scheduler.SchedulerExporter.RenderControl(Page page) +695
169+
Telerik.Web.UI.Scheduler.SchedulerExporter.PdfExportRenderForm(HtmlTextWriter nullWriter, Control form) +154
170+
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +131
171+
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +151
172+
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +49
173+
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
174+
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +131
175+
System.Web.UI.Page.Render(HtmlTextWriter writer) +40
176+
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
177+
Telerik.Web.UI.RadAjaxControl.RenderPageInAjaxMode(HtmlTextWriter writer, Control page) +1040
178+
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +131
179+
System.Web.UI.Page.Render(HtmlTextWriter writer) +40
180+
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
181+
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5363
182+
183+
184+
* System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
185+
186+
**ExceptionMessage**
187+
188+
System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
189+
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
190+
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
191+
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
192+
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
193+
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
194+
at System.Net.Security._SslStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
195+
at System.Net.Security._SslStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
196+
at System.Net.Security._SslStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
197+
at System.Net.TlsStream.Read(Byte[] buffer, Int32 offset, Int32 size)
198+
at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
199+
at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
200+
201+
202+
* A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
203+
204+
**ExceptionMessage**
205+
206+
A connection attempt failed because the connected party did not properly respond after a period of time,
207+
or established connection failed because connected host has failed to respond 216.146.38.125:89
208+
209+
Description:
210+
An unhandled exception occurred during the execution of the current web request.
211+
Please review the stack trace for more information about the error and where it originated in the code.
212+
213+
Exception Details:
214+
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time,
215+
or established connection failed because connected host has failed to respond 216.146.38.125:89
216+
217+
Source Error:
218+
An unhandled exception was generated during the execution of the current web request.
219+
Information regarding the origin and location of the exception can be identified using the exception stack trace below.
220+
221+
222+
### Solutions:
97223
98-
* Problem:
224+
* One possible solution would be using the ClientExportManager to export the Scheduler to PDF as demonstrated in the [Scheduler client PDF export with ClientExportManager](https://www.telerik.com/support/code-library/scheduler-client-pdf-export-with-clientexportmanager) Code Library project.
225+
226+
* To troubleshoot the GetStyleSheet method itself you can use the extracted logic outside the code of the Scheduler in a TestGetStyleSheet method.
227+
228+
````C#
229+
protected void TestGetStyleSheet(object sender, EventArgs e)
230+
{
231+
var url1 = Telerik.Web.SkinRegistrar.GetWebResourceUrl(Page, typeof(RadScheduler), "Telerik.Web.UI.Skins.Scheduler.css");
232+
url1 = UpdateWebResourceUrl(url1);
233+
234+
var styleSheet1 = GetStyleSheet(url1);
235+
236+
var url2 = Telerik.Web.SkinRegistrar.GetWebResourceUrl(Page, typeof(RadScheduler), "Telerik.Web.UI.Skins.Windows7.Scheduler.Windows7.css");
237+
url2 = UpdateWebResourceUrl(url2);
238+
239+
var styleSheet2 = GetStyleSheet(url2);
240+
}
241+
242+
private static string UpdateWebResourceUrl(string path)
243+
{
244+
var currentContext = System.Web.HttpContext.Current;
245+
var request = currentContext.Request;
246+
var schemeAndServer = request.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);
247+
var sb = new StringBuilder(schemeAndServer);
248+
249+
sb.Append(path);
250+
sb.Replace("~", "");
251+
path = sb.ToString();
252+
return path;
253+
}
254+
255+
private string GetStyleSheet(string url)
256+
{
257+
var request = (HttpWebRequest)WebRequest.Create(url);
258+
request.UseDefaultCredentials = true; //Fixes 401 Unauthorized exceptions
259+
var response = request.GetResponse();
260+
261+
var enc = System.Text.Encoding.UTF8;
262+
var loResponseStream = new StreamReader(response.GetResponseStream(), enc);
263+
264+
string result = loResponseStream.ReadToEnd();
265+
266+
loResponseStream.Close();
267+
response.Close();
268+
269+
HttpContext currentContext = System.Web.HttpContext.Current;
270+
271+
string[] splittedResult = result.Split(new string[] { "url('", "')" }, StringSplitOptions.None);
272+
List<string> splittedUrlsThatNeedsUpdate = new List<string>();
273+
274+
for (int i = 0; i < splittedResult.Length; i++)
275+
{
276+
if (splittedResult[i].Contains("WebResource.axd?"))
277+
{
278+
if (!splittedUrlsThatNeedsUpdate.Contains(splittedResult[i]))
279+
{
280+
splittedUrlsThatNeedsUpdate.Add(splittedResult[i]);
281+
}
282+
}
283+
}
284+
285+
List<string> splittedUrlsUpdated = new List<string>();
286+
foreach (string item in splittedUrlsThatNeedsUpdate)
287+
{
288+
var currentRequest = currentContext.Request;
289+
var schemeAndServer = currentRequest.Url.GetComponents(UriComponents.SchemeAndServer, UriFormat.Unescaped);
290+
var sb = new StringBuilder(schemeAndServer);
291+
292+
sb.Append(currentContext.Request.ApplicationPath);
293+
sb.Append("/" + item);
294+
sb.Replace("~", "");
295+
296+
splittedUrlsUpdated.Add(sb.ToString());
297+
}
298+
299+
300+
StringBuilder stringBuilder = new StringBuilder(result);
301+
for (int j = 0; j < splittedUrlsUpdated.Count; j++)
302+
{
303+
stringBuilder.Replace(splittedUrlsThatNeedsUpdate[j], splittedUrlsUpdated[j]);
304+
}
305+
306+
return stringBuilder.ToString();
307+
}
308+
````
309+
310+
311+
99312

100-
**An error occurred while parsing EntityName. Line 1246, position 58or '' is an unexpected token. The expected token is ';'. Line 131, position 10.**
101313

102-
Suggested solution:
103314

104-
If special characters are used, replace them by valid HTML equivalents: **&** - **& a m p ;** …..
105315

106-
You can use this article for reference - [Special Characters in HTML](http://www.degraeve.com/reference/specialcharacters.php) .

0 commit comments

Comments
 (0)