|
Rank: Newbie Groups: Member
Joined: 3/22/2013 Posts: 6
|
Hi, I have EO PDF and am converting html to PDF using EO.Pdf. The issue am facing is that while a static html is converted, its always inserting the following invalid characters in PDF generated - "" Following is the code am using:
Code: C#
StringWriter writer = new StringWriter();
using (var memoryStream = new MemoryStream())
{
EO.Pdf.Runtime.AddLicense(
"my license key");
using (FileStream file = new FileStream(@"E:\file.pdf", FileMode.Create, System.IO.FileAccess.Write))
{
var document = new PdfDocument();
HttpContext.Current.Server.Execute("Sample.html", writer);
HtmlToPdf.ConvertHtml(writer.ToString(), document);
writer.Flush();
document.Save(memoryStream);
memoryStream.Seek(0, SeekOrigin.Begin);
byte[] bytes = new byte[memoryStream.Length];
memoryStream.Read(bytes, 0, (int)memoryStream.Length);
file.Write(bytes, 0, bytes.Length);
file.Close();
memoryStream.Close();
}
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
You can check whether your E:\file.pdf is correct. If E:file.pdf is correct, then the converter is working correctly.
Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 3/22/2013 Posts: 6
|
HI, The path is correct and the file is created successfully, the only issue is that the created file is having some invalid characters in the begining of file.
|
|
Rank: Newbie Groups: Member
Joined: 3/22/2013 Posts: 6
|
HI, On further reading, found the invalid characters are from BOM, please check the url here: I jus need to know if there is a possible solution for not getting the BOM mark in the exported PDF? like some settings on the Html2PDF options.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
I don't think this has anything to do with us. We do not write BOM mark.
Thanks
|
|
Rank: Newbie Groups: Member
Joined: 7/3/2014 Posts: 2
|
Actually, if there is a space in the file name, EO throws this error
Illegal characters in path
EO should fix this because having spaces in file names should be ok.
UPDATE
False alarm. The log file printed this:
C:\Temp\city related.pdf----Illegal characters in path.---- at System.IO.Path.GetFileName(String path) at System.IO.FileStream..ctor(String path, FileMode mode) at EO.Pdf.Internal.hf.b(String A_0) at EO.Pdf.HtmlToPdf.ConvertHtml(String html, String pdfFileName, HtmlToPdfOptions options)
But upon further inspection, it turned out that this "space" was actually some non printable character perhaps a carriage return or something. The value of file name variable is read from a source and that source may be introducing some characters. Once the string was cleaned of special characters, EO worked fine.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
CaseFox wrote:Actually, if there is a space in the file name, EO throws this error
Illegal characters in path
EO should fix this because having spaces in file names should be ok. We are not aware of such issue. The file name is handled by Windows, not by us. So if you see an illegal character in file name error, then that error comes from Windows ---- and obviously in this case the only resolution is to remove the offending character to satisfy Windows. However space is perfectly fine for Windows file name. So please double check if the character is indeed caused by space. If you still have problems and believe the problem is related to us, please try to isolate the problem into a test project and send the test project to us. Please see here for instructions on sending test project: http://www.essentialobjects.com/forum/test_project.aspxWe will look into it as soon as we receive the test project. Thanks!
|
|
Rank: Newbie Groups: Member
Joined: 7/3/2014 Posts: 2
|
eo_support wrote:CaseFox wrote:Actually, if there is a space in the file name, EO throws this error
Illegal characters in path
EO should fix this because having spaces in file names should be ok. We are not aware of such issue. The file name is handled by Windows, not by us. So if you see an illegal character in file name error, then that error comes from Windows ---- and obviously in this case the only resolution is to remove the offending character to satisfy Windows. However space is perfectly fine for Windows file name. So please double check if the character is indeed caused by space. If you still have problems and believe the problem is related to us, please try to isolate the problem into a test project and send the test project to us. Please see here for instructions on sending test project: http://www.essentialobjects.com/forum/test_project.aspxWe will look into it as soon as we receive the test project. Thanks! False alarm. The log file printed this: C:\Temp\city related.pdf----Illegal characters in path.---- at System.IO.Path.GetFileName(String path) at System.IO.FileStream..ctor(String path, FileMode mode) at EO.Pdf.Internal.hf.b(String A_0) at EO.Pdf.HtmlToPdf.ConvertHtml(String html, String pdfFileName, HtmlToPdfOptions options) But upon further inspection, it turned out that this "space" was actually some non printable character perhaps a carriage return or something. The value of file name variable is read from a source and that source may be introducing some characters. Once the string was cleaned of special characters, EO worked fine.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Glad to hear that you found out the root cause. Thanks for the update!
|
|