View PDF files with wxWidgets

1,856 views
Skip to first unread message

skywind mailing lists

unread,
Nov 22, 2011, 5:58:15 PM11/22/11
to wx-u...@googlegroups.com
Hi,

is there a way to display PDF documents or pages using wxWidgets or any 3rd party library based on wxWidgets?`

Thanks,
Hardy

asadilan indrabudi

unread,
Nov 22, 2011, 6:23:21 PM11/22/11
to wx-u...@googlegroups.com
wxPDFdocument


utelle

unread,
Nov 23, 2011, 4:53:01 PM11/23/11
to wx-users
On Nov 23, 2011 at 00:23, asadilan indrabudi wrote:
> wxPDFdocument

wxPdfDocument is a wxWidgets based library for *creating* PDF
documents, it doesn't have support for rendering PDF documents on
screen.

>> is there a way to display PDF documents or pages using wxWidgets or any
>> 3rd party library based on wxWidgets?`

Not that I know of.

In my applications I use method GetOpenCommand of class wxFileType to
retrieve the system command for opening a PDF file and then I use
wxExecute to run this command.

In case you need for whatever reason a full fledged PDF renderer under
your own control you might consider to take a look at xpdf (http://
foolabs.com/xpdf/home.html).

Alternatively there are poppler (based on xpdf) (http://
poppler.freedesktop.org/) or MuPDF (http://www.mupdf.com/).

All 3 named libraries (xpdf, poppler, mupdf) are GPL and therefore
can't be used in commercial applications, but as far as I know
commercial licenses are provided.

Regards,

Ulrich

Gadget/Steve

unread,
Nov 24, 2011, 1:15:25 AM11/24/11
to wx-u...@googlegroups.com
In the wxPython demo v2.9.2.4 there are wx.PdfViewer and
wx.ActiveX_PDFWindow - the latter seems to be available for the C++ on
Windows primarily but the former should be cross platform but does have
some limitations.

Gadget/Steve

Message has been deleted

utelle

unread,
Nov 24, 2011, 8:19:16 AM11/24/11
to wx-users
On 24 Nov., 07:15, Gadget/Steve <GadgetSt...@live.co.uk> wrote:
> In the wxPython demo v2.9.2.4 there are wx.PdfViewer and
> wx.ActiveX_PDFWindow - the latter seems to be available for the C++ on
> Windows primarily but the former should be cross platform but does have
> some limitations.

wx.ActiveX_PDFWindow is platform specific as it uses ActiveX to
communicate with Acrobat Reader. It only works together with Acrobat
Reader. I don't see any real advantage to executing Acrobat Reader (or
whatever PDF viewer is installed) directly as mentioned in my first
post.

wx.PdfViewer depends on pyPDF for parsing PDF documents and therefore
can't be ported to C++ easily. Further it's not a full fledge PDF
renderer, so it might not be capable to display complex PDF documents.

Regards,

Ulrich

Gadget/Steve

unread,
Nov 24, 2011, 8:37:39 AM11/24/11
to wx-u...@googlegroups.com
While wx.PdfViewer is written in python you could embed it, (including
python), in a C++ application if needed. True it will not display every
pdf document however if your application is generating or using specific
pdf files then you may be able to ensure that they are compatible with
it - a lot depends on what you are trying to do.

Gadget/Steve

utelle

unread,
Nov 24, 2011, 9:12:55 AM11/24/11
to wx-users
On 24 Nov., 14:37, Gadget/Steve <GadgetSt...@live.co.uk> wrote:
>
> While wx.PdfViewer is written in python you could embed it, (including
> python), in a C++ application if needed.

Sure, but what would be the advantages im comparison to directly
invoking the system's PDF viewer?

Another alternative comes to mind. One could embed GhostScript to
render PDF. As GhostScript is a C library bundling it with and
controlling it from a wxWidgets application should be straight
forward.

> True it will not display every pdf document however if your application
> is generating or using specific pdf files then you may be able to ensure
> that they are compatible with it - a lot depends on what you are trying to do.

Well, I don't know the requirements of the original poster.

Regards,

Ulrich

Steve Cookson

unread,
Nov 24, 2011, 10:23:55 AM11/24/11
to wx-u...@googlegroups.com
> Is there a way to display PDF documents or pages using wxWidgets or any

3rd party library based on wxWidgets?

There is wxPDFMediaBackend documented at:

http://docs.wxwidgets.org/2.9.2/classwx_active_x_container.html

A PDF backend for wxMediaCtrl. I have no idea if it works, but it says it
does.

Good luck.

It would be nice to know if it does work or not. Maybe it doesn't work
cross-platform.

Regards

Steve.

skywind mailing lists

unread,
Nov 24, 2011, 6:19:58 PM11/24/11
to wx-u...@googlegroups.com
Hi,

thanks for all the feedback.

It seems to be that I am unlucky as I need a cross-platform solution and in some kind of commercial code (though the program itself will not be sold). I had the same idea as Ulrich to use ghostscript for rendering and display afterwards the rendered image.
I have seen that there has once been a lib on the web going this path. But it seems to be that it is gone, now.

Regards,
Hardy

utelle

unread,
Nov 25, 2011, 5:59:34 AM11/25/11
to wx-users

On 25 Nov., 00:19, skywind mailing lists <mailingli...@skywind.eu>
wrote:

> It seems to be that I am unlucky as I need a cross-platform solution and in some kind of commercial code
> (though the program itself will not be sold). I had the same idea as Ulrich to use ghostscript for rendering
> and display afterwards the rendered image.

Could you elaborate a bit more on which requirements you have and
which goals you try to fulfill? This might help to inspire new ideas.

> I have seen that there has once been a lib on the web going this path.
> But it seems to be that it is gone, now.

There is http://wxghostscript.sourceforge.net/, but I can't tell how
usable it might be as it's development stopped 8 years ago. But it
might serve as a starting point.

Regards,

Ulrich

skywind mailing lists

unread,
Nov 25, 2011, 1:42:03 PM11/25/11
to wx-u...@googlegroups.com
Hi,

I am writing an App that is able to display PDF files (articles, magazines etc.) on an iPhone, iPad etc. These files are partially encrypted with a special algorithm because the users have to pay for the content. To extend the usage these PDF files (multiple pages) should also be displayable on desktop computers.
As the files are encrypted and special functionality is implemented I need my own renderer (sorry, can't be more specific). Besides that the program includes other features not available with standard PDF viewers.

Hardy

Gadget/Steve

unread,
Nov 26, 2011, 4:03:54 AM11/26/11
to wx-u...@googlegroups.com
On 25/11/2011 6:42 PM, skywind mailing lists wrote:
> Hi,
>
> I am writing an App that is able to display PDF files (articles, magazines etc.) on an iPhone, iPad etc. These files are partially encrypted with a special algorithm because the users have to pay for the content. To extend the usage these PDF files (multiple pages) should also be displayable on desktop computers.
> As the files are encrypted and special functionality is implemented I need my own renderer (sorry, can't be more specific). Besides that the program includes other features not available with standard PDF viewers.
>
> Hardy
>
> Am 25.11.2011 um 11:59 schrieb utelle:
>
Since you are applying your own encoding and adding your own features to
the pdf files then presumably as well as decoding and displaying from
within your code you will also have at least some input into the
encoding/feature adding process - surely you could also verify at that
stage whether the pfd will be compatible with the wx.PdfViewer, or your
class derived from it, (or whatever other viewer you decide to use).

Gadget/Steve

Reply all
Reply to author
Forward
0 new messages