I have an interesting question:
I give the user the option to upload .MSG files to the system,
Inside the DB I keep the BASE64 of the file
Now I want to introduce the .MSG inside a model
And here I am having a problem
I'm unable to convert BASE64 back
I will note that I can see extensions of PDF and WORD
Using the PDFVUWER library...
I do not have a code because I do not know how to do it
Are you asking how to open an MSG file in JS? You'd need to use Outlook Object Model (Application.Session.OpenSharedItem), but that means JS would only be able to do that in IE.
JavaScript doesn't provide anything for drawing MSG files on the page. You need to use Outlook for opening such files if you want to display them to users. But that would be in Outlook (external application), not in the browser. Moreover, Outlook should be installed on the client side.
Instead, I'd recommend keeping the message body represented by the HTMLBody property value from the OOM in the Db. In that case you will be able to display it to a user like a regular web page. Note, the message body requires some processing before saving to the Db, so embedded images could be displayed.
When MSG files are uploaded to the application you can extract the required pieces of the file such as message body and etc. for displaying it at any point later. The MSG file format is described in the Outlook Item (.msg) File Format section of MSDN.
Related
Html:
<iframe [src] ="fileurl" #iframe>
</iframe>
<button (click)="saveDoc()">
</button>
Stuck at savedoc() functionality.
Typescript:
/*api call to get document blob data on load*/
var fileurl = new blob([res.body],{type:application/pdf});
fileurl = URL.createObjectUrl(fileurl);
savedoc(){//here need logic to access edited pdf content as blob }
I am able to view and write in pdf editable fields (as input or checkboxes) but I can't figure out once filled all details, how to save/access that edited PDF content (mostly in blob format) to send back to server when click on save button. I have also tried ng2-pdf-viewer library of npm but same issue. I have to send this edited pdf to server in blob format to replace with existing.
How can I access edited pdf content?
Edited: Alternative approach, if its possible to trigger saveAs event from code to save iFrame pdf in local drive? I am using Window.showSaveFilePicker();but saved file seem corrupted or not exist.
Have a look at PDF-LIB.
It is a great JavaScript library which provides all sorts of tools to manipulate PDF documents. There is even tooling for filling the fields and saving the newly filled PDF.
In a past project, I used this library to capture user information from an HTML form and have it inserted and saved into a PDF.
Note:
Remember that once you have the filled PDF on client side, you must send it back to server side to update the PDF that is stored on the server.
So what I'm trying to do is get text from a file in the same directory as my html file using JavaScript. I want to store an array inside a text file and change it whenever i want instead of constantly having to go into the code, save it, check if it works etc.
I've tried looking around but couldn't find any clear information, most of what I found is using .readAsBinaryString, etc..
I'm mostly seeing things like this but i can't seem find anything which is actually getting information from a textfile without making the person find the text file directory.
function storearray(newval){
var file = "file location;"
var txt = file.txt;
var array = txt.split("|");
txt = txt + newval + " | ";
return array;
}
To read a file from the user's disk you need to use FileReader and the user must explicitly select the file using a file input. (See JavaScript read file without using input).
To read a a file from the website you need to use Ajax (with fetch, XMLHttpRequest or a library that wraps around them like Axios). (See Using fetch from MDN).
If (as it seems here) you want to read data from the website but the website exists only on the user's disk then you still need to use Ajax but will usually run into security restrictions. Some browsers allow you to disable the security protection, but the general solution is to install a web server and load both HTML and the data file using HTTP.
Alternatively, you can store your data in JavaScript (you are generating an array from your text file, you can so that manually or have a build-time script do it) and just load it with a <script> element.
Basically I have a django app that communicates with a chrome extension. I have a bunch of functionality that interfaces with normal HTML pages that's all done by the extension. I want to allow users to have the same functionalities for PDF files. I have a python script which translates the pdf file into an html page.
The problem I run into is when the pdfs are open locally within chrome.
Like the following file:///home/wcr5048/Downloads/sample_pdf.pdf
This is my current solution, it basically gets the html and replaces all the current html, which is just an embedded pdf, and replaces it with the converted pdf(html). But I run into an issue because the "url" isn't really a url, and therefore I can't append html to something that doesn't exist.
function convert_to_html(request) {
console.log('converting to html...');
document.getElementsByTagName('html')[0].innerHTML = request.data;
chrome.runtime.sendMessage({
detail: 'refresh'
});
}
What I don't want to happen is to download a file just like the pdf but one that's been converted into html. I would rather have everything happen automatically.
I only see two possible options:
I create a unique link for the converted pdf file for every user, and then send the raw html string to populate the corresponding view.
I somehow tell the extension to use a popup to cover the entire width of the screen, and then populate it with the data.
Are there any suggested solutions that would be a better fit, and if not, which would be a better solution.
Thanks for viewing
I am building a Discussion Forum as part of a bigger application I am building, the forum is just 1 section of the Application.
For my TextArea fields when posting a new Topic or a Post Reply, I have decided that nothing is as good as the PageDown Markdown Library. It is the same one that StackOverflow uses on all their sites and it works better than many of it's competitors.
The way the library ships though, I am not happy with the default Insert Image functionality. You hit the button to insert an image and it allows you to enter a URL for an Image and then it inserts the proper MarkDown syntax to show the linked image.
This just won't cut it. I need the functionality that you see on StackOverflow! Very similar anyways.
I need it to show a Dialog when you click the Insert Image button, like it does now, but instead of just an input field for a Image URL, it will have 2 filed options...
Upload image from your computer
Insert an Image URL and it will then DOWNLOAD the image from that URL and insert it into the post just as if you had uploaded it from your computer. This is important to not confuse this step. IT should not simply insert the Image linking it to the original Image URL. Instead it will take that URL and download/upload the Image to the same server that the upload from computer option does and then it will insert the NEW Image URL pointing to the newly uploaded image!
Based on some simple HTML like below for a Dialog window with a filed for my Upload from Computer functionality, which I already have working. I need to come up with some JavaScript and PHP that will download/save a remote image to my upload folder on my server when a button is clicked using only the URL that will be inside the URL text input field.
So it will need to do a few things...
Fetch and save an image file to my uploads folder using PHP when the only thing that the PHP function will receive is a URL of the image which could be on the same server or most likely a remote server.
After successfully saving/uploading an image from the URL, the PHP function will return a JSON string with the status/error and if successful then it will also return the actual URL and filename of where the new image is saved on the local server. The JavaScript/AJAX script will receive this JSON response and insert the Markdown syntax for the image into the PageDown editor.
The PHP function will need to ensure that the URL that it is trying to save/download is a valid image file and not some malicious file! Also not simply just some file of the wrong filetype like a non-image file unless we are allowing the file type.
It will be part of a module installed on many dinosaur servers so it needs to work on as many servers as possible too!
From the web
From your computer
I would be greatful of any help, tips, code snippets or anything to help with this. At this stage I really just need to build a nie PHP function that will upload images from a remote URL and also ensure that the URL passed in is a real image file or even better that it is in the allowed file types array!
A couple years ago I had started this but have now lost it and I am starting over and don't remeber much about how I went about doing it then.
The easiest way to download a file from a remote server would be to use copy (http://php.net/manual/en/function.copy.php):
copy('http://someurl.com/image.png', '/var/www/uploads/image.png');
As this function returns a bool, it is easy to determine whether the operation was successful and create a JSON response.
To verify that the file is an actual image, there is unfortunately no way that is 100% sure. It is probably enough to check the mimetype though. You can use finfo for that (http://php.net/manual/en/function.finfo-file.php):
$finfo = finfo_open(FILEINFO_MIME_TYPE);
echo finfo_file($finfo, $filename);
finfo_close($finfo);
For a gif, this would return image/gif for example. You will have to hardcode a list of all mimetypes you want to allow.
I have developed an app that allows the user to fill out text fields with information. I want them to be able to press a button that will make a file with data (a really long array with info on what they typed and where it should go) so they can reload the data at a later date. I don't have a server now, and I am sending this app as a standalone html app to my friends for their use until I get hosing / mySql / etc.
Is there a way that when they click on a button it will take this data (saved as an array, save_data), put it into a file, and basically begin the download process from their web-browser?
And later on, what tech would I need to be looking into to save this into online user accounts?
It is posible, but only if you force your users to use windows and microsoft internet explorer. You can send the html file as a hta file, wich can write and read from data from the hard disk.
check http://msdn.microsoft.com/en-us/library/ms536496%28VS.85%29.aspx
for more information.
An hta file is basically a local html file with some extra tags in the header, and is run (interpreted) locally without security restrictions, like any exe file.
I don't know how to show the complete html code here,(markdown is not for me), so if you want an example:
1 - create a file test.hta, with the standard html, head, body and script tags
2 - inside head tag, insert
<HTA:APPLICATION
ID="oMyApp"
APPLICATIONNAME="test"
BORDER="yes"
CAPTION="yes"
SHOWINTASKBAR="yes"
SINGLEINSTANCE="yes"
SYSMENU="yes">
</HTA:APPLICATION>
3 - inside body tab put a button with onclick="writeText();"
4 - inside the script tag insert
function writeText(){
try{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var fileObject = fso.OpenTextFile("C:\\testhta.txt", 8, true,0);
fileObject.WriteLine('text file written');
fileObject.close();
}catch(ex){
alert(ex);
}
}
5 - save it, doubleclick it, click on the button and you will get a nice "C:\testhta.txt" file with 'text file written' in it.
If you don't have a server, then no ... there is no way to initiate a file download/save based on dynamically generated data with javascript