adding image to new pdf file problem

Discussions about PDF management.
Post Reply
hardikv
Posts: 43
Joined: Thu Jan 27, 2011 11:46 am

adding image to new pdf file problem

Post by hardikv » Wed Mar 21, 2012 9:07 am

Hi all,

i have tried to add images like JPG,BMP or PNG into new pdf file.
below are some steps

1. create new pdf file
2. select one image file like jpg or bmp or png
3. add that image into new pdf file
4. save new pdf file to specific path

when i tried to add image into new pdf using below code. result is blank pdf file without any image.

Code: Select all

                    GdPictureImaging oGdPictureImaging = new GdPictureImaging();

                    oGdPictureImaging.SetLicenseNumberUpgrade("XXXX", "XXXX");

                    GdPicturePDF objPDF = new GdPicturePDF();

                    objPDF.SetLicenseNumber("XXXX");
                    /// create new empty pdf document
                    objPDF.NewPDF();

                    objPDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitInch);
                    int imageID = oGdPictureImaging.CreateGdPictureImageFromFile("C://temp/image1.png");					 
				     
                    oGdPictureImaging.ConvertTo1BppFast(imageID);
      
                                                if (oGdPictureImaging.IsBitonal(imageID)) 
                                                {
                                                    /// set compression for Bitonal image
                                                    objPDF.SetCompressionForBitonalImage(PdfCompression.PdfCompressionCCITT4);
                                                }
                                                else
                                                {
                                                    /// set compression for Color image
                                                    objPDF.SetCompressionForColorImage(PdfCompression.PdfCompressionJPEG);
                                                }

                                                /// add image to newly created pdf file
                                                objPDF.AddImageFromGdPictureImage(imageID, false, true);

			oGdPictureImaging.ReleaseGdPictureImage(imageID);

   if (!objPDF.SaveToFile("C://temp/NewPdfFile.pdf", PdfEncryption.PdfEncryptionNone, "", "", true, false, false, false, false, false, false, true).Equals(GdPictureStatus.OK))
                            {


                            }
Please correct me or can you please provide me the example for adding image into pdf.

Thanks in advance

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: adding image to new pdf file problem

Post by Loïc » Wed Mar 21, 2012 10:36 am

Hello,

Are you trying the latest available release ?

In 8.5.20 we've fixed a critical error in PDF drawing operations.

Kind regards,

Loïc

hardikv
Posts: 43
Joined: Thu Jan 27, 2011 11:46 am

Re: adding image to new pdf file problem

Post by hardikv » Wed Mar 21, 2012 11:35 am

Hi Loic,

Yes, i have used latest release of GdPicture.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: adding image to new pdf file problem

Post by Loïc » Wed Mar 21, 2012 12:17 pm

OK,

Please replace:

Code: Select all

 oGdPictureImaging.ConvertTo1BppFast(imageID);

            if (oGdPictureImaging.IsBitonal(imageID))
            {
                /// set compression for Bitonal image
                objPDF.SetCompressionForBitonalImage(PdfCompression.PdfCompressionCCITT4);
            }
            else
            {
                /// set compression for Color image
                objPDF.SetCompressionForColorImage(PdfCompression.PdfCompressionJPEG);
            }
by:

Code: Select all

oGdPictureImaging.ConvertTo1Bpp(imageID);
objPDF.SetCompressionForBitonalImage(PdfCompression.PdfCompressionCCITT4);

Kind regards,

Loïc

zoedtdt
Posts: 1
Joined: Mon Jul 18, 2016 9:09 am

Re: adding image to new pdf file problem

Post by zoedtdt » Thu Aug 18, 2016 10:55 am

You can download the trial version from our website. Trial version will have certain limitations in terms of add image to pdf file you can convert on pdfcomponent.com http://www.pdfcomponent.com/online/convert-jpeg-to-pdf/

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: adding image to new pdf file problem

Post by Loïc » Thu Aug 18, 2016 2:00 pm

Instead of spamming our forum you should concentrate your efforts on creating an application that works...

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest