FwSavePreviewToPdf

FwSavePreviewToPdf

Postby vilian » Wed Mar 07, 2018 7:21 pm

Hi Guys,

My application is crashing when I try to save the preview report as a PDF. In hb_out.log I can see this:
Code: Select all  Expand view

Application Internal Error - C:\VFATEC\SFP\SFP.EXE
Terminated at: 2018-03-07 15:56:48
Unrecoverable error 6005: Exception error:

    Exception Code:C0000005 ACCESS_VIOLATION
    Exception Address:76FB22D2
    EAX:74616474  EBX:FFFA0EDF  ECX:026910D0  EDX:00000000
    ESI:74616474  EDI:74616470  EBP:0018EB4C
    CS:EIP:0023:76FB22D2  SS:ESP:002B:0018EB38
    DS:002B  ES:002B  FS:0053  GS:002B
    Flags:00010202
     ....
     ....
   Called from PDFBEGIN(0) in .\source\function\PRV2PDF.PRG
   Called from FWPDF:NEW(171) in .\source\function\PRV2PDF.PRG
   Called from FWSAVEPREVIEWTOPDF(53) in .\source\function\PRV2PDF.PRG
   Called from TPREVIEW:SAVEAS(1667) in rpreview.prg
   Called from (b)TPREVIEW_SAVEASMENU(1569) in rpreview.prg
 


Do you know why ?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 920
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: FwSavePreviewToPdf

Postby karinha » Wed Mar 07, 2018 7:30 pm

Talvez haya perdido la ruta de grabación, en el caso del PDF, lo hice así:

// PRV2PDF.PRG

Code: Select all  Expand view

function FWSavePreviewToPDF( oDevice, cPDF, lOpen )   // oDevice can be oPrinter or oPreview

   local cOrient, oPDF
   local hWnd

   if oDevice:IsKindOf( "TPREVIEW" )
      hWnd    := oDevice:oWnd:hWnd
      oDevice := oDevice:oDevice
   endif
#ifndef USEGDI
   if LoadFreeImage() <= 32
      MsgAlert( FWString( "freeimage.dll not found" ), FWString( "Alert" ) )
      return nil
   endif
#endif

   // MODIFICADO EM: 14/03/2016 PARA SALVAR O PDF NA PASTA: C:\NFEPDF
   cPRGPATH := cFILEPATH( "C:\NFEPDF\" )

   lCHDIR(cPRGPATH)

   // ? hb_CurDrive() + "
:\" + CurDir() + "\"

   DEFAULT cPDF   := cGetFile( FWString( "
PDF files | *.pdf |" ),;
                               FWString( "
Select PDF File to Save" ),, ;
                               CurDir(), .T.,,,;
                               hb_CurDrive() + "
:\" + CurDir() + "\" + ;
                               If( oDevice:IsKindOf( "
TPreview" ),;
                               oDevice:cName, oDevice:cDocument ) + "
.pdf"  )
   if ! Empty( cPDF )
      cPDF = cFileSetExt( cPDF, "
pdf" )
      CursorWait()
      cOrient = If( oDevice:nHorzSize() > oDevice:nVertSize(), 'L', 'P' )
      oPdf = fwPdf():New( cPdf, cOrient )
      AEval( oDevice:aMeta, { | cMeta | oPdf:AddMeta( cMeta ) } )
      oPdf:Close()
      CursorArrow()

      DEFAULT lOpen := MsgYesNo( If( FWLanguageID() == 2, FWString( "
¿" ) + " ", "" ) + ;
                       FWString( "
View" ) + ;
                       "
" + cPDF + " " + FWString( "(Y/N)" ) + " ?",;
                       FWString( "
Please select" ) )

      if lOpen
         ShellExecute( IfNil( hWnd, GetWndDefault() ), "
open", cPDF )
      endif
   else
      cPDF  := nil
   endif

   // VOLTO AO DIRETORIO DO PLENO PARA NAO QUEBRAR OS BANCOS.
   lCHDIR( cDirPleno )

   // ? hb_CurDrive() + "
:\" + CurDir() + "\"

return cPDF
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7213
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: FwSavePreviewToPdf

Postby vilian » Wed Mar 07, 2018 8:59 pm

Karinha,

Thanks , but I think isn't ... I think it's a memory problem, because if I try save as PDF file in other computer with more memory, works. Both computers have the same windows version (7.0).
I don't know why FwSavePreviewToPdf is generating too big files... I think I will return this resource to use Image2PDF.DLL it generate a PDF file 90% smaller than FwSavePreviewToPdf.
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 920
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: FwSavePreviewToPdf

Postby nageswaragunupudi » Wed Mar 07, 2018 9:29 pm

Image2PDF is the best.
FwSavePreviewToPdf is the last resort
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10247
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FwSavePreviewToPdf

Postby vilian » Wed Mar 07, 2018 10:53 pm

ohh... and I'm thinking fivewin is the best :(
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 920
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: FwSavePreviewToPdf

Postby nageswaragunupudi » Wed Mar 07, 2018 11:21 pm

Back to your issue.
This problem can happen if the filename is invalid or can not be written to.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10247
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: FwSavePreviewToPdf

Postby vilian » Thu Mar 08, 2018 12:02 am

Thanks,

I returned to Image2PDF and everything is fine again ;)
Just to illustrate, I included bellow 2 files - The first one from Image2PDF, the second from FwSavePreviewToPdf

Image2PDF-> teste2.pdf 3 kb http://www.mediafire.com/file/cfk7nw1cy1drh3k/teste2.pdf
FiveWin-> teste1.pdf 140kb !!! http://www.mediafire.com/file/f5x6p7b97w4ri4b/teste1.pdf
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 920
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: FwSavePreviewToPdf

Postby TimStone » Thu Mar 08, 2018 12:38 am

I ran into the same problems a few years ago and have stayed with Image2PDF.dll ever since. It always works. The FWH PDF utility often gave my clients frustration.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: FwSavePreviewToPdf

Postby vilian » Thu Mar 08, 2018 12:59 am

Yes, but I'm a little bit worried because I don't find more the utilitywarrior website active . Do you know if they still working ?
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 920
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: FwSavePreviewToPdf

Postby TimStone » Thu Mar 08, 2018 1:57 am

The library works so I wouldnt worry about it now


Sent from my iPhone using Tapatalk
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2904
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: FwSavePreviewToPdf

Postby cnavarro » Tue Mar 13, 2018 8:02 pm

Please try with Printer "Microsoft Print to PDF" if is installed ( default in Win 10 and Win 8 )
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: FwSavePreviewToPdf

Postby Enrico Maria Giordano » Tue Mar 13, 2018 10:02 pm

I don't like "Microsoft Print to PDF" very much because the result PDF is almost ten times bigger than the one created by PDFCreator. And PDFCreator can be driven by OLE.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8315
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FwSavePreviewToPdf

Postby vilian » Wed Mar 14, 2018 12:01 am

Another reason for don´t use "Microsoft Print to PDF" is that sometimes I just want to create the PDF File, I don´t want to preview the report.
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 920
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: FwSavePreviewToPdf

Postby AntoninoP » Wed Mar 14, 2018 6:31 am

Hello,
excuse me for the ignorance, but what is Image2PDF and how can I integrate it in my program? :)
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: FwSavePreviewToPdf

Postby Silvio.Falconi » Wed Mar 14, 2018 7:48 am

yes, of course



MENUITEM "Generar PDF" ACTION SavePDF(oDevice) ;
MESSAGE "Generar archivo tipo PDF" RESOURCE "Acrobat"

Code: Select all  Expand view
FUNCTION SavePDF(oDevice)
   LOCAL error, hLibImg2PDF
   LOCAL imageFilename:=" "
   LOCAL cPdfFilename
   LOCAL nI, iErr:=0
   LOCAL aFiles:={}, cTemp
   cPdfFileName:=cUTem+"\"+Left(cNSys,2)+"_Temp\"+oDevice:cDocument+".Pdf"
   IF !File("
Image2PDF.Dll")
      MsgAlert("
No existe DLL para generar PDFs.","Precaución!")
      RETURN (NIL)
   ENDIF
   aFiles:=oDevice:aMeta
   hLibImg2PDF:=LoadLib32("
Image2PDF.Dll")
   IF ValType(aFiles)=="
A"
      I2PDF_License("
LICENCIA")
      iErr:=IPMeta()              // Flag that his is a meta file
      iErr:=IPSize()              // Reset the size
      iErr:=IPMetaAdjustText()
      iErr:=IPSetDPI(0)           // Set DPI to the default for PDF's.  It works better
      FOR nI:=1 TO Len(aFiles)    // Build the pages using the array of temp files
         CursorWait()
         imageFilename:=aFiles[nI]
         iErr:=IPAddImg(imageFilename)
      NEXT nI
      CursorWait()
      iErr:=IPMakePDF(cPdfFileName,0,error,40)   // Create the PDF.
   ENDIF
   FreeLib32(hLibImg2PDF)
   CursorArrow()
   IF !File(cPdfFileName)
      MsgInfo("
No se generó el archivo PDF.","Información!")
   ELSE
      ShellExecute(,"
Open",cPdfFileName,"",".\",.T.)
   ENDIF
RETURN (NIL)

//----------------------------------------------------------------------------//

   DLL32 FUNCTION I2PDF_License( code AS LPSTR) AS LONG;
   PASCAL FROM "
I2PDF_License" LIB "IMAGE2PDF.dll"

   DLL32 FUNCTION IPMeta( ) AS LONG;
   PASCAL FROM "
I2PDF_MetaToNativePDF" LIB "Image2PDF.dll"

   DLL32 FUNCTION IPMetaAdjustText() AS LONG;
   PASCAL FROM "
I2PDF_MetaTextFitBoundingRect" LIB "Image2PDF.dll"

   DLL32 FUNCTION IPSize( ) AS LONG;
   PASCAL FROM "
I2PDF_UseEMFDeviceSize" LIB "Image2PDF.DLL"

   DLL32 FUNCTION IPAddImg( cImage AS LPSTR ) AS LONG;
   PASCAL FROM "
I2PDF_AddImage" LIB "Image2PDF.dll"

   DLL32 FUNCTION IPSetDpi( nDpi AS LONG ) AS LONG;
   PASCAL FROM "
I2PDF_SetDPI" LIB "Image2PDF.dll"

   DLL32 FUNCTION IPMakePDF( cOutFile AS LPSTR, nOptions AS LONG, cErrTxt AS LPSTR, nMaxESize AS LONG ) AS LONG;
   PASCAL FROM "
I2PDF_MakePDF" LIB "Image2PDF.dll"

   DLL32  FUNCTION COPYFILE( cExistName AS LPSTR, cNewName AS LPSTR, nFailIfExist AS LONG ) AS BOOL;
   PASCAL FROM "
CopyFileA" LIB "kernel32.dll"

   DLL32 FUNCTION xI2PDF_BatesFormat( format AS LPSTR ) AS LONG;
   PASCAL FROM "
I2PDF_BatesFormat" LIB "Image2PDF.dll"

   DLL32 FUNCTION xI2PDF_BatesLocation( verticalPosition AS LONG, horizontalPosition AS LONG, orientation AS LONG, margin AS LONG) AS LONG;
   PASCAL FROM "
I2PDF_BatesLocation" LIB "Image2PDF.dll"

   DLL32 FUNCTION xI2PDF_BatesFont_Int( iSize AS LONG, FontID AS LPSTR, fillRed AS LONG, fillGreen AS LONG, fillBlue AS LONG, iStyle AS LONG, otherRed AS LONG, otherGreen AS LONG, otherBlue AS LONG) AS LONG;
   PASCAL FROM "
I2PDF_BatesFont_Int" LIB "Image2PDF.dll"

   DLL32 FUNCTION xI2PDF_BatesBackground_Int( shape AS LONG, bkRed AS LONG, bkGreen AS LONG, bkBlue AS LONG, borderRed AS LONG, borderGreen AS LONG, borderBlue AS LONG  ) AS LONG;
   PASCAL FROM "
I2PDF_BatesBackground_Int" LIB "Image2PDF.dll"

//----------------------------------------------------------------------------//


Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 59 guests