Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » U++ community news and announcements » Qtf->Pdf simplified
Qtf->Pdf simplified [message #34492] Fri, 25 November 2011 18:17 Go to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Recently I had some minor issues with converting Qtf to Pdf in server environment. Surely, it was not that hard, but I guess dircet support is better. So it inspired two new functions:

Array<Drawing> RenderPages(const RichText& txt, Size pagesize = Size(3968, 6074));

String Pdf(const RichText& txt, Size pagesize = Size(3968, 6074), int margin = 200, bool pdfa = false);


The harder part here is RenderPages, Pdf is then only simply call to PdfDraw package, using RenderPages.

Qtf->Pdf is then just matter of:

#include <RichText/RichText.h>

using namespace Upp;

CONSOLE_APP_MAIN
{
	SaveFile(GetHomeDirFile("test.pdf"), Pdf(ParseQTF("[A9 Hello World!")));
}

Re: Qtf->Pdf simplified [message #38346 is a reply to message #34492] Tue, 11 December 2012 21:15 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
Hi Mikek!

This looks like an useful function.

Sadly it's giving me a 0 byte PDF file.
Re: Qtf->Pdf simplified [message #38372 is a reply to message #38346] Wed, 12 December 2012 18:42 Go to previous messageGo to next message
deep is currently offline  deep
Messages: 263
Registered: July 2011
Location: Bangalore
Experienced Member
It works,

win7, upp 5523,
  • Attachment: tpdf.zip
    (Size: 0.85KB, Downloaded 240 times)


Warm Regards

Deepak

[Updated on: Wed, 12 December 2012 18:43]

Report message to a moderator

Re: Qtf->Pdf simplified [message #38481 is a reply to message #34492] Thu, 20 December 2012 03:51 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
Can U++ also import PDF files?

Something like PDF -> QTF
Re: Qtf->Pdf simplified [message #38482 is a reply to message #38372] Thu, 20 December 2012 04:12 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
deep wrote on Wed, 12 December 2012 12:42

It works,

win7, upp 5523,



Weird. When I try your package it works.

When I use the SAME code in my package it gives me a 0 byte pdf file.
Re: Qtf->Pdf simplified [message #38485 is a reply to message #38482] Thu, 20 December 2012 08:27 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Do you have PdfDraw package in the project?

Mirek
Re: Qtf->Pdf simplified [message #38490 is a reply to message #38485] Thu, 20 December 2012 11:46 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
mirek wrote on Thu, 20 December 2012 02:27

Do you have PdfDraw package in the project?

Mirek


Yes.

Attached is a package that doesn't work for me.

Windows 7, latest Upp nightly, VC++ 2012 Express
  • Attachment: test.7z
    (Size: 0.66KB, Downloaded 217 times)

[Updated on: Thu, 20 December 2012 11:52]

Report message to a moderator

Re: Qtf->Pdf simplified [message #38497 is a reply to message #38490] Thu, 20 December 2012 14:49 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
lectus wrote on Thu, 20 December 2012 05:46

mirek wrote on Thu, 20 December 2012 02:27

Do you have PdfDraw package in the project?

Mirek


Yes.



Well, you did not, not correctly. The PdfDraw you had there was conditionally included only for Posix by CtrlLib (to resolve printing).

After adding PdfDraw as unconditional uses it works.

Mirek
Re: Qtf->Pdf simplified [message #38498 is a reply to message #38497] Thu, 20 December 2012 15:26 Go to previous messageGo to next message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
mirek wrote on Thu, 20 December 2012 08:49

lectus wrote on Thu, 20 December 2012 05:46

mirek wrote on Thu, 20 December 2012 02:27

Do you have PdfDraw package in the project?

Mirek


Yes.



Well, you did not, not correctly. The PdfDraw you had there was conditionally included only for Posix by CtrlLib (to resolve printing).

After adding PdfDraw as unconditional uses it works.

Mirek


Oh Sorry Mirek.

I got confused a little bit.

I added PdfDraw and it now works. PdfDraw showed in the list because it was added to CtrlLib, but not to my package. I didn't know it makes a difference.

Now it works! Smile

BTW... is there any way to import PDF files as QTF?
Re: Qtf->Pdf simplified [message #38499 is a reply to message #38498] Thu, 20 December 2012 16:54 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
lectus wrote on Thu, 20 December 2012 09:26


BTW... is there any way to import PDF files as QTF?


Unfortunately, no, for two reasons:

PDF is basically vector graphics format, while QTF is rich text format - they are not even meant to express the same thing. QTF->PDF is something like typesetting glyphs into graphics.

Means, PDF could only be rendered into something graphical. Painter (and Painting) would be a good target for that, as it matches PDF quite well. Unfortunately, nobody cared to write that code so far, and for a good reason too - PDF is quite complicated.

Note that basically the same thing applies to SVG too, in that case we do yet have QTF->SVG path yet. In fact, we are missing Painter->PDF and Painter->SVG etc... too Sad It is planned in general roadmap, but too costly to implement (I think about 1 month for Painter->PDF, Painter->SVG, 2 months for SVG->Painter, more for PDF->Painter).
Re: Qtf->Pdf simplified [message #38535 is a reply to message #34492] Sat, 22 December 2012 02:42 Go to previous message
lectus is currently offline  lectus
Messages: 329
Registered: September 2006
Location: Brazil
Senior Member
Maybe Poppler could be used to display PDFs in U++?
http://poppler.freedesktop.org/
Previous Topic: MySql now supports reconnection features
Next Topic: GTK backend
Goto Forum:
  


Current Time: Thu Mar 28 21:48:22 CET 2024

Total time taken to generate the page: 0.01790 seconds