Solved Scaling a publisher image not working as expected (1 Viewer)

wackywoo105

Registered User.
Local time
Today, 07:32
Joined
Mar 14, 2014
Messages
203
I capture signatures using an android device and put them in a publisher document that is printed onto a template form. I want to be able to use different devices for signature capture. The problem is the images then have different resolutions. I altered my code to scale the images based on the values found using the original device, but the scaling does not seem to work properly, as evident in the attached image.

Can anyone help with what I am missing here?

Code:
If Not GetSig Like "" Then 'Or Not IsNull(GetSig) Then
    Set ShpTB = DocPub.Pages(1).Shapes.AddPicture _
    (filename:=GetSig, _
    LinkToFile:=msoTrue, _
    SaveWithDocument:=msoFalse, _
    Left:=128 + HorizCor, Top:=650 + VertCor)

With DocPub.Pages(1).Shapes(textboxcount)
'MsgBox .Width
'MsgBox .Height

' 762.75 * 0.258 (original image that fit perfectly was 762.75 in height * 0.258 = 196.79)
SigScale = (196.79 / .Height)
.Width = .Width * SigScale
.Height = .Height * SigScale
End With

20210623_174440.jpg
 

cheekybuddha

AWF VIP
Local time
Today, 15:32
Joined
Jul 21, 2014
Messages
2,272
If your new img has different ratio between width and height then you need to use that as sigscale

Try:
Code:
With DocPub.Pages(1).Shapes(textboxcount)
  SigScale = .Height / .Width
  .Height = 196.79  ' or whatever the appropriate height is
  .Width = .Width * SigScale
End With
 

wackywoo105

Registered User.
Local time
Today, 07:32
Joined
Mar 14, 2014
Messages
203
Hi. Thanks for your reply. I tried the above code but it results in an image that is too big. I then thought to set to the original image size and the convert from that. Sadly that makes the image too small. I feel there is something I'm missing. Could dpi be causing an issue?

Code:
SigScale = .Height / .Width
  .Height = 762.75  ' original image was this height
  .Width = .Width * SigScale

.Width = .Width * 0.258
.Height = .Height * 0.258

Oddly using the above code results in a small image for the original image even though I'm setting its height to the same value. I'm not sure why this would be. Could there be a units issue? Take out the set height and it the correct size again.
 
Last edited:

cheekybuddha

AWF VIP
Local time
Today, 15:32
Joined
Jul 21, 2014
Messages
2,272
What are the height and width values for the new sig image?
 

wackywoo105

Registered User.
Local time
Today, 07:32
Joined
Mar 14, 2014
Messages
203
Properties of original 2047 x 1017 dpi not shown. New image is 1280 x 704 96 dpi.
 

cheekybuddha

AWF VIP
Local time
Today, 15:32
Joined
Jul 21, 2014
Messages
2,272
Also, what is shape 'textboxcount'?

If the sig image is in object ShpTB where is that used?

Can you do something like:
Code:
If Not GetSig Like "" Then 'Or Not IsNull(GetSig) Then
    Set ShpTB = DocPub.Pages(1).Shapes.AddPicture _
    (filename:=GetSig, _
    LinkToFile:=msoTrue, _
    SaveWithDocument:=msoFalse, _
    Left:=128 + HorizCor, Top:=650 + VertCor)
    
With ShpTB
  .LockAspectRatio = msoTrue
  .PictureFormat.FitFrame
End With

' ...
 

wackywoo105

Registered User.
Local time
Today, 07:32
Joined
Mar 14, 2014
Messages
203
textboxcount is just the shape number. Originally I was just using textboxes only. I think I can set the shape to have a particular vertical size when I define it, so will try that and see if it scales the image vertically and horizontally to fit.
 

cheekybuddha

AWF VIP
Local time
Today, 15:32
Joined
Jul 21, 2014
Messages
2,272
OK, let us know how you get on.

I don't think I have ever used Publisher or even ever had it installed so I'm not really very qualified to help! 😬

But those properties in my previous reply seem like a good place to start.
 

wackywoo105

Registered User.
Local time
Today, 07:32
Joined
Mar 14, 2014
Messages
203
The first signature box is 17mm in height so 48.2 points. Specifying the vertical size seems to work as the horizontal size scales by itself. I can't believe it was so simple.

Code:
Left:=128 + HorizCor, Top:=650 + VertCor, Height:=48.2)
 

Users who are viewing this thread

Top Bottom