×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to use FoxyPreviewer to generate a pdf from a label programmatically

How to use FoxyPreviewer to generate a pdf from a label programmatically

How to use FoxyPreviewer to generate a pdf from a label programmatically

(OP)
Hey there,
I found this code which works very well to generate a pdf from a report using FoxyPreviewer :

SET PROCEDURE TO LOCFILE("FoxyPreviewer.App") ADDITIVE
LOCAL loReport AS "PreviewHelper" OF "FoxyPreviewer.App"
loReport = CREATEOBJECT("PreviewHelper")
WITH loReport AS ReportHelper
.lOpenViewer = .f.
.AddReport(m.raport, "NODIALOG")
.cDestFile = cale_aplicatie + raport + ".pdf" && Use to create an output without previewing
.RunReport()
ENDWITH
loReport = NULL


Can someone tell me how to change this code to use a label instead of a "report form" as the source?

Thank you,
Costin

RE: How to use FoxyPreviewer to generate a pdf from a label programmatically

Welcome to the forum.

I've always produced labels in Foxypreviewer in much the same way as producing reports. But my code is different from yours (and much simpler).

I have this at the start my main program:

SET REPORTBEHAVIOR 90
DO FoxyPreviewer.APP


And when I am ready to produce the PDF, I do either this:

REPORT FORM <report name> TO FILE <name of PDF output file>

or

LABEL FORM <label name> TO FILE <name of PDF output file>

There are various customisations you can do, for example the nPDFType property determines the method used to create the PDF, but I've never bothered with these.

Note that all of the above assumes you are using VFP 9.0. If not, none of it willl apply.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: How to use FoxyPreviewer to generate a pdf from a label programmatically

(OP)
Hi Mike,
Thanks for your quick response and offer of help.
I tried your code, but no pdf file was created. Maybe the problem with your code is that the application needs first to select a pdf printer?

PS. I am using FoxyPreviewer v299z41.
Regards,
Costin

RE: How to use FoxyPreviewer to generate a pdf from a label programmatically

Quote:

I am using FoxyPreviewer v299z41

According to the documentation, the method I showed you requires Foxy version 3 or later. For earlier versions, I think you need to add OBJECT TYPE 10 to the REPORT FORM or LABEL FORM command.

Alternatively, it looks from the code that you posted that you are creating the PDF without going through the preview first. If that's so, is there any reason for you to use FoxyPreviewer for this task. Assuming that your users have a PDF printer driver installed, you could simply SET PRINTER to that driver, and then just print the labels in the normal way.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: How to use FoxyPreviewer to generate a pdf from a label programmatically

Mike,

I second your notice, that using a PDF filename in the FILE clause only works in foxypreviewer 3, we had discussed how that works now in the latest version in a recent thread.
But costin77 obviously diectly makes use of a class of foxypreviewer.app directly.

I think the use case for this code is to not use the preview feature of FoxyPreviewer, but its PDF feature without a PDF printer software installed. And that is working this way. I think you can alos use AddReport to add a label file, not sure. It's just whatever is in m.raport that determines what's printed as PDF. Not sure whether that class also has an AddLable() method, it's eas to find out.

Chriss

RE: How to use FoxyPreviewer to generate a pdf from a label programmatically

(OP)
My goal is to create pdf files from my application, without any preview of report/label which is being generated.

RE: How to use FoxyPreviewer to generate a pdf from a label programmatically

In that case, I would think the easiest solution would be to ensure that your users have a suitable PDF driver installed (which they would probably want in any case), and then use the normal LABEL FORM or REPORT FORM commands (as mentioned in my previous post).

You will probably need a way to programmatically set the output filename without any user involvement. Most (not all) PDF printer drivers provide a way of doing that, for example by amending a configuration file. Check the driver's docs for that.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

RE: How to use FoxyPreviewer to generate a pdf from a label programmatically

(OP)
I want a solution which it should work for any pdf printer and any version of Windows.
Do you know where I can find a complete manual for FoxyPreviewer?

RE: How to use FoxyPreviewer to generate a pdf from a label programmatically

Costin77,

FoxyPreviewer, no matter which veersion works for as many Windows versions as VFP9, and that's almost all since Windows95 up until today. I don't know why you bring that up in this discussion.
But more importantly, FoxyPreviwer does not make use of a PDF printer driver, It makes use of the haru pdf library and that doesn't require more.

You just have to upgrade to version 3 to use Mikes method or you have to find out whether the code you have also works, if the file you add is a lbx file instead of a frx. I think it does, haven't tried. It might need to handle lbx differently in later running it with Label Form instead of Report Form and therefore have either or both a AddLabel() method and or a RunLabel() method. Why don't you simply try that out yourself?

Chriss

RE: How to use FoxyPreviewer to generate a pdf from a label programmatically


Quote (Chris Miller)

FoxyPreviewer, no matter which veersion works for as many Windows versions as VFP9, and that's almost all since Windows95 up until today. I don't know why you bring that up in this discussion.
But more importantly, FoxyPreviwer does not make use of a PDF printer driver, It makes use of the haru pdf library and that doesn't require more.

FoxyPreviewer 3.0 use Haru lib or Microsoft PDF Printer or custom render "engine" as output to PDF (nPdfType property).

mJindrova

RE: How to use FoxyPreviewer to generate a pdf from a label programmatically

mJindrova,

yes, that's also new. the point is that FoxyPreviewer doesn't use or need a PDF printer installed.
And Mike has a point that if you like, you can use a PDF printer driver instead of Foxypreviewer, too. Then you would not use that code but simply SET PRINTER TO such a printer driver and be done, for both reports and labels.

Chriss

RE: How to use FoxyPreviewer to generate a pdf from a label programmatically

Costin, I understand that you want to use Foxypreviewer because it would avoid the need to install and configure a PDF driver. And also that you don't need to preview the labels. You can achieve that with the code I suggested in the first of my above posts. I'm fairly sure that the reason it didn't work for you was that you didn't have the latest Foxy version installed. If so, just go ahead and upgrade to the latest.

That said, there are several other ways of creating PDFs without installing a PDF driver. But since you have already started with Foxypreviewer, I suggest you try that first.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close