yyn0210 / alivepdf

Automatically exported from code.google.com/p/alivepdf
0 stars 0 forks source link

writeFlashHtmlText problem when margins are not integers #311

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. If you have non-integer margins that will round to the next highest number 
(such as 12.7), writeFlashHtmlText will cause breaks as shown in the attached 
pdf.

What is the expected output? What do you see instead?
The text should be one the same line.

What version of the product are you using? On what operating system?
latest at the time, which was revision 277

Please provide any additional information below.
The fix is to change the type of two variables in PDF.as from int to Number

In the renderLine() method around line #3809 change

var tmpCellY:int;
var tmpCellHeight:int;

to:

var tmpCellY:Number;
var tmpCellHeight:Number;

The problem would occur in this code around #3823

if (Math.round(cellVO.y) > Math.round(tmpCellY))
    currentY += tmpCellHeight;
else
    currentY -= tmpCellHeight;

Original issue reported on code.google.com by jamie...@insightbb.com on 19 Apr 2011 at 9:40

Attachments:

GoogleCodeExporter commented 8 years ago
AlivePDFBug.mxml contents
----------------------

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" 
minWidth="955" minHeight="600">
    <mx:Script>
        <![CDATA[
            import org.alivepdf.display.Display;
            import org.alivepdf.fonts.CoreFont;
            import org.alivepdf.fonts.FontFamily;
            import org.alivepdf.layout.Layout;
            import org.alivepdf.layout.Orientation;
            import org.alivepdf.layout.Size;
            import org.alivepdf.layout.Unit;
            import org.alivepdf.pdf.PDF;
            import org.alivepdf.saving.Method;

            private function createPDF():void
            {
                var pdf:PDF = new PDF(Orientation.LANDSCAPE, Unit.MM, true, Size.LETTER);
                pdf.setDisplayMode(Display.FULL_PAGE, Layout.SINGLE_PAGE);
                pdf.setMargins(12.7, 12.7, 12.7, 12.7); //12.7mm is 1/2 inch margins    
                pdf.setFont(new CoreFont(FontFamily.ARIAL), 12);
                pdf.addPage();
                pdf.writeFlashHtmlText(5, '<p>This text should all be on the same line</p>');
                var file:FileReference = new FileReference();
                var bytes:ByteArray = pdf.save(Method.LOCAL);
                file.save(bytes, "generated.pdf");
            }
        ]]>
    </mx:Script>
    <mx:Button label="Create PDF" click="createPDF()" />
</mx:Application>

Original comment by jamie...@insightbb.com on 19 Apr 2011 at 9:47

GoogleCodeExporter commented 8 years ago
fixed in r281.

Thanks for reporting the issue.

Original comment by felix.ge...@gmail.com on 8 Oct 2011 at 8:50