Hello -
I’m using SV C11 standard report template and using the functionality to save report(s) to PDF. When saving the report to PDF, output name is selected at Runtime by the User.
I need to save the PDF output name selected by the user when the PDF generation is completed. PDFReportGenerator.IReportGenerator.AskProperties method is storing Filename, but I’m unable to retrieve this value. When I call this method: PDFReporter.Output.GetFileName(), it’s always blank.
Any suggestion how can I get PDF filename that was selected by the user at runtime?
Thanks,
-Rex
So in abprpdf.clw the method PDFReportGenerator.IReportGenerator.AskProperties is using a local variable to store the filename Loc:Filename.
If you follow the code past the filedialog it passes the loc:filename to another method called
SELF.Output.SetFileName(LOC:FileName)
If you search for
.SetFilename
you’ll find the method
PDFGeneratorClass.SetFileName PROCEDURE(STRING pFileName)
CODE
SELF.Output.SetOriginalFileName(pFileName)
so now you need to search for
.SetOriginalFileName
This should lead you to abprtarg.clw which is Output in abprpdf.inc
PDFGeneratorClass CLASS,MODULE('ABPRPDF.CLW'),TYPE,LINK('ABPRPDF.CLW',_ABCLinkMode_),DLL(_ABCDllMode_)
Output &PDFTargetGenerator
In the clw
TargetGenerator.SetOriginalFileName PROCEDURE (STRING TargetFileName)
CODE
SELF.OriginalTargetFileName = TargetFileName
SELF.SetFileName (TargetFileName)
RETURN
So loading up abprtarg.inc which contains a list of the methods and properties (variables) I can see the property
OriginalTargetFileName CSTRING(FILE:MaxFileName),PROTECTED
Its protected so its basically ReadOnly to you but not the classes, but I also see in the inc file
TargetFileName CSTRING(FILE:MaxFileName),PROTECTED
SourceFileName CSTRING(FILE:MaxFileName),PROTECTED
You can see what these properties contain by watching them in the debugger and see if they contain the expected values.
Thanks Richard. I see the value is present when stepping through debugger but I’m probably using wrong embed to get the value.
Any suggestion what would be correct embed to get this value?
I wouldnt know off the top of my head, I havent touched the reporting side of things in years and I dont have any of my old apps because my systems kept being hacked so I’ve ditched loads of backups and computers in a bid to get rid of the hacking on my computers. They even managed to set a bios pwd on of my machines. There is a lot of big organised crime around!
However you might have to add your own embed and I wouldnt shy away from that if you have to.
I know I did it in the past as I’m sure the hackers who hacked my system know I did, but I wouldnt like to guess at this time.
If the user is going to inform the name of the PDF file, put the LOC:FileName field on the screen for him to type the name of the PDF file.
LOC:FileName must be informed in “File Name” in the General tab of the Report to PDF properties.
LOC:FileName can only contain the filename “file.pdf”
or the path + the filename “C:\App\Arquivo.pdf”.
Hi,
I just updated C:\Clarion11.1\LibSrc\win\abprI2pdf.clw / line 247 like that
IF NOT CLIP(SELF.Output.GetFileName()) OR Force THEN
LOC:FileName = CLIP(SELF.Output.GetFileName()) !LOC:FileName = ''
now, if developer gives any name, that filename automatically showing to user. You can also do that changes in PNG, TXT, HTML, XML templates.
1 Like
I encountered the same issue when generating PDFs. While generating the file name, the client could select it, but during the export process, I couldn’t retrieve the entered value to display it in a “Save As” dialog.
@SerhatSatir solution works perfectly when the “force” parameter is set to 1. I’m sharing the complete code for the AskProperties method. I only added a small fix where, if the file name contains a “.”, it saves the PDF with the incorrect extension.
PDFReportGenerator.IReportGenerator.AskProperties PROCEDURE(BYTE Force)
ReturnValue BYTE
LOC:FileName CSTRING(FILE:MaxFilePath+1),AUTO
LExt CSTRING(128),AUTO
CODE
ReturnValue = Level:Benign
SELF.Init()
! -------------------------------------------------------------------------------------------------------
! NEW IMPLEMENTATION ! ORIGINAL SV CODE !
! -------------------------------------------------------------------------------------------------------
IF NOT CLIP(SELF.Output.GetFileName()) OR Force THEN ! IF NOT CLIP(SELF.Output.GetFileName()) THEN
LOC:FileName = CLIP(SELF.Output.GetFileName()) ! LOC:FileName = ''
IF NOT FILEDIALOG('Save PDF File',LOC:FileName,'PDF|*.PDF|All|*.*',FILE:LongName+FILE:Save+FILE:KeepDir) THEN
ReturnValue = Level:Notify
ELSE
Lext=''
PathSplit(LOC:FileName, , , , Lext)
! -----------------------------------------------------------------------------------------------
! NEW IMPLEMENTATION ! ORIGINAL SV CODE !
! -----------------------------------------------------------------------------------------------
if Lext <> '.pdf' ! IF NOT Lext THEN
LOC:FileName = LOC:FileName & '.pdf' ! LOC:FileName=LOC:FileName&'.PDF'
end !* if *
SELF.Output.SetFileName(LOC:FileName)
END !* if +
END !* if *
RETURN ReturnValue
2 Likes