PDFCreator nuova versione 2.2.1, codice da correggere

645 views
Skip to first unread message

Gianni Turri

unread,
Oct 30, 2015, 11:54:55 AM10/30/15
to Foxpro Italia
Ciao a tutti!

E' disponilbile da oggi la versione 2.2.1 di PDFCreator
http://www.pdfforge.org/pdfcreator/download

Posto il codice con la piccola correzione:

*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.PDFCreatorObj

try
loPDFCreator = CreateObject("PDFCreator.PDFCreatorObj")
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.PDFCreatorObj
*loPDFCreator = CreateObject("PDFCreator.PDFCreatorObj")

*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

* 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")


*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
*




Gianni

Mimmo Micelli

unread,
Oct 31, 2015, 5:40:21 AM10/31/15
to foxpro...@googlegroups.com

Grazie Gianni, stavo impazzendo perché sul sito pdfforge non c’è nessuna documentazione relativa alla nuova versione… dove hai trovato?

 

Da: foxpro...@googlegroups.com [mailto:foxpro...@googlegroups.com] Per conto di Gianni Turri
Inviato: venerdì 30 ottobre 2015 16:55
A: Foxpro Italia
Oggetto: PDFCreator nuova versione 2.2.1, codice da correggere

--
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 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/fd1c240e-85f0-407d-8fd4-6f25c4bcc669%40googlegroups.com.
Per altre opzioni visita https://groups.google.com/d/optout.




Avast logo

Questa e-mail è stata controllata per individuare virus con Avast antivirus.
www.avast.com


Laldo Lorso

unread,
Oct 31, 2015, 7:17:53 AM10/31/15
to Foxpro Italia
Grazie anche da parte mia!!
Continuavo a dire ai ns clienti di non cadere in "tentazione" e di non aggiornare MAI oltre alla versione 1.7.3
Ma stamattina ho provato il tuo codice e funziona tutto alla grande!!
Ciao&BuonWeekEnd

Gianni

unread,
Oct 31, 2015, 9:08:27 AM10/31/15
to foxpro...@googlegroups.com
Ciao Mimmo,

è vero, la documentazione online è difficile da trovare e quando la trovi a volte non è aggiornata.

http://docs.pdfforge.org/

Per sicurezza quindi faccio così:

di ogni versione che installo copio altrove gli esempi di codice che si trovano in

C:\Program Files\PDFCreator\COM Scripts\JS Scripts\

e poi confronto le diverse versioni con Beyond Compare.

Gianni

----- Original Message -----
From: "Mimmo Micelli" <mimmom...@tiscali.it>
To: <foxpro...@googlegroups.com>
Sent: Sat, 31 Oct 2015 10:40:19 +0100
Subject: R: PDFCreator nuova versione 2.2.1, codice da correggere

Grazie Gianni, stavo impazzendo perché sul sito pdfforge non c’è nessuna documentazione relativa alla nuova versione… dove hai trovato?

Da: foxpro...@googlegroups.com [mailto:foxpro...@googlegroups.com] Per conto di Gianni Turri
Inviato: venerdì 30 ottobre 2015 16:55
A: Foxpro Italia
Oggetto: PDFCreator nuova versione 2.2.1, codice da correggere

Ciao a tutti!

E' disponilbile da oggi la versione 2.2.1 di PDFCreator
http://www.pdfforge.org/pdfcreator/download

Posto il codice con la piccola correzione:

<code snippet removed>

Gianni

Laldo Lorso

unread,
Nov 5, 2015, 5:44:31 AM11/5/15
to Foxpro Italia
Buongiorno, per ringraziare ancora Gianni per il suo post che mi ha permesso di implementare e capire finalmente che PDFCreator 2punto...
è veramente un ottima evulozione che permette di fare tantissime cose (Attachment, Background in primis) che prima si potevano ottenere solamente
con "sudatissime" righe di codice (tipo merge o sfondi)!!
Per chi volesse approfondire qui
http://docs.pdfforge.org/pdfcreator/2.2/en/pdfcreator/com-interface/reference/settings/
ho trovato molte cose utili
Una cosa volevo però chiedere, se per caso vi fosse già capitata: ho un report da portare in pdf e poi da allegare ad una mail, che in alto riporta un logo aziendale a colori in formato jpeg (per ovvi motivi di dimensione). Bene, con la vecchie versioni di PDFCreator fino alla 1.7.2 me lo riporta corrattamente a colori, con la nuova 2.2.1 non c'è modo... sempre e solo in scale di grigi!!
Qualcuno si è imbattuto o pensate ad un bug??

Grazie&BuonaGiornata
Laldo

Gianni

unread,
Nov 5, 2015, 8:54:21 AM11/5/15
to foxpro...@googlegroups.com
Ciao Laldo (o Aldo?),

no, non ho il problema dei colori che hai tu.

Verifica le impostazioni specifiche di PDFCreator e le impostazioni della stampante PDFCreator.

Gianni

----- Original Message -----

Laldo Lorso

unread,
Nov 5, 2015, 9:55:43 AM11/5/15
to Foxpro Italia
Chiedo scusa... il problema era nel report e non il "povero" Pdf !!
Semplicemente in
- Report Properties
- Page Setup
la stampa era impostata in bianco&nero, sorry ;-(
Tuttavia ne approfitto per chiedere a proposito del Page Setup...
Il motivo per cui non vedevo l'impostazione in bianco&nero, è che (ma non vorrei sbagliarmi?!?!)
da quando lavoro con Windows7 Professional, VFP 9.2 non mi da più la possibilità di avere quelle
informazioni aggiuntive tipo numero di copie, bianco e nero, colore e non ricordo se qualcos'altro...
ma, come vedete nell'allegato, solo formato e orientamento!!
Avete una qualche idea se c'è modo di "riavere" quelle comodissime impostazioni??
Grazie ancora e...
BuonLavoro

P.S.
Si si Aldo... nei nickname aggiungo semplicemente una L nel nome e nel cognome ;-)

PageSetup.jpg

Gianni

unread,
Nov 5, 2015, 10:19:34 AM11/5/15
to foxpro...@googlegroups.com
Ciao Aldo,

volevo giusto ricordarti di verificare le impostazioni nel report, ma dicevi che con la versione vecchia di PDFCreator funzionava per cui ho dato per scontato che fossero a posto.

Da Windows Vista in avanti per poter accedere alle impostazioni di stampa bisogna fare così:

- mentre sei in modifica report (Report Designer), apri il menù File e seleziona Print...
- seleziona la stampante e premi il pulsante Preferenze
- se la stampante selezionata è PDFCreator troverai solo due pannelli: nel pannello Carta/Qualità seleziona Colore
- conferma con OK
- conferma con Applica ed esci con Annulla
- assicurati di NON avere spuntato [ ] Save printer environment nelle Report Properties
- salva il report

Malgrado l'assenza della spunta in [ ] Save printer environment
alcune impostazioni vengono memorizzate comunque,
tipo il formato carta, l'orientamento ed il colore (ma forse anche altre, l'unica è sperimentare),
ma non le informazioni specifiche della stampante.

Gianni

----- Original Message -----
From: Laldo Lorso <al...@interplanet.it>
To: Foxpro Italia <foxpro...@googlegroups.com>
Sent: Thu, 5 Nov 2015 06:55:43 -0800 (PST)
Subject: Re: PDFCreator nuova versione 2.2.1, codice da correggere

Laldo Lorso

unread,
Nov 5, 2015, 11:15:09 AM11/5/15
to Foxpro Italia
Perfetto!!
P.S.
Pensa che aprivo il report come un dbf e nel Memo Expr del primo record modificavo a mano COPIES ;-))

Benissimo, grazie ancora e alla prossima...
Aldo
Reply all
Reply to author
Forward
0 new messages