Welcome Guest Search | Active Topics | Sign In | Register

Invalid Characters in HtmlToPdf Export Options
Bernhard Kaufmann
Posted: Monday, April 22, 2013 5:32:22 AM
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();
                    }
                }
eo_support
Posted: Monday, April 22, 2013 8:13:26 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,072
Hi,

You can check whether your E:\file.pdf is correct. If E:file.pdf is correct, then the converter is working correctly.

Thanks!
Bernhard Kaufmann
Posted: Monday, April 22, 2013 8:29:14 AM
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.
Bernhard Kaufmann
Posted: Monday, April 22, 2013 8:36:29 AM
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.
eo_support
Posted: Monday, April 22, 2013 8:38:54 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,072
Hi,

I don't think this has anything to do with us. We do not write BOM mark.

Thanks
CaseFox
Posted: Thursday, July 31, 2014 2:36:28 PM
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.
eo_support
Posted: Thursday, July 31, 2014 5:13:55 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,072
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.aspx

We will look into it as soon as we receive the test project.

Thanks!
CaseFox
Posted: Thursday, July 31, 2014 5:32:05 PM
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.aspx

We 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.
eo_support
Posted: Thursday, July 31, 2014 9:04:23 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,072
Glad to hear that you found out the root cause. Thanks for the update!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.