Re: CAPI and PDF
Hi Camille,
Use gp:with-external-metafile to draw to a metafile.
On MacOSX, the metafile format is PDF, so in case of a single page, you are already there! If you want to make a multi-page PDF, you can achieve that by saving each page as a separate file and combine them using objc calls:
(let ((output-document (objc:invoke (objc:invoke "PDFDocument" "alloc") "init"))
(page-index 0))
(loop for filename in '("page1.pdf" "page2.pdf") do
(let* ((data (objc:invoke "NSData" "dataWithContentsOfFile:" filename))
(input-document (objc:invoke (objc:invoke "PDFDocument" "alloc") "initWithData:" data))
(single-page (objc:invoke input-document "pageAtIndex:" 0)))
(objc:invoke output-document "insertPage:atIndex:" single-page page-index)
(objc:release input-document)
(incf page-index)))
(objc:invoke output-document "writeToFile:" "multipage.pdf")
(objc:release output-document))
On Windows, the metafile format is EMF. Unfortunately, converting EMF to PDF doesn't seem to be very easy. I put many hours on this last November, without much success.
I managed to write a separate command-line tool in Delphi using an open-source PDF library. While this sort of worked, it suffered from strange graphical offsets of text, which made the resulting PDF useless for our purposes. I thought that the metafile support in LW was flawed, and I made a bug report to LW, but it turned out that the problems were caused by the underlying GDI+ library in Windows itself.
So far, I've failed to find a solution for PDF generation on Windows. If anyone has any input on this subject, I would be most grateful!
(Of course, there is always CL-PDF, but apart from not being actively developed or maintained, it is limited font-wise, as it doesn't have access to the fonts loaded by the system – you have to provide it with actual TTF files, which may not be possible in every case)
Regards
Erik
16 mar 2014 kl. 22:37 skrev Camille Troillard:
>
> Hello,
>
> Is it possible to generate a PDF file using CAPI/GP, without the underlying operating system's printing services?
> I am thinking about server-side PDF generation.
>
>
> Best,
> Cam
>
>
> _______________________________________________
> Lisp Hug - the mailing list for LispWorks users
> lisp-hug@lispworks.com
> http://www.lispworks.com/support/lisp-hug.html
>
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html