473,320 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Formatted report shows different when exporting to PDF

tuxalot
200 100+
I have code that adds vertical lines in a report to create an "excel like" table or sorts. When doing a print preview all is well and the report formats correctly. However, when saving directly to PDF the formatting is lost. Here is my code (not sure if this helps). This code also makes use of (2) classes and I can include those as well if needed.

Code to add vertical lines - in the reports GroupHeader On Print event:
Expand|Select|Wrap|Line Numbers
  1. Dim lns As Lines
  2. Dim lngHeight As Long
  3. Dim ctl As Control
  4.  
  5. Set lns = New Lines 'create new Lines collection
  6. Set lns.Parent = Me 'set reference to current report
  7.  
  8. lns.Add 0 'add line to far left
  9.  
  10. For Each ctl In Me.GroupHeader0.Controls 'loop through controls in detail section
  11. If ctl.Height > lngHeight Then lngHeight = ctl.Height        'find tallest control
  12.         'If ctl.ControlType = acTextBox Then lns.Add (ctl.Left + ctl.Width) 'add a line to the right of each text box
  13. If ctl.Tag = "vert" Then lns.Add (ctl.Left + ctl.Width)        'add a line to the right of each text box
  14.  
  15.     Next
  16.  
  17.     lns.Lengths = lngHeight 'Set all line heights to the tallest control's height
  18.  
  19.     lns.Draw        'draw lines
  20.     Set lns = Nothing
  21.     Set ctl = Nothing
Code to print to PDF directly:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OutputTo acOutputReport, "rptIndivSurveySec", acFormatPDF, MyFilename, False, , , _                                         
  2. acExportQualityPrint
How can I print direct to PDF and retain the formatting?

Any help appreciated.
Jan 13 '12 #1
11 5019
NeoPa
32,556 Expert Mod 16PB
The obvious answer appears to be to design the lines into the report itself. You've said nothing so far that explains why this might not be appropriate in your case.
Jan 13 '12 #2
tuxalot
200 100+
Thanks NeoPa. The field height is not consistent throughout the table so the code I am using adjusts the line height appropriately for the height of the fields' contents.
Jan 13 '12 #3
NeoPa
32,556 Expert Mod 16PB
In that case it may still be simpler to design lines in the report and just update the Height properties of them all when required.

PS. Such information really belongs in the question post as it's relevant to the approach to be taken. I'm sure you'll remember for next time :-)
Jan 13 '12 #4
tuxalot
200 100+
I will look into that option - thanks for the direction NeoPa. I had hoped there was a way to invoke a hidden report as a print preview and save the PDF from that, thus retaining my formatting.
Jan 13 '12 #5
NeoPa
32,556 Expert Mod 16PB
I can't say. I still use 2003 and that doesn't include the option to print to PDF at all :-D I'm just basically theorising as I go.
Jan 13 '12 #6
dsatino
393 256MB
2 things:
1. if the line is not on the last saved version, I don't think it will print. So if you go this way, you may need to programatically save the report, print, then delete the lines, then save, then close.

2. Even if it's there, it may not PDF. I lose formatting such as lines, boxes, and even sides of boxes all the time. They are perfectly visible in the print preview, print fine to an actual printer, but just disappear on the PDF. You should probably google PDF related issues to get to the bottom of it.
Jan 13 '12 #7
dsatino
393 256MB
Oh, and NeoPa, Access 2003 does have a PDF plug-in (As long as you have Adobe Acrobat)
Jan 13 '12 #8
NeoPa
32,556 Expert Mod 16PB
... and I've actually used that ;-)

That's not Access 2003 though (It's Adobe Acrobat). I would not expect my experience with Acrobat to be of much help with the inbuilt facility to print to PDF format in later versions of Access.
Jan 13 '12 #9
tuxalot
200 100+
Even if it's there, it may not PDF. I lose formatting such as lines, boxes, and even sides of boxes all the time. They are perfectly visible in the print preview, print fine to an actual printer, but just disappear on the PDF. You should probably google PDF related issues to get to the bottom of it.
Thanks dsatino. However if I do a print preview then create a PDF from that, the formatting is retained.

I suppose if I could open the report in print preview hidden then save the PDF from that, it may work. Something like:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "reportname", acViewNormal, , , acHidden
then while that is open, save to PDF?
Jan 14 '12 #10
tuxalot
200 100+
Got it. The above works. Here is my code:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport "ReportName", acViewPreview, , , acHidden
  2. DoCmd.OutputTo acOutputReport, "ReportName", acFormatPDF, MyFilename, False, , , _                                        
  3. acExportQualityPrint
  4. DoCmd.Close acReport, "ReportName", acSaveNo
Jan 14 '12 #11
NeoPa
32,556 Expert Mod 16PB
Good thinking Tux :-)
Jan 15 '12 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Ali Eghtebas | last post by:
Hi, I tried this demo application in here (watch for any line breaks in the URL): (http://support.crystaldecisions.com/communityCS/FilesAndUpdates/vbnet_win_a dodotnet.exe.asp When exporting...
0
by: George G. | last post by:
I am exporting a report to an Excel file. Whatever options I use for the formatting the results remain the same. I have set the ExcelTabHasColumnHeadings to true and false without any difference. I...
2
by: deko | last post by:
I use a complied query to export to Excel like this: SELECT * INTO . FROM tblExcelData; But I have a situation where I need to export several tables into the same worksheet. The idea is to...
1
by: warlord | last post by:
In order to save typing, I've borrowed the text from a post of nearly 12 months ago.....but the problem still exists. I've been banging my head all day with this, so I'm hoping someone has some...
10
by: john | last post by:
I have a report to print envelopes. The report is based on a query. Now I need to make 10 more queries to make different selections of addresses. Every query has the same output fields as the...
4
by: cybervigilante | last post by:
I sent HTML formatted email, using PHP, to my Yahoo address from my server, and it came out fine, styles and all. I sent it to my gmail address to test it and all I see is the raw html code. But I...
2
by: heba84 | last post by:
i have aproblem when exporting grid view to excel all columns display correct except the arabic ones it SOMETIMES look like garbage I try: Response.Charset = "utf-8"; but it doesnt work ...
3
by: myemail.an | last post by:
Hi all, I use Access 2007 and have come across this error a number of times. I have two tables (customer information) which should contain - ideally - the same data. I create a query to compare...
1
by: allj | last post by:
Hope you had a good Thanksgiving!! I am stumped. I am trying to make a query that looks like the report with different groupings but one that is exportable to a delimited txt file. In my case a...
3
by: sierra7 | last post by:
Hi, I have a report that displays the correct data in Preview but displays #Name? when printed. (Access 2003) The field is unbound but the control source is read from a form =!. & " (Week " &...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.