PDF images (1 Viewer)

kitty77

Registered User.
Local time
Today, 13:29
Joined
May 27, 2019
Messages
712
I have a report that has a background image (jpg or png) and it prints sharp when I print the report. I also have a command button that converts the report to a PDF.
When I print out that PDF, the background image is fuzzy and not sharp. I'm using DoCmd.OutputTo acOutputReport, , acFormatPDF.

When I print the report to Cute PDF or some other PDF writer, it prints sharp. Clearly something is happening when Access converts it to a PDF.

Any ideas how to improve the quality?

Thanks...
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:29
Joined
Oct 29, 2018
Messages
21,467
Unfortunately, when using acFormatPDF we are stuck with relying on the PDF driver MS provided with Access/Office. To use Cute PDF or Adobe, you may have to resort to setting the default printer before printing the report. Just a thought...
 

kitty77

Registered User.
Local time
Today, 13:29
Joined
May 27, 2019
Messages
712
Actually I've narrowed it down a bit more...

My form is doing two things...
First it sends the PDF to a folder. And this one prints out crisp and clear.
DoCmd.OutputTo acOutputReport, , acFormatPDF, "C:\aaa\" & [idnumber] & ".pdf"

The second thing that I'm doing is sending it to email...
This is the one that prints out fuzzy.

Me.Caption = Me.idnumber
DoCmd.SendObject _
acSendReport, _
"Report1", _
acFormatPDF, _
[Memailsent1], _
[Memailsent2], _
, _
"Body of the email", _
True

Why would the two PDF's be different quality?

Thanks...
 

zeroaccess

Active member
Local time
Today, 12:29
Joined
Jan 30, 2020
Messages
671
See my thread here on this topic: https://www.access-programmers.co.u...port-to-outlook-ugly-jpeg-compression.309517/

SendObject seems to default to low quality with compressed images, while printing defaults to high quality.

You will need to save with the right flag:

NGINX:
DoCmd.OutputTo acOutputReport, , acFormatPDF, "C:\Temp\Report.pdf", True, , , acExportQualityPrint

Then attach to Outlook.

https://docs.microsoft.com/en-us/of...lders-and-stores/attach-a-file-to-a-mail-item
https://docs.microsoft.com/en-us/office/vba/api/outlook.attachments.add
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 13:29
Joined
May 21, 2018
Messages
8,527
If the above does not work try
Go under the Office Button>>Access Options>>Current Database
Find where it says "Picture Property Storage Format" and change the setting to "Convert all picture data to bitmaps (compatible with Access 2003 and earlier).
 

kitty77

Registered User.
Local time
Today, 13:29
Joined
May 27, 2019
Messages
712
the acExportQualityPrint has no effect. The PDF is fine in the folder but not when you attach to email. Convert to all picture data is checked off.
PNG or JPG, both are doing the exact same thing. Strange that it does two different things...
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:29
Joined
Oct 29, 2018
Messages
21,467
In that case, you may have to use Outlook Automation to send out the email by attaching the file created by the OutputTo method.
 

kitty77

Registered User.
Local time
Today, 13:29
Joined
May 27, 2019
Messages
712
Can you give me an example? Are you thinking getting the file from the folder?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 10:29
Joined
Oct 29, 2018
Messages
21,467
Can you give me an example? Are you thinking getting the file from the folder?
Yes. You would basically do the following steps in your code:
  1. Use the OutputTo method to create the high res PDF file
  2. Create an Outlook email
  3. Attach the file to the email
  4. Send the email or have the user review it before sending
 

kitty77

Registered User.
Local time
Today, 13:29
Joined
May 27, 2019
Messages
712
Can you show me an example from what I'm currently using?
Thanks...
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 12:29
Joined
Feb 28, 2001
Messages
27,172
I'll step in for an explanation of what is going on.

The reason given earlier for the difference in the two output methods is due to Rendering. You see, in order to convert an image for PDF, the conversion code has to render (pseudo-display) any images and text and symbols and such because the PDF stores those things as images that can be displayed darned near anywhere (which is why it is called "Portable Document Format" or PDF for short).

You will find that you cannot render an image to any quality that the destination device won't support because the rendering software looks at that to decide. So if you have a piece of crud for a printer, your print preview won't look good either. Unfortunately, I don't know what setting you need to alter the rendering software. But you might check just as a really way-out-there (but simple) thing to try... See what is your default printer and see what resolution it is set to. Set it higher if you can. OR if you have an XPS printer, select that. The idea is to boost resolution so that when the rendering software goes to work, it does so to a high standard.

I absolutely have no idea whether that will work for the specific case of the PDF rendering s/w that is part of Access - but I know it works for Print Preview rendering. (Predictably enough, if you were not choosing Print Preview to view a report but were just going to display it on screen, you would get different resolution.) That resolution is a quirk of the software making the image that you are trying to display when it assumes where you are going to send the image.
 

kitty77

Registered User.
Local time
Today, 13:29
Joined
May 27, 2019
Messages
712
I see... Still strange the two are different. Has to a way to get the file attached, so I don't have to attach it manually.

Thanks...
 

zeroaccess

Active member
Local time
Today, 12:29
Joined
Jan 30, 2020
Messages
671
I see... Still strange the two are different. Has to a way to get the file attached, so I don't have to attach it manually.

Thanks...
If you look in my thread above, you will see why: https://www.access-programmers.co.u...ook-ugly-jpeg-compression.309517/post-1668954

When using SendTo, it is using a preset for Email which lowers resolution and uses compression of images. I don't know of a way around it other than to OutputTo with the Print quality flag, then attach manually. I am dealing with this now and should have the code working soon...

I do wish they gave us the quality flag with SendObject.
 

kitty77

Registered User.
Local time
Today, 13:29
Joined
May 27, 2019
Messages
712
How can I make my code work with the suggested code?

MINE
Me.Caption = Me.idnumber
DoCmd.SendObject _
acSendReport, _
"Report1", _
acFormatPDF, _
[Memailsent1], _
[Memailsent2], _
, _
"Body of the email", _
True

SUGGESTED
Private Sub Email()
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.To = "email address"
' .cc = ""
' .bcc = ""
' .Attachments.Add "filepath\filename"
.Subject = "Test"
.HTMLBody = "Test HL: <a href='folder path here'>Link description here</a>"
' .Send
End With
End Sub
 

June7

AWF VIP
Local time
Today, 09:29
Joined
Mar 9, 2014
Messages
5,470
Instead of SendObject code needs to:

1. OpenReport

2. OutputTo

3. Close Report

4. Outlook automation code
 

kitty77

Registered User.
Local time
Today, 13:29
Joined
May 27, 2019
Messages
712
So, I can I do it in VBA code? Or are you suggesting doing those items manually?
 

June7

AWF VIP
Local time
Today, 09:29
Joined
Mar 9, 2014
Messages
5,470
In the code, as stated.

DoCmd.OpenReport …
DoCmd.OutputTo …
DoCmd.Close …

outlook automation code
 

kitty77

Registered User.
Local time
Today, 13:29
Joined
May 27, 2019
Messages
712
Outlook never opens or does anything... Clearly doing something wrong.

Private Sub Command93_Click()
DoCmd.OutputTo acOutputReport, , acFormatPDF, "C:\aaa\" & [idnumber] & ".pdf"
MsgBox "Saved to folder as " & [idnumber] & ".pdf"
Me.Caption = Me.idnumber
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.To = "test@123.com"
' .cc = ""
' .bcc = ""
' .Attachments.Add "filepath\filename"
.Subject = "Test"
.HTMLBody = "Test HL: <a href='folder path here'>Link description here</a>"
' .Send
End With
End Sub
 

June7

AWF VIP
Local time
Today, 09:29
Joined
Mar 9, 2014
Messages
5,470
Need to uncomment the Attachments.Add line - remove the apostrophe at beginning. Also need to replace "filepath\filename" with your file path and name. Save this to a variable earlier in procedure so it is available for the email code.

Change the HTMLBody text to be whatever you want.

Otherwise, code should work. Does for me.
 

Users who are viewing this thread

Top Bottom