Missing images in pdfs

i’m using printtopdf to create pdf’s from a panx form.
no options. just printtopdf ‘path’.

the images display correctly in the form but are missing from the pdf files.

this began to occur after migrating my panx installation and databases to a new machine, os 10.15.7.

This is a known bug, when used with OS 10.14 or higher.

It is a known issue that still has to be fixed.

For the moment, when you set those Image Display objects to “scale to fit”; they will print. (This may need some preparation of the pictures to avoid ugly distortions.)

thanks dave and kurt. not great news, though, especially as this db has several forms displaying images in different aspect ratios. hope this is fixed someday.

Experimental work around for printing proportionally scaled images.

I was wondering if an image could be proportionally scaled in a Web Browser Object and then printed in the OS version that does not allow proportionally scaled Image Display Objects to print. I replaced the Image Display Object with a Web Browser Object set to square dimensions (300 x 300 in my example). I set the Web Browser Object to Formula mode and entered this formula:

{<body>
 <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<div class="w3-image">
<image src="}+imageFolder+FileName+{" }+?(val(arraylast(shellscript( ||| sips -g pixelHeight |||+imageFolder+FileName),": "))/val(arraylast(shellscript( ||| sips -g pixelWidth |||+quoted(imageFolder+FileName)),": "))>1,{style="height:100%"},{style="width:100%"})+{>
</div>}

Note: imageFolder is a variable with the path to my image files and FileName is a field containing the file names.

Example:
Browser Images

The formula used for the web browser object will check to see which measurement is the largest and set that to use the full height or width and proportionally scale the other dimension. The down side is that the image will not self center in the browser window and will be aligned to the top/left of the object. I will leave it to others more adept at HTML to figure out how to overcome this restriction.

I don’t have the latest OS version to see if these images will actually print so I have no way to know if this is a workable temporary solution to printing scaled images. They print in my 10.13.6 version but so do the normal proportional image objects. Can anyone test this on a more recent OS version to see if they print properly

1 Like

Gary, I did the test on my Catalina Mac. When I had figured out how to set the path correctly, the Web Browser object displayed three images in their different height / width ratios. I used a Web Browser object in size 600 * 600.

I came up with an approach to do the Math without shell scripts using Panorama X’s imagedimensions( function. Here is my code:

{<body>
 <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
<div class="w3-image">
<image src="file:///}+urlencode(unixpath(info("picturesfolder")+FileName))+{" }+
?(v(imagedimensions(info("picturesfolder")+FileName))/h(imagedimensions(info("picturesfolder")+FileName))>1,
{style="height:100%"},
{style="width:100%"})+{>
</div>
</body>}


But printing those records to PDF was a mixed experience. The screenshot shows the resulting PDF on the right side. The pages of the first and second record remained empty, only the third record (height 609, width 814) was successfully printed.

Thanks for taking the time Kurt. Looks like this will not be of much help with this problem but worth the effort anyway.

FYI, the imagedimensions( function actually uses a shell script to determine the dimensions.

… so I don’t have to write that shell script myself. :slightly_smiling_face:

More to my test: The three pictures have different sizes and orientations, but all have the same resolution (72 dpi). So I have no idea why the first two images will never print.

Another impression: The bigger the difference between the size of the Web Browser object and the size of the displayed image (with other words: the bigger the scaling effort), the greater the probability the object will not print and even the likelihood of a crash when I try to print.

Ok, I have ventured down a new path to overcome the proportional scaling and printing problem. My thinking was to somehow create rescaled image files for use in the actual Image Display Object. Rather than making all the rescaled image files before hand, I thought it would be cool to create them on the fly.

First I created the Image Display Object and set it to a square measurement (300 x 300 in my test) and set the Align option to “Center”. I have a TestImage folder in the same folder as my database containing all the full sized images. Inside this folder I have another folder named Scaled. My image names are in a field I called FileName.

Now the cool part. I put this formula in the Formula panel of the Image Display Object:

?(fileexists(dbinfo("folder","")+{TestImages/Scaled/}
    +FileName),dbinfo("folder","")+{TestImages/Scaled/}
    +FileName,shellscript({sips -Z 300 }+dbinfo("folder","")
    +{TestImages/}+FileName+{ --out }+dbinfo("folder","")
    +{TestImages/Scaled/}+FileName)[0;0]+dbinfo("folder","")
    +{TestImages/Scaled/}+FileName)

What this does is check to see if there already is a scaled version of the image in the TestImages/Scaled folder. If none is found, it runs a shellscript( to create the scaled image file and then uses the path and file name as the output. Note the [0;0] text filter after the shellscript( so that the normal shellscript( return info is ignored and only the path & file name remain. If the scaled image already exists then the path and file name are also given but no shellscript( is run.

In my tests this seems to run reliably and rather fast whether or not the resized image file needs to be created or it already exists. It was cool to have a Finder window open to the Scaled folder and see the new resized images being created as I navigated to each new record. The resizing works to reduce an image down or enlarge up as necessary to make the largest dimension the size you indicate to match your Image Display Object (300 in my example).

Instead of the Scaled folder I used you could save the scaled images in your user’s temporary folder using info(“tempfolder”) or your user’s Cache folder using info(“cachefolder”). If you use the temporary folder the scaled files will be deleted by the system in 3 days and they will not be backed up by Time Machine. Files in the Cache folder are not deleted but are also not backed up by Time Machine.

I don’t know if there are any major drawbacks from this method or if it somehow puts undue stress on Panorama using this type of formula in an Image Display Object.

This is a fascinating idea, Gary. I tried to follow your advice, but could not get the shell script to work on my Catalina Mac.

I then used a 3rd party app (Resize Sense) to get smaller pictures in the “Scaled” folder and then tried to print to PDF. I am sorry: Again no success in Catalina.

After that I went the other way and tried to set the proportions of the Image Display object according to the ratio of the original picture and then scale the object to a given width e.g. your 300 px. Worked nicely on screen, but did not print either.

Using a shellscript( function containing embedded path and file name combinations can be a challenge. I had more than one attempt to get it to run while generating the invalid file error return warning.

Well, at least we tried for a work around on this problem. If I ever get a new iMac with a new system version (I’m waiting for the new models with the Apple silicon to hit the market), I’ll maybe give things another look where I can test ideas first hand and not waste anyone else’s time doing it for me.

Thanks for the feed-back Kurt.