0

I want to display a PDF file when push a button in gtk3 c code. In fact, I want to insert User manual button in Help and when push the button a PDF file show:

enter image description here

I insert button (show in figure up) but I can't write code for User manual function to show PDF file.

I use "poppler" and include

#include <C:\Users\Alireza\Desktop\poppler-0.18.4\poppler-0.18.4\glib/poppler.h>

to my code in up.

my function is

void UserManual(GtkWidget *widget, gpointer data)
{
    GtkWidget* win;
GError* err = NULL;


doc = poppler_document_new_from_file("C:/Program Files (x86)/Sepand64bit/logo/UserManual.pdf", NULL, &err);
if (!doc) {
    printf("%s\n", err->message);
    g_object_unref(err);
    //return 2;
}

page = poppler_document_get_page(doc, 0);
if (!page) {
    printf("Could not open first page of document\n");
    g_object_unref(doc);
    //return 3;
}

int pages = poppler_document_get_n_pages(doc);
printf("There are %d pages in this pdf.\n", pages);
}

But I have errors:

*error LNK2001: unresolved external symbol poppler_document_get_page

*error LNK2001: unresolved external symbol poppler_document_new_from_file

*error LNK2001: unresolved external symbol poppler_document_get_n_pages

I think poppler inistall on my code in incorrectly way. What ideas on how to solve this task would you suggest? Or on what resource on the internet can I find help?

1 Answers1

0

If you otherwise don't need to display PDFs inside your application with Poppler, then I would suggest taking a simpler approach (though offering you less control over the result) and use

gtk_show_uri(gdk_screen_get_default(), "file:///path/to/UserManual.pdf",
    GDK_CURRENT_TIME, &error);

It will open the PDF in whatever the default viewer is for PDF files.

ptomato
  • 56,175
  • 13
  • 112
  • 165
  • I used this function **without use of poppler**: void UserManual(GtkWindow *win) { GError *error = NULL; gtk_show_uri(gdk_screen_get_default(), "file:///C:/Program Files (x86)/Sepand64bit/logo/UserManual.pdf", GDK_CURRENT_TIME, &error); and **it doesn't show**. –  Nov 28 '16 at 08:47