Unsolved Using existing pdf file?
-
Hi,
Is it possible to use existinf pdf document?
For example, I want to create empty invoice template table first. Then I will use this pdf file and fill the lines and save as new pdf invoice number name?Regards,
Mucip:) -
Why do need the template? Print the invoce at once.
With the QTextDocument class you can write your invoice and save it as PDF with print and QPdfWriter.
-
Hi @beecksche,
I know. But I hate to adjust grids, horizontal/vertical lines and put company image on pdf file! This is really TORTURE for me...I want to skip all this layout (grid, line, picture) works and jump to write values on the appropriate location on the template invoice...
Regards,
Mucip:) -
@Mucip
AFAIK that's not possible with Qt. Maybe you need a third party library.Maybe you can read/import the PDF template and use it as image and paint the text at specific positions. But I think that the output won't be of high quality (and you need also a lot of work to adjust the positions of the text).
I would create the PDF at once, here you need to create your class only once with the wished style. And the output should look better.
-
@beecksche
Any advice about third party library which is opensource and platform independent?...Regards,
Mucip:) -
If you have Acrobat Pro (i.e. the paid version) you can create the base PDF and add form fields on it. Then you can use
QXmlStreamWriter
to create an XFDF file with the values that will fill the form -
@VRonin ,
Unfortunatelly no... :(
Any other?
What about poopler?... Is there anyone who use it?Regards,
Mucip:) -
@Mucip
Hi
Just as a note.
you can cheat and use
command line tool that can merge 2 pdfs.
https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/so you print your data to one pdf and use pdftk to merge with the
template form pdf into a new pdf. -
Hi @mrjj ,
I think using extra command line is not clean way to solve this... :(Regards,
Mucip:) -
@Mucip
Hi
Well it worked pretty flawless for years for me.
pdftk is really high quality.
But yes, it's not as smooth as having
the feature directly in the app.
It was just a suggestion as editing a pdf is
hard to archive for free.Have you considered just use an SVG file as the template ?
-
Hi @mrjj ,
Ofcourse. Why not? I may prepare some template with Inkscape. No problem...
Well, How???..Regards,
Nucip:) -
@Mucip
Hi
Was thinking on inkscape :)
You can get positions of SVG elements with
http://doc.qt.io/qt-5/qsvgrenderer.html#boundsOnElement
so its possible to load the SVG and find out where placeholders are and then
first draw SVG template , then draw the text in place holders positions.
and then save it all as pdf.
SVG looks good in all resolutions.Please notice that Inkscape kinda flips the y coordinates, so google that as
it fooled me a bit. -
Hi @mrjj ,
How can I prepare some template with text input?
As I understant from your post SVG elements need to be put on template and I don't know about this.
I will check google how to work with SVG elements.By the way do you have sample SVG file or manual to do your suggestion?
Regards,
Mucip:) -
Hi @bougti ,
I couldn't understand why I need this?...Regards,
Mucip:) -
@Mucip It was a spam post.
-
Hi @SGaist
What a strange guys?! :(
I couldn't understand what is the benefit of this beheviour?Regards,
Mucip:) -
Trying to lure people going on their fishy website for who knows what.
Some are tricky to detect.
-
@Mucip said in Using existing pdf file?:
-
How can I prepare some template with text input?
Draw it using inkscape.
Each element of page has an ID. ( and you can change it to something more easy to read)
So place a rect, where you want the USER text to be put.
Set the ID of this rect to something that make sense. ( name of what text is for)
Then from Qt, you can use http://doc.qt.io/qt-5/qsvgrenderer.html#boundsOnElement
to find the place rect again and then draw the USER text there.
So first draw the SVG template, then draw USER text at the ID locations and
save it all as pdf. -
As I understant from your post SVG elements need to be put on template and I don't know about this.
Well the template is the SVG file and you just use a rect as place holder to where text goes.
-