That's a new feature of SP4 :-(



Change hhe writeBitmap() method of PDFViewer to look like this, then you're back to working bitmaps :



public void writeBitmap(OutputBitmapField _field, OuputSection _section)

{

    BinData bin = new BinData();

    image img;

    container data;

    str s;

    real x1,x2, y1,y2;

    struct br;

    int imageObjectNo = 0;

    //real PDFPreviewScale = 0.8;       // New in SP4 - not needed when using SP3 version

    boolean generateXImage = false;

    container c;

    str fn;



    br = this.boundingRectTwips(currentPage, _section, _field);



    x1 = br.value('x1'); y1 = br.value('y1');

    x2 = br.value('x2'); y2 = br.value('y2');



    if (_field.type() == 10) // resourceId, DB_RESID

    {

        img = new Image(_field.resourceId());



        if (resourceIdImageMap.exists(_field.resourceId()))

            imageObjectNo = resourceIdImageMap.lookup(_field.resourceId());

        else

        {

            imageObjectNo = this.nextObjectNo();

            resourceIdImageMap.insert(_field.resourceId(), imageObjectNo);

            generateXImage = true;

        }



        if (debugLevel >= 1)

            info ('Image in resource ' + int2str(_field.resourceId()));

    }

    else if (_field.type() == 7) // queue

    {

        c = _field.value();

        if (c)

        {

            img = new Image(c);

            imageObjectNo = this.nextObjectNo();

        }

        generateXIMage = true;



        if (debugLevel >= 1)

        {

            if (img)

                info ('Image in container');

            else

                info ('No image in container');

        }

    }

    else // string containing filename

    {

        img = new Image(_field.imageFilename());



        if (stringImageMap.exists(_field.imageFilename()))

            imageObjectNo = stringImageMap.lookup(_field.imageFilename());

        else

        {

            imageObjectNo = this.nextObjectNo();

            stringImageMap.insert(_field.imageFilename(), imageObjectNo);

            generateXImage = true;

        }



        if (debugLevel >= 1)

            info ('File is ' + _field.imageFileName());

    }



    if (img)

    {

        if (generateXImage)

        {

            // We have not seen this image before, so generate an XIMage for it

            // Save the image as a jpg file.

            fn = winApi::getTempFilename(winApi::getTempPath(), 'AXP');



            // SP4 does not work! - back to SP3 code

            //RH#4382, v-yuriv, 24-11-2004

            //We should resize the bitmap according to the area given in PDF page otherwise there will be out of area drawing

            //The PDF bitmap drawing has wrong scaling from what we see in the preview so we should also scale it by PDFPreviewScale

            //img.resize(min(abs(x2-x1)/PDFPreviewScale, img.width()), min(abs(y2-y1)/PDFPreviewScale, img.height()), 4);



            img.saveImage(fn, ImageSaveType::JPG);



            bin.loadFile(fn);

            data = "">


            // Get rid of the temporary file.

            winApi::deleteFile(fn);



            if (bitmapEncode85)

                s = bin.ascii85Encode();

            else

                s = bindata::dataToString(data);



            // Use the image dimensions if the user didn't specify resize



            objectOffsetMap.insert(imageObjectNo, buffer.size());

            imagesOnPage.add(imageObjectNo);



            buffer.appendText(int2str(imageObjectNo) + ' 0 obj <<\r');

            buffer.appendText('  /Type/XObject /Subtype/Image /ColorSpace /DeviceRGB\r');

            buffer.appendText('  /Name /I' + int2str(imageObjectNo) + ' /BitsPerComponent 8\r');

            if (!bitmapEncode85)

            {

                buffer.appendText('  /Filter [/ASCIIHexDecode/DCTDecode] /DecodeParms[null<<>>]\r');

                buffer.appendText(strfmt('  /Length %1\r', strlen(s)+1));    // Allow for end of data marker

            }

            else

            {

                buffer.appendText('  /Filter [/ASCII85Decode/DCTDecode] /DecodeParms[null<<>>]\r');

                buffer.appendText(strfmt('  /Length %1\r', strlen(s)));

            }

            buffer.appendText(strfmt('  /Width %1 /Height %2\r', img.width(), img.height()));

            buffer.appendText('>>\rstream\r');

            buffer.appendText(s);



            if (!bitmapEncode85)

                buffer.appendText('>'); // End of Data marker



            buffer.appendText('\rendstream\rendobj\r');

        }



        // SYP-Modification R-DEN-DDSP-KITR-04447 - Begin (SP3)

        // Have to put imageObjectNo or it will be only on page #1

        imagesOnPage.add(imageObjectNo);

        // SYP-Modification R-DEN-DDSP-KITR-04447 - End (SP3)



        // Generate the object that draws the image...

        s  = 'q\r';



        s += this.drawFieldFrame(_field, x1, y1, x2, y2);



        // Provide a scaling factor bringing the image size up to the size requested by the report

        // Also, provide x,y pos)

        if (_field.resize())

            s += '   ' + this.real2str(x2-x1) + ' 0 0 ' + this.real2str(y2-y1) + ' ' + this.real2str(x1) + ' ' + this.real2str(y1) + ' cm\r';

        else

        {

            x1 += this.twips(this.borderWidth(_field.borderWidth(), _field.lineLeft()));

            y1 += this.twips(this.borderWidth(_field.borderWidth(), _field.lineRight()));

            x2 -= this.twips(this.borderWidth(_field.borderWidth(), _field.lineTop()));

            y2 -= this.twips(this.borderWidth(_field.borderWidth(), _field.lineBottom()));



            if (_field.alignment() == ALIGNMENT::Center)

            {

                x1 = (x1 + x2 - img.width()) / 2;

                y1 = (y1 + y2 - img.height()) / 2;

            }

            else if (_field.alignment() == ALIGNMENT::Right)

            {

                x1 = x2 - img.width();

                y1 = y2 - img.height();

            }

            else    // left

            {

                y1 = y2 - img.height();

            }

            // SP4 does not work! - back to SP3 code

            //RH#4382, v-yuriv, 24-11-2004

            //The PDF bitmap drawing has wrong scaling from what we see in the preview so we should also scale it by PDFPreviewScale

            //s += '   ' + this.real2str(PDFPreviewScale*img.width()) + ' 0 0 ' + this.real2str(PDFPreviewScale*img.height()) + ' ' + this.real2str(x1) + ' ' + this.real2str(y1) + ' cm\r';

            s += '   ' + this.real2str(img.width()) + ' 0 0 ' + this.real2str(img.height()) + ' ' + this.real2str(x1) + ' ' + this.real2str(y1) + ' cm\r';

        }



        s += '   /I' + int2str(imageObjectNo) + ' Do\r';

        s += 'Q\r';



        pagePDF.appendText(s);

    }

    super(_field, _section);

}



Regards

     Palle Mølgaard

      Systemate A/S

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Allan Ørum
Sent: 27. februar 2006 21:30
To: [email protected]
Subject: [development-axapta] Bitmaps in pdf files



Hi,
I have a problem with pdf files.
When I print to screen (eg a confirmation), my bitmaps comes out fine and
scaled.
But when I print to a pdf file, the bitmaps are placed funny, and are no
longer scaled.

Anyone with experience in this area?

Regards Allan






SPONSORED LINKS

Computer part <http://groups.yahoo.com/gads?t=ms&k=Computer+part&w1=Computer+part&w2=Programming+languages&w3=Microsoft+axapta&w4=Support+exchange&c=4&s=90&.sig=yLpvcLTIDJ5FTkRJGsO11w

Programming languages <http://groups.yahoo.com/gads?t=ms&k=Programming+languages&w1=Computer+part&w2=Programming+languages&w3=Microsoft+axapta&w4=Support+exchange&c=4&s=90&.sig=cuhEClK4dU4wapXFmKisbQ

Microsoft axapta <http://groups.yahoo.com/gads?t=ms&k=Microsoft+axapta&w1=Computer+part&w2=Programming+languages&w3=Microsoft+axapta&w4=Support+exchange&c=4&s=90&.sig=yfeG_U6QaLfPOZZIud02Fg

Support exchange <http://groups.yahoo.com/gads?t=ms&k=Support+exchange&w1=Computer+part&w2=Programming+languages&w3=Microsoft+axapta&w4=Support+exchange&c=4&s=90&.sig=hy8yRGMzrmxdphyITTUeqA







________________________________

YAHOO! GROUPS LINKS



*      Visit your group "development-axapta <http://groups.yahoo.com/group/development-axapta> " on the web.
       
*      To unsubscribe from this group, send an email to:
      [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
       
*      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .



________________________________



[Non-text portions of this message have been removed]





SPONSORED LINKS
Computer part Programming languages Microsoft axapta
Support exchange


YAHOO! GROUPS LINKS




Reply via email to