Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help With PDF files- URGENT:

Status
Not open for further replies.

FoxLearner

Programmer
Aug 29, 2002
93
US
Hi All
I posted a question yesterday about outlook - access denial. The actual problem is I generate reports in pdf format using Amyuni pdf converter. I need to attach an instruction document which is in PDF format. I thought I can use outlook and attach the report and instructions together to the recipent. But Citrix server where my app runs is denied access to the outlook app on the user's client machine where I activate the outlook app.
I have an alternate idea if it works!

Is there a way in foxpro where I can concatenate/append 2 pdf files? Ex. file1 is my report, file2 is instruction doc. Both are in pdf format.

Can you please shed some light on this, or can suggest any alternate method so that I can open both in IE browser?

Thanks and regards
FoxLearner
 

Wow, PageMaster is exactly what I was looking for a long time.

Thanx for the link!
 
FoxLearner

Of course there are free solutions, but this is assuming that Adobe Acrobat (the full verion is installed). Since Adobe Acrobat can be automated and there is a method to merge two or more pdf documents together. Unfortunatly Adobe is not really helpful when it comes time to disclose the methods and properties of the different COM that composes Acrobat. But if you are using VFP7.0's object browser you can discover the appropriate methods to acheive what you need. It just takes a little digging.
[ol][li]For example if you create two instances of the Acrobat (each one containing a different document)[/li]
[li]On the second document you get the last page number (GetNumPages(), which is one of the parameters required[/li]
[li]The InsertPages method is the oner that will merge your two documents together.[/li]
[li]And finally you would save the merged documnet with the Save method the allows you to name your final documnet.[/li][/ol].

I hope that will help you get started.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
FoxLearner

Here is a couple of functions that will combine all files in a chosen directory (Author:Richard A. Schummer)
Code:
tcDirectory=Getdir()
mergefiles(tcDirectory)
Function mergefiles
Lparameters tcDirectory, tcPDFCombinedFile
Set Step On
Local lcFileSkeleton, ;
	lnPDFCount, ;
	lcCombinedFile, ;
	lcLastFile, ;
	lcResult
Do Case
Case Vartype(tcDirectory) # "C"
	Return "First PDF file parameter not passed as a character"
Case Vartype(tcPDFCombinedFile) # "C"
	tcPDFCombinedFile = Addbs(Fullpath(Curdir())) + "DirectoryCombined.pdf"
Otherwise
Endcase
If Directory(tcDirectory)
	tcDirectory = Addbs(tcDirectory)
Else
	Return tcDirectory + " does not exist"
Endif
Dimension laPDFFiles[1]
lcFileSkeleton = Addbs(Alltrim(tcDirectory)) + "*.pdf"
lnPDFCount     = Adir(laPDFFiles, lcFileSkeleton)
Do Case
Case lnPDFCount > 1
	lcLastFile = tcDirectory + laPDFFiles[1, 1]
	For lnCount = 2 To lnPDFCount
		If lnCount = lnPDFCount
			lcCombinedFile = tcPDFCombinedFile
		Else
			lcCombinedFile = Forceext(Addbs(Sys(2023)) + "Temp" + Alltrim(Str(lnCount)), "PDF")
		Endif
		lcResult   = PdfMerger(lcLastFile, tcDirectory + laPDFFiles[lnCount, 1], lcCombinedFile)
		lcLastFile = lcCombinedFile
	Endfor
Case lnPDFCount = 1
	Copy File laPDFFiles[1, 1] To tcPDFCombinedFile

Otherwise
Endcase
Return
Endfunc
Function PdfMerger
Lparameters tcPDFOne, tcPDFTwo, tcPDFCombined, tlShowAcrobat
#Define  ccSAVEFULL 0x0001
Local loAcrobatExchApp, ;
	loAcrobatExchPDFOne, ;
	loAcrobatExchPDFTwo, ;
	lnLastPage, ;
	lnNumberOfPagesToInsert, ;
	lcOldSafety
Do Case
Case Vartype(tcPDFOne) # "C"
	Return "First PDF file parameter not passed as a character"
Case Vartype(tcPDFTwo) # "C"
	Return "Second PDF file parameter not passed as a character"
Otherwise
Endcase
tcPDFOne      = Forceext(tcPDFOne, "PDF")
tcPDFTwo      = Forceext(tcPDFTwo, "PDF")
If File(tcPDFOne)
	If File(tcPDFTwo)
	Else
		Return tcPDFTwo + " does not exist"
	Endif
Else
	Return tcPDFOne + " does not exist"
Endif
If Vartype(tcPDFCombined) # "C"
	tcPDFCombined = Addbs(Justpath(tcPDFOne)) + "combined.pdf"
Endif
tcPDFCombined = Forceext(tcPDFCombined, "PDF")
Wait Window "Combining " + Justfname(tcPDFOne) + Chr(13) + ;
	"with " + Justfname(tcPDFTwo) + Chr(13) + ;
	"into " + tcPDFCombined + Chr(13) + ;
	"please wait..." Nowait Noclear
lcOldSafety = Set("Safety")
Set Safety Off
Erase tcPDFCombined
Set Safety &lcOldSafety
loAcrobatExchApp    = Createobject("AcroExch.App")
loAcrobatExchPDFOne = Createobject("AcroExch.PDDoc")
loAcrobatExchPDFTwo = Createobject("AcroExch.PDDoc")
If tlShowAcrobat
	loAcrobatExchApp.Show()
Endif
loAcrobatExchPDFOne.Open(tcPDFOne)
lnLastPage = loAcrobatExchPDFOne.GetNumPages() - 1
loAcrobatExchPDFTwo.Open(tcPDFTwo)
lnNumberOfPagesToInsert = loAcrobatExchPDFTwo.GetNumPages()
loAcrobatExchPDFOne.InsertPages(lnLastPage, loAcrobatExchPDFTwo, 0, lnNumberOfPagesToInsert, .T.)
loAcrobatExchPDFTwo.Close()
loAcrobatExchPDFOne.Save(ccSAVEFULL, tcPDFCombined)
loAcrobatExchPDFOne.Close()
loAcrobatExchApp.Exit()
Release loAcrobatExchPDFTwo
Release loAcrobatExchPDFOne
Release loAcrobatExchApp
Wait Clear
Return Space(0)
Endproc
Endfunc
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
I use the Amyuni driver and as long as you keep the psuedo printer active, just keep printing to it and all reports will be contained in the same PDF file. Also the Amyuni documentation discuss merging existing PDF files together. (Page 34 of the ver 2.03 Amyuni PDF Converter Doc)

I had the same problem with CITRIX - the user's outlook PST are on their local machines - not the CITRIX server, so you must have an Outlook Profile on the CIRTIX server to allow you attach and send MAPI emails. To get around this, I use West Wind's ( WWIPStuff which allows SMTP emails (as long as you have a mail server you can connect to). As part of the PDF send, I allow the user to BCC themselves so they get a copy of the PDF (if they want one).

HTH
msc
 
Thank you All for your excellent support.
Thanks once again.
FoxLearner
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top