Printing to PDF
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Printing to PDF
I am using the new Printing to PDF command which is something that I've been waiting
for for a long time.
HOwever, when I save as standalone app it doesn't work!
The print dialogue appears, you choose a name to save it as and nothing happens.
Am I doing something wrong here? I have changed the settings in standlone settings
but still cant get this to work after saving as standalone.
Anyone else had these issues in 4.5?
for for a long time.
HOwever, when I save as standalone app it doesn't work!
The print dialogue appears, you choose a name to save it as and nothing happens.
Am I doing something wrong here? I have changed the settings in standlone settings
but still cant get this to work after saving as standalone.
Anyone else had these issues in 4.5?
Re: Printing to PDF
bsouthuk,
Rev 4.5 is not to be discussed in public.
Mark
Rev 4.5 is not to be discussed in public.
Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode
Re: Printing to PDF
This seems like a great new feature.
I found two issues so far:
1) Using a stack for a page layout I can control the text placement pretty well, but I get a blank page #1 before the page I am actually printing to the pdf file. So it always produces 2 pages if the first one is full.
2) I tried setting the options with an array and the keys as documented with no success.
Also I see no documentation to help with these features yet and no way to set the page size.
I am sure some of these will be cleared up with the documentation.
I found two issues so far:
1) Using a stack for a page layout I can control the text placement pretty well, but I get a blank page #1 before the page I am actually printing to the pdf file. So it always produces 2 pages if the first one is full.
2) I tried setting the options with an array and the keys as documented with no success.
Also I see no documentation to help with these features yet and no way to set the page size.
I am sure some of these will be cleared up with the documentation.
Developing with Windows XP & Revolution 4.5
Re: Printing to PDF
The best thing to do when a blank page is being created is adding the below script to your card script:
This way, you will never get that annoying blank page.
Code: Select all
on preopenstack
set the printScale to 1
set the printMargins to 0, 0, 0, 0 --1/2 inch margins
set the printGutters to 0, 0 --1/4 inch gutters
end preopenstack
Re: Printing to PDF
Thank you for the suggestion but that did not work. But I played with your code below and discovered that I was setting the margins after opening the print to pdf. Once I moved the code below to manage the setting before opening the print channel everything worked as expected. No blank page.
So basically you set print scale, margins, gutters ...ect first then open the print channel. VERY IMPORTANT sequence of events. I naturally expected it to be coded by the opposite sequence but NOT.
Thank you again.
So basically you set print scale, margins, gutters ...ect first then open the print channel. VERY IMPORTANT sequence of events. I naturally expected it to be coded by the opposite sequence but NOT.
Thank you again.
Code: Select all
on preopenstack
set the printScale to 1
set the printMargins to 0, 0, 0, 0 --1/2 inch margins
set the printGutters to 0, 0 --1/4 inch gutters
end preopenstack
Developing with Windows XP & Revolution 4.5
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Re: Printing to PDF
Well, it's just like regular printing, so all settings have to be made before the call to 'open printing' - you can't switch page orientation in the middle, for instance.
Shameless plug: if you want to go beyond 'print to pdf file' you should check out Quartam PDF Library
Jan Schenkel.
Shameless plug: if you want to go beyond 'print to pdf file' you should check out Quartam PDF Library

Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Re: Printing to PDF
Thank you Jan I will look into the Quartam PDF Library.
The issue with the option keys still stands. I will try setting all the keys to see if that is the issue. My test only set a few of the option keys so I will report after another try.
The issue with the option keys still stands. I will try setting all the keys to see if that is the issue. My test only set a few of the option keys so I will report after another try.
Developing with Windows XP & Revolution 4.5
Re: Printing to PDF
Well the option keys Author , Title, and Subject seem to work in Windows XP when printing to a pdf. The keys are visible when you hover over the file name with the mouse pointer.
I did not think the keys worked because I was looking for them in the file properties dialog. These same values in the file properties dialog are not set.
I guess this is the intended use for the option keys.
I did not think the keys worked because I was looking for them in the file properties dialog. These same values in the file properties dialog are not set.
I guess this is the intended use for the option keys.
Developing with Windows XP & Revolution 4.5
-
- VIP Livecode Opensource Backer
- Posts: 977
- Joined: Sat Apr 08, 2006 7:47 am
- Contact:
Re: Printing to PDF
Some of the Options may only show up when you look at the document properties inside Adobe Reader or Apple Preview. Windows Explorer may only show some of those properties.
Jan Schenkel.
Jan Schenkel.
Quartam Reports & PDF Library for LiveCode
www.quartam.com
www.quartam.com
Re: Printing to PDF
Jan:
You are 100% correct. More options show up in the reader than windows explorer. So all is good.
You are 100% correct. More options show up in the reader than windows explorer. So all is good.
Developing with Windows XP & Revolution 4.5
Re: Printing to PDF
On another note.
I application is a proposal generating app that different companies use and the images/info thats shown on each card of the proposal is determined by which company logs into the system.
Before the print to pdf feature I was using a pdf convertor which was working fine, however have started to use the print to PDF feature. Problem is that when I save the PDF its a large file - mine is around 8 MB and I think the reason is that it is taking into account the images that are not visible. Is there a way that the Print to PDF feature can dislude the hidden images on a card?
I application is a proposal generating app that different companies use and the images/info thats shown on each card of the proposal is determined by which company logs into the system.
Before the print to pdf feature I was using a pdf convertor which was working fine, however have started to use the print to PDF feature. Problem is that when I save the PDF its a large file - mine is around 8 MB and I think the reason is that it is taking into account the images that are not visible. Is there a way that the Print to PDF feature can dislude the hidden images on a card?
Re: Printing to PDF
Actually this is only when in pre build mode. Once i have built as standalone the pdfs are normally around 1.5 MB. Why is this so?
Also when using the following code, the pdf saves in the folder in which the executable is in even though i have selected the desktop or another folder. Would I need to add to the script? By the way, the reason for the 'put field "ID" card 2 stack "Disty Report" & ".pdf" into it' line of code is because I need the pdfs name to be generated by the app not allowing the use to change the name.
Also when using the following code, the pdf saves in the folder in which the executable is in even though i have selected the desktop or another folder. Would I need to add to the script? By the way, the reason for the 'put field "ID" card 2 stack "Disty Report" & ".pdf" into it' line of code is because I need the pdfs name to be generated by the app not allowing the use to change the name.
Code: Select all
ask file "Choose a file for the PDF:"
if it is not empty then
put field "ID" card 2 stack "Disty Report" & ".pdf" into it
open printing to pdf it
close printing
launch document it
END IF
Re: Printing to PDF
Hi Daniel,
Put everything in IT that you get with "ask" or "answer" or "get" into a variable IMMEDIATELY since IT will change when you least exspect it!
In your case you should:
...
ask FOLDER "Where should I save the PDF?"
put IT & "/" & field "ID" card 2 stack "Disty Report" & ".pdf" into target_file
open printing to file target_file
...
since user do not like when they enter a name for a file, but the app uses another name for the file.
They might not find the file anymore and blame the programmer, and they are right
Best
Klaus
Important hints:bsouthuk wrote:
This script cannot do what you want!Code: Select all
ask file "Choose a file for the PDF:" ## Now IT contains something like "C:/A Folder/another folder/User chosen name.pdf" if it is not empty then put field "ID" card 2 stack "Disty Report" & ".pdf" into it ## Should read "...field "ID" OF card 2..." ##THis line overwrites the complete content of IT with(guessing) the content of field "ID" & ".pdf" ## NO path in IT anymore, that's why you find the PDF in the apps directory open printing to pdf it ## I guess you just left out the actual printing here close printing launch document it END IF
Put everything in IT that you get with "ask" or "answer" or "get" into a variable IMMEDIATELY since IT will change when you least exspect it!
In your case you should:
...
ask FOLDER "Where should I save the PDF?"
put IT & "/" & field "ID" card 2 stack "Disty Report" & ".pdf" into target_file
open printing to file target_file
...
since user do not like when they enter a name for a file, but the app uses another name for the file.
They might not find the file anymore and blame the programmer, and they are right

Best
Klaus
Re: Printing to PDF
Thanks as always Klaus. I now have the following print to PDF script:
I get an error message saying Printing Failed after the 'open printing to PDF target_file.
Also, when I put ASK FOLDER Rev says its an execution error
Code: Select all
ask file "Choose a file for the PDF:"
if it is not empty then
put IT & "/" & field "ID" card 2 stack "Disty Report" & ".pdf" into target_file
open printing to pdf target_file
answer the result
close printing
launch document target_file
Also, when I put ASK FOLDER Rev says its an execution error
Re: Printing to PDF
Klaus
I have now got this working - I just removed & "/" & from th following line:
Thanks again for your help!
I have now got this working - I just removed & "/" & from th following line:
Code: Select all
put IT & "/" & field "ID" card 2 stack "Disty Report" & ".pdf" into target_file