How to print image in output stream? - progress-4gl

Is it possible to print some text + image with 4GL? I tried several approaches and nothing works for me. My code is below
DEFINE VARIABLE mMyMemPtr AS MEMPTR NO-UNDO.
FILE-INFO:FILE-NAME = "C:\image.png".
SET-SIZE(mMyMemPtr) = FILE-INFO:FILE-SIZE.
INPUT FROM VALUE(FILE-INFO:FILE-NAME) BINARY NO-MAP NO-CONVERT.
IMPORT mMyMemPtr.
INPUT CLOSE.
OUTPUT STREAM printstream TO PRINTER.
PUT "some text: " AT 1 SKIP.
PUT mMyMemPtr.
OUTPUT CLOSE.

Yes and no. It's possible to print images with ABL/Progress 4GL but not that way. You will need some other technique. The easiest way is probably to look into some kind of document format that supports printing. For example creating and printing:
a Word document via ActiveX automation (start here: https://knowledgebase.progress.com/articles/Article/P20445)
an HTML document
a PDF (there are freeware PDF-tools for Progress like the outdated http://www.oehive.org/pdfinclude.html - possibly others as well) or PostScript document
Via any report generator like Crystal, Eclipse BIRT etc.

Related

How to save/export array as PDF in MATLAB

I have a large cell array which I want to export as report-like format. Is it possible to export arrays (strings and numbers) as a PDF file?
For example, say I have this cell array
data = {'Frank' 'Diana' '06-May-2018'}
and I want to export the this array content to a PDF file. In this case it should simply create a PDF file with the text:
Frank Diana 06-May-2018
The only way I know of for MATLAB to generate a PDF file is through a figure window. You can write text to a figure window, and print it to a PDF file:
fh = figure;
ah = axes('parent',fh,'position',[0,0,1,1],'visible','off',...
'xlim',[0,1],'ylim',[0,40],'ydir','reverse',...
'fontsize',14);
text(0.01,1,'text line 1','parent',ah);
text(0.01,2,'text line 2','parent',ah);
print(fh,'-dpdf','output.pdf')
The MATLAB File Exchange has a bunch of submissions that can help you print text to a figure window. Search for the tag "fprintf".
An alternative solution is to write the data to e.g. a Word document, or a Markdown or LaTeX file, and call appropriate programs from within MATLAB to convert those to PDF. The File Exchange has a submission to control Word. The pandoc or pdflatex external programs can be invoked through the ! or system functions.
Yes, easiest is use Matlab Notebook. Make it as pretty as you like.
Suggest to remove matlab-guide tag from your question, doesn't belong there.

Progress 4gl Creating a .xlsx file without excel

Version: 10.2b
I want to create a .xlsx file with progress but the machine this will run on doesn't have excel.
Can someone point me in the right direction about how to do this.
Is there a library already written that can do something like this?
Thanks for any help!
The project was moved to the Free DocxFactory Project.
It was rewritten in C++ with Progress 4GL/ABL wrappers and tutorial.
It is 300x times faster, alot of new features were added including barcodes, paging features etc.
and it's completely free for private and commercial use without any time or feature limits.
HTH
You might find this to be useful: http://www.oehive.org/project/libooxml although it appears that there is nothing there right now. There might also be an older version of that code here: http://www.oehive.org/project/lib
Also -- in many cases the need to provide data to Excel can be satisfied with a Tab or Comma delimited file.
Another trick is to create an HTML table fragment. Excel imports those quite nicely.
A super simple example of how to export a semi-colon delimited file from a temp-table. In 90% of the cases this is enough Excel-support - at least it has been for me.
DEFINE STREAM strCsv.
DEFINE TEMP-TABLE ttExample NO-UNDO
FIELD col1 AS CHARACTER
FIELD col2 AS INTEGER.
CREATE ttExample.
ASSIGN ttExample.col1 = "ABC"
ttExample.col2 = 123.
CREATE ttExample.
ASSIGN ttExample.col1 = "DEF"
ttExample.col2 = 456.
OUTPUT STREAM strCsv TO VALUE("c:\test\test.csv").
FOR EACH ttExample NO-LOCK:
EXPORT DELIMITER ";" ttExample.
END.
OUTPUT STREAM strCsv CLOSE.

Word 2010 additional file format

I'm not sure whether this is the best approach for this or whether I perhaps should ask the question more clearer.
What I want to do is to create an additional file output - e.g. if the user uses Word to create a description consisting of known tags, I want to be able to save this as bbcode.
Now I do have an idea of how to do this, but is there a way to say add another file format to the "Save file"-dialog box and have it run a parser and file writer, that'd read the current document and export it using known bbcode-tags (that perhaps would be adjustable from some configuration window)?
The result would be a file containing bbcode as well as the text information that the user has entered.
How would I hook up my addin to the file output dialog? Is there a way to do this? I'm not sure it's custom XML since I won't be using the XML at all.
Thanks in advance and please excuse my poor English.
Edit: after having a look at the Word 2010 AddIn-project, I figured, that I'm looking for a way to define my own "export"-format. I'd like to export the BBCode to a .txt (or even .bbcode) file. The Microsoft.Office.Interop.Word.WdExportFormat seems to have its own fixed enumeration. Is there a way to add an export-format?
There is some code for this here:
phpbb.com/community/viewtopic.php?f=17&t=395554

Trouble reading text from a pdf in Perl

I am trying to read the text content of a pdf file into a Perl variable. From other SO questions/answers I get the sense that I need to use CAM::PDF. Here's my code:
#!/usr/bin/perl -w
use CAM::PDF;
my $pdf = CAM::PDF->new('1950-01-01.pdf');
print $pdf->numPages(), " pages\n\n";
my $text = $pdf->getPageText(1);
print $text, "\n";
I tried running this on this pdf file. There are no errors reported by Perl. The first print statement works; it prints "2 pages" which is the correct number of pages in this document.
The next print statement does not return anything readable. Here's what the output looks like in Emacs:
2 pages
^A^B^C^D^E^C^F^D^G^H
^D^A^K^L^C^M^D^N^C^M^O^D^P^C^Q^Q^C ^D^R^K^M^O^D ^A^B^C^D^E
^F^G^G^H^E
^K^L
^M^N^E^O^P^E^O^Q^R^S^E
.... more lines with similar codes ....
Is there something I can do to make this work? I don't understand pdf files too well, but I thought that because I can easily copy and paste the text from the PDF file using Acrobat, it must be recognized as text and not an image, so I hoped this meant I could extract it with Perl.
Any guidance would be much appreciated.
PDFs can have different kinds of content. A PDF may not have any readable text at all, only bitmaps and graphical content, for example. The PDF you linked to, has compressed data in it. Open it with a text editor, and you will see that the content is in a "/Filter/FlateDecode" block. Perhaps CAM::PDF doesn't support that. Google FlateDecode for a few ideas.
Looking further into that PDF, i see that it also uses embedded subsets of fonts, with custom encodings. Even if CAM::PDF handles the compression, the custom encoding may be what's throwing it off. This may help: Web page from a software company, describing the problem
I'm fairly certain that the issue isn't with your perl code, it is with the PDF file. I ran the same script on one of my own PDF files, and it works just fine.

Setting an Excel worksheet's custom page size (not the printable area) from Perl

Long story short, all I'm really attempting to do is print my reports on half sheets. I had Kinko's chop a pack of printer paper in half and my laser printer is perfectly happy to suck them in and print the reports properly, if the paper size of the Excel report is set to exactly 8.5" x 5.64".
That can be done easily in Excel, but it's the one and only adjustment, in my project, I wasn't able to automate with Perl using Spreadsheet::WriteExcel. The CPAN documentation states that you can pick from some of the default sizes normally available with Excel, but doesn't provide an option to specify your own paper size.
Even if you establish the custom size you need in Excel beforehand, making it available in future spreadsheets, as one of your selectable paper sizes, there doesn't seem to be an index, using set_paper($index), that would specify that newly established custom size.
Thank you in advance!
#!/usr/local/gnu/bin/perl --
use strict;
use warnings;
use Spreadsheet::WriteExcel;
my $repWB = Spreadsheet::WriteExcel->new('../tmp/test.xls');
my $repWS = $repWB->add_worksheet('AA');
$repWS->set_paper(1);
Since VBScript can do many of these things natively, maybe you could try embedding the necessary VBScript into your main Perl script using Inline:WSC.
You could determine the needed VBScript by recording an Excel macro of you setting the print size. Then embed that code into your main Perl script.
I am the author of Spreadsheet::writeExcel.
As far as I know there isn't an option in Excel to set a custom paper size. This is usually set in the printer (correct me if I am wrong).
Excel can store printer information along with the workbook data so there may be a workaround.
Can you send me a single sheet workbook with data in cell A1 only and a copy with the custom page set and I'll take a look to see if it is possible.
P.S. The available option B5 (index 13) in landscape mode is fairly close: 8.27" x5.83". Or the undocumented "Organiser L" (index 129) which should be half Letter size: 8.5" x 5.5".