Convert EPL image to PDF? - ups

I am using the UPS API to generate EPL labels to print on our thermal printer, which is working perfectly using CUPS and lpr.
However, I would like to be able to save that label in a computer-renderable format: GIF, PDF, PostScript - anything, really.
I have not been able to find a library to convert between raw EPL data to any other format. Is there a library that can do this? Or an LPR option or package which will output to a file, rather than a printer? How can I accomplish converting Eltron Programming Language files to something else?

There is no way to programmatically render EPL as an image. Yet.

Related

Autodesk design automation Revit , text file as input

The Revit API I developed, take a text file as input.
the text file looks like as below......
1.002, 20,502, 21.706
12.502, 5,502, 7.706
21.002, 15,502, 14.706
.....................
.....................
(The values are not correct.just imaginary. I am just showing how my text file looks like)
I am basically reading the text data as input.
Now if I want to convert the same API as Design automation API, I guess I will not be able to use "text file" as input.
My question is, what should be file type of input file, if it is consisted of 3d point coordinates as described above.
Should it be Json? If it need to be json, then how I should write it for point coordinates? or any other suggestion for file type will be a big help.
If there is any example code, will be a big help.
In the list for supported input file format, txt file is not included.
If I write a Json file, then please give me some clue, how should I arrange it and read the file for Revit.
Many thanks in advance.
T
Thank you for your query.
The slightly more complex question is how to generate multiple output files.
That is answered by the article
on How to generate dynamic number of output with Design Automation for Revit V3.
In passing, it also mentions multiple input files, saying:
"... For the zipped input file, it's well documented at https://forge.autodesk.com/en/docs/design-automation/v3/tutorials/revit/step6-post-workitem/, but for the output zipped result, it's not so clear..."
Trying to follow that link, I note that it is out of date.
The updated link is:
https://forge.autodesk.com/en/docs/design-automation/v3/tutorials/revit/step7-post-workitem/
Looking at the additional notes on input arguments, I see the instructions on how to pass JSON input data directly in the workitem itself.
I would assume that you can also use a different prefix instead of data:application/json such as data:application/text to pass in the data in its current form.
Please try that out and let us know how it works for you.
Alternatively, you can just stay on the safe side and convert your text data to JSON format.
There are innumerable ways of doing so.
The most minimalistic and simple would look like this:
[1.002, 20,502, 21.706,
12.502, 5,502, 7.706,
21.002, 15,502, 14.706,
...]
That represents on single array of doubles.
A slightly more structured approach might be to pass in an array of triples of doubles like this:
[[1.002, 20,502, 21.706],
[12.502, 5,502, 7.706],
[21.002, 15,502, 14.706],
...]
As you see, it is not hard.
I hope this helps.

Load a CSV template and write data to it via java

I have a CSV template file, say, having 10 columns.
I would like to load this CSV file template, and then write data to the relevant cells(say only to 5 of the 10 cells) through a java program.
I went through JSAPAR, SuperCSV etc, but am not sure whether these libraries have the "stuff" what exactly I need.
Is there any framework supporting this kind of operations?
Checkout freemarker: http://freemarker.org/
Open your text file.
Enter freemarker paramerters for required cells.
Your template file may look something like below:
"Templatetext1","text2","text4", "${myVal4}",${myVal5}","text6", ${myVal7}",${myVal8}",${myVal9}","textInCell10"
Pass in the values, you have your csv from template.
If you want to pass for multiple rows you can use other elements like <#list> etc.
OpenCSV is generally considered the best CSV toolkit for Java. It's a very lightweight library that makes working with CSV dead simple. I would recommend looking at it since it's not among the list of things you've tried yet.

Convert RTF File into HTML in Objective C

How can I convert an RTF file into an HTMLformat ?? I have a text editor which saves the file in rtf format but I need to put the contents on my server. For that I need to convert the rtf file into that of an html.. I am unable to find any help with regards to Objective C . Thanks.
I don't know of any library in objective-c that does rtf to html conversion.
However if you are able to perform the conversion server side then that opens up a lot more possibilities, such as php and c# libraries, as well as gnu utilities.
For example (and you can google for many more):
php: Pa software's RTF to HTML converter (paid product), Martin Mevald's rtf2htm (old GPL'ed software), Marcus Fischer's RTF Parse class (GPL'ed code), Zend's LiveDocX or even alternatives to livedocx on SO alternative-for-phplivedocx .. etc
C#: On SO convert-rtf-to-html, simple-convert-rtf-to-html, or from MS Converting-between-RTF-and-HTML
GNU: GNU's UnRTF utility.
If you really want Objective-c then the source code of the php and GNU solutions could be translated - however that will not be a trivial task. As such I still think your best bet would be to do it server side.

Generate HTML reports containing info stored in pdf files

I would like to generate an html report containing some outputs (graphs, statistics from R). The graphs are saved in pdf files.
My option : perl script that will generate the html report( by converting the pdf into jpeg)
What other options would be ideal in this case?
I am working in UNIX environment.
If you are familiar with R, you can probably look at the knitr package. R2HTML is based on Sweave, which is not quite extensible, and knitr is fully extensible and supports HTML naturually; see a minimal example with source.
You have many choices on how to save R graphics (pdf, png, jpeg, ...); see the dev option (graphical device). So there is no need for conversion from PDF to other bitmap formats on R's side.
You said you had Ruby and C output as well; I'm not sure how you are going to deal with them: do you want to generate the output dynamically (literate programming) or insert them manually? For the former, you can probably use the R function system() to run external programs (e.g. call C to generate PDF and call perl to convert). You can also define knitr hooks to do these jobs, but you may need to more to learn how hooks work in knitr.
Another approach is to convert your PDF output with a batch job, and modify the HTML code, e.g. replace <img src='foobar.pdf' /> with <img src='foobar.jpeg' /> in HTML after you have converted all PDF files to JPEG. This should easier.
If you have control over the how the graphs and statistics are created in R, your easiest approach would probably be using the R2HTML package to generate the HTML directly. This would include an sweave-like approach which would substitute R output in appropriate places in an HTML template.
Also, R can create jpeg files (or gif's) for graphs as easily as it creates PDF's, so that conversion step can be avoided entirely.

How to extract data from a PDF?

My company receives data from an external company via Excel. We export this into SQL Server to run reports on the data. They are now changing to PDF format, is there a way to reliably port the data from the PDF and insert it into our SQL Server 2008 database?
Would this require writing an app or is there an automated way of doing this?
As already mentioned - you will have to write an app to do this, but ideally you would be able to get the raw data from the external company rather than having to process the PDF.
However, if you do want to extract the data from the PDF, I've used iText and found it to be very powerful, reliable and most importantly - free. It comes in Java and .Net flavours - iTextSharp is the .Net version. It allows you to programatically manipulate PDF documents and it will expose the contents of the PDF to the application that you write.
It all depends on how they've included the data within the PDF. Generally speaking, there's two possible scenarios here:
The data is just a text object within a PDF. You'll need to use a tool to extract the text from the PDF then insert it into your database.
The data is contained within form fields in a PDF. You'll need to use a tool to extract data from the form fields and insert it into your database.
Hopefully scenario #2 applies to you because this is precisely what PDF forms are designed for. Scenario #1 is really just a hack that you'd only use if you didn't have any other options. Extracting plain text from a PDF isn't as easy or accurate as you might expect.
If you're receiving a PDF form then all you need to do is match up the right fields in the PDF form with the corresponding fields in your database and then suck in the data. This process could be entirely automated if you wrote your own application.
Would this require writing an app or
is there an automated way of doing
this?
Yes, both of these options would require writing an app or buying an app. If you write your own app then you'll need to find a third-party PDF library that supports retrieving data from form fields or extracting text from a PDF.
Disclaimer: I am affiliated with the makers of ByteScout PDF Extractor SDK tool
Just wanted to share some additional real-life scenarios for text data extraction from PDF:
Scanned image with no searchable text: should be processed by OCR engine (like free Tesseract from Google)
XFA forms: it is the subset of PDF which is supported mostly by Adobe tools. But the data can be extracted as XML data with low level PDF processing tools like iTextSharp or similar tools.
ZUGFeRD PDF files which are just PDF documents with the copy of a form data attached as XML file (which can be extracted with tools like this)
Text incorrectly encoded by some PDF generators (can be restored via OCR engine with some acceptable error rate though).
Using ItextSharp, do the following
using System;
using System.Configuration;
using System.Data.SqlClient;
using System.IO;
using System.Text;
using iTextSharp.text.pdf;
protected void BtnSubmit_Click(object sender, EventArgs e)
{
String FilePath = #"GetFilePath";
StringBuilder sb = new StringBuilder();
PdfReader reader = new PdfReader(FilePath);
PdfStamper myStamp = new PdfStamper(reader, new FileStream(FilePath + "_TMP", FileMode.Create));
AcroFields form = myStamp.AcroFields;
if (form.GetField("GetFieldIdFromPDF") != null)
sb.Append(form.GetField("GetFieldIdFromPDF").ToString());
}
I think you will have to write an application for this. This question talks about extracting data from PDF. After this you can export the data to excel format so that you can preserve the existing import format.
Look for information on "Scraping" the data from the PDF. I believe Adobe has some tools that allow you to do this for simple text but I've not used them.
Honestly though, I would try to do anything you can to get this data in a raw format from your vendor.