Hi All,
I have a question about my custom Word report Layout.
Since I have a customer that wants to make use of the NAV Custom Word layout, I created some nice content with nesting repeaters.
So I created a dataset that has loops within loops (loopieloopie).
When my repeater on the page, hits the next page when viewing my result report everything goes well in Word.
But when I try to print the report as a PDF (CTRL+SHIFT + P), the PDF skips my next page.
It seems that it's trying to post everything on 1 page.
When saving the Word-file as PDF or send the report to a PDF-printer (Bullzip) the PDF is created as it should be.
Only when saving as PDF directly from the requestpage it goes wrong.
I am using NAV 2017
Answers
Niels-Henrik Sejthen
Senior Software Developer
Microsoft Dynamics NAV
The information in this post is provided "AS IS" with no warranties, and confers no rights. This post does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion.
IF NOT GetWordApplication(WordApplication) OR ISNULL(WordApplication) THEN
ERROR('Microsoft Word is necessary for conversion to PDF format.');
FileName := FileMgt.ClientTempFileName('docx');
FileName := FileMgt.BLOBExport(TempBlob,FileName,FALSE);
FileNamePDF := FileMgt.ClientTempFileName('pdf');
WordDocument := WordHelper.CallOpen(WordApplication,FileName,FALSE,FALSE);
WordHelper.CallSaveAsPdf(WordDocument,FileNamePDF);
WordHelper.CallClose(WordDocument,FALSE);
WordHelper.CallQuit(WordApplication,FALSE);
IF DeleteClientFile(FileName) THEN;
ServerFileName := FileMgt.UploadFileSilent(FileNamePDF);
FileMgt.BLOBImportFromServerFile(TempBlob,ServerFileName);
IF DeleteClientFile(FileNamePDF) THEN;
IF DeleteServerFile(ServerFileName) THEN;
DeleteServerFile is a custom TryFunction implemented like DeleteClientFile and essentially calls
FileMgt.DeleteServerFile. Furthermore some new local variables have to be defined:
Be sure to make the three Word-DotNet variables RunOnClient=Yes.
This code is also useful for Wordlayout+ when a PDF output is needed.
(see https://massivedynamicsblog.wordpress.com/2016/09/15/wordlayout/ )