How to set password protected PDF file in NAV 2009?

Aravindh_Navision
Member Posts: 258
Hi FRiends,
[Version: 2009 SP1 Classic Client]
I need to convert Customer Statement (and Sales Invoice) report to PDF and send to customer's e-mail ID which is mentioned in Customer card. I can able to convert into PDF and attach send as an e-mail successfully.
I am facing couple of issues:
1. How to set password to the PDF file (Password: Customer No.)?
2. How to avoid the dialog window SaveAs (show the path to store the file)?
Below are the local variables defined in the function SaveCustStatementInPDF, I am using.
Code in the function...
SaveCustStatementInPDF(CustNo : Code[20]) : Text[250]
Can anyone help me how to solve this?
Thanks in advance, Aarvi.
[Version: 2009 SP1 Classic Client]
I need to convert Customer Statement (and Sales Invoice) report to PDF and send to customer's e-mail ID which is mentioned in Customer card. I can able to convert into PDF and attach send as an e-mail successfully.
I am facing couple of issues:
1. How to set password to the PDF file (Password: Customer No.)?
2. How to avoid the dialog window SaveAs (show the path to store the file)?
Below are the local variables defined in the function SaveCustStatementInPDF, I am using.
Customer (Record) - Customer File1 (Automation) - 'Microsoft Scripting Runtime'.FileSystemObject Filename1(Text200) RunOnceFile (Text250) TimeOut (Integer ) SalesStat (Report) - Statement report
Code in the function...
SaveCustStatementInPDF(CustNo : Code[20]) : Text[250]
SMTPSetup.GET; Customer.SETRANGE("No.",CustNo); IF Customer.FINDSET THEN BEGIN IF ISCLEAR(File1) THEN CREATE(File1); IF ISCLEAR(BullZipPDF) THEN CREATE(BullZipPDF); IF NOT File1.FolderExists(SMTPSetup."Path to Save Report") THEN File1.CreateFolder(SMTPSetup."Path to Save Report"); Filename1:= SMTPSetup."Path to Save Report" +'Statement' + '.pdf'; IF EXISTS(Filename1) THEN ERASE(Filename1); BullZipPDF.Init; BullZipPDF.LoadSettings; RunOnceFile := BullZipPDF.GetSettingsFileName(TRUE); BullZipPDF.SetValue('ShowSaveAs','never'); BullZipPDF.SetValue('OwnerPassword','abc'); BullZipPDF.SetValue('UserPassword', CustNo); BullZipPDF.SetValue('KeyLength', 'Standard128bit'); BullZipPDF.SetValue('Output',Filename1); BullZipPDF.SetValue('ShowSaveAS','never'); BullZipPDF.SetValue('Showsettings', 'never'); BullZipPDF.SetValue('ShowPDF', 'no'); BullZipPDF.SetValue('ShowProgress', 'no'); BullZipPDF.SetValue('ShowProgressFinished', 'no'); BullZipPDF.SetValue('SuppressErrors', 'yes'); BullZipPDF.SetValue('ConfirmOverwrite', 'no'); BullZipPDF.WriteSettings(TRUE); SalesStat.SETTABLEVIEW(Customer); SalesStat.USEREQUESTFORM(FALSE); SalesStat.RUNMODAL; TimeOut := 0; WHILE EXISTS(RunOnceFile) AND (TimeOut < 30) DO BEGIN SLEEP(1000); TimeOut += 1; END; CLEAR(File1); CLEAR(BullZipPDF); END; EXIT(Filename1);
Can anyone help me how to solve this?
Thanks in advance, Aarvi.
0
Comments
-
does it do any of the settings?
if i remember correctly you have to select the printer before doing the settingsfile
something along the lines of
BullZipPDF.PrinterName := PrinterName;
before the init0 -
Nope. None of the BullZipPDF setting is working.0
-
Oh wow this has been a while. It has something to do with the bullzip settingsfile being written to some folder that's then not used during the print. It's a bullzip bug/compatibility issue with the nav 3-tier scenario. You have to make sure that the runonce settings file is being picked up correctly. Make sure that after the bullzipPDF.Writesettings command, the appropriate file is stored in the correct location:
See more at wiki.bullzip.com/pdf-printer/documentation/reference/configuration-files0 -
Geronimo/Sog.. Thanks a lot for your responses. I have sorted the issue. I have created a new table Printer Selection and wrote below code..
IF NOT PrinterSelection.GET('',50003) THEN BEGIN PrinterSelection.INIT; PrinterSelection."Report ID" := 50003; PrinterSelection."Printer Name" := 'Bullzip PDF Printer'; PrinterSelection.INSERT; END;
0 -
I have another issue where I got struct. I need to merge the Open Invoices in one single pdf file.
Function: SendMailToRegOpenInvoicesLocals: Parameter CustNo (Code20) Variables: Customer (Record) - Customer File1 (Automation) - 'Microsoft Scripting Runtime'.FileSystemObject Filename1- (Text200) RunOnceFile - (Text250) TimeOut - (Integer) SalesInv (Report) - Sales Invoice report SalesInvoice - (Record) - Sales Invoice Header PrinterSelection - (Record) - Printer Selection CustLedgEntry - (Record) - Cust. Ledger Entry InvoiceNo - (Code20) mergeAfterFilename - (Text200)
Coding..
SendMailToRegOpenInvoices(CustNo : Code[20])SMTPSetup.GET; Customer.GET(CustNo); CustLedgEntry.SETCURRENTKEY("Customer No.",Open,Positive,"Due Date","Currency Code"); CustLedgEntry.SETRANGE(CustLedgEntry."Customer No.",CustNo); CustLedgEntry.SETRANGE(Open,TRUE); CustLedgEntry.SETRANGE(CustLedgEntry."Document Type",CustLedgEntry."Document Type"::Invoice); IF CustLedgEntry.FINDFIRST THEN BEGIN REPEAT InvoiceNo := CustLedgEntry."Document No."; SalesInvoice.SETFILTER(SalesInvoice."No.",InvoiceNo); IF SalesInvoice.FINDFIRST THEN BEGIN IF ISCLEAR(File1) THEN CREATE(File1); IF ISCLEAR(BullZipPDF) THEN CREATE(BullZipPDF); IF NOT File1.FolderExists(SMTPSetup."Path to Save Inv. Report") THEN File1.CreateFolder(SMTPSetup."Path to Save Inv. Report"); Filename1:= SMTPSetup."Path to Save Inv. Report" +'SalesInvoice' + '.pdf'; mergeAfterFilename := SMTPSetup."Path to Save Inv. Report" +'SalesInvoiceA' + '.pdf'; IF NOT PrinterSelection.GET('',50003) THEN BEGIN PrinterSelection.INIT; PrinterSelection."Report ID" := 50003; PrinterSelection."Printer Name" := 'Bullzip PDF Printer'; PrinterSelection.INSERT; END; BullZipPDF.Init; BullZipPDF.LoadSettings; RunOnceFile := BullZipPDF.GetSettingsFileName(TRUE); BullZipPDF.SetValue('Output',Filename1); BullZipPDF.SetValue('OwnerPassword','abc'); BullZipPDF.SetValue('UserPassword', CustNo); BullZipPDF.SetValue('EncryptionType', 'Standard128bit'); BullZipPDF.SetValue('ShowSaveAs', 'never'); BullZipPDF.SetValue('Showsettings', 'never'); BullZipPDF.SetValue('ShowPDF', 'no'); BullZipPDF.SetValue('ShowProgress', 'no'); BullZipPDF.SetValue('ShowProgressFinished', 'no'); BullZipPDF.SetValue('SuppressErrors', 'yes'); BullZipPDF.SetValue('ConfirmOverwrite', 'no'); BullZipPDF.SetValue('Mergefile', Filename1 + '|.|' + mergeAfterFileName); BullZipPDF.SetValue('MergePosition', 'below'); BullZipPDF.WriteSettings(TRUE); SalesInv.SETTABLEVIEW(SalesInvoice); SalesInv.USEREQUESTFORM(FALSE); SalesInv.RUNMODAL; TimeOut := 0; WHILE (TimeOut < 20) DO BEGIN SLEEP(3000); TimeOut += 1; END; CLEAR(File1); CLEAR(BullZipPDF); END; UNTIL CustLedgEntry.NEXT = 0; END;
Can anybody let me know where I made mistake?
Thanks.0 -
The problem is that you call
SalesInv.RUNMODAL;
once per invoice. This produces one file per invoice.
You need to build a filtrer for all the invoice Nos you need to be included in one PDF file and call the SalesInv.RUNMODAL only once.
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-030 -
I did something similar as a prototype for some other purpose but the code below creates a PDF file on location with password :
PdfFile.CREATE('D:\Invoice.pdf');
PDFSecurity := PDFSecurity.PdfSettings;
PDFSecurity.PrinterName('Bullzip PDF Printer');
PDFSecurity.SetValue('Output',PdfFile.NAME);
PDFSecurity.SetValue('ShowSaveAs', 'never');
PDFSecurity.SetValue('ShowSettings', 'never');
PDFSecurity.SetValue('ShowPDF', 'no');
PDFSecurity.SetValue('ShowProgress', 'no');
PDFSecurity.SetValue('ShowProgressFinished', 'no');
PDFSecurity.SetValue('ConfirmOverwrite', 'no');
PDFSecurity.SetValue('UserPassword','1234');
PDFSecurity.SetValue('OwnerPassword','12345');
PDFSecurity.WriteSettings(TRUE);
CLEAR(SalesInvHeader);
SalesInvoiceHeader.SETRANGE("No.","No.");
IF SalesInvoiceHeader.FINDSET THEN;
REPORT.RUNMODAL(REPORT::"Sales - Invoice", FALSE,FALSE,SalesInvHeader);
PdfFile.CLOSE;
Looking your code I think on REPORT.RUNMODAL you have to pass System printer as false if you are defining different printer for this report on printer selection else it is going to take default printer of Windows.
0 -
Thanks Rishabh for your reply.. Setting of password had been done already. I need to merge open invoices in one single PDF of a customer from Customer Card (from some menuitem).0
-
As Slawek_Guzek mentioned it would be best by building a filter to filter all your invoices in your repeat loop.
you can use a text variable for this and fill it with numbers split by the "|" sign. like invoiceno1|Invoiceno2 and so on.
After the loop you then set the filter on salesinvoiceheader with a setfilter and run the report once0 -
https://support.microsoft.com/en-us/help/2496107/platform-hotfix-resource-files-for-microsoft-dynamics-nav-2009-service
Refer This Link- You can use .net Variable and re-create this functionality.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions