Page 1 of 1

PDF from XML/XSL

Posted: Thu May 22, 2014 11:20 am
by kenbla
Hello, I work in a Delphi environment and I want to find out what the best way is to create a PDF file in the following case:
- I have an XML file
- I have an XSL file which is use/can use to convert the XML file to an HTML report
- I want to create a PDF file from the HTML report and store it to disk
Thanks!

Re: PDF from XML/XSL

Posted: Thu May 22, 2014 12:19 pm
by Tracker Supp-Stefan
Hello Kenbla,

You've posted in our OCR forums, so I will move your topic in a more appropriate place when you see this reply.

I believe it would be easiest for you to utilize our printing drivers:
https://www.pdf-xchange.com/product ... rivers-api
And you will only need to "print" either the XML of HTML file to it, and can then control the print job fully via code.

Regards,
Stefan

Re: PDF from XML/XSL

Posted: Fri May 23, 2014 12:02 pm
by kenbla
I have made some progress in this matter but I'm not quite there yet!
I have copied some code from the examples that came with PDFXChange like this:
"if (bwrPrint.ReadyState = READYSTATE_COMPLETE then)"
Normally bwrPrintReadyState should be equal to READYSTATE_COMPLETE but in my case it is equal to READYSTATE_LOADING (value 1) which means that the PDF conversion doesn't take place!
Can anyone explain to me what I might have done wrong?
Have a good weekend!

Re: PDF from XML/XSL

Posted: Mon May 26, 2014 11:50 pm
by John - Tracker Supp
Can you please provide some Pseudo code as to the process you are using to do the conversion and if you are interacting with any 3rd party tools or app's - etc - what they are and we will try to help.

Thanks

Re: PDF from XML/XSL

Posted: Tue May 27, 2014 5:24 am
by kenbla
Thanks John, I have now solved the problem and it works fine! I don't know what the problem was, all of a sudden it simply worked!

Re: PDF from XML/XSL

Posted: Tue May 27, 2014 8:12 am
by Tracker Supp-Stefan
Glad to hear that kenbla,

Cheers,
Stefan

Re: PDF from XML/XSL

Posted: Tue May 27, 2014 8:22 am
by kenbla
Hello again, I don't know to say this but the PDF creation in my Delphi program works at times but not always!! It worked fine from friday afternoon until this morning (tuesday) but when I ran the application this morning the PDF file did not get created! I have not made any changes to the application that has anything to do with the PDF creation!
Is PDFXChange unstable or what can the problem be?

Re: PDF from XML/XSL

Posted: Tue May 27, 2014 8:53 am
by kenbla
When it doesn't work the bwrPrint.ReadyState in my code example below is = 1 (is loading) and therefore the code including bwrPrint.ExecWB is not run! I have tried a number of things like put the application to sleep for a few seconds but it didn't help. One odd thing that has made the application work is to add a ShowMessage to the code (bwrPrint.ReadyState is then set to 4 for some reason)! But that is not a very good solution!
My code:
if bwrPrint.ReadyState = READYSTATE_COMPLETE then
begin
bwrPrint.Navigate(msExportPath + '\' + VAL_TEXT + msExcelFile + msBlobStreamFormat);
vaIn := OleVariant(VarAsType(PRINT_WAITFORCOMPLETION, varSmallint));
bwrPrint.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, vaIn, vaOut);
end;

Any explanation to my problem?

Re: PDF from XML/XSL

Posted: Tue May 27, 2014 5:11 pm
by Ivan - Tracker Software
I suspect you have to call bwrPrint.Navigate, then wait until bwrPrint.ReadyState become READYSTATE_COMPLETE.
Please check documentation about IWebBrowser interface (http://msdn.microsoft.com/en-us/library ... s.85).aspx)

Re: PDF from XML/XSL

Posted: Wed May 28, 2014 1:04 pm
by kenbla
Thanks for your reply. I have already performed a bwrPrint.Navigate (doesn't show in the piece of code I provided) and I have also tried to put my application to sleep for 10 seconds after the first bwrPrint.Navigate so that doesn't seem to be the problem in my case. And also the fact that it works sometimes but not always is a bit scary!

Re: PDF from XML/XSL

Posted: Thu May 29, 2014 7:53 pm
by Ivan - Tracker Software
We have no control over IWebBrowser component - it is IE's part.