Options

Save Custom Word Report layout as PDF - Skips next page

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


mqfw09ioned0.png


Answers

  • Options
    gerdhuebnergerdhuebner Member Posts: 155
    As far as I know for PDF creation of Wordlayout reports, a serverbased AddIn is used (which is based upon Aspose.Words in NAV 2016). Does the same effect occur with NAV 2016? It might be helpful, if you could show the correct printout for comparison. May be there is some issue with the page height setting or the page boundaries.
  • Options
    nhsejthnhsejth Member, Microsoft Employee Posts: 34
    This looks more or less like a problem in the Aspose.Words component that is being used to convert the rendered document to PDF. Is it possible to get a sample docx file without any customer data that I can use for testing the problem and possibly file a support case at Aspose? Sometimes it helps we upgrade the Aspose component to the latest version.
    _________________
    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.
  • Options
    gerdhuebnergerdhuebner Member Posts: 155
    edited 2017-01-13
    As a workaround you may try a clientside conversion to pdf via Word (MS Word needs to be installed on the client computer). Here is a small code snipet, which should replace the code in function ConvertToPdf in Codeunit 9651 and should work with NAV 2017, too:

    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:
    6z8gqdvmauwa.png
    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/ )
    p3.PNG 25.7K
Sign In or Register to comment.