2011-04-19

The simplest way to create your PDF's / FoxyPreviewer Latest changes

It's been a long time since my last blog post about foxypreviewer. although somehow quiet in the blog, the work behind the scenes has been hard, and I've just released version 2.38, with several fixes and enhancements.

One of the coolest is the following:
to export a report to PDF without previewing, people just need to do the following:
     DO FoxyPreviewer.app
     REPORT FORM YourReport OBJECT TYPE 10


Yes !
That's all you need.
Even better than that, the new - oops !!!!, hahahaha, VFP9 is quite old right now, reporting system from VFP9 allows me to access some of the report clauses used in the report form command. so now we can use the object type clause of the report form command much better, using the "to file" and the "preview", see:

     DO FoxyPreviewer.app
     REPORT FORM (_Samples + "\Solution\Reports\Wrapping.frx") ;       
          OBJECT TYPE 10 ; && regular PDF
          TO FILE ("c:\FoxyNewTest.PDF") ; && destination file        
          PREVIEW    && open the default PDF viewer


to file - is the destination file, that can be sent directly in the report form command !
preview - opens the default file viewer, eg. adobe reader for PDFs

So, in summary, I've enabled 2 object type's allowing automatic PDF generation, without previewing, with just one single line of code, just the same way we used to run our reports!
  • object type # 10 = regular PDF, searchable
  • object type # 11 = PDF as image, non searchable
  • object type # 12 = RTF
  • object type # 13 = XLS
  • object type # 14 = HTML using XSL
  • object type # 15 = HTML using basic HTML commands, easier to export to web
  • object type # 20 = Any file type from the above, just send the corrret file extension, and FoxyPreviewer will internally use the needed ReportListener to create the output
New horizons
A very cool part of all this is that now we have even a new option for report previsualization, trasforming our reports in pdf, and using Adobe Reader to preview them !
that's really neat! Because the reader brings some very nice options for printing, text searching, hyperlinks, emailing, saving, etc etc etc...
If you want to customize your PDFs using the new object type clause, of course you can! Just use the following properties available in the _Screen.oFoxyPreviewer object:
WITH_Screen.oFoxyPreviewer
    .lQuietMode
    .lPdfEmbedFonts
    .lPdfCanPrint
    .lPdfCanEdit
    .lPdfCanCopy
    .lPdfCanAddNotes
    .lPdfEncryptDocument
    .cPdfMasterPassword
    .cPdfUserPassword
    .lPdfShowErrors
    .cPdfSymbolFontsList
    .cPdfAuthor
    .cPdfTitle
    .cPdfSubject
    .cPdfKeywords
    .cPdfCreator
    .cPdfDefaultFont
    .lOpenViewer
    .nPpdfPageMode


These properties are all described in the foxypreviewer documentation.
Of course this needs some tests, i'm waiting for the feedback of people interested in that feature.

The recommended mode - make it simple !!!

From now on, I'm recommending people to use only the simplified mode:
     DO FoxyPreviewer.app
     REPORT FORM YourReport PREVIEW

Some of the main improvements / fixes

- improved the fonts substitution in the PDF rendering. the fonts Arial and Courier New will appear well, using some internal fonts from the pdf engine.
- wingdings was enabled too!
- fix in PDF "stretch to fit" and multilines sentences - thanks to Fabio Vieira
- fix sending emails, automatic opening tables
- from now on, whatever that the pdf engine will not be able to draw, it will get an image from the source report surface, crop and paste the image in the PDF document. This works nice for barcodes, and some fonts that can't be embedded.
- included all of the available properties for the complete mode to the "_screen.ofoxypreviewer" object (that is created after you "do foxypreviewer.app"
- several small fixes in the xls rendering, hopefully now all reports will generate valid worksheets. (special thanks to jorge chang for his samples and testing)
- using the simplified mode now you can change your printer directly from the combobox, thanks to lisa slater nicholls, for her great article "a print job to call your own"


Special thanks

- to all the translators who have been translating the localizations table, alowing the tool to be multilanguage. currently we have 16 languages available!
- Soykan Ozcelik and Luis Maria Guayan, for their terrific support, tests and help, and more than that, for translating the Foxypreviewer documentation to Turkish and Spanish, allowing more people to use the tool, and for providing a very positive and constant support in their local VFP forums. currently we have all dialogs, tooltips and captions available in:

  • english
  • portuguese
  • czech
  • spanish
  • dutch
  • turkish
  • french
  • german
  • indonesian
  • arabic
  • greek
  • italian
  • persian
  • polish
  • russian
  • swahili
- and thanks to all people who have been testing this product very deeply.

That's super important, because this utility is getting really big, with lots of possibilities of usage, and for me it's impossible to test in all environments.


Documentation

As said above, the documentation has been updated, and also translated to turkish and spanish:
English documentation
Turkish documentation / Türkçe dökümantasyon
Spanish documentation / Documentacion en español


The foxypreviewer.app file size

- notice that the file foxypreviewer.app has become bigger, about 3MB. that is because I added the "debug info" information to the app.

That makes the file bigger, but on the other hand, provides a more detailed debugging information. that way, people will be able to tell me the line that originated the bug, even running foxypreviewer in production.

That will be only for now, during the tests. in the future, after i stop making constant changes, I'll remove that, and the apps will come back to the original and compact size, about 1.5 MB

And of course, you can recompile the app using the sources, removing the debuginfo if you want!

Foxypreviewer general info
Foxypreviewer documentation
FoxyPreviewer FAQS
Foxypreviewer downloads

29 comments:

  1. This is awesome! Thanks for all your hard work!!

    ReplyDelete
  2. Hello Cesar,


    it's a great new your library, i have some problem with the report quality and gdi.

    I hope the FoxyPreviwer can make more quality for my Customer.


    ps : know you, if your library we can make without border (print whole) ?

    Thanks

    Olivier

    ReplyDelete
  3. Cesar, todo funciona de maravillas en mi pc de desarrollo, pero nunca he podido hacer funcionar la utilidad.


    Al ejecutar sale la pantalla "Open" pidiendo "foxypreviewer" (tengo el .app instalado) y luego un error:


    Error In UpdateSettings

    12- Variable "LOCALLANG' is not Found.

    Line: 0-

    ReplyDelete
  4. Dear Sir
    This is vary nice and simplest way to create pdf and xls . But i have one problem in foxypreviewer that is tp1. In my table is same field ,when i go to preview a report,
    error was occured. i find out that where is problem and open your source code and replaced tp.. instead of __tp....

    Now its woking fine now

    Thanks A lot

    Hi Arjun, Please be more specific with the string you change, an the location I need to replace it!

    ReplyDelete
  5. Hello Cesar,

    Hey Tom,

    wonderful and so easy to use.

    Just 2 things :
    a) How to disable Options in Toolbar/menu ?
    Otherwise users can easyliy revert to save pdf allowed (for example)

    I understand, I'll have to think in a way to disable all options in the settings menu. Or maybe disablin/hidingg the PageFrame Tabs would be enough ?

    b) If you use the type 10 option to generate a pdf directly,
    this does not work if you have "dynamics" in your report.

    Ooops, I'll have to check that


    For both I made a thread in foxite under reports with details.

    Thanks, I'll try to find that message, I really lost it

    Again, thanks
    Tom

    Regards and thanks !

    ReplyDelete
  6. Dear Sir

    I have face someone error  
    fx update listener

    function Argument,Value ,type or count is Invalid
    FX_388109AMF
    Error :11
    Method : SendFX
    i think this error may show if in my table field name is tp1
    if i remove tp1 field, it work fine

    Please remove this bug

    Thanks a lot


    Warm Regards
    From Arjun Bagojikop



    Hi Arjun,
    "tp1" was used by Microsoft VFP team to be used as Parameters in SEVERAL parts of the Report classes. I'm sorry, but it would be easier if you just changed that in your programs.
    Or would that be a specific location that I should change ?

    ReplyDelete
  7. This is very good.But have a big problem.It can't support Chinese simple fonts.like as "SimSun","SimHei"
    Any idea for it?

    Hi Richard,
    Please get in contact directly, so that we can work together in that !

    ReplyDelete
  8. Perfect! very good software.
    I am Chinese.I found if there Simplified Chinese character in *.frx report.When I export to PDF file.But all the Chinese fonts character become unreading charater.like as Unrecognizable code.
    Do you have any suggestion to me for using foxypreviewer.
    Thanks

    ReplyDelete
  9. This is truly the easiest way to create PDF's with Foxypreviewer and the quality of my pdf is excellent.

    I will definitely use Foxypreviewer in my application.


    I wish to thank everyone involved in this project.


    ReplyDelete
  10. I wish to thank the creator(s) of this program.

    This program is very good.

    I will definitely use it in my programs

    Gio Car


    ReplyDelete
  11. I wish to thank Cesar and all the people involved in the realization of foxypreviewer.
    Foxypreviewer is a great realisation and works fine.
    I will definitely use in my program.

    Hi Gio,
    Thanks very much for your kind words. It's very nice to know that you find this work useful.
    Regards
    Cesar

    ReplyDelete
  12. "class to display feedback during report generation process is not available.
    report run will continue silently"
    i didn't find it in my project but i found this information on my executable application, and i dont understand what class i have left when i builded the project
    can you help me?
    anyway, this realy cool....
    thanks a lot...

    Hello,
    It seems that you have put some of the source files of foxypreviewer in your project, is that correct ? Please remove them all from your project, and distribute FoxyPreviewer.App, separately !

    ReplyDelete
  13. Saludos..felicitaciones por tu dedicacion a este proyecto, de maravilla, me funciono perfectamente la orden simplificada, pero especialmente inmensas gracias por compartir con los que aprendemos de los maestros como tu (soy aprendiz de programcion en Fox). Espero poder dominar a la perfeccion esta gran utilidad..saludos y exitos..
    Gracias !

    ReplyDelete
  14. I wish I had discovered this app long ago, really, really nice. The only thing I cannot get to work is the "Release" parameter. I'm running VFP 9 w/sp2.  Even after executing DO foxypreviewer.app with "Release", foxypreviewer is still active.  

    What do I need to do to get the native previewer back after using foxy?

    Thanks!
    Hello Dick,
    What Foxypreviewer version are you using ?

    ReplyDelete
  15. I really appreciate all of the hard work you have invested into this incredible project.  In a million years, I would never have the skill-set needed to create anything like this.  This will enhance almost every project I've written since I started in 1987 with Dbase :)

    I posted earlier that I am unable to get the Release parameter (DO FOXYPREVIEWER.APP WITH "Release")  to work.

    I have even reset the _reportpreview parameter manually using
    _REPORTPREVIEW = HOME()+"ReportPreview.app"  and Foxy still is present.  

    My only other issue is I am unable to get the nZoomLevel property to change.

    Everything else works incredibly well :)

    Thanks again.

    Dick

    I suppose you are not using the most recent version. Could you try with version 2.65 ?

    ReplyDelete
  16. You were correct, I was running 250a.  I downloaded 265b today and made sure that was in the path (not in the project) and I am still running into the same 2 problems.  I tried removing the DO foxypreviewer.app from the scan and after the first pass, it crashes like before.  If I insert the DO statement in the scan code, it works fine.  That I can sure live with.  

    My only real problem is that I cannot get it to release back to the native vfp previewer. I am sure I'm doing something wrong but cannot see what it is.

    To test the release, I added 2 buttons to a form. The Plain button has the following code...

    Select a_temp3
    Go Top
    Report Form cp_efile_proof preview
    Select a_temp3
    Go Top

    The Foxy button has the following code...

    Select a_temp3
    Go Top
    DO FOXYPREVIEWER.APP
    Report Form cp_efile_proof preview &&&mdisprint &&for .not.empty(a_temp3.scratch)
    DO FOXYPREVIEWER.APP with "Release"
    Select a_temp3
    Go Top

    After running the Foxy code, if I click the Plain button, it is still has bits and pieces of Foxy in the toolbar, not all icons are there but the multi-page icons are still there plus the same Foxy progress meter shows just before the report is shown, so I know it's not the native toolbar.  Also, the fact that the plain toolbar now displays the cTitle as the Foxy toolbar makes me pretty sure Foxy is still controlling report preview.

    I LOVE the program and just want to be sure I am not doing something wrong.

    Thanks again.


    Thanks a lot! I've applied some changes, and just uploaded v2.67, could you test it please ?

    ReplyDelete
  17. Cesar, I don't know how often you check the vfp forum, but Pavel Celba has been trying to help me figure out why version 265b goes to debug when you try to print the report using the simple method.  It gets the error in the actionclose procedure. Set step on is called and the debugger sasy that the source is not available.  The report prints fine. I have downloaded fresh 265b's on 2 different PC's and get the exact same error.

    Thoughts?
    Just applied the fix proposed by Pavel in v2.67. In fact. the real issue came from the problem in the release of FoxyPreviewer, that is hopefully resolved in v2.67
    Cheers

    ReplyDelete
  18. Hi Cesar, this is a great app!  I use it to keep archived files of invoices and cheques printed - it works fine, but I have one question:  I have a JPG image (our logo) in the reports and after each report there is a file added to the original exe path - a file which is apparently a random numbered JPG file of the same JPG that is in the report.
    Again, the report prints fine, but these files keep being added to my directory (example file name _3B10VSTC4.JPG).  I'm not sure if I'm doing something wrong or what?  I'm not really an 'expert' but please advise.

    Thanks!
    Scott
    Hello Scott,
    Can you provide more details on how you're using FoxyPreviewer ? There are many ways to use it, it would help a lot to know exactly the code you're running to use it.
    Regards
    Cesar

    ReplyDelete
  19. reportname = IIF(EMPTY(reportname)=.T.,"Un-named report",ALLTRIM(reportname))

    lcpdfname = "Reports\"+"Unnamed"+TTOC(DATETIME(),1)+".PDF"

    ENDCASE  


    Hi Again Cesar,

    The code I'm using is as follows...


    Reportname = Invoices.frx

    lcpdfname = 112345.PDF


    SET PROCEDURE TO LOCFILE("FoxyPreviewer.App") ADDITIVE

    LOCAL loReport as "PreviewHelper" OF "FoxyPreviewer.App"

    loReport = CREATEOBJECT("PreviewHelper")

    WITH loReport as ReportHelper

           .AddReport(Reportname, "NODIALOG")

           .cDestFile = lcpdfname  && Use to create an output without previewing

           .RunReport()

    ENDWITH

    loReport = NULL


    I call my app from a local directory on C:\ drive, and all the data and report files are in a shared directory, along with the foxypreviewer.app.  The report has our JPG logo on it, and is included in our app, and I found that I had to copy it to the path in order for foxypreviewer to find it (no surprise there!).  The files that are added each time I run the report are located in the local C:\ drive directory that our app is originally called from, and again they seem to be a copy of our logo with a random numbered name.    Hope this helps....


    Thanks,

    Scott Johnstone

    ReplyDelete
  20. Fist I would thank you about your effort, I have only one comment when I use PDF OR XLS with my data in Arabic font the output come in non Arabic font lile this "ÇáÇÕæá ÇáãÊÏÇæáÉ"

    Thanks.

    Alaa Eddin Yousef

    ReplyDelete
  21. I have been struggling for years with printing PDF’s. FoxyPreviewer - what a wonderful solution. Thank you very much indeed.

    ReplyDelete
  22. Thanks Keith ! Nice to know that you find it useful :-D

    ReplyDelete
  23. Hi Cesar
    Really incredible. I've just begin using your great project, soon I'll send you comments about how it works
    Thanks a lot !!!!!!!!

    ReplyDelete
  24. Hi Fernando,
    I'm glad you like it!
    Abraço

    ReplyDelete
  25. please i try to use it but i don't know how, can you put it as step because i found many folder and files and don't know where to put it and how to use it please i need it urgent

    ReplyDelete
  26. Hi Cesar!

    I am using this tool first time and its working fine. I am facing a simple problem i.e. when i am saving report to PDF thru context menu the company logo does not appear in PDF but when using REPORT FORM .... Object type 10... its appearing. Logo is a .JPG file and am using simplified method

    WKR
    HAQ

    ReplyDelete
  27. Cesar,

    I just came into a situation where I needed to print multiple PDFs from a foxpro report and do so without prompts. It doesn't get any easier than...

    report form (_samples + "\solution\reports\wrapping.frx") ;
    object type 10 ; && regular pdf
    to file ("c:\foxynewtest.pdf") ; && destination file

    which works flawlessly. Thank you for all the time and effort you spent putting this together. I look forward to finding out what else this can do:)

    ReplyDelete
  28. sir its not working under vfp6

    ReplyDelete
  29. not support thai font

    ReplyDelete