PDF - odd action when no records

edited January 2016 in Devices

WE have used Report Builder to create reports in various
formats for years - especially pdfs. (now version 15.x)

-Sometimes a pdf file is generated by doing a print-to-file
and specifying the filetype. Easy.

-Sometimes in code we stream the pdf by creating a pdfdevice
and using printtodevices. Slick.


A client noticed recently that if the primary pipeline SQL select
returns no records the pdf action seems to breaks down.

In that case,

Building the report and streaming it back returns a small stream
of bytes but they do not seem to constitute a valid PDF.

Printing the report to file does not create a file at all.

What we expected was a valid pdf showing the fixed header and footer
elements with mostly empty space in between.

Has anyone any experience with this?

(The Streaming case is the one that concerns us - our REST web service
is returning invalid pdf streams on some requests because of this)

tonyM
ClearCycle

using both 12.x and 15.x

Comments

  • edited January 2016
    Hi Tony,

    Take a look at the TppCustomReport.NoDataBehaviors topic in the
    ReportBuilder help. This property controls whether a page is sent to
    the devices (PDF, Printer, Screen, etc.) when no data is present.

    By default this is set to ndBlankPage which prevents a page from being
    sent. If you would like to see all non data-aware components, you will
    need to change this to ndBlankReport.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2016

    Thanks Nico,
    Your suggestion was eminently sensible.

    Before calling PRINTTODEVICES we tried specifying an empty is OK - to be
    generated:

    rp.NoDataBehaviors:=[ndBlankPage,ndBlankReport]; //tested

    rp.NoDataBehaviors:=[ndBlankReport]; //also tested

    The resulting streamed PDF consistently gives the same behavior with or
    without these lines.

    when streamed into firefox it displays a blank pdf and suggests that a
    different program
    should be tried to better view it.

    When streamed to a file and opened with Acrobat reader it just says its bad.

    Again, we can work around this since our webbroker code knows that the sql
    returned
    no records and can stream back a suitable stub pdf in such cases...but we
    did wonder about this.

    thank you for your help,

    tonyM
    clearcycle


  • edited January 2016
    Hi Tony,

    The OutputStream property is meant to give the developer complete
    control over the generated stream. It is up to you to verify and process
    the stream once it is created.

    In my testing, using ndBlankPage and exporting to a memory stream then
    saving to file did give an invalid file due to the fact that no pages
    were received. This was expected.

    In a similar test, using ndBlankeReport gave a valid PDF with the non
    data-aware controls present.

    Please create a simple test application that demonstrates the behavior
    you describe and send it to support@digital-metaphors.com so we can
    track down any issues with the ndBlankReport property.

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.