PDF from XML/XSL

PDF-XChange Drivers API (only) V4/V5
This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-XChange Printer Drivers SDK (only) - VERSION 4 & 5 - Please use the PDF-Tools SDK Forum for Library DLL assistance.

Moderators: TrackerSupp-Daniel, Tracker Support, Vasyl-Tracker Dev Team, Sean - Tracker, Chris - Tracker Supp, Tracker Supp-Stefan

Post Reply
kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

PDF from XML/XSL

Post by kenbla » Thu May 22, 2014 11:20 am

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!
Regards,
Kenbla

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13632
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: PDF from XML/XSL

Post by Tracker Supp-Stefan » Thu May 22, 2014 12:19 pm

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:
http://www.tracker-software.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

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Re: PDF from XML/XSL

Post by kenbla » Fri May 23, 2014 12:02 pm

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!
Regards,
Kenbla

John - Tracker Supp
Site Admin
Posts: 8203
Joined: Tue Jun 29, 2004 10:34 am
Location: Vancouver Island - Canada
Contact:

Re: PDF from XML/XSL

Post by John - Tracker Supp » Mon May 26, 2014 11:50 pm

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
If posting files to this forum - you must archive the files to a ZIP, RAR or 7z file or they will not be uploaded - thank you.

Best regards
Tracker Support
http://www.tracker-software.com

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Re: PDF from XML/XSL

Post by kenbla » Tue May 27, 2014 5:24 am

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!
Regards,
Kenbla

User avatar
Tracker Supp-Stefan
Site Admin
Posts: 13632
Joined: Mon Jan 12, 2009 8:07 am
Location: London
Contact:

Re: PDF from XML/XSL

Post by Tracker Supp-Stefan » Tue May 27, 2014 8:12 am

Glad to hear that kenbla,

Cheers,
Stefan

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Re: PDF from XML/XSL

Post by kenbla » Tue May 27, 2014 8:22 am

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?
Regards,
Kenbla

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Re: PDF from XML/XSL

Post by kenbla » Tue May 27, 2014 8:53 am

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?
Regards,
Kenbla

Ivan - Tracker Software
Site Admin
Posts: 3611
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: PDF from XML/XSL

Post by Ivan - Tracker Software » Tue May 27, 2014 5:11 pm

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)
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.

kenbla
User
Posts: 64
Joined: Wed Jun 21, 2006 1:29 pm

Re: PDF from XML/XSL

Post by kenbla » Wed May 28, 2014 1:04 pm

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!
Regards,
Kenbla

Ivan - Tracker Software
Site Admin
Posts: 3611
Joined: Thu Jul 08, 2004 10:36 pm
Location: Vancouver Island - Canada
Contact:

Re: PDF from XML/XSL

Post by Ivan - Tracker Software » Thu May 29, 2014 7:53 pm

We have no control over IWebBrowser component - it is IE's part.
Tracker Software (Project Director)

When attaching files to any message - please ensure they are archived and posted as a .ZIP, .RAR or .7z format - or they will not be posted - thanks.

Post Reply