[Interest] Creating pdf with QTextDocument with chart

Duane duane.hebert at group-upc.com
Mon Oct 26 20:04:49 CET 2015


On 26/10/2015 2:04 PM, Edward Sutton via Interest wrote:
> You can add image resources to a QTextDocument.
>
> QTextDocumenttextDocument;
>
> textDocument.setPageSize(QSizeF(m_pageWidth,m_pageHeight));
>
>
> QStringhtmlImageClient;
>
> QImageimageClient(this->m_model->jobInformation()->clientInfo.logoImagePath);
>
> if(false==imageClient.isNull())
>
> {
>
> htmlImageClient=QString("<imgsrc=\"mydata://client.png\"align='left'height=\"%1\"/>")
>
> .arg(imageHeight);
>
> textDocument.addResource(QTextDocument::ImageResource,
>
> QUrl("mydata://client.png"),QVariant(imageClient));
>
> }
>
>

Thanks, I will try this.

> The QTextDocument to PDF approach works for Android, Windows, and OS X.
>   I expect Linux too.

If you mean QPrinter() to print a PDF file, then yes it works on Linux 
as well.

> If you need to generate PDF’s on iOS, you will need to find a non-Qt
> approach.  Unfortunately Qt PDF generation is implemented in
> QPrinter and iOS has no printer support.
>
> -Ed
>
>

Thanks.



>> On Oct 26, 2015, at 11:28 AM, Duane <duane.hebert at group-upc.com
>> <mailto:duane.hebert at group-upc.com>> wrote:
>>
>> On 26/10/2015 12:07 PM, Jason H wrote:
>>>
>>>>
>>>> I don't think 4.8 has the ability to paint images in a document.  It
>>>> looks like Qt5 would make a lot of this simpler.
>>>
>>> If you read http://doc.qt.io/qt-4.8/richtext-html-subset.html You'll
>>> see it supports the <img> tag.
>>>
>>
>> Yes but img requires a file name.  I'd have to create a png or jpg.
>> Maybe.  I'll look into that.
>>
>> _______________________________________________
>> Interest mailing list
>> Interest at qt-project.org <mailto:Interest at qt-project.org>
>> http://lists.qt-project.org/mailman/listinfo/interest
>
> This email and any files transmitted with it from The Charles Machine
> Works, Inc. are confidential and intended solely for the use of the
> individual or entity to which they are addressed. If you have received
> this email in error please notify the sender. Our company accepts no
> liability for the contents of this email, or for the consequences of any
> actions taken on the basis of the information provided, unless that
> information is subsequently confirmed in writing. Please note that any
> views or opinions presented in this email are solely those of the author
> and do not necessarily represent those of the company. Finally, the
> recipient should check this email and any attachments for the presence
> of viruses. The company accepts no liability for any damage caused by
> any virus transmitted by this email.
>
>





More information about the Interest mailing list