Skip to content

Commit b134868

Browse files
Merge pull request #2059 from syncfusion-content/882858
882858: Added trouble shooting in the HTML to PDF converter.
2 parents f5c205d + 0cd672e commit b134868

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

File-Formats/PDF/Convert-HTML-To-PDF/troubleshooting.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,4 +851,61 @@ Blink binaries (Version 109.0.5414.75),
851851
</td>
852852
</tr>
853853

854+
</table>
855+
856+
857+
## There was an error opening this document. This file is already open or in use by another application.
858+
859+
<table>
860+
<th style="font-size:14px" width="100px">Issue</th>
861+
<th style="font-size:14px">There was an error opening this document. This file is already open or in use by another application.
862+
</th>
863+
<tr>
864+
<th style="font-size:14px" width="100px">Reason
865+
</th>
866+
<td>The reported issue occurs due to the document or file not being properly disposed or closed, leading to conflicts when attempting to access it again.
867+
</td>
868+
</tr>
869+
<tr>
870+
<th style="font-size:14px" width="100px">Solution</th>
871+
<td>
872+
873+
We can resolve the reported issue by using the FileStream within the "using" block.
874+
{% tabs %}
875+
{% highlight C# %}
876+
877+
using (FileStream fs = new FileStream("path_to_file", FileMode.Open))
878+
{
879+
// Use the file here
880+
} // File stream is automatically closed and disposed
881+
882+
{% endhighlight %}
883+
{% endtabs %}
884+
885+
Or
886+
887+
Dispose of the FileStream at the end of the process and ensure that the file or document is not already open in another application.
888+
{% tabs %}
889+
{% highlight C# %}
890+
891+
892+
PdfDocument document = htmlConverter.Convert(");
893+
894+
FileStream fileStream = new FileStream(baseUrl+ "Bill_PDF_04_16_24.pdf", FileMode.CreateNew, FileAccess.ReadWrite);
895+
896+
//Save and close the PDF document.
897+
898+
document.Save(fileStream);
899+
900+
document.Close(true);
901+
902+
document.Dispose();
903+
904+
fileStream.Dispose();
905+
906+
{% endhighlight %}
907+
{% endtabs %}
908+
</td>
909+
</tr>
910+
854911
</table>

0 commit comments

Comments
 (0)