Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Automation of printing PDF files from Web

Posted on 1999-07-30
12
Medium Priority
?
219 Views
Last Modified: 2010-04-30
I am not sure if this is a VB question or not -- we're publishing PDF files on the web.  Instead of manually accessing the Adobe Acrobat reader when clicking on the PDF file Hyperlink method, we'd like to set up a macro driven or some sort of program that would print the files automatically (without having to select File - Print from Adobe's menu).
Thanks.
0
Comment
Question by:kearley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 5
12 Comments
 
LVL 1

Expert Comment

by:bshuler072699
ID: 1528604
Write a VB OCX that will..
Download the PDF
Open and instance of Acrobat
Print the PDF
Clean Up
0
 

Author Comment

by:kearley
ID: 1528605
I'm sorry but I do not know VB but do have experience with VBA.  Wouldn't I have to have the object model for Acrobat to open a PDF file using VB?  How would I download the PDF?
Thanks.  I can increase the points here if need be.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1528606
I do this by having the VB fire up the Adobe reader as a child task and then I use SendKeys to drive it. With a little effort you can open a file, select a single page and print - reliably.

Here is some code to get you started.

'
' Ummm, one final check to derive wether document file actually
' exists. If not tell operator and log event
'
On Error GoTo nopdf
X = 0
X = FileLen(datadrive & "\" & filename)
'
' If we get here then the file exists, good - keep flying
'
On Error GoTo 0
'
sendit ("%WA")                      'Close all windows
sendit ("%FO" & datadrive & "\" & filename & "{enter}")
sendit ("%VG")                      ' Issue page select command
sendit (onpage & "{enter}")         ' Specify page
'
' Ok, right here we need to make a decision about printing
'
If UCase(Trim(param)) = "PRINT" Then
    '
    ' Issue Print command
    '
    sendit ("%FP")
    '
    ' Just the one page
    '
    sendit ("%U{enter}")
End If
'
On Error Resume Next
AppActivate RetVal      'Flip adobe onto screen
DoEvents
'
GoTo drain              'Drop into exit point
' =================
'
' Here if after all of that we can't locate the file
'
nopdf:
Resume nopdf1
'
nopdf1:
'
reply = MsgBox("ERROR!" & vbCrLf & "Document file: " & datadrive & "\" & filename & vbCrLf & "is NOT FOUND!", vbSystemModal + vbCritical + vbOKOnly, "Document Unavailable!")
'
drain:

Here is the SENDIT routine:

Private Sub sendit(txt As String)
'
' Send string to child task
'
On Error Resume Next    'Ignore any errors that occur
AppActivate RetVal      'Make sure child task is active
DoEvents                'Give it a shot to run
SendKeys txt, True      'Tell it what to do and wait
DoEvents                'Cede some more time
'
End Sub

Finally here is where I start Adobe:

RetVal = Shell(Quote & Adobe_Path & Quote, vbMaximizedFocus)

M

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:kearley
ID: 1528607
Ok Mark2150 - I like your answer.  How do I give you the points?
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1528608
First you reject the answer you've got and leave a comment telling me to post for points. I'll get the update and write 'Thanx!' in the box and check the answer button. You'll get the notice and give me a nice 'A' (grin) and I'll get 4x the 200 points you posted!

M

0
 

Author Comment

by:kearley
ID: 1528609
Mark2150 post for the points.
0
 
LVL 12

Accepted Solution

by:
mark2150 earned 800 total points
ID: 1528610
Thank you!

M

0
 

Author Comment

by:kearley
ID: 1528611
Mark2150 - where does the VB code reside? Do I create an active X control that says "Print"? Sorry I'm so illiterate on this, but this is a first time experience for me.
Thanks.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1528612
Basically, yes.

M

0
 
LVL 12

Expert Comment

by:mark2150
ID: 1528613
One other thing you could do is to put a [Print] button in the .PDF itself! With Adobe Exchange you can create a button and mark it "Don't Print" so it won't show when the page prints. You can set the Mouse Down event to run a menu command, File/Print. The button can even be replicated to all pages of the document. This way they open the document and if they want the page they click once on the button and out it comes. No programming required.

M

0
 

Author Comment

by:kearley
ID: 1528614
Ok - one last question.  My situation is that I have a hyperlink on a webpage that opens Adobe Acrobat and the user can print if he/she chooses.  You are talking VB.  How do I create VB code and attach it to the hyperlink?  I don't want Adobe to execute at all, just print the report from a click of the hyperlink.  So I won't be putting a print button in the PDF.  Do you have a book you can refer me to?  Thanks.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 1528615
You have to have the adobe plugin running to view the document. If this is in a web prowser then you either need an external button or a button embedded in the document itself. There's no other place to "stand" to run from.

M

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question