|
| [WD19] How to print a multi page pdf. |
| Iniciado por guest, 06,abr. 2015 18:22 - 3 respuestas |
| |
| | | |
|
| |
| Publicado el 06,abril 2015 - 18:22 |
IF iConfigure() THEN IMG_PrintCopy = sTempImageName
sBitmapInfo = BitmapInfo(sTempImageName) IMG_PrintCopy..Width = ExtractString(sBitmapInfo, 2,TAB) IMG_PrintCopy..Height = ExtractString(sBitmapInfo, 3,TAB)
FOR i = 1 _TO_ IMG_PrintCopy..NumberPage IMG_PrintCopy..PageNumber = i iPrintImage(IMG_PrintCopy,0,0,IMG_PrintCopy..Width,IMG_PrintCopy..Height)
IF i < IMG_PrintCopy..NumberPage THEN iSkipPage() END END iEndPrinting() END
This code only prints the first page. If there are 4 pages it will print the first page 4 times. How should this be done. I found an old example at the link below, but there has to be a better way. Also, if I use the method below, the image quality gets worse when saving to another image format to print.
<a class="ExternalLink" rel="nofollow" target="_blank" href="http://27130.foren.mysnip.de/read.php?27131,35151,35157#msg-35157">http://27130.foren.mysnip.de/read.php…</a> |
| |
| |
| | | |
|
| | |
| |
| Publicado el 06,abril 2015 - 19:31 |
IF iConfigure() THEN // Include the PDF in a temporary image HExtractMemo(CustomerDoc,Doc,sTempFile) IMG_PrintCopy = sTempFile // Resize the image control sBitmapInfo = BitmapInfo(sTempFile) IMG_PrintCopy..Width = ExtractString(sBitmapInfo, 2,TAB) IMG_PrintCopy..Height = ExtractString(sBitmapInfo, 3,TAB) FOR i = 1 _TO_ IMG_PrintCopy..NumberPage IMG_PrintCopy..PageNumber = i sTempImage = sTempDir + ["\"] + i + "_pdf.jpg" // // Save the image dSaveImageJPEG(IMG_PrintCopy,sTempImage,100) // Print the image iPrintImage(sTempImage,0,0,IMG_PrintCopy..Width,IMG_PrintCopy..Height) IF i < IMG_PrintCopy..NumberPage THEN iSkipPage() END END iEndPrinting() // Delete the temporary images FOR i = 1 _TO_ IMG_PrintCopy..NumberPage sTempImage = sTempDir + ["\"] + i + "_pdf.jpg" fDelete(sTempImage) END IMG_PrintCopy = "" END This code actually works fine and the quality is good, but it places a border around each page. Any idea how to get rid of that? Seems like a size paramater issue? |
| |
| |
| | | |
|
| | |
| |
| Publicado el 06,abril 2015 - 20:05 |
Hi Curtis,
1rst, a remark. I think that you should do this: // Resize the image control sBitmapInfo = BitmapInfo(sTempFile) IMG_PrintCopy..Width = ExtractString(sBitmapInfo, 2,TAB) IMG_PrintCopy..Height = ExtractString(sBitmapInfo, 3,TAB)
before doing that: IMG_PrintCopy = sTempFile
This will allow the image to be loaded AS IS, without any resizing that would create a lowering in quality.
2nd, about your question.... 2 things : 1. you are printing the image according to its original size:iPrintImage(sTempImage,0,0,IMG_PrintCopy..Width,IMG_PrintCopy..Height) You should be printing according to the paper size, if you do not want any border 2. I do not see any code to modify the print driver margins... therefore, it is possible that your border is just that... And if it is the case, be aware that a lot of printer have what is a called a "technical" margin, which is an area where printing is not possible for technical reason (moving the paper, mostly)... So even if you set the margin to 0,0,ipagewidth,ipageheight, you may STILL have a border, the technical margin
Best regards |
| |
| |
| | | |
|
| | |
| |
| Publicado el 06,abril 2015 - 21:59 |
Thanks.
iParameter(iPaperSize, iPaperSize_Letter) seems to make everything look better. I also made sure to remove the border from the IMG_PrintCopy control.
So there isn't a way to do this without saving each pdf page to a jpg file? |
| |
| |
| | | |
|
| | | | |
| | |
|