Create template with variables and convert to PDF - templates

I have a client, that sells stuff and has to send a PDF with variable information (customers name and address, generated numbers...)
Currently we get a couple of templates (about 10 at the moment) for that from our client - in .docx We take those, fill in the variables and convert it to a PDF for sending to the customer.
As you can imagine, this is really a pain for us, because we always have to fix some formatting issues in there.
Is there a "best practice" on how to do this? We really don't want to work fix word files and it should also be very easy for our client. I was thinking about some kind of WYSIWYG editor that creates a PDF out of html?
Does anyone has any other suggestion or experience with this issue?

Related

Django Upload File, Analyise Conents and write to DB or update form

I'm pretty new to Django, Trying to get my grips with it, and expand what I think its capable of doing, and maybe one of you more intelligent people here can point me in the right direction.
I'm basically trying to build a system similar to a so called "Asset Management" system, to track software version of a product, so when an engineer updates the software version, they run a script which gathers all the information (Version, Install date, Hardware etc), which is stored in a .txt file, The engineer then comes back to the website and upload this .txt file for that customer, and it automatically updates the fields in the form, or directly to the database.
While, I've search a bit on here for concepts, I haven't been able to find something similar (Maybe my search terms aren't correct?), and wanted to ask if anyone knows, what I'm doing is even feasible, or am I lost down the rabbit hole of limitations :) Maybe its not do-able within Django, Any suggestions on how I should approach such a problem would be greatly appreciated.
What you're asking is doable both in the form and post-submit of a form or file upload.
In the form approach you'll want a live-reload of the form should the data come from a .txt file. That can be done with JavaScript. This will mean that the data will come from the text file and be input into the forms in the manner you define. This also means form validation will work as you want it to.
Another option is to require a txt file in a specified format, and parse it in the view, form_valid() for Class-Based Views, and request.FILES[] for function based views, and then perform all the required validations and then save the values to the database as the model instance.

Django -- printing lots of documents?

I have a Django app that stores client data. Currently, there are just over 1,000 clients in the database. Twice a year, I need to print a semi-customized letter for each client. Ideally, I want to be able to click a button/link and the entire batch is sent to the printer; I don't want to have to click "print" for each letter since that would be absurdly time consuming.
I have thought of is using Celery to chug through the process of printing all the documents, but I don't know how that would be accomplished. I would have to 'build' the document and send it to the printer without the user seeing this happen.
The other idea I had was to create a "web page" that contains all the letters on one page. Then the user can hit "Print" and the pages would come out of the printer as a collection of letters. Although, this seems sloppy.
Any ideas?
Thanks
I would advise using wkhtmltopdf for this task. You can then create the required letters from one long html with pagebreaks or separately and print them as you regularly print PDF's.
http://code.google.com/p/wkhtmltopdf/
As wk stands for WebKit it will print exceptionally good quality PDF's. It's a commandline tool that you can just download and run. Small tutorial is here for you.
http://shivul.posterous.com/django-create-dynamic-pdfs-using-wkhtmltopdf
ReportLab is also a good option. But myself I don't want to create raw pdf syntax and Pisa the html library for ReportLab is not really that good. wkhtmltopdf is much better and easier to use.
I'd suggest using something like Reportlab to create the whole thing as a single PDF document that you can send to the printer in one go.
See the docs on generating PDFs from Django.

Django big file transfers

I am looking for a django app that can help smooth the process of uploading big size documents by using HTTP Post.
Documents ranging anything from 150mb to 500mb.
I wrote a small library that handles PDF uploads and parses it to my scribd library and through that embed it onto my site.
Currently my model is quite simple, it takes a FileField, preferably PDF and just and uploads the PDF File, through that makes use of the scribd library and send it directly to scribd for encoding.
The problem is, somewhere along the actual upload process, it times out, no errors in the log, I have adjusted my django apps size for files, Apache's size for files, and I am a bit lost at the moment not knowing where to go from here.
Although I want to eliminate the manual work, so ideally I'd still like to use it through my site.
Any help or pointers would be appreciated.
Probably a bit too late, but, have you tried django-bft

Create PDFs with editable forms in Qt

I'm trying to find out if there's a way to embed an editable text cell in a PDF generated in a Qt application. I'm currently using QPrinter to generate the PDF, but if there's another library that could do this, that would be fine. The environment is limited, though, to C or C++, so libraries like iText are out. In terms of form capabilities, this pdf,
http://examples.itextpdf.com/results/part2/chapter08/text_fields.pdf, is a good example with the exception that I don't need a password text field.
Thanks,
Frank
This may not be terribly helpful, but I'll throw it out there anyway.
wkhtmltopdf is based on QTWebkit.
One of its command line options is to convert HTML fields into PDF fields (off by default).
There's almost no pdf-related code within wkhtmltopdf. Certainly nothing dealing with fields. Something upstream is doing the PDF conversion for them.
So find out what that "something" is and you're golden.
EDIT: That or spend a lot of time writing JNI wrappers for iText. :/ Having done so myself, I can say it'd be much more interesting to write a JNI generator tailored to iText, but far more practical to write a Java app that uses iText and then make JNI calls from your C/C++ app to pass the data it'll need and retrieve any response.
The form field borders are a part of the page, not the field itself. Odd, but that's not the first time I've encountered it. Our own software, LiquidOffice, used to generate fields with backgrounds AcroForms couldn't support the same way (now we use an icon-only button).
Those Real PDF Fields have their visibility flags set to "visible but doesn't print" within the pDF. I doubt wkhtmltopdf will let you control that directly. Patch time.
BUT, you could make a second pass with some PDF manipulation library to go through and change the visibility settings on your fields. I'm partial to iText, but there are many other fish in that particular sea.

excel in django

How can i make user to downlaoad a excel from the django app.i HAVE A MODEL WHICH gives the report.Now i want a option from user can download the file in excel form.ANy Solution
You can output the data as .csv which is easily imported into MS Excel.
http://docs.djangoproject.com/en/dev/howto/outputting-csv/
EDIT
After I wrote that I got curious if there actually was some way to do it directly to excel format and found:
http://www.python-excel.org/
That made me wonder why you didn't google your question before posted it here.....
I'm not sure quite what you're asking. If you're asking how can you generate output that's able to be read into Excel, IMO your best bet is using a CSV (see amoeba's response) as that's pretty generic. There are ways of using true Excel formats as well.
I'm thinking though that perhaps you're asking how you can have a user click a link (or whatever) and have Excel pop up with your data in it? (IOW, you've already generated the output).
I suppose I'd say a few things:
1) It shouldn't be specific to Excel, many users use things like OO.o (thus my CSV suggestion)
2) It's going to vary depending on their browser and how they have it set up. Personally, I don't like pages opening up the "proper application" so I turn all of that off - other people enable it.