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.
Related
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.
I have an application that generates a HTML page with data which the user can edit.
At the end I generate a .pdf file with jsPDF.
Is there any way that I can save this generated .pdf on my server-side database?
I'm using PrimeFaces.
Thanks in advance
Updating my solution for other users:
I found the .output('datauristring') method of the jsPDF which returns me a BASE64 String.
Then the String is sent via JSON to my backed bean and converted as my will.
Thanks all for the help! I've found my solution:
Once the user presses on the button to generate the .pdf, I'll save all the data he filled on the database, just the data.
When the user wants to see the pdf he generated back, I'll generate a new one with the data collected on his first submit.
Thank you all for the answers, they were helpful.
I suggest to use wkhtmltopdf.
It is a open source cross platform command line tool to generate pdf files from html content.
So to your requirement what you can do is, you need to send the html content to the server and save this content into a html file.
Once you saved html content into html you can call wkhtmltopdf like you execute MS-DOS commands in java.
Example: new ProcessBuilder("wkhtmltopdf.exe", htmlFilePath, pdfFilePath);
Once pdf file is generated you can read and store into database.
I have a PHP script that's outputting a CSV file and up until now I've been just using a link and passing parameters that are used to determine the output in the GET data. However recently the size of the data increased and now that code gets Error 414 - Request URI too Large. I tried using a hidden form to do it with POST but it just reloaded the page and didn't supply a prompt to download the file and all of the suggestions I've been able to find online about doing it with AJAX suggest using a link with GET data instead. Does anyone know a workaround that will have the browser still let the user easily download the data?
Presently I'm just setting the href attribute of a <a> tag.
$("#exportCSV").attr('href', "myscript.php/?data=" + exportData);
exportData has become too long for GET data but I want to maintain the behavior where if you click on a link that has say a CSV file being outputted the browser provides a download dialog for the user.
I have an image on my HMTL page. This is generated by DevExpress library at runtime and the src url points to a DevExpress script with a cache key:
<img id="Chart_89_IMG" src="/DXB.axd?DXCache=30f02093-de66-4ed6-8557-2382065c701a" />
I'm trying to get this file onto the server in a subsequent form post to use in an email. I've tried just passing the url in my form, but by the time it gets to the server, I get a 404 (assuming the cache key is expired).
I've also tried using canvas to get the bytes and pass that to the server, but was having trouble converting that byte stream back to an image, and canvas won't work for IE8, which I need to support.
My last idea was to include a file upload input on my form and pass the image to the server that way. But, how can I create a file from an image in javascript to use as an upload?
Any other ideas would be appreciated too!
Since this was DevExpress, I was able to change the BinaryStorageMode to the session:
settings.BinaryStorageMode = BinaryStorageMode.Session;
Then after I posted the form, the chart's bytes were accessible in the Session:
byte[] bytes = ((DevExpress.Web.ASPxClasses.BinaryStorageData)HttpContext.Current.Session[sessionKey]).Content;
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