APP REQUEST: Attributes-Export to a printable sheet

Started by sinus, July 10, 2017, 05:27:20 PM

Previous topic - Next topic

sinus

Hi
I have 2 important scripts, what I am simply not be able to scripting.
One I have requested here (or Jingo did it for me, thanks!): https://www.photools.com/community/index.php?topic=6871.0
This one above is the heavy stuff, what I am surely not able to coding.

It should end up with some text and numbers in the Attributes - fields (one global set for Adresses, one calculations-set per file).
So I have the correct adress and numbers and dates in the attributes-fields of a file.

What I want to do now is finally to create a bill for a client.
With IMatch5 I had this coded with VB as an export to Microsoft Word. This worked fine, because Word has also a VB-scripting-language and I could exacly positioning each field in the word-doc.
Even such things like bold - text and so on.

See attachment 1, shows the Attributes-fields
Attachement 2 shows the word-doc after the export-script.
Each attributes-field has its place (at least these fields in the red rectangles).

Now, with JS I think this is not possible or only very difficult to scripting.

Hence my question and request:
The target would be, ending with a document, what I could finally print out.
This could be a doc, or a pdf or an excel-sheet or, like Mario proposed once, a html-output, what could be converted into a word or pdf.

What format (pdf, doc...) does finally not matter. Important is, that is works somehow.
I tried also something with csv-export, but could not find a good solution.

What do you think, is it possible to create a script? (like I could do in Visual Basic)
Or do you have another good and easy proposal?


If I could solve these two requests (attribute-calculation and export to a printable sheet), then I could use IMatch2017, what I would of course like to do!  :D

Thanks for any help in advance.

Best wishes from Switzerland! :-)
Markus

Jingo

Thanks Markus...

Thorsten - is this second something you can work on as part of the other attribute app you working on?  If not - I'm happy to give this a shot once your attribute APP is complete...

sinus

Quote from: Jingo on July 11, 2017, 03:40:05 PM
Thanks Markus...

Thorsten - is this second something you can work on as part of the other attribute app you working on?  If not - I'm happy to give this a shot once your attribute APP is complete...

No, Andy, I do not work on this, because I am simply not able to do it.  :-[

And the other app (APP REQUEST: Attribute Script Calculator), this is the app, on what Thorsten does work.

Would be really cool, if you could help here out. If you have more questons, do not hesitate to ask! Thanks in advance, for looking into this.  :D
Best wishes from Switzerland! :-)
Markus

Jingo

Quote from: sinus on July 11, 2017, 03:46:02 PM
Quote from: Jingo on July 11, 2017, 03:40:05 PM
Thanks Markus...

Thorsten - is this second something you can work on as part of the other attribute app you working on?  If not - I'm happy to give this a shot once your attribute APP is complete...

No, Andy, I do not work on this, because I am simply not able to do it.  :-[

And the other app (APP REQUEST: Attribute Script Calculator), this is the app, on what Thorsten does work.

Would be really cool, if you could help here out. If you have more questons, do not hesitate to ask! Thanks in advance, for looking into this.  :D

Thx Markus - I was actually seeing if this 2nd part was something that Thorsten wanted to try and tackle as well once this 1st part is complete.   ;D  I know you are still in the early stages of IM2017 App learning which is just fine... we are here to help!!   8)

sinus

Thanks really, Andy!

Phew, if you and Thorsten really could create such scripts, this would simply cool and very good.

I just downloaded IMatch 2017 ... to try and "play" a bit with it. My huge DB will hopefully also be a bit faster.

Best wishes from Switzerland! :-)
Markus

thrinn

@Markus: The Attribute Calculator works already in a preliminary version (only a few fields), but I have to do some tests before publishing it.

@Andy: Regarding the export to a printable sheet: I think creating a HTML page with all required fields will be doable without any helper libraries. Maybe getting the layout right could be a challenge. After all, HTML was created with layout flexibility in mind.  For creating a PDF one would need some external JS library. I am sure there will be a bunch of them in the wild, but I do not know them (and, honestly, I am not keen on diving into that).
If every invoice fits on one page, using HTML should be ok. Either as an export, or for direct printing using standard browser  functionality. If one needs a PDF, using a PDF printer should suffice.

So far my thoughts on this subject. But I want to finish part one first, so if you want to try the export part, you are welcome  :)
Thorsten
Win 10 / 64, IMatch 2018, IMA

sinus

Quote from: thrinn on July 11, 2017, 09:11:27 PM
@Markus: The Attribute Calculator works already in a preliminary version (only a few fields), but I have to do some tests before publishing it.

Hi Thorsten
Wow, sounds cool. I am curious, how you could scripting something like this.  :o

Best wishes from Switzerland! :-)
Markus

sinus

So, finally, thanks to Thorsten, "my"  :-[ first app is almost finnished.
Without help I would have been lost.

But it works now really, what I had never thought.
You can see this in my attachement.
For me personally it is very important having a working start.
Because then I can look up and can add fields or other stuff. But if I begin with a white paper, I am at lost.

So the Attribute-calculator is (almost) finnished, except some design-things.

Now, when the values are in the Attributes, exporting this in Word (or excel) would be the second step (see start of this thread).

Mario gave lately a good hint  https://www.photools.com/community/index.php?topic=6389.msg48326#msg48326
with something like this (from Mario:)
Please consider revising the way you write scripts. When all you want is to automate Word (get data from IMatch into Word) it is probably much easier to write a Word script in VBA (which runs in Word) and which loads data from IMatch via IMWS. VBA has been designed to automate Office products, and loading some data from a web service (like IMatch) is very easy.

He gave me also the tip of this link: https://waidner-itsolutions.de/wordpress/2012/11/03/webservices-mit-vba-ansprechen/

' Democode für Webservice-Aufrufe über GET und POST
'
' 3.11.2012 - Waidner IT Solutions

Option Explicit

Sub XMLHttpTest()
    Dim XMLHttp As Object
    Dim strURL As String, strMethod As String, strUser As String
    Dim strPassword As String
    Dim bolAsync As Boolean
    Dim varMessage

    ' Microsoft XML HTTP Objekt erzeugen
    Set XMLHttp = CreateObject("MSXML2.XMLHTTP")

    ' -------------- POST-Request, der xml liefert -------------

    ' Parameter für einen simplen POST-Request ohne Authentifizierung füllen
    strMethod = "POST"
    strURL = "http://www.webservicex.net/country.asmx/GetCountryByCountryCode"
    bolAsync = False
    strUser = ""
    strPassword = ""
    varMessage = "CountryCode=DE"

    MsgBox "POST-Request, der XML liefert"

    ' Request absetzen
    Call XMLHttp.Open(strMethod, strURL, bolAsync, strUser, strPassword)
    Call XMLHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
    Call XMLHttp.send(varMessage)

    ' Rückgabewerte ausgeben
    MsgBox "Status: " & XMLHttp.Status
    MsgBox "responseText: " & XMLHttp.responseText
    MsgBox "reponseXML: " & XMLHttp.responseXML.Text

    ' ---------------- GET-Request, der json liefert ----------------

    ' Parameter für einen simplen GET-Request ohne Authentifizierung füllen
    strMethod = "GET"
    strURL = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=test"
    bolAsync = False
    strUser = ""
    strPassword = ""
    varMessage = ""

    MsgBox "GET-Request, der JSON liefert"

    ' Request absetzen
    Call XMLHttp.Open(strMethod, strURL, bolAsync, strUser, strPassword)
    Call XMLHttp.send(varMessage)

    ' Rückgabewerte ausgeben
    MsgBox "Status: " & XMLHttp.Status
    MsgBox "responseText: " & XMLHttp.responseText
    MsgBox "reponseXML: " & XMLHttp.responseXML.Text
End Sub


and this from Mario:
Google for

access REST web service from VBA

to find many examples for Excel and Word.


I did already look up and did even some first test, but so far without success.


Finally, Andy, would you think, should I go this line, what Mario proposed (VB with access to IMatch).
Maybe, I am of course very unsure, I could have success one day, with this way, because code of VB is more familiar to me. (but I am also a very bad scripter, really).

Or do you think, the other way round (do it with JS from inside IMatch out) is better? But in this case I am more lost, I am afraid and would be happy for some start-hints.
But maybe the VB - way is maybe really better?!

Grrr, what a pity, that all is soooo difficult (for me specialy for a starting point).
But, btw, it makes really fun, when I can work with Thorsten's app, adding field for field and see, after also add some calculations, that it works, in a kind of magic).  :D







Best wishes from Switzerland! :-)
Markus

sinus

After a lot of trying an reading and trying I think, this is not doable for me, too difficult. :-\

I think, I do try to work with the "Copy data app" and copy / paste some stuff several times in a word-doc.
Though not nice and akward, it is the only way I can see, that I can do what I want.

Luckily IM5 still works perfectly with my old VB-scripts, hence I have time to find a good solution for this problem here.  :D
Best wishes from Switzerland! :-)
Markus

Mario

Why don't you use the Text export module to create a CSV file with all the data you need? This can be imported into Excel, into the Serienbrieffunktion in Word etc.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Quote from: Mario on August 06, 2017, 10:12:54 AM
Why don't you use the Text export module to create a CSV file with all the data you need? This can be imported into Excel, into the Serienbrieffunktion in Word etc.

Thanks Mario,
I will look again in this. I had troubles to create from a csv a nice formatted letter.

But the day will come, where I will find a good solution for me.  :)
After this is solved, I have still some minor scripts to convert, but there I am positive, that I can do it, because they are not that difficult.
Best wishes from Switzerland! :-)
Markus

sinus

Quote from: Mario on August 06, 2017, 10:12:54 AM
Why don't you use the Text export module to create a CSV file with all the data you need? This can be imported into Excel, into the Serienbrieffunktion in Word etc.

Not so easy, see attachement.   :-[

But I will try and look further, but it turns out, that this problem is not that easy like it was with VB, phew, but I will work and try, and one day I will have a solution.  ;D
Best wishes from Switzerland! :-)
Markus

Mario

Eycel does not understand the format you have created and probably does not find the columns in your file.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

sinus

Hm.

Excel or Word in connection with csv it is quite hard to do, if not impossible (like in the start of this thread I explained I must have ONE Adress and several other fields.
A script would be best, I think, but is it not doable for me (at least not yet, maybe in 1 or 2 years).  ::)

But
at the moment I think I have an interesting solution, what would work even with images (export selected images).

Finally I have only say 10 images with attributes.
And I want only export some attributes, in this case 10 different attributes -fields, but 1 address-field (If I send a bill, the billed events are of course different, but the customer is the same).

And guess, what? (I tried a bit, but not deeply, but theoretically it should work)  ;)

Guess?!







...









The famous and very good "Design & Print"!

I am on a good track and here I am not an expert, but I know this modul very well.  :D
Hence maybe this could be my solution.
Boah, would be a milestone for me (another one after the Thorsten-script).
Best wishes from Switzerland! :-)
Markus

sinus

Just for those, who are interested.  :D 8)

Yep. Design & Print (or Print & Design, I can never remember  ::)) is the solution for me NOW.

It works great, but if I compare it with my old script, D&P is a bit more akward.
But one advantage: I can easy add (small) images, looks great.
(A bill with a nice picture of the event, for example).

My workflow is/was:
1) Select some images


The old VB-script:
a) opens Word
b) export some metadata-fields and attributes-fields into nice formated lines
c) I could even add bold, color and so on by the script
d) at the end the script calculated the total sum of all images, added the tax and calculated the total sum
e) the script does add the name of the word-doc based on one thumb and added some words
f) save and print the word-doc

The new workflow:
a) open D&P
b) choose a template, based on the amount of selected images (different templates)
c) add for each image in D&P one thumb from the lower row (static template)
d) the sums are neatly formated (from the attributes-fields), but for each position one image, but once created very quickly
e) Because I am not able to calculate the total sum with a script (from Thorsten), I add the total sum to one image.
f) This image with the total sum comes at the end and hence I have also the tax and total for all selected files.
g) because I need one thumb for each position, I can place it or I do simply overlay one big white rectangle over them, hence the images are hidden, means not on the paper
h) save a pdf, the name I have to add myself (also a bit akward)
i) Print the pdf

So the final result is the same.
Looks both very good.

D&P offers some very good things.

In the future I can maybe do some steps, what works better.
For exmple "calculate the sum of all selected images", I could add in my first script (the attributes-calculator from Thorsten), or maybe I could create a second script to "print the selected images out".
Also for the automatically created name of the pdf I could find a solution one day (like in my old script).

Fazit:
My current workflow works very good, although a bit akward.
But there is room for more enhancements.  ;D :)

At least I have changed now to IMatch2017!








Best wishes from Switzerland! :-)
Markus