Support

Knowledge Base - How to create an image page? (Windows)

To create a new image page, you can use the following code (premium license is needed):

StorageFolder storageFolder = ApplicationData.Current.LocalFolder;
StorageFile newFile = await storageFolder.CreateFileAsync("new.pdf", CreationCollisionOption.ReplaceExisting);
IRandomAccessStream stream = await newFile.OpenAsync(FileAccessMode.ReadWrite);

PDFDoc mNewDoc = new PDFDoc();
if (mNewDoc.Create(stream) == PDF_ERROR.err_ok)
{
       float width = 297f, height = 210f;
       mNewDoc.SetCahce(storageFolder.Path + "\\new.dat");
       PDFPage page = mNewDoc.NewPage(0, width, height);

       StorageFile imageFile = await storageFolder.GetFileAsync("bitmap.jpg");
       IRandomAccessStream streamImage = await imageFile.OpenAsync(FileAccessMode.Read);
       WriteableBitmap writeableBitmap = new WriteableBitmap(1, 1);
       writeableBitmap.SetSource(streamImage);

       PDFDocImage image = mNewDoc.NewImage(writeableBitmap, true);
       if (image != null)
       {
             PDFPageImage pageImage = page.AddResImage(image);
             if (pageImage != null)
             {
                  PDFPageContent pageContent = new PDFPageContent();
                  pageContent.GSSave();

                  PDFMatrix matrix = new PDFMatrix(width, height, 0, 0);
                  pageContent.GSSetMatrix(matrix);
                  pageContent.DrawImage(pageImage);
                  pageContent.GSRestore();
                  page.AddContent(pageContent, true);
                  page.Close();
              }
        }
        mNewDoc.Save();
        mNewDoc.Close();
}
Applies To

RadaeePDF SDK for Windows 8.1/10 and Phone

Related Articles

How to add an image to a pdf? (Android)

How to add an image to a pdf? (iOS)

How to create an image page using Xamarin? (Android)

Details

Created : 2017-04-11 12:26:53, Last Modified : 2017-05-09 10:48:09

Order history

Login to handle your order history.