Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
kpatelacmm
Contributor
Contributor

Printing PDF's with a loop

I don't have the publisher server therefore i need to be able to print pdf's but i have a loop set up in my reports and really would like to be able to create a pdf for each loop. So i have a list of doctors and i need a PDF printout for each and an added bonus would to save the pdf's according to a specified naming convention.

13 Replies
rustyfishbones
Master II
Master II

Create a report that contains what you want to show.

You can then export based on the Doctors name using Banding, so it will create a report for each Doctors name as that field has been selected as Banding

Here is a video link from youtube, Banding is explained at the end, this could work for you

http://youtu.be/AqU0FanTmag

this link about the video will also help  http://www.quickintelligence.co.uk/qlikview-reports/

kpatelacmm
Contributor
Contributor
Author

Yes thank very helpful. It works however it creates one huge PDF. Is there a way to save each PDF separately automatically so instead of 500 doctor reports on one PDF it will create 500 individual PDFs and automatically save each PDF with the doctors name in the naming convention.

Thanks.

rustyfishbones
Master II
Master II

Sorry, that's as much as I know about it.

I will ask some friends if it can be done and I will get back to you, but you may still get an answer on this community, good luck!

kpatelacmm
Contributor
Contributor
Author

Great thanks for your help.

rustyfishbones
Master II
Master II

try this blog post from Stephen Redmond

http://qliktips.blogspot.com/2012/02/printing-reports-to-pdf-using.html

I am not sure if this will, I hope it does

calvindk
Creator III
Creator III

I did all of that in vba script.

Loop through and print to bullzip or similar pdf.

Then you can save them as that, email them, whatever.

here are the vb macros i used:

Sub ProdPrint()

ActiveDocument.ClearAll True

Set Prods = ActiveDocument.Fields("ProdTour_id").GetPossibleValues

For i = 0 to Prods.count -1

    ActiveDocument.Fields("ProdTour_id").Select Prods.item(i).Text

    DagRapport()

Next

ActiveDocument.ClearAll True

End Sub

'//////////////////////////////////////////////

Sub Dagrapport()

set v=ActiveDocument.Fields("ProdTour_id").GetSelectedValues

set vPrint=ActiveDocument.Fields("Print").GetPossibleValues

IF(v.Count = 1 and vPrint.item(0).Text = "Print") Then

    vReport = "RP01" 'Set report

    vName = v(i).Text 'Name of output pdf

    ActiveDocument.PrintReport(vReport), "Bullzip PDF Printer", false 'Printreport

    reportFile = "H:\" & vName &".pdf" 'Setting outputname

    'HAS TO HAVE FULL PATH!

    MyPrintPDFWithBullZip(reportFile) 'Call pdf printer

    ActiveDocument.GetApplication.Sleep 2000

'    SendGMail() 'SENDING MAIL

END IF

End sub

'//////////////////////////////////////////////

FUNCTION MyPrintPDFWithBullZip (pdfOutputFile)

  Set obj_printer_util = CreateObject("Bullzip.PDFUtil")

  printername = obj_printer_util.defaultprintername

  set obj = CreateObject("Bullzip.PdfSettings")

  obj.printername = obj_printer_util.defaultprintername

  obj.SetValue "Output" , pdfOutputFile

  obj.SetValue "ConfirmOverwrite", "no"

  obj.SetValue "ShowSaveAS", "no"

  obj.SetValue "ShowSettings", "never"

  obj.SetValue "ShowPDF", "no"

  obj.SetValue "RememberLastFileName", "no"

  obj.SetValue "RememberLastFolderName", "no"

  obj.SetValue "ShowProgressFinished", "no"

  obj.SetValue "ShowProgress", "no"

  obj.WriteSettings True

END FUNCTION

'//////////////////////////////////////////////

Sub SendGMail() 'send gmail with attachment

On Error Resume Next

    ' Object creation

    Set objMsg = CreateObject("CDO.Message")

    Set msgConf = CreateObject("CDO.Configuration")

   

    ' Server Configuration

    msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

    msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"

    msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465

    msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

    msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Something@gmail.com"

    msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Password"

    msgConf.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1

    msgConf.Fields.Update

   

    'Variables for email

    Set vDateObject = ActiveDocument.Fields("TourDate").GetPossibleValues

    vDate=vDateObject(i).Text

   

        set v=ActiveDocument.Fields("ProdTour_id").GetSelectedValues ' FINDING WHAT FILE TO SEND

        vName = v(i).Text 'Name of output pdf

        reportFile = "H:\" & vName &".pdf" 'Setting outputname

        'HAS TO HAVE FULL PATH!

   

    ' Email

    'objMsg.To = "Anders.Moller@domain.com" ' - TEST MAIL ME

    objMsg.From = "Random@domain.com"

    objMsg.Subject = "Liability Waiver " & vName & " " & vDate

    objMsg.HTMLBody = "Here is the liability waiver for prod: " & vName & " departing on the " & vDate

    objMsg.Sender = "Anders Moller"

   

    objMsg.AddAttachment reportFile ' Attachement

   

    Set objMsg.Configuration = msgConf

If err = 0 then   

    'Send

    objMsg.Send

End If

'Clear

Set objMsg = nothing

Set msgConf = nothing

End Sub

'//////////////////////////////////////////////

Sub TestPrint()

set v=ActiveDocument.Fields("ProdTour_id").GetSelectedValues

IF(v.Count = 1) Then

    vReport = "RP01" 'Set report

    vName = v(i).Text 'Name of output pdf

    ActiveDocument.PrintReport(vReport), "Bullzip PDF Printer", false 'Printreport

    reportFile = "H:\" & vName &".pdf" 'Setting outputname

    'HAS TO HAVE FULL PATH!

    MyPrintPDFWithBullZip(reportFile) 'Call pdf printer

    ActiveDocument.GetApplication.Sleep 2000

END IF

End sub

ngulliver
Partner - Specialist III
Partner - Specialist III

Hi,

Have you looked into using NPrinting ? It is considerably cheaper than Publisher. It has the functionality to enable you to loop and reduce data and send it out in a number of different formats (.pdf, excel, word, ppt etc) to multiple destinations. The scheduling function will allow you to do this automatically sending the files to email addresses, folders or google drive.

Have a look at http://www.quickintelligence.co.uk/nprinting/ for an intro. You can download a free trial version from . You can also request a trial licence that lasts 35 days which would give you full functionality.

Cheers,

Neil

jpapador
Partner - Specialist
Partner - Specialist

The vba script might work but if you are open to purchasing an add-on nprinting will do all of that and more. 

http://www.vizubi.com/nprinting/

Qlikview's default report editor is lack luster, probably because if they let you distribute easily people would'nt need to buy more licenses.

kpatelacmm
Contributor
Contributor
Author

For some reason i cannot access the webpage? How much does it cost?