OBJECT Codeunit 50003 WaterMark { OBJECT-PROPERTIES { Date=06/14/07; Time=[ 3:32:01 PM]; Modified=Yes; Version List=; } PROPERTIES { OnRun=BEGIN END; } CODE { VAR FileDirectory@1000000012 : Text[100]; FileName@1000000011 : Text[100]; ReportID@1000000010 : Integer; Object@1000000009 : Record 2000000001; PDFCreator@1000000008 : Automation "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613} 4.1:{3A619AE4-50EC-46C8-B19E-BE8F50DD2F22}:'PDFCreator'.clsPDFCreator" WITHEVENTS; PDFCreatorOption@1000000007 : Automation "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613} 4.1:{F8F15298-30FD-427C-BDFA-55E9AB615632}:'PDFCreator'.clsPDFCreatorOptions"; PDFCreatorError@1000000006 : Automation "{1CE9DC08-9FBC-45C6-8A7C-4FE1E208A613} 4.1:{082391C9-8188-4364-B4FD-66A1524B2097}:'PDFCreator'.clsPDFCreatorError"; DefaultPrinter@1000000005 : Text[200]; Window@1000000004 : Dialog; WindowisOpen@1000000003 : Boolean; FileDialog@1000000002 : Codeunit 412; watermark@1000000001 : Text[30]; adobe@1000000000 : Automation "{E64169B3-3592-47D2-816E-602C5C13F328} 1.1:{72498821-3203-101B-B02E-04021C009402}:'Adobe Acrobat 8.0 Type Library'.AcroAVDoc"; SalesHeader@1000000013 : Record 36; PROCEDURE makepdf@1000000000(rSpecifier@1000000000 : Code[10];OrderType@1000000001 : Code[10]); BEGIN FileDirectory := 'C:\'; FileName := 'pdf_file.pdf'; findsalesheader(rSpecifier); IF ISCLEAR(PDFCreator) THEN CREATE(PDFCreator); IF ISCLEAR(PDFCreatorError) THEN CREATE(PDFCreatorError); PDFCreatorError := PDFCreator.cError; IF PDFCreator.cStart('/NoProcessingAtStartup',TRUE) = FALSE THEN ERROR('Status: Error[' + FORMAT(PDFCreatorError.Number) + ']: ' + PDFCreatorError.Description); Window.OPEN('processing'); WindowisOpen := TRUE; IF FileName = '' THEN ERROR('Please specify what the file should be saved as'); //Object.GET(Object.Type::Report,'',ReportID); PDFCreatorOption := PDFCreator.cOptions; PDFCreatorOption.UseAutosave := 1; PDFCreatorOption.UseAutosaveDirectory := 1; PDFCreatorOption.AutosaveDirectory := FileDirectory; PDFCreatorOption.AutosaveFormat := 0; //PDF file, you can also save in other formats PDFCreatorOption.AutosaveFilename := FileName; PDFCreatorOption.StampFontname := 'Arial'; PDFCreatorOption.StampFontsize := 150; PDFCreatorOption.StampUseOutlineFont := 1; PDFCreatorOption.StampOutlineFontthickness := 2; PDFCreatorOption.StampString := OrderType; PDFCreator.cOptions := PDFCreatorOption; PDFCreator.cClearCache(); DefaultPrinter := PDFCreator.cDefaultPrinter; PDFCreator.cDefaultPrinter := 'PDFCreator'; PDFCreator.cPrinterStop := FALSE; //REPORT.RUNMODAL(ReportID,FALSE,TRUE); REPORT.RUNMODAL(50020,FALSE,TRUE,SalesHeader); END; PROCEDURE printpdf@1000000001(); BEGIN IF ISCLEAR(adobe) THEN CREATE(adobe); adobe.Open(FileDirectory + FileName,''); adobe.PrintPages(0,999,3,0,0); adobe.Close(0); CLEAR(adobe); CLEAR(PDFCreator); CLEAR(PDFCreatorError); END; PROCEDURE findsalesheader@1000000002(rSpecifier@1000000000 : Code[10]); BEGIN SalesHeader.RESET; SalesHeader.SETRANGE(SalesHeader."Document Type",SalesHeader."Document Type"::Order); SalesHeader.SETRANGE(SalesHeader."No.",rSpecifier); END; EVENT PDFCreator@1000000008::eReady@1(); BEGIN PDFCreator.cPrinterStop := TRUE; PDFCreator.cDefaultPrinter := DefaultPrinter; PDFCreator.cClose(); IF WindowisOpen THEN Window.CLOSE; WindowisOpen := FALSE; printpdf; END; EVENT PDFCreator@1000000008::eError@2(); BEGIN ERROR('Status: Error[' + FORMAT(PDFCreatorError.Number) + ']: ' + PDFCreatorError.Description); END; BEGIN END. } }4. call this function from PRINT button on say.. sales order.
Comments
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
changed it's extension to .fob
imported it in navision
now when i am trying to compile the code,it is giving an error--"could not load the selected type library".I have installed the PDF creator(Also verified its usage by converting reports in pdf ).
i have also activated the parameters on the functions in this code unit.
And the cursor points to the position where it is written
("ERROR('Status: Error: ' + PDFCreatorError.Description); ").
And it is at the end of the codeunit.
what to do now.
Explain it in detail.
Thanx in advance
No replies???
I have seen a couple different ones. This one is free, open source. Let me know if thats what you have.
Microsoft Certified Business Management Solutions Professional
Microsoft Certified Business Management Solutions Specialist
http://www.navisiontech.com
i have downloaded the PDF Creator from the same link but even then it's not working---the watermark thing.
Make sure you have right Automation libraries setup.
PDFCreator Automation 'PDFCreator'.clsPDFCreator
PDFCreatorOption Automation 'PDFCreator'.clsPDFCreatorOptions
PDFCreatorError Automation 'PDFCreator'.clsPDFCreatorError
adobe Automation 'Adobe Acrobat 8.0 Type Library'.AcroAVDoc
Microsoft Certified Business Management Solutions Professional
Microsoft Certified Business Management Solutions Specialist
http://www.navisiontech.com
Pls Provide the Report 50020 to work Watermark
Kiran
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I followed all the steps and called makepdf function from a print button with all the parameters but it just show me a processing window and nothing else. So i added the printpdf function after the makepdf and i get an error 'cannot create an instance of automation server. Check the automation server is correctly installed and registered'. The debugger stops on create(adobe) in printpdf function. But i have adobe reader 9.0 installed.
Thanks for any tip in the right direction
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n