04-02-2014 01:39 AM
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
04-02-2014 12:49 PM
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
04-02-2014 02:00 PM
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
04-02-2014 02:13 PM
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.
04-04-2014 11:41 AM
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
04-08-2014 07:50 AM
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
04-10-2014 02:15 PM
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