Omnis kDevOmnisPDF document size

jmv jmvoegeli at bluewin.ch
Wed Feb 16 14:16:02 UTC 2022


Hi Xavier,

I have a solution that uses gs (terminal command)

It is transparent. The "big" pdf is written in a temp folder and then compressed to the needed one (through task variables)

You may want to delete the big ones in the temporary directory.

methods that execute the compression : 


$Reduce_PDF_File_Size of object o_Script

Calculate vScript as ""
Calculate vScript as con(vScript,"set vCommande to",kSp,kDq)
Calculate vScript as con(vScript,"/usr/local/bin/gs",kSp)
Calculate vScript as con(vScript,"-sDEVICE=pdfwrite",kSp)
Calculate vScript as con(vScript,"-dCompatibilityLevel=1.4",kSp)
Calculate vScript as con(vScript,"-dPDFSETTINGS=/ebook",kSp)
Calculate vScript as con(vScript,"-dNOPAUSE",kSp)
Calculate vScript as con(vScript,"-dQUIET",kSp)
Calculate vScript as con(vScript,"-dBATCH",kSp)
Calculate vScript as con(vScript,"-sOutputFile=",pCompressed,kSp)
Calculate vScript as con(vScript,pOriginal)
Calculate vScript as con(vScript,kDq,kCr)
Calculate vScript as con(vScript,"do shell script vCommande",kCr)
Do $runapplescript(vScript,vResult,vTextErr) Returns vError
Quit method vError



Method that init the compression in objet o_Data_Print

If (tBools.bL_Compression)
Calculate iDossier as tData.dT_Dossier
Calculate iFichier as tData.dT_Fichier
Do fObj_Script.$Get_Shared_Folder() Returns vPath_To_Shared_Folder
Calculate vOK as (len(vPath_To_Shared_Folder)>0)
If (vOK)
Calculate vPath as con(vPath,"Omnis/Provi/") ## "/Users/Shared/Omnis/Provi/"
Do fObj_Files.$Test_Directory(vPath,kTrue,kFalse) Returns vOK
If (vOK)
Calculate tData.dT_Dossier as vPath
Calculate tData.dT_Path as con(tData.dT_Dossier,tData.dT_Fichier)
End If
End If
End If
Quit method vOK




tBools and tData are task variables (rows with many columns)

Method of object o_Data_Print that calls the script method :

Calculate vOK as pOK

If (tBools.bL_Compression)
Calculate vPath as con(iDossier,iFichier)
Do fObj_Script.$Reduce_PDF_File_Size(tData.dT_Path,vPath) Returns vError
Calculate tData.dT_Dossier as iDossier
Calculate tData.dT_Fichier as iFichier
Calculate tData.dT_Path as con(tData.dT_Dossier,tData.dT_Fichier)
Calculate vOK as (pOK)&(vError=0)
End If

Quit method vOK


Hope this help

kindly yours,

Jean-Marc



Methods called :

$Get_Shared_Folder of object o_Script
Do method $Get_Current_User_Dir Returns vPath_To_Current_User_Dir
Calculate vPath_To_Shared_Folder as con(vPath_To_Current_User_Dir,kSep,"Shared",kSep)
Quit method vPath_To_Shared_Folder

$Get_Current_User_Dir of object o_Script
Do method $Get_Home Returns vPath_To_Current_User_Dir
Quit method vPath_To_Current_User_Dir

$Get_Home of object o_Script
Calculate vScript as getenv("HOME")
Do FileOps.$convertposixpathtohfspath(vScript,vPath)
Do replaceall(vPath,":",kSep) Returns vHome
Calculate vHome as con(kSep,"Volumes",kSep,vHome,kSep)
Quit method vHome




> I’m printing reports with some images that printed with Omnis built-in pdf takes around 459KB.
> 
> Opening the pdf with macOS Preview and exporting using Quartz Filter Reduce File Size takes only 86KB. Results a very similar image quality.
> 
> The difference in size is big.
> 
> There is no option in Omnis PDF to reduce the output pdf size.
> 
> I’m desktop only but if this pdf documents were generated for mobile devices this could be a big problem.
> 
> I’m only macOS. Is there any tip to reduce the omnis generated pdf without user interaction?
> 
> Any advice will be welcome
> 
> regards
> 
> xavier 
> 
> 
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 



More information about the omnisdev-en mailing list