Want to save table data into pdf file in vision

Hi,
can we do like below instead of creating reports n all.
Here I just passed my table data to writefile function.
but it showing error at writefile function like '2nd args cant be coresed to bytes, string'

any solution for this?

resultSet =system.dataset.toPyDataSet(event.source.parent.getComponent('Table').data)
if len(resultSet) > 0: # if the query returned anything...
filename = system.file.saveFile("LogBookReport1122.pdf")
data=system.dataset.toDataSet(resultSet)
if filename is not None:
system.file.writeFile(filename, data)

image

No. A Dataset object is not a PDF. It could be serialized into a bytestream and saved, but that would not be readable by anything else.

The only tool in Ignition to make PDF files is the report engine. There are numerous external tools that can make PDFs, some are even free, but all would require communications between Ignition and that external tool.

{ I fixed the category, too. }

okay, Now I am trying to convert dataset 1st into excel and again it to pdf
like this

image

it is storing pdf file with 46kb but its not opening.
any idea?

Don't use a PDF extension. It isn't a PDF. Use .xls or .xlsx. The PDF conversion would be outside Ignition.

I use LibreOffice instead of MS Office. Among its other benefits (like being free), it has a command-line option to convert a document to PDF. I use it with LibreOffice Writer to automate updates to my user manuals in a few of my add-on modules. The command line looks like this:

lowriter --convert-to-pdf SomeDocument.odt

Which yields SomeDocument.pdf. Rather handy. I bet it works with LibreOffice Calc, too. I'm not sure what is possible via command line with MS Office.

But if there is, you can call such a command from Ignition with system.util.execute or use Java's ProcessBuilder tool.

FWIW, LibreOffice is pretty good at working directly with MS Office files, so might be able to handle this task for you.

1 Like

Hi, Ignition Reporting tool is worked for me, not sure what was the exact issue but I just created one new report and tried with that and it worked.

Thank you so much.

I have one doubt regarding named query,
I want to write like statement in where condition,
If I passes hardcoded value it is working, like below
where F_NUMBER like '%OTS-MAT-0040-F01%' ## It is giving proper result

If I used parameter like this, It is not giving output, whats wrong here?
where F_NUMBER like '%'+:num+'%' # Not working

Please help me this as well.
Thanks.

Your like statement needs to conform to SQL. So F_NUMBER like '%'+:num+'%' need to change to F_NUMBER like '%:num%' .

No Not working, I think it is considering num as a string but
:num is a parameter.

image

OK... so in the table what is the type of the column F_NUMBER? In the named query what is the parameter type of :num?

both have string datatype.f_number is a form_number it is a string.

What SQL Database server are you using? MySQL? MSSQL?

MSSQL database, or you can suggest me how to write it is report SQL Query.
anything will be ok for me.
finally I want to use that query for report only

In report as well If I pass hardcode value then it is working, If I pass ? (as parameter)
it's not working.

Hmmmm. What does F_NUMBER look like in the database? IE can you give an example of what kind of data is stored in there? And then what is something that you are using for :num to try and filter on?

Can you post your named query?

F_NUMBER consist of these type of values and I am passing same value, Its a very big nested query, very confusing,

image

If you test the named query and put in a value that you know exists in the column does it work? If you hardcode a value rather than using the num parameter does it work?

No, I tried with that but not working.
even I tried with f_number='OTS-MAT-0040-F01' instead of like n all
still not working

Then you have a fundamental Query issue. If this is MSSQL can you run the query in the SQL Server Management studio and make it work?

Are you able to post the query here?

sure. There are more 6 parameretes, for now I am trying with only one i.e f_number

Yeah... that's a big one huh.
You may need to break it down into sections and test the sections individually to figure out where the issue is.

I think issue is with parameter only, for harcode value it is returning proper output.
will '-' causes the issue?
its in the value of f_number

image