I have 2 docx files that I am working with. One docx file contains text information of a product (start serial number, length, width, and height). The other docx file contains a sticker label with an image and all of the text information from the first file.
This is what I do currently:
I open the first docx file and copy all of the text information (serial, length, width, and height)
Then I paste each info into the second docx file that contains the formatted label.
If I need to make more than one label, I copy the label and increment the serial number by 1.
This takes a lot of time to make several labels for different products. My goal is to come up with an easier way to take data from one docx and inject it into the other. Also, generating more labels when needed.
My first thought was to extract the docx file to get it's xml contents. Then read the data using javascript, c++, or any other language. Then Ask user to input number of labels to generate, manipulate the xml, and repack it as a docx file.
Then I thought about trying to use the windows office "mail merge" feature, but I have never done this before.
I would like to know if anyone has any suggestions for an easy solution to import data from one docx file and generating labels into another.
I am open for any suggestion.
Also, I am not a professional programmer. I am an undergraduate computer engineering student with some experience in c, c++, java, javascript, python, MIPS assembly, and php.
The only open-source (and probably easier to come by) solution I know know is:
http://poi.apache.org/
http://poi.apache.org/document/quick-guide-xwpf.html
This is a good bet when it comes to speed and it is free software.
But if you open a file, alter it and save it again - the result can be flaky: The formatting can be slightly off. At least in my tests with the pptx counterpart.
I reckon when you have user interaction (web page?) in order to create the document, you can build a small HTTP Api around the library.
There is also: http://www.docx4java.org/trac/docx4j - which I have not tested yet.
You can also go the C#/Redmond way: How do I create the .docx document with Microsoft.Office.Interop.Word?
The Interop (2nd Example in the first answer of the question above) way gives the best result when it comes to the accuracy of the formatting. Basically when you open a file with Interop - it will look the same when you alter and save it. But you cannot use this when interacting with a user - because it starts a separate MS Office process - and I would not count on this from my own user experience. But if you want to generate these files as a batch in a single user session - it will deliver a good result.
I cannot comment on the "OpenXML SDK" library described in the above SO question.
Wath about the Open XML https://www.youtube.com/watch?v=rMnEl6JZ7I8 and website developer http://openxmldeveloper.org/ .
On the site you found sdk for:
Open XML SDK for JavaScript: http://openxmldeveloper.org/wiki/w/wiki/open-xml-sdk-for-javascript.aspx. Demo: http://openxmldeveloper.org/blog/b/openxmldeveloper/p/openxmlsdkjs_demo.aspx
Open XML and Java http://openxmldeveloper.org/blog/b/openxmldeveloper/archive/2006/11/21/openxmlandjava.aspx
.Net Resources http://openxmldeveloper.org/resources/dotnet/m/cc/default.aspx
Related
Intro
Hi, I was looking for answer in the whole Internet (in some way I kind of feel that I know every question in Stack Overflow), but the answers were never appropriate to what I'm looking for. I was trying to avoid posting question here, but situation forced me to do this.
Sorry if the answer is simpler than I think.
I'm in the middle of building my first app in Electron using JavaScript. I think that I should describe it in few words, so flam:ngo™ (which is projects name) should work like this:
User will upload two files:
file with tables (like XLSX or DOC)
file with data and blank spaces (which will be used as a template)
App will import from tables.
Now app should let user choose which rows he's interested in and where in uploaded file he wants them to be placed.
flam:ngo save document in PDF (or DOC).
Clue
Right now I need solutions just for myself and in little simpler form. For now I need flam:ngo just to work with one specify XLSX and with one DOC template, but I stuck. I know which rows in document I will always need, but I don't know what should I write to specify in JS's code that I need exactly this ones (like hey, app, pick only this one, this one and maybe this one) while JS is reading file and I don't know how to create new DOC (or PDF) file, how to write data in specified blank spaces and then at the end: how to save it in direction which I should choose for every time I'm using an app - everything in one, maybe two, processes.
Ending
Could you, please, help me: for now I have implemented file uploader which is importing file in XLSX and which is saving it as CSV, XML oraz HTML. What should I do to keep moving forward?
I really appreciate your help!
PS. For better explanation:
For now this should look like this:
1. "template.docx" is uploaded in the core
2. user uploads .xlsx
3. app reads tables and select rows chosen in code
4. app puts data from chosen rows in specify places
5. app saves file > new life of the app :)
Ok, so it's been a while and app has been already written by me. Maybe this will help someone in the future:
Solution
Packages that helps me with this issue was:
js-xlsx which converts my file to simple HTML file, where cells from my XLSX template file have always the same ID (which was important for me to work with document templates).
officegen which helps me write brand new document based on earlier prepared template.
Rest of it was just Vanilla JS.
Hello as I am dyslexia my text writing skills are not the best, so please bear with me.
I have a problem that I am kind of stuck on.
I have a form on a webpage where a user fills in their details and clicks submit, after that a mail is being sent with a PDF as an attachment to my email. ATM. I am using JsPDF to create the PDF, and that is working fine.
But I now need to create both a PDF and docx/doc(Or some other word compatible file) that is easily editable, so that it is possible to make minor changes before forwarding the document to a 3. party. (Could be for extra personalization of the text)
It is important that it is easy to edit the template for nonskilled coders (Where JsPDF is on the heavy site)
I have without luck tried to find a solution that could use a word file as a template and fill in the users first name, last name, etc. but without luck.
Anyone, who has any idea about how to solve this?
Requirements:
* Opensource/Freeware/onetime payment
** Usable on multiple domains (PHPDOCX is out of my price range)
* Support for custom fonts
* Support for special characters like the Danish "ÆØÅ."
* No installs required on the server, other than PHP (5 or 7), Javascript and HTML.
* The PDF and docx/doc need to be equal in the layout.
* Easy template creation and maintenance (preferable though either plain HTML or word 2016+)
* Support for Images in the template
#Laswrence was right PHPWORD does solve my problem, as I can install the composer on my DEV pc get all dependencies and then upload everything to the server.
The only thing that I am not sure about yet is how to get the PDF part to work as there are some issues with PHPWORD and PDF.
I am trying to figure out how to develop a multi-lingual website. My background in HTML, JS, CSS is not that broad (I have started only a week ago), therefore my understanding of this may not be the best.
For our example we will be creating three language mutations:
English (main one)
Spanish
French.
Here is what I have come across when I started searching for this under uncle Google.
The longest solution I can imagine: Create three folders named en, es, fr. These will contain the replica of the original webpage (e.g. index.html), but will be translated to respective language. Then on the top panel, you will have a button which upon clicking it will redirect used to a different folder (link is hard coded here). This solution is feasible if we are dealing with very small websites (with a few pages).
Second option I have found, was using WordPress plugins (found quite a few of those). Unfortunately, this solution is not viable, as I am not using wordpress to create a website.
Next option (which I believe would be the best), is to have one page for all language mutations, but instead of real text, you would insert some attribute with the key, which will determine what phrase should be inserted here. It could look like data-toTranslate('sTitle') (making this up). The question now would be, where would you store your texts? One option would be into a database, but I have not worked with them (under websites), therefore I would prefer something like a text file / csv file / or something like this. The problem I have with this solution (except the fact that I don't know how to do it yet :) ) is that I am not quite sure how website would react to this in terms of loading time. Maybe this is the best solution for a developer, yet the worst for the website?
Any comments, links or suggestions which would point me in the right direction would be more than welcome!
EDIT: as this question may seem too broad, I will try to trim it a bit down.
As I believe the option number three would be the best, then I would like to know the following things:
1) What do I need to create when I want to store simple key - value pairs (such as in this translation)? If I were in C#, I would e.g. create either simple XML or CSV file and I would parse it during runtime.
2) Can I achieve this with a simple JavaScript, or do I need to create some specific controllers / directives with AngularJS?
Create the english version of the website statically, as this is the main language. You should have a separate ID for every text element (and don't use obe word ids such as "a" "b" etc., so you can easily fibd them later.
Have a file on your server (text file works too) with the ids of fhe text tags, and the text in a format like
welcome-text | ["Welcome to the website" in Spanish]
-------------
Etc...
(Note: yoh need to store the translated sentences, but I don't know Spanish nor France)
Name your file to something like Spanish.txt.
When the page loads, download this file with javascript trough AJAX (this is where the static english version kicks in as a fallback), loop trough the text file and set the texts to the translated version.
You can of course use PHP with MysQL too, but I thought it is a bit overkill for 2 languages.
And yes, this can be done with 100% pure javascript, not even JQuery is required.
I normally using PHP to handle this multilingual. When every moment user view the website, it will set the default language to ENG. But, when the user select other language as the website display language, the website will reload and the PHP code will call the respective language folder to display all the selected language on the website. So, I think you should having few language folder, then dynamic calling each of the folder to get the keywords words and display it.
This will be just a noobie question: This is one step of a multistage process which runs predominantly in IMACROS. So I need a solution which I can access by IMACROS in firefox browser. I have a working solution, but I know there is a faster, better and elegant solution and something which I can run locally on my computer.
I cannot do CTRL+F and search since it will be automated and IMACROS do not support keyboard shortcuts.
I have a imacros script which extracts a text string from a website, feeds it as input to a (my 1000 line text file is preloaded in the text area) online grep utility at: http://www.online-utility.org/text/grep.jsp and then extracts the first matching line and parses the output in required format using javascript and then submits this extracted and parsed text string to another website.
ATTEMPTS & LIMITATIONS:
I tried using imacros SEARCH command, but it takes hardcoded search
string. I need something where it can take the search string as
variable, since the search string changes at every iteration.
I can programs whole thing in javascript and then do all the
processing at each iteration .i.e. read the file, search and then
output), But that will be unnecessary repeated reading the file from local
hard disk and will be CPU intensive. THIS STEP IS DONE 100K+ times a
day. (THIS WILL BE SLOW AND VERY MUCH CPU INTENSIVE, I AM RUNNING THESE
SCRIPTS IN VIRTUALBOX, SO RESOURCES ARE TIGHT)
I can program imacros to output search string to a file and then
write a shell script to run every 0.1 seconds and get content of
this newly created file and use (grep, sed or awk) to search and output in another
file and from where IMACROS can read the string and feed it to
another website. (THIS WILL HAVE ISSUES SINCE SCRIPT WILL BE RUNNING NON-STOP AND I
NEED IT TO BE 100% ACCURATE, ANY ERROR AND IT STOPS THE WHOLE PROCESS DOWNSTREAM AND
I HAVE TO CORRECT IT MANUALLY AT THE END OF THE DAY, PLAUSIBLE SOLUTION WILL BE
SOMETHING WHERE SCRIPT IS CALLED ONLY WHEN REQUIRED, I WILL BE MULTI-THREADING IT)
I need to be able to do it locally on my browser. Something like a search page, with input box for variable string and button to click and then it uses my CPU to search for the string in the HTML which can have the 1000 lines of text embedded in it (so basically it can search the HTML) or it can search the link to the local TXT file and show the output on same page.
A local clone of http://www.online-utility.org/text/grep.jsp will be perfect solution. But without all the ads and extra menus and stuff. Something which can cut short 2-3 seconds of the search and response time the online utility now takes.
Each second saved amounts to a lot of time savings. Simplest, creative and elegant solution is what I am looking for.
I am trying to create/improve a microscope stage tracking system. So far I have written a python code (based on an old matlab one) which takes input from a webcam and uses it to calculate the position of the camera (and thus the stage). I now need to work out how to 'pass' data (an x and y position) to an xml file (which acts as the user interface) where certain positions can be saved etc.
Currently the python script constantly updates a text file, which is then constantly read by the xml file, but I'm wondering if there is a better solution. It has been suggested to me that I create a simple, local 'web server' to host the data, but I can only find information on how to host files which would seem to defeat the purpose...
Is there an easier way of doing this? Ive used python a decent amount (mainly for the numpy and scipy packages), but have little to no experience with web servers or xml...
Thanks
edit: I think this is the relevant part?
function getStagePos(xId,yId){
stagePosStr=getFromServer("file:///c:/stagePos.txt");
if(stagePosStr.substr(0,1)!="!"){
data=stagePosStr.split(",");
document.getElementById(xId).value=data[1];
document.getElementById(yId).value=data[2];
process();
}else{
warningNode.innerHTML="Stage Position too inaccurate";
window.setTimeout('warningNode.innerHTML=""',1000);
}
edit2: sorry for not being clear, this is the 'function' of the xml file (written in javascript?) which (I think) is reading in the two fields from the stagepos.txt file. Currently,this txt file is being updated by a matlab script which I have rewritten (and improved) using python. What I am trying to ask is if there is a way to update the two fields that appear when I open the xml file (which is used to save them at certain values to 'mark' locations on the stage) without first saving them to a text file?
edit3: re: changing tag from python to javascript: the code I posted is from the xml file (didnt realise It was javascript..) but my question relates to a python script which generates two constantly updating (at 30fps) fields and how to 'output' them to this file