I want to generate pdf report.But error in path not found. This code work well in localhost. but not work in live server. On live server all folders are created and set all permission also.
Document doc = new Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35);
var PdfFileName = "/Resources/StatementReport/" + DateTime.Now.ToString("dd/MM/yyyy_hh_mm_ss_tt") + ".pdf";
PdfWriter writer = PdfWriter.GetInstance(doc, new FileStream(Server.MapPath(PdfFileName), FileMode.Create));
This problem was solved.
Error in convert datetime.
I replace fileName Postfix: dd/MM/yyyy_hh_mm_ss_tt TO dd_MM_yyyy_hh_mm_ss_tt
Related
We tried with the below code and cannot able to open in Microsoft Excel. Is this the right way to generate the .xlsb file using NPOI? Please advise
using (var exportdata = new MemoryStream())
{
var name = output.xlsb;
System.Web.HttpContext.Current.Response.Clear();
workbook.Write(exportdata);
System.Web.HttpContext.Current.Response.ContentType = "application / vnd.ms - excel.sheet.binary.macroEnabled.12";
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", string.Format("attachment;filename=" + name + ";"));
System.Web.HttpContext.Current.Response.BinaryWrite(exportdata.ToArray());
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
}
I am writing a script for Indesign that collects the contents from TextStyleRange objects, adds them to a javascript object, and should then write out a JSON file with the stringified JSON.
I can create the JSON just fine, with the contents from all of the TextStyleRanges in the current document, however the final file never gets written.
Here is a simplified example of what I have:
#include "json2.js";
main();
function main(){
myObj = { "key_1": "value_1", "key_2": "value_2" };
myContents = JSON.stringify(myObj, null, 4);
myFile = new File("~/Documents/myproject/en/translation.json");
myFile.open("w");
myFile.write( myContents );
$.writeln( myContents );
myFile.close();
}
In the VSCode debugger I can correctly see the JSON being output by $.writeln, however the file is not being created on disk. Any ideas what might be going wrong?
I'm using Windows 10, and Adobe Indesign 2022.
I have also tried with file edit but no luck:
myFile.open("e", "????", "????");
Actually it was simply that I needed to create the subfolder first:
var parentFolder = myFile.parent;
if (!parentFolder.exists && !parentFolder.create())
throw new Error("Cannot create file in path " + myFile.fsName);
After adding this to my script the folder and the file were created successfully.
I have two build steps
in second step I am launching some UI Test that looks like:
DesiredCapabilities appCapabilities = new DesiredCapabilities();
appCapabilities.SetCapability("app", #"ViewBrowser/bin/Debug/ViewBrowser.exe");
appCapabilities.SetCapability("deviceName", "WPF");
var includeController = new WindowsDriver<WindowsElement>(new Uri(#"http://127.0.0.1:4723"), appCapabilities);
includeController.Manage().Window.Position = new System.Drawing.Point(20, 20);
includeController.CloseApp();
But in my code I need to specify #"ViewBrowser/bin/Debug/ViewBrowser.exe". In my case what i need to place there because Test cannot find .exe file. I am new in Teamcity. Can you advice something?
You can store ViewBrowser.exe in the resource folder or in the folder around your project.
and just take the file path. E.g.
string RunningPath = AppDomain.CurrentDomain.BaseDirectory
+ "path/to/folder/ViewBrowser.exe";
or take from resources
string FileName = string.Format("{0}Resources\\ViewBrowser.exe", Path.GetFullPath(Path.Combine(RunningPath, #"path/to/folder")));
I came across a strange issue while reading files from Ti.Filesystem.applicationDataDirectory. Whenever I want to access the text property of the Ti.Blob returned by Ti.Filesystem.File.read() I get null
var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'foo.key');
var contents = f.read();
Ti.API.debug('contents: ' + JSON.stringify(contents));
var text = contents.text;
Ti.API.debug('text: ' + JSON.stringify(text)); // is NULL
The file was created like so
var f = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,'foo.key');
f.write(JSON.stringify({foo: 'bar'});
I'm developing on Android by the way with 6.0.1.GA
TL;DR it's the file extension that's causing the problem
When looking at the Ti.Blob more thoroughly I found that it says mimeType : application/gpg-keys. After updating my code above so it uses foo.json as filename everything works as expected.
I'm trying to make a script in photoshop that will modify some layers and than export them as a PNG image. I've copied the following code from another place:
function SavePNG(saveFile){
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = true;
pngOpts.quality = 100;
activeDocument.exportDocument(saveFile,ExportType.SAVEFORWEB,pngOpts);
}
The function export the active document of photoshop to the file specified by the saveFile parameter.
It's working fine with simple paths like "C:\images\result.png" but when trying with different paths like "~/Desktop/" or paths with some special characters the file isn't exported, and a "destination folder does not exist" error message appears.
Any idea how can I solve it?
Well, I'm not sure why this is occur but you could try the following modification:
function SavePNG(saveFile){
var tmpFile = "./tmp.png";
tmpFile = new File(tmpFile);
var pngOpts = new ExportOptionsSaveForWeb;
pngOpts.format = SaveDocumentType.PNG
pngOpts.PNG8 = false;
pngOpts.transparency = true;
pngOpts.interlaced = true;
pngOpts.quality = 100;
activeDocument.exportDocument(tmpFile,ExportType.SAVEFORWEB,pngOpts);
tmpFile.rename (saveFile);
tmpFile.changePath(saveFile);
}
it'll export the file into a temporary file and then rename & move it to the requested path, should solve the path problem.
exportDocument expects a full file name, not a folder path.
This works:
activeDocument.exportDocument(new File("~/foo/foo.png"), ExportType.SAVEFORWEB, pngOpts);
This doesn't work and gives the 'destination folder does not exist' error message:
activeDocument.exportDocument(new File("~/foo/"), ExportType.SAVEFORWEB, pngOpts);
For people having this error and not using photoshop-script.
The error might be unbound to the destination folder, but occurs because the folder, which was used for the export step, is deleted. So either
recreate the folder, which was used during recording, or
recreate the export step