Dragging a "file" from Omnis to the operating system.
Paul Mulroney
pmulroney at logicaldevelopments.com.au
Wed Mar 26 00:11:16 UTC 2025
Hi Xavier
We used a JSWorker object and node to access pdf-lib which can do the same thing as you're doing with ghostscript. We published a demo on github, which you're free to use and adapt to your setup:
https://github.com/Logical-Developments/ldpdftools-demo
The demo creates a watermark diagonally across the page, but you could also stamp your order number in a specific position on the page too if you wish.
There's a great deal of power in the toolkit - for example we added the ability to merge PDFs, but you can also do much more.
Regards
Paul.
> On 25 Mar 2025, at 6:03 pm, IT <it at plastipol.com> wrote:
>
> Hi Doug,
>
> I read and store all files as binary. The extension indicates what the file contains. Before storing the document in the database, you can verify that file's content matches the extension by using macos command line tool “file”.
> For example, the command "file -I /Users/xavier/Documents/Word.docx” returns
> "application/vnd.openxmlformats-officedocument.wordprocessingml.document; charset=binary”,
> so you can validate that extension matches the content. Some users can be dangerous by simply changing a file’s extension, mistakenly thinking that this alters its content !
>
> When a user double clicks on documents list in omnis window, omnis writes the binary file back to disk again and it’s opened with excel word, preview, mail, etc as needed, based on the extension.
> I don’t want to manipulate excel, pdf, word, eml, etc in Omnis. I want’t the raw content of a mail message that is dragged from Apple Mail application.
>
> But, for example PDFs, just before storing in the database, are stamped with small number from our order in the very top of the document, so, in the future when you see this document some where, you know which order it came from and it’s a relevant document coming from the database. At the same time I optimize the size because many PDFs coming from customers are extremely big and you can reduce the size with ivdPDFSETTINGS and ivdColorImageResolution settings, without loosing quality.
> I use Ghostscript to accomplish this.
>
>
> Do method calcularPS1 Returns lvText
> Calculate lvText as con('-c ';lvText)
>
> Begin text block
> Text: [ivbin_gs]
> Text: -sDEVICE=pdfwrite
> Text: -dCompatibilityLevel=1.4
> Text: -dPDFSETTINGS=/[ivdPDFSETTINGS]
> Text: -dColorImageResolution=[ivdColorImageResolution]
> Text: -dNOPAUSE
> Text: -dQUIET
> Text: -dBATCH
> Text: -sOutputFile='[pFitxerSortida]'
> Text: [lvText]
> Text: -f '[pFitxerOrigen]'
> End text block
> Get text block lvShellScript
> Calculate lvShellScript as con('do shell script ';kDq;lvShellScript;kDq)
> Do $runapplescript(lvShellScript) Returns lvError
> # Breakpoint
> If lvError=0
> Quit method kFalse
> Else
> Quit method kTrue
> End If
>
>
> Method “calcularPS1” generates Postscript code, which actually writes on the PDF and contains the following:
>
> Begin text block
> Text:'<< /EndPage { 2 eq
> Text: { pop false }
> Text: { gsave /[ivFont] findfont [ivFontSize] scalefont setfont newpath [ivSetgray] setgray 130 [ivMovetoH] [ivMovetoV] moveto ([ivWatermarkText]) false charpath 1 setlinewidth stroke grestore true }
> Text: ifelse } bind >> setpagedevice'
> End text block
> Get text block lvText
> Quit method lvText
>
>
>
> Now I’m evaluating cpdf command line tool (https://community.coherentpdf.com/) which lets perform very interesting operations with PDFs like adding annotations, attaching files, converting PDF to JSON(!) and vice versa among may other useful functions.
>
> regards
>
> xavier
>
>> El 24 mar 2025, a las 18:26, Doug Easterbrook via omnisdev-en <omnisdev-en at lists.omnis-dev.com> escribió:
>>
>> now, if we had the mesage path, we’d still need to read the file and extract the text. I assume its in sone sort of encoding. and why should be do it if mail does for us anyway.
>>
>> There has to be some way to extract the HTML view of the email from the file.
>>
>>
>>
>>
>> there is a subtle thing to this. to make the extract of content from any application into Omnis, we need to know the application the data is coming from, what the application is giving us, and I assume we have to process it ins some way.
>>
>> for example,
>>
>> suppose it is PDF, and dropping a pDF file — I’d want to save it untouched
>> or RTF format, I might want to run it through oWrite to convert it to something displayable
>> or an email - convert to text, or convert to HTML
>> or drag from word, I think I might just want the text, or maybe rich text.
>
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
I saw an ad that said "Radio for sale. $1. Volume stuck on full"
I thought "I can't turn that down"! https://www.facebook.com/DadJokeOfTheDay
--
Paul W. Mulroney We Don't Do Simple Pty Ltd
pmulroney at logicaldevelopments.com.au Trading as Logical Developments
www.logicaldevelopments.com.au ACN 161 009 374
Ph: +61 8 9458 3889 86 Coolgardie Street
BENTLEY WA 6102
More information about the omnisdev-en
mailing list