Set size of jpg file after pdf conversion

ksimpson61

Registered User.
Local time
Today, 00:35
Joined
Sep 8, 2016
Messages
36
I was fortunate to receive help recently on downloading a pdf's and converting them to jpg's. However, some of the images are distorted when they open in the image control in the report. I thought that maybe there was a way to set the size of the image when I am saving them after the conversion and that might eliminate the stretched image in the report. Can anyone help with the code to resize a jpg and re-save the image?
 
You SHOULDN'T convert pdf's to jpg. It will lower the quality.
Just open the PDF in its viewer.
 
Unfortunately, there was not a way to open the pdf in the subreport. I had to convert it to an image in order to view it.
 
Thank you! However, I am too new at this to know how to apply it to my existing code. Of course, my translation may be wrong too. I added the code and then tried to use Resize () in the loop, but I am getting an error - argument not optional. When I try to put in additional arguments, i.e. width and length, I get an error that the path is all it needs.

I have attached a scaled down version of my database - with just a few records included for testing. Any help would be greatly appreciated!!!
 

Attachments

I don't have the acrobat file and get a missing link.
Also, your jpgs are on your L drive and not available to readers.

This is the test routine I have used.

Code:
'---------------------------------------------------------------------------------------
' Procedure : ImageResizeTest
' Author    : mellon
' Date      : 03/03/2016
' Purpose   : Works very well in my test
' Calls:  Redimensionar
'
'* Arguments: strArchivo => file path to resize
'* LngAlto => height in pixels to apply
'* LngAncho => width in pixels to apply
'---------------------------------------------------------------------------------------
'
Sub ImageResizeTest()

Dim sPath As String
   On Error GoTo ImageResizeTest_Error

sPath = "C:/users/mellon/documents/tenancy.jpg"
 Call Redimensionar(sPath, 1500, 1600)

   On Error GoTo 0
   Exit Sub

ImageResizeTest_Error:

    MsgBox "Error " & err.number & " (" & err.Description & ") in procedure ImageResizeTest of Module UtterAccessRelated"
End Sub

It takes my file and resizes it, and names the new file
oldfile.jpg---> oldfile.redim.jpg

The original (oldfile.jpg) still exists.
 
Last edited:
The pdf's are created when the url is downloaded, which is all in the code. I have changed the folder where the pdfs and jpgs will save to wherever the database is located. The URL's should work, but if you don't have Adobe Acrobat, and enable the Acrobat Library, I don't think the process will work.
 

Attachments

I don't have these files



Dim objAcroApp As Acrobat.AcroApp
Dim objAcroAVDoc As Acrobat.AcroAVDoc
Dim objAcroPDDoc As Acrobat.AcroPDDoc


If your jpgs are saved to the file system, then you should be able to reference them similar to the way shown in my test scenario.

sPath = "C:/users/mellon/documents/tenancy.jpg"

You are converting pdf to jpg and saving the jpg in your code
Code:
 .....
  ExportFormat = "com.adobe.acrobat.jpeg" '[COLOR="Red"]<-------------------format[/COLOR]
    
    'Check if the format is correct and there are no errors.
    If Err.Number = 0 Then
        
        'Format is correct and no errors.
        
        NewFilePath = Replace(PDFPath, ".pdf", ".jpg") '[COLOR="Red"]<-----------------Path[/COLOR]
        
        'Save PDF file to the new format.
        boResult = objJSO.SaveAs(NewFilePath, ExportFormat) '[COLOR="Red"]<-------saving the jpg to path[/COLOR]
             ....
 
I am still confused. Do I need to translate the code, or just paste it into my database in Spanish? Where do I paste it? In a new module? or is it a class object?

Disregard this post...
 
Last edited:
I finally got it to work!!!

I saved the original Redimensionar code in Spanish and pasted it into the Convert PDF Code module, then placed your code (except for the Sub line and exit Sub) just after the creation of the jpg. I used sPath = Replace(PDFPath, ".pdf", "_page_2.jpg") in the code to find the jpeg that needed to be resized.

It seems to be working perfectly. I will find out how the images actually look after it has finished updating all the files. :)

Thank you!!!
 
standard module
Glad to see it's working.
Good luck with your project.
 

Users who are viewing this thread

Back
Top Bottom