This seems to work but you need libcairo-2.dll which can be found also on my OneDrive (x86 / x64 folders).
;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...