How i can take a pdf page as image in wxDc?
How i can take a pdf page as image in wxDc?
Hello.
I must take a pdf page as image in wxDc.
There is some example to see?
Thanks
Jim.
I must take a pdf page as image in wxDc.
There is some example to see?
Thanks
Jim.
- eranon
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
- Contact:
Re: How i can take a pdf page as image in wxDc?
Basically, you have to display your PDF in a control, then capture the rendered result. So, it means 3 steps: read, render, capture. I never dealed with PDF against wxWidgets, but typing "wxpdf" in Google returns some results...
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
Re: How i can take a pdf page as image in wxDc?
But how to pdf page to ctrl, or image?
Using wxPdfDoc i do not want to use other library, so i am looking for some example.
For example i found for Magick ... But already use wxPdfDoc...
Using wxPdfDoc i do not want to use other library, so i am looking for some example.
For example i found for Magick ... But already use wxPdfDoc...
Code: Select all
#include <Magick++.h>
using namespace Magick;
....
vector<Image> imageList;
readImages( &imageList, "my.pdf" );
for (int i = 0; i < imageList.size(); i++) {
stringstream fileName;
fileName << "my" << i << ".tiff";
imageList[i].write(fileName.str());
}
- eranon
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
- Contact:
Re: How i can take a pdf page as image in wxDc?
This is the research you have to do about the point one in your roadmap. There's nothing premade, ready-to-use in wxWidgets itself. You need a class to read, parse, then render the PDF. There're a lot of PDF specs and even if a page can be already an image, most will be not... Then you have to render it to have something to capture (towards an image).dkaip wrote:But how to pdf page to ctrl, or image?
You say you want to stick with wxPdfDoc and you show a Magick example: it's contradictory! However, the example you shows seems (I don't know Magick) to extract the existing images from a PDF, then save them in files... It's far from what you want to achieve since you want to capture a rendered page including text, images, specific layout.dkaip wrote:Using wxPdfDoc i do not want to use other library, so i am looking for some example. For example i found for Magick ... But already use wxPdfDoc...
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
Re: How i can take a pdf page as image in wxDc?
From where i must looking to find code?
Evince? Some lib like PoDoFo?
Evince? Some lib like PoDoFo?
Re: How i can take a pdf page as image in wxDc?
First, you have to specify exactly what you want to accomplish. In your previous posts you described that you want/need to display a page from a PDF document on screen, and you stated that you are using wxPdfDocument and want to stay with it.dkaip wrote:From where i must looking to find code?
Evince? Some lib like PoDoFo?
What you did not tell yet is whether the PDF page you need to display on screen is part of a foreign PDF document or whether it is part of a PDF document you created with your own application. In the latter case you could use the wxPdfDC class and the wxWidgets printing framework, which would allow you to display a preview of your document on screen. In the former case you would need a way to render the PDF page in question. The problem is that wxPdfDocument is a library for creating PDF documents, not for rendering them. The same is true for PoDoFo.
One approach to render a PDF page could be to use a tool like imagemagick to convert a PDF page to a image graphic format like JPEG or PNG and to display the image on screen.
Another approach could be to render a PDF page using PDFium, for which a wxWidgets wrapper, wxPDFView, exists. Not a trivial approach, I'd like to add.
Regards,
Ulrich
Re: How i can take a pdf page as image in wxDc?
Sorry, the PDF page i need to display on screen is part of a foreign PDF document, and this pdf insert in mine wxPdfDocument. But i need to put some things on some pages, so i must can ability to see pages.
Thank you very much, i will try wxPDFView.
Thank you very much, i will try wxPDFView.
- eranon
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
- Contact:
Re: How i can take a pdf page as image in wxDc?
As utelle stated, your approach is a little blur and it becomes more and more opaque at every message. Until now, you wanted to convert a PDF page to an image and in your last message you introduce the fact that you want to insert a PDF into a PDF you created and that you need to edit this foreign PDF too... It's a lot of different things! Maybe you should draw a global flowchart... There's no magic button that will give you the overall design of you app. It's up to you to sort the tasks and ask when you have a precise question; and eventually with some code showing you really started to try something by yourself.
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
Re: How i can take a pdf page as image in wxDc?
It is simple. I have an external pdf file. Creating a wxPDFDocument file, insert all pages in that.
But i must add some text and images at certain pages on that, depends of the page image that i must see first.
That is all. Very clear. To see a page in a wxDC is the hole problem.
So i must do all that have told me.
Thank's
Jim.
Some questions for utelle. First thanks for answer about all that.
There are 2 projects and i have download first as you say. I think that second project is for Foxit Reader as well.
Downloading PDFium, i don’t know what files i must add to project to run ok.
Thank's again.
Jim.
But i must add some text and images at certain pages on that, depends of the page image that i must see first.
That is all. Very clear. To see a page in a wxDC is the hole problem.
So i must do all that have told me.
Thank's
Jim.
Some questions for utelle. First thanks for answer about all that.
There are 2 projects and i have download first as you say. I think that second project is for Foxit Reader as well.
Now i am trying to run the simple at /wxPDFView/samples/simple/Simple.h. So i am add all files .h and .cpp from 'stc' and 'include' and 'private' dirs, for running without make a lib.
Downloading PDFium, i don’t know what files i must add to project to run ok.
Thank's again.
Jim.
Re: How i can take a pdf page as image in wxDc?
As far as I can tell you will need wxPDFView and probably PDFium at Google (since it seems that PDFium at github wasn't updated for quite a while). Building PDFium is not trivial - you should follow the instructions given on its website.dkaip wrote:Some questions for utelle. First thanks for answer about all that.
There are 2 projects and i have download first as you say. I think that second project is for Foxit Reader as well.Now i am trying to run the simple at /wxPDFView/samples/simple/Simple.h. So i am add all files .h and .cpp from 'stc' and 'include' and 'private' dirs, for running without make a lib.
Downloading PDFium, i don’t know what files i must add to project to run ok.
Regards,
Ulrich
Re: How i can take a pdf page as image in wxDc?
I have done those things to build pdfium
or
i have no results, only "now monitoring process activity", so i cant make the static lib for wxPDFView.
Any advice welcome.
Thank's
Jim
But withdownload depot_tools
----------------
git clone https://chromium.googlesource.com/chrom ... _tools.git
export PATH=$PATH:/home/a/depot_tools
ninja
--------
sudo apt-get install ninja
pdfium
----------
mkdir repo
cd repo
gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git
gclient sync
cd pdfium
mkdir build-gtk
cd build-gtk
gedit args.gn
--------------------------------
# Build arguments go here.
# See "gn args <out_dir> --list" for available build arguments.
is_debug = true # Enable debugging features.
pdf_is_standalone = true # Set for a non-embedded build.
---------------------------------
cd ..
gn gen build-gtk
ninja -C build-gtk
or
Code: Select all
ninja -C build-gtk pdfium_all
Any advice welcome.
Thank's
Jim
Re: How i can take a pdf page as image in wxDc?
Unfortunately, I have no experience in building PDFium under Linux. Maybe you could try to contact the developer of wxPDFView directly and ask him.
Sorry that I don't have a better answer for you.
Regards,
Ulrich
Sorry that I don't have a better answer for you.
Regards,
Ulrich
- eranon
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
- Contact:
Re: How i can take a pdf page as image in wxDc?
The pdfium forum is there: https://groups.google.com/forum/#!forum/pdfium.
This post is called "Entire page as an image in pdfium": https://groups.google.com/forum/#!topic ... KAe-NroS-w
This post is called "Entire page as an image in pdfium": https://groups.google.com/forum/#!topic ... KAe-NroS-w
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]
Re: How i can take a pdf page as image in wxDc?
Hello.
Thank's for answer.
I just made libs, so i am upload how.
Download depot-tools
from https://ninja-build.org/ the instructions ...
Next we must place arguments ... so.. in our 'out/debug' directory.
It take me a hole day to make all these ...
Today i must connect with wxPDFView...
Thank's all.
Jim
Thank's for answer.
I just made libs, so i am upload how.
Download depot-tools
Set PATH
Do those.. sorry my english... i know well ansient Greekexport PATH=$PATH:/home/a/depot_tools
Next install ninja ... NOT THIS ... sudo apt-get install ninja, NOmkdir repo
cd repo
gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git
gclient sync
cd pdfium
from https://ninja-build.org/ the instructions ...
build ninjagit clone git://github.com/ninja-build/ninja.git && cd ninja
git checkout release
cat README
the ninja executable file is done, so we copy that to /home/a/repo/pdfium directory../configure.py --bootstrap
Next we must place arguments ... so.. in our 'out/debug' directory.
out/debug/args.gn file generate and with...gn args out/debug
we add what we want ...gedit out/debug/args.gn
We save and then we must generate ninja files with ..# Build arguments go here.
# See "gn args <out_dir> --list" for available build arguments.
pdf_is_standalone = true # Set for a non-embedded build.
is_component_build = false # Disable component build (must be false)
clang_use_chrome_plugins = false # Currently must be false.
Now we are ready to compile pdfium lib.gn gen out/debug
and then after some time we take .. exe files ...sudo ./ninja -C out/debug pdfium_all
and the lib files .../home/a/repo/pdfium/out/debug/genmacro
/home/a/repo/pdfium/out/debug/genmodule
/home/a/repo/pdfium/out/debug/genperf
/home/a/repo/pdfium/out/debug/genstring
/home/a/repo/pdfium/out/debug/genversion
/home/a/repo/pdfium/out/debug/icudtl.dat
/home/a/repo/pdfium/out/debug/mksnapshot
/home/a/repo/pdfium/out/debug/natives_blob.bin
/home/a/repo/pdfium/out/debug/pdfium_diff
/home/a/repo/pdfium/out/debug/pdfium_embeddertests
/home/a/repo/pdfium/out/debug/pdfium_test
/home/a/repo/pdfium/out/debug/pdfium_unittests
/home/a/repo/pdfium/out/debug/re2c
/home/a/repo/pdfium/out/debug/snapshot_blob.bin
/home/a/repo/pdfium/out/debug/v8_build_config.json
/home/a/repo/pdfium/out/debug/yasm
Running for example/home/a/repo/pdfium/out/debug/obj/libfdrm.a
/home/a/repo/pdfium/out/debug/obj/libformfiller.a
/home/a/repo/pdfium/out/debug/obj/libfpdfapi.a
/home/a/repo/pdfium/out/debug/obj/libfpdfdoc.a
/home/a/repo/pdfium/out/debug/obj/libfpdftext.a
/home/a/repo/pdfium/out/debug/obj/libfxcodec.a
/home/a/repo/pdfium/out/debug/obj/libfxcrt.a
/home/a/repo/pdfium/out/debug/obj/libfxge.a
/home/a/repo/pdfium/out/debug/obj/libfxjs.a
/home/a/repo/pdfium/out/debug/obj/libimage_diff.a
/home/a/repo/pdfium/out/debug/obj/libpdfium.a
/home/a/repo/pdfium/out/debug/obj/libpwl.a
/home/a/repo/pdfium/out/debug/obj/libtest_support.a
we see all mozilla.pdf pages as png images.out/debug/pdfium_test --png /home/a/mozilla.pdf
It take me a hole day to make all these ...
Today i must connect with wxPDFView...
Thank's all.
Jim
Last edited by dkaip on Tue Dec 19, 2017 4:30 pm, edited 1 time in total.
- eranon
- Can't get richer than this
- Posts: 867
- Joined: Sun May 13, 2012 11:42 pm
- Location: France
- Contact:
Re: How i can take a pdf page as image in wxDc?
Nice to post this guide Well, *not sure*, but don't forget to take a look at the second link I pushed to you in my previous post: if pdfium allows to catch any PDF page as an image, your job is done and you don't need to render it in a control with wxPDFView (unless you need it for another part of your app, of course)...
[Ind. dev. - wxWidgets 3.0/3.1 under "Win 7 64-bit, TDM64-GCC" + "OS X 10.9, LLVM Clang"]