private void ConvertToPdf(string fileIN, string fileOUT)
        {
            //string projectDir = Server.MapPath("~/");

            NameValueCollection commonLoggingproperties = new NameValueCollection();

            commonLoggingproperties["showDateTime"] = "false";
            commonLoggingproperties["level"]        = "INFO";
            Common.Logging.LogManager.Adapter       = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(commonLoggingproperties);


            Common.Logging.ILog log = Common.Logging.LogManager.GetCurrentClassLogger();
            log.Info("Hello from Common Logging");

            // Necessary, if slf4j-api and slf4j-NetCommonLogging are separate DLLs
            ikvm.runtime.Startup.addBootClassPathAssembly(
                System.Reflection.Assembly.GetAssembly(
                    typeof(org.slf4j.impl.StaticLoggerBinder)));

            // Configure to find docx4j.properties
            // .. add as URL the dir containing docx4j.properties (not the file itself!)
            Plutext.PropertiesConfigurator.setDocx4jPropertiesDir(Server.MapPath("~/src/samples/resources/"));

            //org.docx4j.openpackaging.parts.WordprocessingML.ObfuscatedFontPart.getTemporaryEmbeddedFontsDir()

            // OK, do it..
            org.docx4j.openpackaging.packages.WordprocessingMLPackage wordMLPackage = org.docx4j.openpackaging.packages.WordprocessingMLPackage.load(new java.io.File(fileIN));

            java.io.FileOutputStream fos = new java.io.FileOutputStream(new java.io.File(fileOUT));

            org.docx4j.Docx4J.toPDF(wordMLPackage, fos);

            fos.close();
        }
Exemple #2
0
 private void UnzipFile(string zipFileName)
 {
     try
     {
         string fileName;
         fileName = "EQ" + dateTimePicker1.Value.Day.ToString("00") + dateTimePicker1.Value.Month.ToString("00") + dateTimePicker1.Value.Year.ToString().Replace("20", "") + ".CSV";;
         sbyte[] buf = new sbyte[1024];
         int     len;
         //filename = "EQ" + dateTimePicker1.Value.Day.ToString("00") + dateTimePicker1.Value.Month.ToString("00") + dateTimePicker1.Value.Year.ToString("00") + ".csv" ;
         //filename = filename.Replace("zip", "CSV");
         java.io.FileInputStream      fis = new java.io.FileInputStream(zipFileName);
         java.util.zip.ZipInputStream zis = new java.util.zip.ZipInputStream(fis);
         java.util.zip.ZipEntry       ze;
         while ((ze = zis.getNextEntry()) != null)
         {
             if (fileName == ze.getName())
             {
                 // File name format in zip file is:
                 // folder/subfolder/filename
                 // Let's check...
                 int index = fileName.LastIndexOf('/');
                 if (index > 1)
                 {
                     string        folder = fileName.Substring(0, index);
                     DirectoryInfo di     = new DirectoryInfo(folder);
                     // Create directory if not exists
                     if (!di.Exists)
                     {
                         di.Create();
                     }
                 }
                 java.io.FileOutputStream fos = new java.io.FileOutputStream(fileName);
                 while ((len = zis.read(buf)) >= 0)
                 {
                     fos.write(buf, 0, len);
                 }
                 fos.close();
             }
         }
         zis.close();
         fis.close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Error" + ex.Message.ToString());
     }
     finally
     {
         // Close everything
     }
 }
Exemple #3
0
        static void Main(string[] args)
        {
            string projectDir = System.IO.Directory.GetParent(
                System.IO.Directory.GetParent(
                    Environment.CurrentDirectory.ToString()).ToString()).ToString() + "\\";

            string fileIN = projectDir + @"src\samples\resources\sample-docx.docx";

            string fileOUT      = projectDir + @"OUT\sample-docx2.html";
            string imageDirPath = projectDir + @"OUT\sample-docx2_files";

            System.IO.Directory.CreateDirectory(projectDir + "OUT");
            System.IO.Directory.CreateDirectory(imageDirPath);

            string imageTargetUri = imageDirPath;

            // Programmatically configure Common Logging
            // (alternatively, you could do it declaratively in app.config)
            NameValueCollection commonLoggingproperties = new NameValueCollection();

            commonLoggingproperties["showDateTime"] = "false";
            commonLoggingproperties["level"]        = "INFO";
            LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(commonLoggingproperties);


            ILog log = LogManager.GetCurrentClassLogger();

            log.Info("Hello from Common Logging");

            // Necessary, if slf4j-api and slf4j-NetCommonLogging are separate DLLs
            ikvm.runtime.Startup.addBootClassPathAssembly(
                System.Reflection.Assembly.GetAssembly(
                    typeof(org.slf4j.impl.StaticLoggerBinder)));

            // Configure to find docx4j.properties
            // .. add as URL the dir containing docx4j.properties (not the file itself!)
            Plutext.PropertiesConfigurator.setDocx4jPropertiesDir(projectDir + @"src\samples\resources\");

            // OK, do it..
            WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
                                                    .load(new java.io.File(fileIN));

            java.io.FileOutputStream fos = new java.io.FileOutputStream(new java.io.File(fileOUT));

            org.docx4j.Docx4J.toHTML(wordMLPackage, imageDirPath, imageTargetUri, fos);

            fos.close();

            Console.WriteLine("done!");
        }
        static void Main(string[] args)
        {

            string projectDir = System.IO.Directory.GetParent(
                System.IO.Directory.GetParent(
                Environment.CurrentDirectory.ToString()).ToString()).ToString() + "\\";

            string fileIN = projectDir + @"src\samples\resources\sample-docx.docx";

            string fileOUT = projectDir + @"OUT\sample-docx2.html";
            string imageDirPath = projectDir + @"OUT\sample-docx2_files";

            System.IO.Directory.CreateDirectory(projectDir + "OUT");
            System.IO.Directory.CreateDirectory(imageDirPath);

            string imageTargetUri = imageDirPath;

            // Programmatically configure Common Logging
            // (alternatively, you could do it declaratively in app.config)
            NameValueCollection commonLoggingproperties = new NameValueCollection();
            commonLoggingproperties["showDateTime"] = "false";
            commonLoggingproperties["level"] = "INFO";
            LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(commonLoggingproperties);


            ILog log = LogManager.GetCurrentClassLogger();
            log.Info("Hello from Common Logging" );

            // Necessary, if slf4j-api and slf4j-NetCommonLogging are separate DLLs
            ikvm.runtime.Startup.addBootClassPathAssembly(
                System.Reflection.Assembly.GetAssembly(
                    typeof(org.slf4j.impl.StaticLoggerBinder)));

            // Configure to find docx4j.properties
            // .. add as URL the dir containing docx4j.properties (not the file itself!)
            Plutext.PropertiesConfigurator.setDocx4jPropertiesDir(projectDir +@"src\samples\resources\");

            // OK, do it..
            WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
                    .load(new java.io.File(fileIN));

            java.io.FileOutputStream fos = new java.io.FileOutputStream(new java.io.File(fileOUT));

            org.docx4j.Docx4J.toHTML(wordMLPackage, imageDirPath, imageTargetUri, fos);

            fos.close();

            Console.WriteLine("done!");

        }
Exemple #5
0
 public static bool writeObjectToFile(string fileName, object obj)
 {
     try
     {
         java.io.File f = new java.io.File(fileName);
         f.setWritable(true);
         java.io.FileOutputStream   fout = new java.io.FileOutputStream(f);
         java.io.ObjectOutputStream oo   = new java.io.ObjectOutputStream(fout);
         oo.writeObject(obj);
         fout.close();
         return(true);
     }
     catch (System.Exception)
     {
         return(false);
     }
 }
        /// <summary>
        /// AUTHOR: Ashok Kolwal
        /// COMPANY: VITRANA
        /// Version: 1.0
        /// Description: The IDfSysObject.getContent() command lets you get the contents of a document as a ByteArrayInputStream
        /// Last Modified date: 11 Jul,2017
        /// </summary>
        /// <param name="sessionManager"></param>
        /// <param name="repositoryName"></param>
        /// <param name="objectIdString"></param>
        /// <returns></returns>
        public bool GetContent(IDfSessionManager sessionManager, String repositoryName, String objectIdString, String outputFolderPath)
        {
            IDfSession mySession = null;
            bool       result    = false;

            try
            {
                mySession = sessionManager.getSession(repositoryName);
                // Get the object ID based on the object ID string.
                IDfId idObj = mySession.getIdByQualification("dm_sysobject where r_object_id='" + objectIdString + "'");
                // Instantiate an object from the ID.
                IDfSysObject sysObj = (IDfSysObject)mySession.getObject(idObj);
                // This is file output path plus file name.
                string fileFullPath = string.Concat(outputFolderPath, "\\", sysObj.getObjectName(), ".", sysObj.getContentType());
                java.io.ByteArrayInputStream inputByteStrm = sysObj.getContent();
                java.io.InputStream          inputStrm     = inputByteStrm;
                java.io.OutputStream         outputStrm    = new java.io.FileOutputStream(fileFullPath);
                // Transfer bytes from in to out
                byte[] byteArry = new byte[30720];
                int    len      = 0;
                while ((len = inputStrm.read(byteArry)) > 0)
                {
                    outputStrm.write(byteArry, 0, len);
                }
                inputStrm.close();
                outputStrm.close();
                result = true;
                // Console.WriteLine("Document has been exported with Name: " + Path.GetFileName(fileFullPath));
            }
            // Handle any exceptions.
            catch (Exception ex)
            {
                // Console.WriteLine(ex.Message);
                throw new Exception("[GetContent] Error: " + ex.Message, ex);
            }
            // Always, always, release the session in the "finally" clause.
            finally
            {
                sessionManager.release(mySession);
            }

            return(result);
        }
Exemple #7
0
        /// <summary>
        /// Extract the first file from a Zip file in the form of a byte array
        /// </summary>
        /// <param name="ba"></param>
        /// <param name="outputFile"></param>

        public static void ExtractFirstFile(
            byte[] ba,
            string outputFile)
        {
            string     tempZipFile = TempFile.GetTempFileName();         // temp file for zip file
            FileStream fs          = new FileStream(tempZipFile, FileMode.Create);

            fs.Write(ba, 0, ba.Length);
            fs.Close();

            ZipFile currentFile = new ZipFile(tempZipFile);

            foreach (ZipEntry entry in new EnumerationAdapter(new EnumerationMethod(currentFile.entries)))
            {             // extract first file from the .zip file
                if (entry.isDirectory())
                {
                    continue;
                }
                java.io.InputStream s = currentFile.getInputStream(entry);
                try
                {
                    java.io.FileOutputStream dest = new java.io.FileOutputStream(outputFile);
                    try
                    {
                        ZipUtils.CopyStream(s, dest);
                    }
                    finally
                    {
                        dest.close();
                    }
                }
                finally
                {
                    s.close();
                    FileUtil.DeleteFile(tempZipFile);
                }

                break;
            }
        }
 /// <hide></hide>
 public virtual void dumpGfxInfo(java.io.FileDescriptor fd)
 {
     java.io.FileOutputStream fout = new java.io.FileOutputStream(fd);
     java.io.PrintWriter      pw   = new java.io.PrintWriter(fout);
     try
     {
         lock (this)
         {
             if (mViews != null)
             {
                 pw.println("View hierarchy:");
                 int   count            = mViews.Length;
                 int   viewsCount       = 0;
                 int   displayListsSize = 0;
                 int[] info             = new int[2];
                 {
                     for (int i = 0; i < count; i++)
                     {
                         android.view.ViewRootImpl root = mRoots[i];
                         root.dumpGfxInfo(pw, info);
                         string name = root.GetType().FullName + '@' + Sharpen.Util.IntToHexString(GetHashCode
                                                                                                       ());
                         pw.printf("  %s: %d views, %.2f kB (display lists)\n", name, info[0], info[1] / 1024.0f
                                   );
                         viewsCount       += info[0];
                         displayListsSize += info[1];
                     }
                 }
                 pw.printf("\nTotal ViewRootImpl: %d\n", count);
                 pw.printf("Total Views:        %d\n", viewsCount);
                 pw.printf("Total DisplayList:  %.2f kB\n\n", displayListsSize / 1024.0f);
             }
         }
     }
     finally
     {
         pw.flush();
     }
 }
Exemple #9
0
        /// <summary>
        /// Extract files from a ZipFile to a file folder
        /// </summary>
        /// <param name="file"></param>
        /// <param name="path"></param>
        /// <param name="filter"></param>

        public static void ExtractZipFile(
            ZipFile file,
            string path,
            FilterEntryMethod filter = null)
        {
            foreach (ZipEntry entry in new EnumerationAdapter(new EnumerationMethod(file.entries)))
            {
                if (!entry.isDirectory())
                {
                    if ((filter == null || filter(entry)))
                    {
                        java.io.InputStream s = file.getInputStream(entry);
                        try
                        {
                            string fname   = System.IO.Path.GetFileName(entry.getName());
                            string newpath = System.IO.Path.Combine(path, System.IO.Path.GetDirectoryName(entry.getName()));

                            System.IO.Directory.CreateDirectory(newpath);

                            java.io.FileOutputStream dest = new java.io.FileOutputStream(System.IO.Path.Combine(newpath, fname));
                            try
                            {
                                CopyStream(s, dest);
                            }
                            finally
                            {
                                dest.close();
                            }
                        }
                        finally
                        {
                            s.close();
                        }
                    }
                }
            }
        }
Exemple #10
0
        static void Main(string[] args)
        {
            // set up logging
            clog = LoggingConfigurator.configureLogging();
            clog.Info("Hello from Common Logging");

            string projectDir = System.IO.Directory.GetParent(
                System.IO.Directory.GetParent(
                Environment.CurrentDirectory.ToString()).ToString()).ToString() + "\\";

            string fileIN = projectDir + @"src\samples\resources\sample-docx.docx";

            string fileOUT = projectDir + @"OUT\sample-docx2.html";
            string imageDirPath = projectDir + @"OUT\sample-docx2_files";

            System.IO.Directory.CreateDirectory(projectDir + "OUT");
            System.IO.Directory.CreateDirectory(imageDirPath);

            string imageTargetUri = imageDirPath;

            // Configure to find docx4j.properties
            // .. add as URL the dir containing docx4j.properties (not the file itself!)
            Plutext.PropertiesConfigurator.setDocx4jPropertiesDir(projectDir +@"src\samples\resources\");

            // OK, do it..
            WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage
                    .load(new java.io.File(fileIN));

            java.io.FileOutputStream fos = new java.io.FileOutputStream(new java.io.File(fileOUT));

            org.docx4j.Docx4J.toHTML(wordMLPackage, imageDirPath, imageTargetUri, fos);

            fos.close();

            Console.WriteLine("done!");

        }
Exemple #11
0
		public override java.io.FileOutputStream openFileOutput(string name, int mode)
		{
			bool append = (mode & MODE_APPEND) != 0;
			java.io.File f = makeFilename(getFilesDir(), name);
			try
			{
				java.io.FileOutputStream fos = new java.io.FileOutputStream(f, append);
				setFilePermissionsFromMode(f.getPath(), mode, 0);
				return fos;
			}
			catch (java.io.FileNotFoundException)
			{
			}
			java.io.File parent = f.getParentFile();
			parent.mkdir();
			android.os.FileUtils.setPermissions(parent.getPath(), android.os.FileUtils.S_IRWXU
				 | android.os.FileUtils.S_IRWXG | android.os.FileUtils.S_IXOTH, -1, -1);
			java.io.FileOutputStream fos_1 = new java.io.FileOutputStream(f, append);
			setFilePermissionsFromMode(f.getPath(), mode, 0);
			return fos_1;
		}
 /// <summary>
 /// Writes a stream of bytes representing an audio file of the file format
 /// indicated to the external file provided.
 /// </summary>
 /// <remarks>
 /// Writes a stream of bytes representing an audio file of the file format
 /// indicated to the external file provided.
 /// </remarks>
 /// <param name="stream">
 /// - the audio input stream containing audio data to be written
 /// to the file.
 /// </param>
 /// <param name="fileType">- file type to be written to the file.</param>
 /// <param name="out">- external file to which the file data should be written.</param>
 /// <returns>the number of bytes written to the file.</returns>
 /// <exception>
 /// IOException
 /// - if an I/O exception occurs.
 /// </exception>
 /// <exception>
 /// IllegalArgumentException
 /// - if the file format is not supported by the system
 /// </exception>
 /// <seealso cref="javax.sound.sampled.spi.AudioFileWriter.isFileTypeSupported(javax.sound.sampled.AudioFileFormat.Type)
 /// 	">javax.sound.sampled.spi.AudioFileWriter.isFileTypeSupported(javax.sound.sampled.AudioFileFormat.Type)
 /// 	</seealso>
 /// <seealso cref="getAudioFileTypes()">getAudioFileTypes()</seealso>
 /// <exception cref="System.IO.IOException"></exception>
 public override int write(javax.sound.sampled.AudioInputStream stream, javax.sound.sampled.AudioFileFormat.Type
     fileType, java.io.File @out)
 {
     javax.sound.sampled.AudioFileFormat.Type[] formats = getAudioFileTypes(stream);
     if (formats != null && formats.Length > 0)
     {
         java.io.FileOutputStream fos = new java.io.FileOutputStream(@out);
         return write(stream, fos);
     }
     else
     {
         throw new System.ArgumentException("cannot write given file type");
     }
 }
Exemple #13
0
        private void CreateUeBF(string putanjaDoKnjige)
        {
            java.io.FileOutputStream fos = new java.io.FileOutputStream(putanjaDoKnjige);
            java.util.zip.ZipOutputStream zos = new java.util.zip.ZipOutputStream(fos);

            string[] priv = path.Substring(3).Replace('\\', '/').Split('/');
            AddToZip(fos, zos, path, priv[priv.Length - 1]);

            saveMeta(fos, zos);

               /*     if (path.Contains("pdf"))
            {
                CreateSWF(path);
                string swfPath = Application.StartupPath + "\\" + isbn + ".swf";
                while (!File.Exists(swfPath)) { Thread.Sleep(2000); };
                AddToZip(fos, zos, swfPath, isbn + ".swf");
                System.IO.File.Delete(swfPath);
            } */

            zos.close();
            fos.close();
        }
 private void setWallpaper(java.io.InputStream data, java.io.FileOutputStream fos)
 {
     throw new System.NotImplementedException();
 }
		/// <summary>
		/// Method for constructing JSON generator for writing JSON content
		/// to specified file, overwriting contents it might have (or creating
		/// it if such file does not yet exist).
		/// </summary>
		/// <remarks>
		/// Method for constructing JSON generator for writing JSON content
		/// to specified file, overwriting contents it might have (or creating
		/// it if such file does not yet exist).
		/// Encoding to use must be specified, and needs to be one of available
		/// types (as per JSON specification).
		/// <p>
		/// Underlying stream <b>is owned</b> by the generator constructed,
		/// i.e. generator will handle closing of file when
		/// <see cref="JsonGenerator.close()"/>
		/// is called.
		/// </remarks>
		/// <param name="f">File to write contents to</param>
		/// <param name="enc">Character encoding to use</param>
		/// <since>2.1</since>
		/// <exception cref="System.IO.IOException"/>
		public virtual com.fasterxml.jackson.core.JsonGenerator createGenerator(Sharpen.FilePath
			 f, com.fasterxml.jackson.core.JsonEncoding enc)
		{
			Sharpen.OutputStream @out = new java.io.FileOutputStream(f);
			// true -> yes, we have to manage the stream since we created it
			com.fasterxml.jackson.core.io.IOContext ctxt = _createContext(@out, true);
			ctxt.setEncoding(enc);
			if (enc == com.fasterxml.jackson.core.JsonEncoding.UTF8)
			{
				return _createUTF8Generator(_decorate(@out, ctxt), ctxt);
			}
			System.IO.TextWriter w = _createWriter(@out, enc, ctxt);
			return _createGenerator(_decorate(w, ctxt), ctxt);
		}
Exemple #16
0
 public static bool sync(java.io.FileOutputStream stream)
 {
     throw new System.NotImplementedException();
 }
Exemple #17
0
		/// <hide></hide>
		public virtual void dumpGfxInfo(java.io.FileDescriptor fd)
		{
			java.io.FileOutputStream fout = new java.io.FileOutputStream(fd);
			java.io.PrintWriter pw = new java.io.PrintWriter(fout);
			try
			{
				lock (this)
				{
					if (mViews != null)
					{
						pw.println("View hierarchy:");
						int count = mViews.Length;
						int viewsCount = 0;
						int displayListsSize = 0;
						int[] info = new int[2];
						{
							for (int i = 0; i < count; i++)
							{
								android.view.ViewRootImpl root = mRoots[i];
								root.dumpGfxInfo(pw, info);
								string name = root.GetType().FullName + '@' + Sharpen.Util.IntToHexString(GetHashCode
									());
								pw.printf("  %s: %d views, %.2f kB (display lists)\n", name, info[0], info[1] / 1024.0f
									);
								viewsCount += info[0];
								displayListsSize += info[1];
							}
						}
						pw.printf("\nTotal ViewRootImpl: %d\n", count);
						pw.printf("Total Views:        %d\n", viewsCount);
						pw.printf("Total DisplayList:  %.2f kB\n\n", displayListsSize / 1024.0f);
					}
				}
			}
			finally
			{
				pw.flush();
			}
		}