Re: [Inkscape-devel] PDF import extension

OK, I figured this out. By default poppler does not install all the headers. To force 0.59 to install its headers over the old ones, configure it thus:
./configure --prefix=/usr --enable-xpdf-headers
On 7/12/07, Miklós Erdélyi <erdelyim@...400...> wrote:
On 7/12/07, bulia byak <buliabyak@...400...> wrote:
It does not compile for me. I first tried with poppler 0.51 from dapper, then installed 0.59 from source, but this didn't help:
extension/internal/pdfinput/pdf-parser.cpp: In member function 'void PdfParser::parse(Object*, GBool)': extension/internal/pdfinput/pdf-parser.cpp:372: error: no matching function for call to 'Parser::Parser(XRef*&, Lexer*, int)' /usr/include/poppler/Parser.h:26: note: candidates are: Parser::Parser(XRef*, Lexer*) /usr/include/poppler/Parser.h:22: note: Parser::Parser(const Parser&)
Any ideas?
You have the includes of the older version set by pkg-config (eg. /usr/include). Check that Inkscape really uses the include files from 0.59 (which might reside in /usr/local/include). I also use the 0.59 src tarball and the constructor of the class Parser takes 3 arguments.
miklos

OK, I compiled Inkscape with poppler. Now what? All I see in the Import dialog list is "Adobe PDF" and it does not work - imports just an empty group for any PDF files I tried. Have you added yours to the list of input extensions? It would be nice, for now, to name it something like "PDF (via poppler)" so it is obvious what one uses. Later, when we switch to the poppler one completely and remove the old sketch/pstoedit/gs hacks, we will rename it to just "PDF".
And by the way, then we'll need to bind the .AI extension to this importer as well, because most AI files these days are PDF-based and should work with poppler. The old perl script can then be renamed "AI (versions before 7.0)" or just removed altogether as it's not maintained.

On 7/12/07, bulia byak <buliabyak@...400...> wrote:
OK, I compiled Inkscape with poppler. Now what? All I see in the Import dialog list is "Adobe PDF" and it does not work - imports just an empty group for any PDF files I tried.
Oops sorry - that was my fault, I commented out something in your earlier commit so it could compile and forgot about that. Now "Adobe PDF" works! Now to try it on a lot of pdfs...

Wow!
PDF and AI import works perfectly. (You need to rename *.ai to *.pdf, for now). Very impressive. I imported several complex book covers and other stuff. Everything looks as it should. Granted I don't have complex AI files with fancy features like gradient meshes, so it needs more testing, but for my simple files it works excellent - or at least the result _looks_ excellent.
It even reproduces all text in the original font... although not as text. Each letter is a clone of a path sitting in <defs>. So it's not editable as text - but still it's vector, and it looks absolutely flawless. I think we should preserve this as an option even after we add a more correct text handling (converting it to <text> using SVG fonts embedded in the document).
Now, Inkscape is officially no longer a toy application. This opens up huge perspectives. Now all we need is the equally good PDF export... (Hi cairo :)
Some problems:
- It indeed crashes when you try to open a *,pdf file from command line. From Open or Import dialogs, however, it works.
- It only imports the first page of PDF files. That's reasonable, but ideally I would like to see an "import options" dialog where I could select the page
- PDF files are not listed in the open dialog when you select "All images"
- It imports gradients as a stack of many overlapping shapes. Again, this _looks_ correct, but I would much prefer to see that converted to regular SVG gradients. Unlike fonts, Inkscape's gradient support is quite good. (Although, of course, this only applies to regular gradients; gradient meshes will still need to be represented by small tiles).

On 7/12/07, bulia byak <buliabyak@...400...> wrote:
- It indeed crashes when you try to open a *,pdf file from command
line. From Open or Import dialogs, however, it works.
backtrace:
Program received signal SIGSEGV, Segmentation fault. [Switching to Thread -1229326656 (LWP 13351)] 0xb74da202 in has_case_prefix (haystack=0x0, needle=0xb751a21d "file:/") at gconvert.c:1422 1422 while (*n && *h && Current language: auto; currently c (gdb) bt #0 0xb74da202 in has_case_prefix (haystack=0x0, needle=0xb751a21d "file:/") at gconvert.c:1422 #1 0xb74da679 in IA__g_filename_from_uri (uri=0x0, hostname=0x0, error=0x0) at gconvert.c:1718 #2 0xb6f872bc in poppler_document_new_from_file (uri=0x0, password=0x0, error=0x0) at poppler-document.cc:132 #3 0x08425080 in Inkscape::Extension::Internal::PdfInputCairo::open (this=0x868ff20, mod=0x86acdf8, uri=0x0) at extension/internal/pdf-input-cairo.cpp:40 #4 0x0840e8ad in Inkscape::Extension::Input::open (this=0x86acdf8, uri=0x0) at extension/input.cpp:156 #5 0x0840d2d5 in Inkscape::Extension::open (key=0x0, filename=0x86bc8bc "bc-front-final_sharon.pdf") at extension/system.cpp:92
So looks like extension system passes null to the opener, probably the input extension is not properly registered.

On 7/12/07, bulia byak <buliabyak@...400...> wrote:
On 7/12/07, bulia byak <buliabyak@...400...> wrote:
- It indeed crashes when you try to open a *,pdf file from command
line. From Open or Import dialogs, however, it works.
Update: latest SVN does not crash anymore, but when I load a PDF, whether from command line or from Open, some debug info is spewed (below) and text and gradients are missing. I opened that same file an hour ago and it worked, please fix it back! :)
** Message: Created globalParams ** Message: setTransform: 1.250000 0.000000 0.000000 -1.250000 0.000000 177.165000 ** Message: setTransform: 76.380371 0.000000 0.000000 -76.380371 267.742188 58.336914 ** Message: setTransform: 76.380600 0.000000 0.000000 -76.380600 105.741699 121.336914 doShowText() called sdoShowText() called hdoShowText() called adoShowText() called rdoShowText() called odoShowText() called ndoShowText() called doShowText() called zdoShowText() called idoShowText() called mdoShowText() called adoShowText() called PdoShowText() called RdoShowText() called OdoShowText() called ...

Am Donnerstag, den 12.07.2007, 16:42 -0300 schrieb bulia byak:
Wow!
PDF and AI import works perfectly. (You need to rename *.ai to *.pdf, for now). Very impressive. I imported several complex book covers and other stuff. Everything looks as it should. Granted I don't have complex AI files with fancy features like gradient meshes, so it needs more testing, but for my simple files it works excellent - or at least the result _looks_ excellent.
I think you can find some complex AI files here: http://www.vecteezy.com/gallery?fc=&fft=&fl=&sort=r
Regards, Tobias

On 7/12/07, bulia byak wrote:
Some problems:
- It indeed crashes when you try to open a *,pdf file from command
line. From Open or Import dialogs, however, it works.
- It only imports the first page of PDF files. That's reasonable, but
ideally I would like to see an "import options" dialog where I could select the page
PDF files are not listed in the open dialog when you select "All images"
It imports gradients as a stack of many overlapping shapes. Again,
this _looks_ correct, but I would much prefer to see that converted to regular SVG gradients. Unlike fonts, Inkscape's gradient support is quite good. (Although, of course, this only applies to regular gradients; gradient meshes will still need to be represented by small tiles).
And here is an issue I've encountered with an AI file from AI10.
This is how a page looks by default when opened in Inkscape:
http://prokoudine.info/shots/inkscape/pdf-import-midterm-ice-1.png
This is how it looks when I ungoup twice:
http://prokoudine.info/shots/inkscape/pdf-import-midterm-ice-2.png
I can provide the file privately (it contains outlines of a font that is not meant to be distributed in any form).
Alexandre

On 7/14/07, Alexandre Prokoudine <alexandre.prokoudine@...400...> wrote:
This is how a page looks by default when opened in Inkscape:
http://prokoudine.info/shots/inkscape/pdf-import-midterm-ice-1.png
This is how it looks when I ungoup twice:
http://prokoudine.info/shots/inkscape/pdf-import-midterm-ice-2.png
Inkscape's cairo-based importer just clips the entire page by the page rectangle (first image). Looks like your AI artist ignored the page size and drew the image larger than the page. Still, it should not do any clipping that was not in the original file - Miklós, can you make sure that your native importer is free from this defect?
Then, as the clipping is applied to the top-level group, when you ungroup it you lose the clip and everything becomes visible (second image). This is not a bug.

On 7/14/07, bulia byak <buliabyak@...400...> wrote:
On 7/14/07, Alexandre Prokoudine <alexandre.prokoudine@...400...> wrote:
This is how a page looks by default when opened in Inkscape:
http://prokoudine.info/shots/inkscape/pdf-import-midterm-ice-1.png
This is how it looks when I ungoup twice:
http://prokoudine.info/shots/inkscape/pdf-import-midterm-ice-2.png
Inkscape's cairo-based importer just clips the entire page by the page rectangle (first image). Looks like your AI artist ignored the page size and drew the image larger than the page. Still, it should not do any clipping that was not in the original file - Miklós, can you make sure that your native importer is free from this defect?
Yes, I'm avoiding this. Actually, now I'm only clipping when there's a cropBox specified in the PDF or an explicit clip operation. Indeed, the cairo-based importer always emits a clippath which clips to the size of the page (don't know why was this design decision taken).

On 7/12/07, bulia byak wrote:
OK, I figured this out. By default poppler does not install all the headers. To force 0.59 to install its headers over the old ones, configure it thus:
./configure --prefix=/usr --enable-xpdf-headers
It doesn't help here
Alexandre

On 7/14/07, Alexandre Prokoudine <alexandre.prokoudine@...400...> wrote:
that looks like a different error than what I was having

On 7/14/07, bulia byak wrote:
that looks like a different error than what I was having
Never mind, already solved. Sorry for disturbing :)
Alexandre
participants (4)
-
Alexandre Prokoudine
-
bulia byak
-
Miklós Erdélyi
-
Tobias Jakobs