Popular Post UEZ Posted April 2, 2024 Popular Post Posted April 2, 2024 (edited) Quote Cairo is a 2D graphics library with support for multiple output devices. Currently supported output targets include the X Window System (via both Xlib and XCB), Quartz, Win32, image buffers, PostScript, PDF, and SVG file output. Cairo is designed to produce consistent output on all output media while taking advantage of display hardware acceleration when available (eg. through the X Render Extension). The cairo API provides operations similar to the drawing operators of PostScript and PDF. Operations in cairo including stroking and filling cubic Bézier splines, transforming and compositing translucent images, and antialiased text rendering. All drawing operations can be transformed by any affine transformation (scale, rotation, shear, etc.) Cairo is implemented as a library written in the C programming language, but bindings are available for several different programming languages. Cairo is free software and is available to be redistributed and/or modified under the terms of either the GNU Lesser General Public License (LGPL) version 2.1 or the Mozilla Public License (MPL) version 1.1 at your option. I ported half of the Cairo functions to Autoit. You can read more about the functions here: https://www.cairographics.org/documentation/ The probability is high that errors have crept in and I have only tested a fraction of the functions. Anyone who wants to can contribute examples. All needed files (DLLs, UDF and examples) can be download from my OneDrive: Cairo for Autoit If you find a mistake, I am sure you will, then please report it. Edited April 4 by UEZ mutleey, jchd, Werty and 5 others 4 4 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Andreik Posted April 2, 2024 Posted April 2, 2024 Can you write an example using a PDF surface? argumentum 1
UEZ Posted April 2, 2024 Author Posted April 2, 2024 The functions are added but the created PDF is currently empty. When I found a way to create working PDFs I will post it. argumentum 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
UEZ Posted April 2, 2024 Author Posted April 2, 2024 (edited) This seems to work but you need libcairo-2.dll which can be found also on my OneDrive (x86 / x64 folders). expandcollapse popup;Coded by UEZ build 2024-04-02 beta #AutoIt3Wrapper_UseX64=n #include "..\Cairo.au3" Cairo_Example() Func Cairo_Example() If Not Cairo_Init("libcairo-2.dll") Then ConsoleWrite(@error & @CRLF) Exit EndIf If FileExists("Example.pdf") Then FileDelete("Example.pdf") Local $MM_TO_PT = 72.0 / 25.4, $PAGE_WIDTH_A5 = 148, $PAGE_HEIGHT_A5 = 210, $PAGE_WIDTH_A4 = 210, $PAGE_HEIGHT_A4 = 297 Local Const $pSurface = Cairo_PDF_Create("Example.pdf", $PAGE_WIDTH_A5 * $MM_TO_PT, $PAGE_HEIGHT_A5 * $MM_TO_PT) Cairo_PDF_RestrictToVersion($pSurface, $CAIRO_PDF_VERSION_1_4) Local Const $pContext = Cairo_Context_Create($pSurface) Cairo_Context_SetLineWidth($pContext, 6) Cairo_Context_PathAddRectangle($pContext, 12, 12, 232,70) Cairo_Context_PathBeginNewSub($pContext) Cairo_Context_PathAddArc($pContext, 64, 64, 40, 0, ACos(-1) * 2) Cairo_Context_PathBeginNewSub($pContext) Cairo_Context_PathAddArcNegative($pContext, 192, 64, 40, 0, -ACos(-1) * 2) Cairo_Context_SetFillRule($pContext, $CAIRO_FILL_RULE_EVEN_ODD) Cairo_Context_SetSourceRGB($pContext, 0, 0.7, 0) Cairo_Context_FillPreserve($pContext) Cairo_Context_SetSourceRGB($pContext, 0, 0, 0) Cairo_Context_Stroke($pContext) Cairo_Context_Translate($pContext, 0, 128) Cairo_Context_PathAddRectangle($pContext, 12, 12, 232,70) Cairo_Context_PathBeginNewSub($pContext) Cairo_Context_PathAddArc($pContext, 64, 64, 40, 0, ACos(-1) * 2) Cairo_Context_PathBeginNewSub($pContext) Cairo_Context_PathAddArcNegative($pContext, 192, 64, 40, 0, -ACos(-1) * 2) Cairo_Context_SetFillRule($pContext, $CAIRO_FILL_RULE_WINDING) Cairo_SetColor($pContext, 0, 0, 0.9) Cairo_Context_FillPreserve($pContext) Cairo_SetColor($pContext, 0, 0, 0) Cairo_Context_Stroke($pContext) Cairo_Context_PathClear($pContext) Cairo_Context_PathAddMoveTo($pContext, 40, 150) Cairo_Font_SelectFace($pContext) Cairo_Font_SetSize($pContext, 30) Cairo_Context_PathAddText($pContext, "PDF Example") Cairo_SetColor($pContext, 0.9, 0, 0, 1) Cairo_Context_FillPreserve($pContext) Cairo_SetColor($pContext, 0, 0, 0.1, 0.5) Cairo_Context_SetLineWidth($pContext, 1.5) Cairo_Context_Stroke($pContext) Cairo_Surface_Finish($pSurface) Cairo_Surface_Flush($pSurface) ConsoleWrite(Cairo_Surface_GetStatus($pSurface) & @CRLF) Cairo_Context_Destroy($pContext) Cairo_Surface_Destroy($pSurface) Cairo_Close() ConsoleWrite(FileGetSize("Example.pdf") & @CRLF) EndFunc I seems that the Cairo.dll / Cairo64.dll doesn't work properly with PDF creation... Edited April 2, 2024 by UEZ argumentum and Danyfirex 1 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now