NSCoding to java - java

Hee,
I currently am using NSCoding to write my objects to data and save them to an file in objective-c.
Does anybody know if there is a way to use the same coding to decode the object structure in an Java application?
Thanks

Quite probably the easiest way is to use the third-party plist Java library.
Otherwise, you've got the problem that OS X supports two different types of property list — XML and binary. XML's easy enough and the relevant wikipedia page even includes a quick summary of the tags. You can use the command line tool plutil to convert any property list to XML format but the default is binary so that's not much help if you need there to be no manual step in between.
Apple don't seem to have a formal documentation of the binary format, but their code is open source so you can reverse engineer it from here.

Related

Java creating PDF file

I am currently working at a project which generates contracts. The idea is that I put the data in a form and save it in a simple database.
So long, this was my favorite place to search for good ideas and simple solutions.
Now I am facing another problem and I don't know how I can solve that. I want to create a PDF and replace some placeholders with some data from my form.
One idea was, that I use an existing Word template with some bookmarks and replace them with the data from my form. Maybe there is a way to do that, and I am just too stupid to find it.
Another idea was, that I am using XML. Therefore, I thought I was clever and just converted the Word template to an PDF, so I am able to convert that PDF to an XML. Attached, you find the XML file. But now I need the XSL file - is there an easy way to create the XSL file?
Or maybe there is another simple solution to solve my problem.
In these attachments you find the PDF file, the Word template and the XML:
Thank you a lot :)
Using a template is a good idea - it makes some changes much quicker to make and then deploy. The comments above are focused on conversion, but don't forget you need to merge your data in (population) first.
If you can use Adobe tools, you can have a PDF template and use the Adobe tools to populate. This saves a "conversion" stage.
You mentioned using Word for templates. This means you to run through two stages of processing:
population - docx is a zipped set of XML files - so you can process them with your own code or using a library.
conversion - you need pdf, so you have to convert the docx to pdf. You also have to watch out for fonts at this stage (ie make sure they are available on your host).
The population stage you could do yourself since you are familiar with XML. But it is definitely complicated. The conversion needs to use a tool that is ideal for it. There are a few mentioned in the comments already.
There are some free/os and commercial tools that can do both parts:
docx4j
JOD Reports
Libre Office (using the Java Uno API) (I blogged this once - Java Convert Word to PDF with UNO)
Docmosis (please note I work for Docmosis)
I suggest starting with the simple example you have attached and prove you can both populate and convert that. Then switch to a more complicated example to see if you can do the other things that might be required (eg repeating or conditions or other logic) during the population stage.

JSON object flattening to CSV one row

Has anyone ever been involved with exporting JSON like this one in my sample made only for the purposes of this conversation:
https://gist.github.com/slavisah/97b57a5826dc0b49ee22895035eb244a
It represents a list of material objects (wood, metal etc.) Requirement is that every material has to be written in one line of CSV file with all of it's behaviors and properties, and their sub-lists in relation to them in the same row. Every list is N sized.
My question is how to structure that CSV file for easiest export/import in my application? Maybe someone is familiar with Java library which is capable of doing things like this?
Thanks.
Some good libraries for working with csv files using java...
http://www.beanio.org/
http://super-csv.github.io/super-csv/index.html
i suggest you to use Apache poi the Java API for Microsoft Documents : https://poi.apache.org/

Word2Fo Java PlugIn

I'm using Word2Fo to generate XSL-FO code so that my Java application can generate a PDF instead of a Doc. This is all well and good, and I've gotten the raw XSL-FO code now, but there's over a thousand lines of FO instructions, and it would be a pain to go over every single line to format it for Java output in w.write.
Is there any plugin for Word2Fo that can do this automatically on conversion? Directing me to a Word2Fo Plugin library would be help in and of itself as well, since I can't seem to find one naturally existing anywhere.

Java Google Docs API - Document Conversion Tool used in a standalone java program

First time asking something, let's see if I don't mess up.
My question is, I believe, a simple one:
Can one you use the Document Conversion Tool present in the Google Docs API to convert a PPTX/PPT to ODP (OpenDocument Presentation) without any intent of uploading it to Google Docs.
Basically I just want to use the conversion tool and have the file to save. Is it possible?
Thank a bunch for your time.
Your contribution will keep the entire World spinning.. well, at least my World :P
No, it is not possible to use the API to convert file into different formats if they are not uploaded to Google Drive.
You can always upload a file to Drive, convert it to a different format and then delete the original file, but I don't why you might want to do that :)

How to load my data into a GraphML file for easy use in Prefuse?

I'm trying to generate some graphs with prefuse, and it seems like the easiest way to load the data into prefuse is to use a GraphML file.
Is there an easy way to write these files from my data?
Or is there an easier way to load my data into prefuse?
Thanks
yEd can export graphs in GraphML format and JGraphT has a GraphMLExporter. Leaves the problem on how to get your data into those products or libraries. But at least both can create the desired format.
on the other hand - GraphML is in XML format so you can easily use jdom or dom4j to create a DOM, add the nodes based on your data an serialize it to an XML file. This shouldn't be to complicated.
You could use the Network Workbench, which allows you to load data in a lot of different forms including edge lists. Edge lists are usually the easiest format to generate.
I'm not completely sure if you can export from NWB to say GraphML, but NWB includes a number of visualizations, some of which are based on Prefuse.
If you want to do more with your data than just visualize it then NWB might help you.
Check PyGraphML, a basic Python library designed to parse and generate GraphML files. http://hadim.github.io/pygraphml/index.html

Categories

Resources