NAV2016 - Report is printed or saved as pdf ?

aod74aod74 Posts: 4Member
Dear all,

I have a Report, that uses a logo.. everything works fine, but now I have the request to hide the Logo when the Report is printed, but show it when the Repost is saved as pdf using the Option "Save as pdf" from the Request Page.

How can I do this ? Any Possibility to set a Variable at Request Page, depending which Option is chosen (or Button is pressed) ?

Thank you

Answers

  • rehansattirehansatti Posts: 36Member
    Hi @aod74, Include a Boolean variable in the data-set o report. Set the value of this variable to true or false on the relevant action. For example set this variable true on Print. Attach this variable to the visibility control on the report. That,s All.
    Best Regards
    Rehan Satti
    Microsoft Dynamics NAV Technical Consultant
    Please verify the answer if it satisfy your question. This will help other members of community.
  • aod74aod74 Posts: 4Member
    edited 2017-02-08
    Thank you rehansatti, but I think I did not describe the Problem really good.. What you have written is clear for me, but how can the Report know at Runtime if it's called to print or "saveaspdf" .. I can use CurrReport.Preview to know if it's a Preview.. But how to find out if Report is called by "Save PDF" Option from the request Page
  • TiwazTiwaz Posts: 95Member
    I think that this, as described, is impossible to determine at runtime.
    I suggest following solution which will, perhaps, be acceptable by your clients.
    You can add a boolean field to RequestPage, put logo inside rectangle and set rectangle visibility to be HIDDEN if that boolean field is being checked.
    For example, that boolean field could be called: Hide company logo.
  • aod74aod74 Posts: 4Member
    Thank you Tiwaz. I think this is not an acceptable solution and will not work in this case because most Invoices are booked by Batch-Post of Sales Order and there are some Customers that get printed Docs by Mail and others that should get them as pdf via E-Mail ..

    I hope somebody can help me..
  • binilabrahambinilabraham Posts: 45Member
    Just try this way, Create an Option variable with two options like ; Print,PDF. Use this option in your request page. Then set a visibility expression to hide or show the logo as per the option you selected in request page. Like this; IIF(Fields!ReqOptionValue.Value="Print",TRUE,FALSE)
    Software Developer,
    Archerpoint India Pvt. Ltd,Chennai.
  • rehansattirehansatti Posts: 36Member
    In the request Page set the page property savevalue to Yes So it will keep the option values saved.
    Best Regards
    Rehan Satti
    Microsoft Dynamics NAV Technical Consultant
    Please verify the answer if it satisfy your question. This will help other members of community.
  • kaspermoerchkaspermoerch Posts: 43Member
    edited 2017-02-14
    I think your option would be to take at look at how the Customer Statement (Report 116) is handled.

    It's marked as Processing Only and then has an output option on the request page, where you select the output you want.

    Then when the report is run it calls itself again, but this time using the Report.SAVEAS, specifying the output according to what was selected on the the request page or using Report.PRINT.

    You might however need to modify the way reports are run when doing e.g. Batch Post.
  • armelaarmela Posts: 17Member
    aod74, did you come up with a solution on this ? DO you mind sharing ? I need to do exactly the same thing.
  • xStepaxStepa Posts: 88Member
    Hi, there is a way to detect it using the DotNet and call stack (System.Diagnostics.StackTrace), but it's not very easy and clean solution ...
    Regards
    xStepa
  • BlackTigerBlackTiger Posts: 1,216Member
    The Question is - what for?
    Technically there is no difference between print to paper and print to pdf.

    PS: report can be saved as Word/HTML document too.
    "You can’t just ask customers what they want and then try to give that to them.
    By the time you get it built, they’ll want something new.” Steve Jobs
  • einsTeIn.NETeinsTeIn.NET BochumPosts: 1,036Member
    I also don't understand the problem. I mean if the issue is that the report needs to be printed by batch, then there's somewhere a condition that determines whether the current customer wants to have a hardcopy or an email. You can use the same condition to decide whether to show the logo or not.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • jglathejglathe Posts: 638Member
    Hi there,

    I happened to have exactly the same requirement. Solution is to have a field in the root table of the report (like Sales Invoice Header), and set a filter on it in appropriate places (codeunit 452, EmailDocument() among them, but (for NAV2016) not the only one). In the report, on OnPreDataItem, check for the filter, take action (show logo or not), and remove the filter on this field. The report has no other way to know it's printing in SAVEASPDF mode.
    Now my issue with SAVEASPDF is this: The logo image gets distorted, in fact really botched up when the report prints via SAVEASPDF. It doesn't when you use a printer driver, or to Word/Excel the logo image stays as it should. Anybody seen this? And how do you avoid it?

    with best regards

    Jens
  • jglathejglathe Posts: 638Member
    jglathe wrote: »

    And how do you avoid it?

    Well, this seems to be an issue with jpegs as an embedded image in the RDLC report. Use a png file, and it works.

    Merry christmas everybody. :)

  • vaprogvaprog Posts: 877Member
    For RDL rendering you can use Globals!RenderFormat.Name in a visibility condition.

    I guess there will be something similar using VBA for Word layout.
Sign In or Register to comment.