*PROCEDURE PDFCREATOR
local m.report_filename, m.pdf_filename, m.pdf_password
m.report_filename = "C:\MiaApp\Reports\MioReport"
m.pdf_filename = "C:\MiaApp\Stampe\MiaStampa.PDF"
m.pdf_password = "" && "MiaPassword"
m.pdf_author = "Autore"
select MiaTabella
do STAMPA_PDF with m.report_filename, m.pdf_filename, m.pdf_password, m.pdf_author
RETURN
*
PROCEDURE STAMPA_PDF
parameters m.pp_report_filename, m.pp_pdf_filename, m.pp_pdf_password, m.pp_pdf_author
private loPDFCreator
loPDFCreator = NULL
local PDFCreatorVersion
PDFCreatorVersion = PDFCREATOR_VERSION()
if PDFCreatorVersion = 0
RETURN
endif
private m.directory, m.filename
m.directory = addbs(iif(! empty(justpath(m.pp_pdf_filename)), justpath(m.pp_pdf_filename), set("default") + curdir()))
m.filename = justfname(m.pp_pdf_filename)
if file(m.directory + m.filename)
local lnResponse
lnResponse = 0
do while .t.
try
erase (m.directory + m.filename) recycle
catch
endtry
if ! file(m.directory + m.filename)
EXIT
endif
lnResponse = messagebox( ;
"Attenzione!" + chr(13) + chr(13) + ;
"Non riesco a cancellare il file " + m.filename + chr(13) + ;
"contenuto nella cartella " + m.directory, ;
5 + 48 + 0, "Crea PDF con PDFCreator", 3000)
if lnResponse = 2
EXIT
endif
enddo
if lnResponse = 2
RETURN
endif
endif
do case
case PDFCreatorVersion > 210
do STAMPA_PDF_200
case PDFCreatorVersion = 210
do STAMPA_PDF_200 with "Beta"
case PDFCreatorVersion = 200
do STAMPA_PDF_200 with "Beta"
case PDFCreatorVersion = 173
do STAMPA_PDF_173
endcase
RETURN
*
FUNCTION PDFCREATOR_VERSION
local PDFCreatorVersion
PDFCreatorVersion = 0
if PDFCreatorVersion = 0
PDFCreatorVersion = 220
*local loPDFCreator as PDFCreator.PDFCreator
try
loPDFCreator = CreateObject("PDFCreator.PDFCreator")
catch
PDFCreatorVersion = 0
endtry
endif
if PDFCreatorVersion = 0
PDFCreatorVersion = 210
*local loPDFCreator as PDFCreatorBeta.PDFCreatorObj
try
loPDFCreator = CreateObject("PDFCreatorBeta.PDFCreatorObj")
catch
PDFCreatorVersion = 0
endtry
endif
if PDFCreatorVersion = 0
PDFCreatorVersion = 200
*local loPDFCreator as PDFCreatorBeta.PDFCreator
try
loPDFCreator = CreateObject("PDFCreatorBeta.PDFCreator")
catch
PDFCreatorVersion = 0
endtry
endif
if PDFCreatorVersion = 0
PDFCreatorVersion = 173
*local loPDFCreator as PDFCreator.clsPDFCreator
try
loPDFCreator = CreateObject("PDFCreator.clsPDFCreator")
catch
PDFCreatorVersion = 0
endtry
endif
RETURN PDFCreatorVersion
*
PROCEDURE STAMPA_PDF_200
lparameters m.beta_version
do case
case empty(m.beta_version)
m.beta_version = ""
case ! empty(m.beta_version)
m.beta_version = "Beta"
endcase
*local loPDFCreator as PDFCreator.PDFCreator
*loPDFCreator = CreateObject("PDFCreator.PDFCreator")
*local loPDFCreator as PDFCreatorBeta.PDFCreatorObj
*loPDFCreator = CreateObject("PDFCreatorBeta.PDFCreatorObj")
*local loPDFCreator as PDFCreatorBeta.PDFCreator
*loPDFCreator = CreateObject("PDFCreatorBeta.PDFCreator")
local lnResponse
lnResponse = 0
do while loPDFCreator.IsInstanceRunning
lnResponse = messagebox( ;
"Attenzione!" + chr(13) + chr(13) + ;
"Per poter proseguire è prima necessario chiudere PDFCreator!", ;
5 + 48 + 0, "Crea PDF con PDFCreator", 3000)
* Riprova 4, Annulla 2
if lnResponse = 2
EXIT
endif
enddo
if lnResponse = 2
RETURN
endif
local loPDFCreatorQueue as PDFCreator.JobQueue
local loPDFCreatorQueue as PDFCreatorBeta.JobQueue
loPDFCreatorQueue = CreateObject("PDFCreator" + m.beta_version + ".JobQueue")
loPDFCreatorQueue.Initialize()
local m.old_printer
m.old_printer = set("PRINTER", 3)
set printer to name "PDFCreator"
report form (m.pp_report_filename) to printer noconsole
set printer to name (m.old_printer)
do while ! loPDFCreatorQueue.WaitForJob(0.1)
doevents
wait window nowait "Attesa creazione file 1 ..."
enddo
wait clear
local loPDFCreatorJob as loPDFCreatorQueue.NextJob
do while .t.
loPDFCreatorJob = loPDFCreatorQueue.NextJob
if ! isnull(loPDFCreatorJob)
EXIT
endif
doevents
wait window nowait "Attesa creazione file 2 ..."
enddo
wait clear
* http://www.pdfforge.org/pdfcreator/manual/singlefileconversion
* 4. Setup the profile of the job with SetProfileByGuid(guid).
* The guid parameter is a string type that is used to assign the apropriate conversion profile(see enumeration below).
* Note: Alternatively, you can use SetProfileByName("MyNameForACertainProfile").
* For the standard profiles it holds that their guids are equal to their names.
* 49. job.SetProfileByGuid("DefaultGuid")
* Alternative:
* job.SetProfileByName("DefaultGuid")
* Guids:
* "DefaultGuid" (for conversions to pdf-files)
* "PrintGuid" (for printing after conversion)
* "HighCompressionGuid"(for highly compressed files)
* "HighQualityGuid" (for high quality files)
* "JpegGuid" (for conversions to jpeg-files)
* "PngGuid" (for conversion to png-files)
* "TiffGuid" (for conversions to tif-files)
* "PdfaGuid" (for conversions to pdfa-files)
loPDFCreatorJob.SetProfileByGuid("DefaultGuid")
*loPDFCreatorJob.SetProfileByName("DefaultGuid")
* http://www.pdfforge.org/pdfcreator/manual/com-interface-settings
*loPDFCreatorJob.SetProfileSetting("AutoSave.Enabled", "True")
*loPDFCreatorJob.SetProfileSetting("AutoSave.EnsureUniqueFilenames", "False")
*loPDFCreatorJob.SetProfileSetting("AutoSave.Enabled", "False")
loPDFCreatorJob.SetProfileSetting("OpenViewer", "False")
loPDFCreatorJob.SetProfileSetting("ShowProgress", "False")
loPDFCreatorJob.SetProfileSetting("TitleTemplate", juststem(m.filename))
if ! empty(m.pp_pdf_author)
loPDFCreatorJob.SetProfileSetting("AuthorTemplate", m.pp_pdf_author)
endif
if ! empty(m.pp_pdf_password)
loPDFCreatorJob.SetProfileSetting("PdfSettings.Security.Enabled", "True") && If true, the PDF file will be password protected
loPDFCreatorJob.SetProfileSetting("PdfSettings.Security.EncryptionLevel", "Aes128Bit") && Defines the encryption level. Valid values are: Rc40Bit, Rc128Bit, Aes128Bit
loPDFCreatorJob.SetProfileSetting("PdfSettings.Security.OwnerPassword", m.pp_pdf_password) && Password that can be used to modify the document
loPDFCreatorJob.SetProfileSetting("PdfSettings.Security.RequireUserPassword", "True") && If true, a password is required to open the document
loPDFCreatorJob.SetProfileSetting("PdfSettings.Security.UserPassword", m.pp_pdf_password) && Password that must be used to open the document (if set)
endif
loPDFCreatorJob.ConvertTo(m.directory + m.filename)
do while ! file(m.directory + m.filename)
doevents
wait window nowait "Attesa creazione file 3 ..."
enddo
wait clear
do while ! loPDFCreatorJob.IsFinished
doevents
wait window nowait "Attesa rilascio file ..."
enddo
wait clear
if ! loPDFCreatorJob.IsSuccessful
messagebox("Errore nella creazione del file PDF!")
endif
loPDFCreatorQueue.ReleaseCom()
RETURN
*
PROCEDURE STAMPA_PDF_173
*local loPDFCreator as PDFCreator.clsPDFCreator
*loPDFCreator = CreateObject("PDFCreator.clsPDFCreator")
if ! loPDFCreator.cStart("/NoProcessingAtStartup")
loPDFCreator.cStart("/NoProcessingAtStartup", 1)
endif
if ! inlist(loPDFCreator.cError.Number, 0, 2)
messagebox( ;
"Errore " + ltrim(str(loPDFCreator.cError.Number)) + chr(13) + chr(13) + ;
loPDFCreator.cError.Description, "Crea PDF con PDFCreator")
RETURN
endif
loPDFCreator.cPrinterStop = 0
loPDFCreator.cOption("AutosaveFormat") = 0
loPDFCreator.cOption("UseAutosave") = 1
loPDFCreator.cOption("UseAutosaveDirectory") = 1
loPDFCreator.cOption("AutosaveDirectory") = m.directory
loPDFCreator.cOption("AutosaveFilename") = m.filename
loPDFCreator.cOption("StandardTitle") = juststem(m.filename)
if ! empty(m.pp_pdf_password)
loPDFCreator.cOption("PDFOwnerPasswordString") = m.pp_pdf_password
loPDFCreator.cOption("PDFOwnerPass") = 1
loPDFCreator.cOption("PDFUseSecurity") = 1
endif
loPDFCreator.cOption("PDFDisallowCopy") = 0
loPDFCreator.cClearcache()
local m.old_printer
m.old_printer = set("PRINTER", 3)
set printer to name "PDFCreator"
report form (m.pp_report_filename) to printer noconsole
set printer to name (m.old_printer)
do while ! file(m.directory + m.filename)
doevents
wait window nowait "Attesa creazione file ..."
enddo
wait clear
do while loPDFCreator.cCountOfPrintjobs > 0
doevents
wait window nowait "Attesa rilascio file ... " + ltrim(str(loPDFCreator.cCountOfPrintjobs))
enddo
wait clear
loPDFCreator.cClose()
RETURN
*
Grazie Gianni, gentilissimo! ;)
Nel frattempo avevo disinstallato e reinstallato Acrobat Reader… e sembra che il problema si sia risolto, mah… non sò che dire…
Utilizzerò il tuo codice per la versione aggiornata.
Ciao.
Da: foxpro...@googlegroups.com [mailto:foxpro...@googlegroups.com] Per conto di Gianni Turri
Inviato: venerdì 11 settembre 2015 11:19
A: Foxpro Italia
Per postare in questo gruppo, invia un'email a foxpro...@googlegroups.com.
Per visualizzare questa discussione sul Web, visita https://groups.google.com/d/msgid/foxpro-italia/3a25c079-a6ff-45fa-a289-8b0d31ae7fe1%40googlegroups.com.
Per altre opzioni visita https://groups.google.com/d/optout.
--
Hai ricevuto questo messaggio perché sei iscritto al gruppo "Foxpro Italia" di Google Gruppi.
Per annullare l'iscrizione a questo gruppo e non ricevere più le sue email, invia un'email a foxpro-itali...@googlegroups.com.
Per visualizzare questa discussione sul Web, visita https://groups.google.com/d/msgid/foxpro-italia/d13e3d13-19cb-4936-9068-9dbf2f9289e8o%40googlegroups.com.
Ciao Alfredo,per fare la stampa fai un comando di tipo REPORT FORM? o hai creato una procedura propria che ti fa la stampa?Se utilizzi il comando REPORT FORM puoi utilizzare la clase gratuita FoxyPreviewer che ti risolve il prpblema.Saluto___________________Enrique Vasquez B.
El mar., 30 jun. 2020 a las 10:22, alfredo mirabelli (<alfre...@gmail.com>) escribió:
ciao Mimmo sai indicarmi come fare da un file xml generato e visibile a video creare in automatico lo stesso in pdf e in una directory specifica?--quale comando posso mettere nel pulsante di stampa sul file xml visualizzato?grazie
Il giorno giovedì 10 settembre 2015 19:20:30 UTC+2, Mimmo ha scritto:Utilizzo da un pò di anni PdfCreator per automatizzare la creazione di report in pdf ma ormai mi sono convinto che non sia una soluzione affidabile.
Oltre al problema che le nuove versioni non siano compatibili con il codice VFP, succede spesso che i pdf non vengono creati oppure che viene fuori la finestra di dialogo di PdfCreator con le varie opzioni di salvataggio.
Mi sono ormai deciso a trovare un'altra soluzione e vorrei chiedere se qualcuno ha già risolto diversamente.
Ciao a tutti,
Mimmo.
Hai ricevuto questo messaggio perché sei iscritto al gruppo "Foxpro Italia" di Google Gruppi.
Per annullare l'iscrizione a questo gruppo e non ricevere più le sue email, invia un'email a foxpro...@googlegroups.com.