Code Monkey home page Code Monkey logo

Comments (9)

jcramer avatar jcramer commented on July 21, 2024 1

Confirmed. Great work.

from itextsharp.lgplv2.core.

VahidN avatar VahidN commented on July 21, 2024

Thank you.
What exceptions are reported? These tests need some modifications to run on Linux. For instance in the TestUtils class, c:\windows\fonts is defined as the fonts folder or GetBaseDir should be adjusted too.

from itextsharp.lgplv2.core.

jcramer avatar jcramer commented on July 21, 2024

I did notice the issue with the font paths, but the error that hits right away seems to be this other issue. Here's an example of the text exception:

Error Message:
Test method iTextSharp.LGPLv2.Core.FunctionalTests.RtfTests.Verify_PDF_To_RTF_File_CanBeCreated threw exception:
System.ArgumentOutOfRangeException: Length cannot be less than zero.
Parameter name: length
Stack Trace:
at System.String.Substring(Int32 startIndex, Int32 length)
at iTextSharp.LGPLv2.Core.FunctionalTests.TestUtils.GetBaseDir() in /lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core.FunctionalTests/TestUtils.cs:line 20
at iTextSharp.LGPLv2.Core.FunctionalTests.TestUtils.GetOutputFolder() in /lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core.FunctionalTests/TestUtils.cs:lin
e 25
at iTextSharp.LGPLv2.Core.FunctionalTests.RtfTests.Verify_PDF_To_RTF_File_CanBeCreated() in /lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core.FunctionalTes
ts/RtfTests.cs:line 19

I dropped in a couple of WriteLines in for debugging within my docker container, to see what the root and idx values were. Here's the modifed method and console output:

public static string GetBaseDir()
{
           var currentAssembly = typeof(TestUtils).GetTypeInfo().Assembly;
           var root = Path.GetDirectoryName(currentAssembly.Location);
           var idx = root.IndexOf(@"\bin", StringComparison.OrdinalIgnoreCase);
           Console.WriteLine("Print root:" + root);
           Console.WriteLine("Print idx:" + idx);

           return root.Substring(0, idx);
}

Output:

Print root: /lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core.FunctionalTests/bin/Debug/netcoreapp1.0

Print idx: -1

The index should obviously not equal to -1.

from itextsharp.lgplv2.core.

jcramer avatar jcramer commented on July 21, 2024

ok and now this issue was kindof fixed by just removing the @ symbol in this line:

var idx = root.IndexOf(@"\bin", StringComparison.OrdinalIgnoreCase);

After removing the @ symbol 44 tests pass, but the results are stored in a directory named "b". Must be something to do with support for string literals..? I haven't been able to get it to work with "\bin".

from itextsharp.lgplv2.core.

VahidN avatar VahidN commented on July 21, 2024

GetBaseDir() is not an important method. You can replace it with the following path on your system:

return  "/lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core.FunctionalTests/";

Final produced PDF files will be stored there.

from itextsharp.lgplv2.core.

VahidN avatar VahidN commented on July 21, 2024

This issue can be fixed by using a platform specific directory separator char:

var idx = root.IndexOf($"{Path.DirectorySeparatorChar}bin", StringComparison.OrdinalIgnoreCase);

Also I updated the repository to reflect these changes. Please use a new clone to run the tests.

from itextsharp.lgplv2.core.

jcramer avatar jcramer commented on July 21, 2024

Thank you. That works perfect! 👍 👍 Now 46/60 tests passing...

Here is the next type of error below. The next different type of error is a FileNotFoundException, It looks like the root path gets preppended to whole resource path for the image. Any pdf looking for a resource has the same issue.

Failed   Verify_iTextXML_To_PDF_File_CanBeCreated
Error Message:
   Test method iTextSharp.LGPLv2.Core.FunctionalTests.XmlITextTests.Verify_iTextXML_To_PDF_File_CanBeCreated threw exception:
System.IO.FileNotFoundException: Could not find file '/lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core.FunctionalTests/\\lib\iTextSharp.LGPLv2.Core\src\iText
Sharp.LGPLv2.Core.FunctionalTests\iTextExamples\resources\img\hitchcock.png'.
Stack Trace:
    at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Interop.CheckIo[TSafeHandle](TSafeHandle handle, String path, Boolean isDirectory, Func`2 errorRewriter)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
   at System.IO.UnixFileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
   at System.IO.UnixFileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at iTextSharp.LGPLv2.Core.System.NetUtils.WebUtils.GetResponseStream(Uri url) in /lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core/System/NetUtils/WebUtils
.cs:line 15
   at iTextSharp.text.Image.GetInstance(Uri url) in /lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core/iTextSharp/text/Image.cs:line 938
   at iTextSharp.text.Image.GetInstance(String filename) in /lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core/iTextSharp/text/Image.cs:line 1353
   at iTextSharp.text.factories.ElementFactory.GetImage(Properties attributes) in /lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core/iTextSharp/text/factories/
ElementFactory.cs:line 227
   at iTextSharp.text.xml.TextHandler.HandleStartingTags(String name, Properties attributes) in /lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core/iTextSharp/t
ext/xml/ITextHandler.cs:line 656
   at iTextSharp.text.xml.TextHandler.StartElement(String uri, String lname, String name, Hashtable attrs) in /lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Cor
e/iTextSharp/text/xml/ITextHandler.cs:line 853
   at iTextSharp.text.xml.ParserBase.Parse(XmlReader reader) in /lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core/iTextSharp/text/xml/ParserBase.cs:line 59
   at iTextSharp.text.xml.XmlParser.Go(IDocListener document, XmlReader reader) in /lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core/iTextSharp/text/xml/XmlPa
rser.cs:line 134
   at iTextSharp.LGPLv2.Core.FunctionalTests.XmlITextTests.converITextXmlToPdfFile(String iTextXML, String pdfFilePath) in /lib/iTextSharp.LGPLv2.Core/src/iTextSha
rp.LGPLv2.Core.FunctionalTests/XmlITextTests.cs:line 2000
   at iTextSharp.LGPLv2.Core.FunctionalTests.XmlITextTests.Verify_iTextXML_To_PDF_File_CanBeCreated() in /lib/iTextSharp.LGPLv2.Core/src/iTextSharp.LGPLv2.Core.Fun
ctionalTests/XmlITextTests.cs:line 52

from itextsharp.lgplv2.core.

VahidN avatar VahidN commented on July 21, 2024

It's fixed now
lintext

from itextsharp.lgplv2.core.

lock avatar lock commented on July 21, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related problems.

from itextsharp.lgplv2.core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.