@@ -40,44 +40,55 @@ source product.
4040 For more information, please contact iText Software Corp. at this
41414242 */
43+
4344using System ;
44- using System . Collections . Generic ;
4545using System . Globalization ;
46- using System . Linq ;
47- using System . Text ;
4846using System . Threading ;
4947using iText . IO . Image ;
48+ using iText . Kernel . Pdf ;
5049using iText . Layout . Element ;
50+ using iText . Test ;
51+ using NUnit . Framework ;
5152
52- namespace iText . Layout
53- {
53+ namespace iText . Layout {
5454 // This test is present only in c#
5555 // Also this test in only for windows OS
56- class NetWorkPathTest
57- {
56+ public class NetWorkPathTest : ExtendedITextTest {
57+
5858 [ NUnit . Framework . Test ]
59- public virtual void NetworkPathImageTest ( )
60- {
61- var fullImagePath = @"\\someVeryRandomWords\SomeVeryRandomName.img" ;
62- string startOfMsg = null ;
59+ public virtual void NetworkPathImageTest ( ) {
60+ String fullImagePath = @"\\someVeryRandomWords\SomeVeryRandomName.img" ;
61+ String startOfMsg = null ;
6362#if ! NETSTANDARD1_6
6463 Thread . CurrentThread . CurrentCulture = CultureInfo . InvariantCulture ;
6564 Thread . CurrentThread . CurrentUICulture = CultureInfo . InvariantCulture ;
6665#else
6766 CultureInfo . CurrentCulture = CultureInfo . InvariantCulture ;
6867 CultureInfo . CurrentUICulture = CultureInfo . InvariantCulture ;
6968#endif
70- try
71- {
69+ try {
7270 Image drawing = new Image ( ImageDataFactory . Create ( fullImagePath ) ) ;
73- }
74- catch ( Exception e )
75- {
71+ } catch ( Exception e ) {
7672 if ( e . InnerException != null && e . InnerException . Message . Length > 18 )
7773 startOfMsg = e . InnerException . Message . Substring ( 0 , 19 ) ;
7874 }
7975 NUnit . Framework . Assert . IsNotNull ( startOfMsg ) ;
8076 NUnit . Framework . Assert . AreNotEqual ( "Could not find file" , startOfMsg ) ;
8177 }
78+
79+ [ NUnit . Framework . Test ]
80+ [ Ignore ( "Manual run only" ) ]
81+ public virtual void NetworkPathImageTest02 ( ) {
82+ // TODO This test can work only if shared folder exists on some local network computer.
83+ // Suggested apporach is to create such folder on your computer and input corresponding names as variables values below.
84+ String comupterNameAndSharedFolderPath = @"INSERT_YOUR_COMPUTER_NAME" ; // e.g. \\DESKTOP-ABCD3TQ\_inbox
85+ String outPath = "INSERT_OUTPUT_PATH" ;
86+
87+ String fullImagePath = @"\\" + comupterNameAndSharedFolderPath + @"\img.jpg" ;
88+ Image drawing = new Image ( ImageDataFactory . Create ( fullImagePath ) ) ;
89+ Document doc = new Document ( new PdfDocument ( new PdfWriter ( outPath ) ) ) ;
90+ doc . Add ( drawing . SetAutoScale ( true ) ) ;
91+ doc . Close ( ) ;
92+ }
8293 }
83- }
94+ }
0 commit comments