We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

HD Image as PDF Background

I am able generate PDF from Word file successfully. Once PDF is generated, I need to insert HD image of dimensions - { Width: 2480px, Height: 3508px, Bit Depth: 24 Image is of A4 page size.} as a background image in generated PDF.

I am able to insert such image using below code.

/* Step 1 - Read Original HD Image and Scale it to have New Bitma as of required size. */
Bitmap newImage = new Bitmap(sourceImg, Convert.ToInt32(this.pageDimensions.PageWidth * pixelsPerInch), Convert.ToInt32(this.pageDimensions.PageHeight * pixelsPerInch));

Here I have constants as -
pixelsPerInch = 96.
this.pageDimensions.PageWidth = 8.27 in.
this.pageDimensions.PageHeight = 11.7 in.

/* Step 2 - Save Newly created Bitmap in Step 1 */
newImage.Save(destFile);

/* Step 3 - Include New Bitmap image in HTML. */
body = “”;

/* Step 4+ => This HTML is then used to generate Word file, which intern generates PDF using Aspose */

But now, problem i face is - Since above code to add image scale the image (to make it fit with PDF Page size) quality is compromised.

So essentially I am looking out for -

  1. Better way to insert HD image as PDF background.
    OR
  2. Retain HD image quality while scaling the image before having it as PDF background.

Thanks.

@Aniruddha.Bhide

Thanks for your inquiry. As you want to manipulate PDF document, please use Aspose.Pdf for the purpose. Please check following documentation link to add image background to PDF document, it will help you to accomplish the task.

Please feel free to contact us for any further assistance.

Best Regards,