From: John Ellson Date: Mon, 5 Aug 2013 13:52:45 +0000 (-0400) Subject: remove example code used during development X-Git-Tag: LAST_LIBGRAPH~32^2~107^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0532004f974261cf91363aad1faf08d96cc6f9b5;p=graphviz remove example code used during development --- diff --git a/plugin/poppler/Makefile.test b/plugin/poppler/Makefile.test deleted file mode 100644 index 63734afa1..000000000 --- a/plugin/poppler/Makefile.test +++ /dev/null @@ -1,17 +0,0 @@ -CFLAGS=`pkg-config --cflags cairo poppler-glib` -LDFLAGS=`pkg-config --libs cairo poppler-glib` - -all: pdftops pdftoimage hello.png - -pdftops: pdftops.c - -pdftoimage: pdftoimage.c - -hello.png: pdftoimage hello.pdf - ./pdftoimage hello.pdf hello.png 1 - -hello.pdf: - echo 'digraph {hello->world}' | dot -Tpdf -o hello.pdf - -clean: - rm -f pdftops pdftoimage hello.* diff --git a/plugin/poppler/pdftoimage.c b/plugin/poppler/pdftoimage.c deleted file mode 100644 index c0cbdc38e..000000000 --- a/plugin/poppler/pdftoimage.c +++ /dev/null @@ -1,105 +0,0 @@ -#include -#include -#include -#include - -#define IMAGE_DPI 150 - -int main(int argc, char *argv[]) -{ - PopplerDocument *document; - PopplerPage *page; - double width, height; - GError *error; - const char *pdf_file; - const char *png_file; - gchar *absolute, *uri; - int page_num, num_pages; - cairo_surface_t *surface; - cairo_t *cr; - cairo_status_t status; - - if (argc != 4) { - printf ("Usage: pdftoimage input_file.pdf output_file.png page\n"); - return 0; - } - - pdf_file = argv[1]; - png_file = argv[2]; - page_num = atoi(argv[3]); - g_type_init (); - error = NULL; - - if (g_path_is_absolute(pdf_file)) { - absolute = g_strdup (pdf_file); - } else { - gchar *dir = g_get_current_dir (); - absolute = g_build_filename (dir, pdf_file, (gchar *) 0); - free (dir); - } - - uri = g_filename_to_uri (absolute, NULL, &error); - - fprintf(stderr, "%s\n%s\n", absolute, uri); - - free (absolute); - if (uri == NULL) { - printf("%s\n", error->message); - return 1; - } - - document = poppler_document_new_from_file (uri, NULL, &error); - if (document == NULL) { - printf("%s\n", error->message); - return 1; - } - - num_pages = poppler_document_get_n_pages (document); - if (page_num < 1 || page_num > num_pages) { - printf("page must be between 1 and %d\n", num_pages); - return 1; - } - - page = poppler_document_get_page (document, page_num - 1); - if (page == NULL) { - printf("poppler fail: page not found\n"); - return 1; - } - - poppler_page_get_size (page, &width, &height); - - /* For correct rendering of PDF, the PDF is first rendered to a - * * transparent image (all alpha = 0). */ - surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, - IMAGE_DPI*width/72.0, - IMAGE_DPI*height/72.0); - cr = cairo_create (surface); - cairo_scale (cr, IMAGE_DPI/72.0, IMAGE_DPI/72.0); - cairo_save (cr); - poppler_page_render (page, cr); - cairo_restore (cr); - g_object_unref (page); - - /* Then the image is painted on top of a white "page". Instead of - * * creating a second image, painting it white, then painting the - * * PDF image over it we can use the CAIRO_OPERATOR_DEST_OVER - * * operator to achieve the same effect with the one image. */ - cairo_set_operator (cr, CAIRO_OPERATOR_DEST_OVER); - cairo_set_source_rgb (cr, 1, 1, 1); - cairo_paint (cr); - - status = cairo_status(cr); - if (status) - printf("%s\n", cairo_status_to_string (status)); - - cairo_destroy (cr); - status = cairo_surface_write_to_png (surface, png_file); - if (status) - printf("%s\n", cairo_status_to_string (status)); - - cairo_surface_destroy (surface); - - g_object_unref (document); - - return 0; -} diff --git a/plugin/poppler/pdftops.c b/plugin/poppler/pdftops.c deleted file mode 100644 index 610913bc7..000000000 --- a/plugin/poppler/pdftops.c +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ - PopplerDocument *document; - PopplerPage *page; - double width, height; - GError *error; - const char *filename; - gchar *absolute, *uri; - int num_pages, i; - cairo_surface_t *surface; - cairo_t *cr; - cairo_status_t status; - - if (argc != 2) { - printf ("Usage: pdf2cairo input_file.pdf\n"); - return 0; - } - - filename = argv[1]; - g_type_init (); - error = NULL; - - if (g_path_is_absolute(filename)) { - absolute = g_strdup (filename); - } else { - gchar *dir = g_get_current_dir (); - absolute = g_build_filename (dir, filename, (gchar *) 0); - free (dir); - } - - uri = g_filename_to_uri (absolute, NULL, &error); - free (absolute); - if (uri == NULL) { - printf("poppler fail: %s\n", error->message); - return 1; - } - - document = poppler_document_new_from_file (uri, NULL, &error); - if (document == NULL) { - printf("poppler fail: %s\n", error->message); - return 1; - } - - num_pages = poppler_document_get_n_pages (document); - - /* Page size does not matter here as the size is changed before - * * each page */ - surface = cairo_ps_surface_create ("output.ps", 595, 842); - cr = cairo_create (surface); - for (i = 0; i < num_pages; i++) { - page = poppler_document_get_page (document, i); - if (page == NULL) { - printf("poppler fail: page not found\n"); - return 1; - } - poppler_page_get_size (page, &width, &height); - cairo_ps_surface_set_size (surface, width, height); - cairo_save (cr); - poppler_page_render_for_printing (page, cr); - cairo_restore (cr); - cairo_surface_show_page (surface); - g_object_unref (page); - } - status = cairo_status(cr); - if (status) - printf("%s\n", cairo_status_to_string (status)); - cairo_destroy (cr); - cairo_surface_finish (surface); - status = cairo_surface_status(surface); - if (status) - printf("%s\n", cairo_status_to_string (status)); - cairo_surface_destroy (surface); - - g_object_unref (document); - - return 0; -}