Jump to content

misc_bb

Members
  • Content Count

    65
  • Joined

  • Last visited

Community Reputation

7 Neutral

1 Follower

Technical Information

  • Delphi-Version
    Delphi 11 Alexandria

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. misc_bb

    New Delphi job opportunity

    I'd love to see Delphi opportunities as well. Looking forward to seeing them as I am very much interested. I've worked with Delphi 7 but currently I'm now working with Delphi 11 focusing mostly on using Delphi as backend for a web application with primary task on integrating accounting software such as Xero, Quickbooks and MYOB. Should there be any opportunities in this area, hit me up. 🙂
  2. misc_bb

    Work with PDF documents

    I have been using PDFtk (https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/) in our Delphi apps to merge documents. I haven't tried splitting but PDFtk has also the splitting function. you may want to give it a try. As for our case, we utilized the command prompt and we just issue a call Shellexecute in our app. Works just fine.
  3. Currently we have a web app with Delphi as a backend. We are planning to incorporate NodeJS as well because we want to take advantage of some JS libraries like a headless browser in our application. I am still not sure if this would work out just fine since I'm currently exploring. I just wanted to ask if someone else have tried this setup before I fully dive into this. Any thoughts or comments are appreciated. Thank you.
  4. misc_bb

    Working with Delphi and Excel

    @corneliusdavid Thank you. I think I'll go for this library. @Dave Nottage I'm currently using OLE but wanted to avoid Excel app from opening. Thank you for the suggestion but I've been thru a lot with OOXML working with docx files, I don't want to go there for the mean time.
  5. misc_bb

    Working with Delphi and Excel

    I think I've read this article as well. Not interested in buying yet but we'll see. Thank you.
  6. misc_bb

    Working with Delphi and Excel

    I know a lot of you might have worked with reading and writing Excel sheets with Delphi. I would like to ask if its possible to read an excel file without opening it?
  7. misc_bb

    Delphi REST with PDF files

    After some trial and error again, was able to figure it out. This integration is with the Datylon API & Delphi REST components which handles a PDF return type. Although free account in Datylon doesn't work with this API integration. If anyone want to implements the API or something similar, the following code can be utilized. You just need to add some error handling. Getauthorization - a function that return the Basic authentication with username and password 64bit encoded, small letter 'a' in 'authorization' is from datylon documentation templateid and datasource - these are datylon parameters that needs be followed based on Datylon documentation JSONStr - this is actually the JSON string that needs to be sent TRY RESTRequest := TRESTRequest.create(nil); RESTRequest.Client := TRESTClient.create(RESTRequest); RESTRequest.SynchronizedEvents := False; RESTRequest.Client.UserAgent := DatylonUserAgent; RESTRequest.Client.FallbackCharsetEncoding := 'raw'; RESTRequest.Client.BaseURL := datylon_BaseURI; RESTRequest.Client.ContentType := 'application/json'; RESTRequest.Client.Params.AddItem('authorization', Getauthorization, TRESTRequestParameterkind.pkHTTPHEADER, [TRESTRequestParameterOption.poDoNotEncode]); RESTRequest.Client.Params.AddItem('x-graph-template-id', templateid, TRESTRequestParameterkind.pkHTTPHEADER, [TRESTRequestParameterOption.poDoNotEncode]); RESTRequest.Client.Params.AddItem('x-graph-datasource-name', datasource, TRESTRequestParameterkind.pkHTTPHEADER, [TRESTRequestParameterOption.poDoNotEncode]); RESTRequest.Body.ClearBody; RestRequest.body.Add(JSONStr, ctAPPLICATION_JSON); // RESTRequest.Resource := 'render'; RESTRequest.Method := rmPOST; RESTRequest.Response := TRESTResponse.Create(RESTRequest); RESTRequest.Accept := 'application/pdf'; RESTRequest.Execute; Codesite.Send('AuthenticationProcess Result: ' + RESTRequest.Response.Content); Result := RESTRequest.Response.RawBytes; finally RESTRequest.Free; end; This code result will return rawbytes which you need to convert to a file. You need the FallbackCharsetEncoding to 'raw' - this I'm not sure but I've read this from here: https://community.embarcadero.com/de/component/easydiscuss/rest-request-error-to-get-pdf-attached-berlin-10-1?Itemid=1 I'm not even sure if it made a difference but I lost track of it which ones is working and which one is not when I was doing my trial and error. 🤣 the ultimate goal is to make it work haha This is for the bytes to file conversion: procedure TfrmMain.SaveBytesToFile(const Data: TBytes; const FileName: string); var Stream: TFileStream; begin Stream := TFileStream.Create(FileName, fmCreate); try if Data <> nil then Stream.WriteBuffer(Data[0], Length(Data)); finally Stream.Free; end; end; //This will call the REST function above RestResultFile := API.PDFProcess(LoadTextFromFile('text1.txt')); //text file here contains the JSON string SaveBytesToFile(RestResultFile, 'test.pdf'); Thank you guys for your ideas. It led me to this solution above. Cheers!
  8. misc_bb

    Delphi REST with PDF files

    In my testing I encounter this result: {"Error":"Content type not recognized"} Should I explicitly specify the return type in code? In Postman, there's no need for that but I'm not sure with Delphi REST. I've dealt with other APIs before but those are all text, json values and Delphi REST works perfectly.
  9. misc_bb

    Delphi REST with PDF files

    Thank you. I guess i'll just have to figure it out how to handle the return PDF file. @Mohammed Nasman Yes, Delphi MVC is very good but I think it's too much for what I require. Thank you.
  10. Hello, I'm currently implementing a tool to handle an API using Delphi REST components. The API we are dealing with returns a PDF file. Can Delphi handle REST this file type? I don't see any file type/content type option in the object inspector. I've made some testing it doesn't seem to replicate what I have in Postman. Anyone have tried using Delphi REST with a PDF file as response? I just want to know otherwise I'll shift to Python. Thanks in advance.
  11. misc_bb

    PDF Library

    Any recommendations for Delphi library for PDF handling? I'm currently working on merging multiple files into 1 pdf file. Fast-reports said it handle this, any thoughts?
  12. misc_bb

    Getting PID of winword.exe based on filename

    Thank you for the idea on this topic. I don't want to go the hard way I can probably do this one at a time. I'll just terminate winword after every documents' final save until the next document opens.
  13. I'm able to get the PID of a processname (ex: winword.exe) but interested of getting the PID of winword.exe based on a specific filename, is this possible? I was able to look capture the PID from winword but if there are multiple instance I can't kill all instance but only a specific one. I'm not so familiar with Winapi handling, based on this post: Delphi Get the handle of a EXE he is trying to change his approach from 'Window name' to an Exe name. But parameter @processid needs to be specified. How can I get the processid in this case based on filename or window name?
  14. misc_bb

    Using COM to update Word docx files

    Thank you @Remy Lebeau I'll give this a try. wow it does work! I never thought it was possible because in my readings, word needs to open the file in order to update the table of contents. Thanks again! 😉
  15. Anyone playing around with docx files and trying to update a table of contents via win32com? I've got a working one with Python but our production environment runs on 10.4 only and we're having issues compiling it with P4D. So, i'll just ask if anyone has some similar implementation of this Python code in Delphi? def update_toc(docx_file): word = win32com.client.DispatchEx("Word.Application") doc = word.Documents.Open(docx_file) doc.TablesOfContents(1).Update() doc.Close(SaveChanges=True) word.Quit() thanks in advance for your thoughts and comments.
×