Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wrap set_metadata and set_custom_metadata #370

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Pango_jll = "36c8627f-9965-5494-a995-c6b170f724f3"

[compat]
Cairo_jll = "1.16"
Cairo_jll = "1.18"
Colors = "0.12, 0.13"
Glib_jll = "2.59.0"
Graphics = "1"
Expand Down
10 changes: 10 additions & 0 deletions src/Cairo.jl
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,16 @@ function CairoPDFSurface(filename::AbstractString, w_pts::Real, h_pts::Real)
CairoSurface(ptr, w_pts, h_pts)
end

function set_metadata(surf, metadata_type, str)
ccall((:cairo_pdf_surface_set_metadata,libcairo), Cvoid,
(Ptr{Nothing}, Cint, Cstring), surf.ptr, metadata_type, str)
end

function set_custom_metadata(surf, name, value)
ccall((:cairo_pdf_surface_set_custom_metadata,libcairo), Cvoid,
(Ptr{Nothing}, Cstring, Cstring), surf.ptr, name, value)
end

## EPS ##

function CairoEPSSurface(stream::T, w::Real, h::Real) where {T<:IO}
Expand Down
16 changes: 15 additions & 1 deletion src/constants.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,14 @@ const STATUS_DEVICE_TYPE_MISMATCH = Int32(33)
const STATUS_DEVICE_ERROR = Int32(34)
const STATUS_INVALID_MESH_CONSTRUCTION = Int32(35)
const STATUS_DEVICE_FINISHED = Int32(36)
const STATUS_LAST_STATUS = Int32(37)
const STATUS_JBIG2_GLOBAL_MISSING = Int32(37)
const STATUS_PNG_ERROR = Int32(38)
const STATUS_FREETYPE_ERROR = Int32(39)
const STATUS_WIN32_GDI_ERROR = Int32(40)
const STATUS_TAG_ERROR = Int32(41)
const STATUS_DWRITE_ERROR = Int32(42)
const STATUS_SVG_FONT_ERROR = Int32(43)
const STATUS_LAST_STATUS = Int32(44)

const surface_t = Int32
const CAIRO_SURFACE_TYPE_IMAGE = Int32(0)
Expand Down Expand Up @@ -148,6 +155,13 @@ const OPERATOR_OVERLAY = 16
const OPERATOR_DARKEN = 17
const OPERATOR_LIGHTEN = 18

const PDF_METADATA_TITLE = 0
const PDF_METADATA_AUTHOR = 1
const PDF_METADATA_SUBJECT = 2
const PDF_METADATA_KEYWORDS = 3
const PDF_METADATA_CREATOR = 4
const PDF_METADATA_CREATE_DATE = 5
const PDF_METADATA_MOD_DATE = 6

## LaTex Token Dicts ##
const _common_token_dict = Dict(
Expand Down
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,8 @@ end
output_file_name = "a.pdf"
surf = CairoPDFSurface(output_file_name,512,512)
hdraw(surf,64,8,4)
Cairo.set_metadata(surf, Cairo.PDF_METADATA_CREATOR, "Cairo.jl")
Cairo.set_custom_metadata(surf, "id", "42")
finish(surf)

@test isfile(output_file_name)
Expand Down
Loading