Grid report multipage

If you have any questions regarding Quartam PDF Library for LiveCode, this is the place to get answers from your fellow users - experts and newbies alike.
Post Reply [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
dRoss
Posts:4
Joined:Thu Dec 05, 2013 10:11 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
Grid report multipage

Post by dRoss » Thu Dec 05, 2013 11:10 am

Hi,
my target is to create a quote reports, multi-mobile tablet.
I'm trying the 'example 4 and example 3, but with the long text in a column do not work.
Quartam can create a multipage PDF reports, as this table.
https://drive.google.com/file/d/0B2LAio ... sp=sharing
Thanks in advance

JanSchenkel
Site Admin
Posts:110
Joined:Sun Jul 18, 2010 5:21 pm
Location:Aalst, Belgium
Contact:

Re: Grid report multipage

Post by JanSchenkel » Thu Dec 05, 2013 6:38 pm

Welcome to the forums.

Unfortunately, the 'qrtPDF_WriteTextTable' command was never designed for such a use case: it doesn't support vertical alignment or splitting individual cells over multiple pages. But that doesn't mean it's impossible to achieve the layout you're looking for - just that it will require some work on your part.

One handy feature of the 'qrtPDF_WriteText' command is that it updates the internal 'text' X and Y positions. After a blob of text is 'written', the X position is to the right of the last bit of text, and the Y position is on the last row of text. This means after the multi-line 'Description' is written, the Y position is correct for the 'Quantity', 'Unit Price' and 'Subtotal' column of the row.

Here's how I would tackle it:
- draw the header text and lines in the 'qrtPDF_PrintHeader' callback
- iterate over the rows
-> set the left and right margin to match the horizontal start / end positions of the 'Id' column
-> use the 'qrtPDF_WriteText' command to output the ID
-> set the left and right margin to match the horizontal start / end positions of the 'Description' column
-> use the 'qrtPDF_WriteText' command to output the Description
-> set the left and right margin to match the horizontal start / end positions of the 'Quantity' column
-> use the 'qrtPDF_WriteText' command to output the Quantity
-> set the left and right margin to match the horizontal start / end positions of the 'Unit Price' column
-> use the 'qrtPDF_WriteText' command to output the UnitPrice
-> set the left and right margin to match the horizontal start / end positions of the 'Subtotal' column
-> use the 'qrtPDF_WriteText' command to output the Subtotal
- draw left, right and bottom lines in the 'qrtPDF_PrintFooter' callback

I don't have the time right now to convert this idea into example code, but I hope it gets you started.
(Note that you currently can't output a "PageNumber/PageCount" pair, but you'll have to decide how important this is.)

Jan Schenkel.
Quartam Developer Tools for LiveCode
http://www.quartam.com

dRoss
Posts:4
Joined:Thu Dec 05, 2013 10:11 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Grid report multipage

Post by dRoss » Fri Dec 06, 2013 4:25 pm

Hi Jan, thanks for the reply, this is a good starting point.
I'll keep you updated on the work

dRoss
Posts:4
Joined:Thu Dec 05, 2013 10:11 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Grid report multipage

Post by dRoss » Wed Dec 11, 2013 7:19 pm

I started playing with this script, but the text of the columns Price and Total wrap.
Maybe I do not understand the setting right and left of the column….

Code: Select all

on mouseUp
   if "qrtPDFLib" is not among the lines of the stacksInUse then start using stack "qrtPDFLib"
   ask file "Save as:" with "myReport.pdf"
   if it is empty then exit mouseUp
   put it into tFilePath
   try
      put qrtPDF_CreateDocument() into tDocRef
      qrtPDF_OpenDocument tDocRef
      qrtPDF_CreatePage tDocRef
      
      qrtPDF_SetFontSize tDocRef,9
      
      qrtPDF_SetLeftMargin tDocRef,15
      qrtPDF_SetRightMargin tDocRef,25
      qrtPDF_WriteText tDocRef, 5, ID
      
      qrtPDF_SetLeftMargin tDocRef,25
      qrtPDF_SetRightMargin tDocRef,45
      qrtPDF_WriteText tDocRef, 5, Quantity
      
      qrtPDF_SetLeftMargin tDocRef,45
      qrtPDF_SetRightMargin tDocRef,130
      qrtPDF_WriteText tDocRef, 5, Description
      
      qrtPDF_SetLeftMargin tDocRef,130
     qrtPDF_SetRightMargin tDocRef,155
      qrtPDF_WriteText tDocRef, 5, Price
      
      qrtPDF_SetLeftMargin tDocRef,155
      qrtPDF_SetRightMargin tDocRef,190
      qrtPDF_WriteText tDocRef, 5, Total
      
      qrtPDF_CloseDocument tDocRef
      qrtPDF_SaveDocument tDocRef, tFilePath
      qrtPDF_DeleteDocument tDocRef
      LaunchDocument tFilePath
   catch tError
      answer error tError
      qrtPDF_DeleteAllDocuments
   end try
   
end mouseUp

JanSchenkel
Site Admin
Posts:110
Joined:Sun Jul 18, 2010 5:21 pm
Location:Aalst, Belgium
Contact:

Re: Grid report multipage

Post by JanSchenkel » Mon Dec 16, 2013 9:44 pm

I think I see where you got into trouble: the margins are always set from the outer edge of the page inwards. So if you pass in 130 as the 'right margin', you're actually telling the library that you want to stay 130 units from the right hand side of the paper.

HTH,

Jan Schenkel.
Quartam Developer Tools for LiveCode
http://www.quartam.com

dRoss
Posts:4
Joined:Thu Dec 05, 2013 10:11 am
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable

Re: Grid report multipage

Post by dRoss » Wed Jul 16, 2014 3:42 pm

hello Jan,

I re-started with this script just now, I'm not lost :)

I did not realize that the right margins must start from the right not from the left, now the script works.

Is there a solution to print the rich text you see in the image attached? (Superscript, unordered list ...)

I thought the htmlText property of, but I not found the reference to this.

Thanks in advance


Image
Attachments
Senza titolo.jpg
(154.07KiB)Not downloaded yet

JanSchenkel
Site Admin
Posts:110
Joined:Sun Jul 18, 2010 5:21 pm
Location:Aalst, Belgium
Contact:

Re: Grid report multipage

Post by JanSchenkel » Sun Aug 03, 2014 8:52 pm

Styled text is not directly supported ; most of it can be done if you take the time to code it, but it can get complicated.

The two main obstacles in the current version of the library are: unicode and arbitrary fonts.
Adding unicode support is not trivial - and LiveCode 7 should finally make this easier. I have been working on code to use any truetype font you want, but this, too, hinges on unicode support.

Even with those two things in place, you will have to do a fair bit of coding to place text exactly where you want it to be.
The sad thing is, PDF as a document structure is by its very nature quite poor when it comes to word processing features. All it offers is the ability to set a font name and size and then drop a blob of text in a certain location.
The rest is up to you, or some kind soul who writes commands and functions which do the footwork of mapping between a styled text format and the low-level PDF instructions.

Jan Schenkel.
Quartam Developer Tools for LiveCode
http://www.quartam.com

Post Reply
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable
[phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/lib/Twig/Extension/Core.php on line 1275: count(): Parameter must be an array or an object that implements Countable