DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

use of .pdf file in report

Hello,

is it in any way possible to use an existing pdf file or page in report or include it in the pdf generation?

Tijs

0 Kudos
Message 1 of 7
(5,779 Views)

Hi Tijs,

 

It is possible to concatenate the sheets in REPORT to the end of an existing *.pdf file by setting the second parameter to TRUE or 1 in the PDF export commands:

 

Call Report.Sheets.ExportToPDF(PdfFilePath, TRUE)

 

Call PicPDFExport(PdfFilePath, TRUE)

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 7
(5,762 Views)

Brad,

Thank you very much for this usefull answer, it is actually more than I expected to be possible. I'll have to play around with a series of this function but from your description of it I expect It can fulfill my needs.

 

Tijs

0 Kudos
Message 3 of 7
(5,758 Views)

And wow, sorry for my ignorance. A 2 second search in Diadem help was all needed to find this. Still I thank you very much for pointing this feature out to me.

Also just now thinking about it, this solution, unfortunately, might not do what I hoped to achieve as any existing PDF will always end up up front. I would like to be able to include existing PDF info in between REPORT Sheets I create and convert to PDF.

0 Kudos
Message 4 of 7
(5,756 Views)

Hi Tijs,

 

The concatenation feature will always add to the end of the PDF file.  If you want to assemble the pages in any order, I recommend you save each page to an image files such as *.png and then when you are done load each picture back into DIAdem and do a final PDF export.

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 5 of 7
(5,737 Views)

Brad,

 

This indeed seems to be the only way to fulfill my need as the PDF files I need to add are pre existing and I'd like the complete report be generated by Diadem 'with one push of a button'.

After some minimal research I think I can get everything working as I would like using Ghostscript to convert any required PDF file to seperate PNG files and then load its pages.

I currently use:

Call ExtProgram ("C:\Program Files\gs\gs9.14\bin\gswin64c", "-dSAFER -dBATCH -dNOPAUSE -r200 -sDEVICE=png16m -dGraphicsAlphaBits=4 -sPAPERSIZE=letter -sOutputFile=D:\Drop\Temp\PNG-%d.png D:\Drop\Temp\PDF.pdf")

 I have tried to get a variables within this command for the input and output files and locations but couldn't get it to work so as is I'll have to shuffle files around to be able to use this rigid approach. If there is any way to get a variable within this code it's use would be a lot easier.

As the external program is called the script continues without knowing when the required info (files) is available. To prevent using a fixed pause time I tried to use a small pause and compare filesize before and after pause to determine if a file is fully available, Unfortunately this doesn't realy work as well as I hoped. Also I guess that used h/w and other processes running at the same time would effect what pause time to  use. I might have to find another way to see if a file is generated completely but I'll quote anyways:

Do
k= FileSize (Wrkdir & "PNG-"&i&".png")
   Call Pause (0.3)
Loop Until (k=FileSize (Wrkdir & "PNG-"&i&".png")) 

 Although the script now does what it needs to do there is some shuffeling of files required because of the rigidity in the call to the external program and to keep it reliable longer than required pause times are needed.

The realisation of a function that will insert existing Pdf files(pages) is becoming within grasps If I can get around these 2 minor issues.

 

Tijs

 

 

0 Kudos
Message 6 of 7
(5,712 Views)

Hi Tijs,

 

You can use string concatenation in VBScript to pass the contents of a variable to either parameter of the ExtProgram function, like this:

 

PdfOutFilePath = " D:\Drop\Temp\PDF.pdf"
ProgramPath = "C:\Program Files\gs\gs9.14\bin\gswin64c"
Extensions = " -dSAFER -dBATCH -dNOPAUSE -r200 -sDEVICE=png16m"
Extensions = Extensions & " -dGraphicsAlphaBits=4 -sPAPERSIZE=letter"
Extensions = Extensions & " -sOutputFile=D:\Drop\Temp\PNG-%d.png"
Extensions = Extensions & PdfOutFilePath
Call ExtProgram(ProgramPath, Extensions)

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 7 of 7
(5,684 Views)