Convert long image to multiple page pdf


#1

Hi,

I have an image which is basically a screenshot of a web form which a client wants to print off. I have some java script that converts this to an image and when printed this prints a 6 pages and this looks perfect. Annoyingly the want a pdf and when I try to embed this into a pdf it puts in onto one page when I want this image to be copied onto multiple pages. The image in questions has a width of 1080px and a height of 22,542px (It’s a long form).

Is there anyway using any aspose product that does this? I have tried Aspose.Imaging, pdf and word but the image gets shrunk onto one page?


#2

@Matt_b,

Can you please share source file along with generated result and sample code so that we may investigate to help you out.


#3

Some code is shown below.

I have also attached…

An example example file of the same size as my original file.
A pdf of the output I would like. I created the pdf by right clicking on the image and clicking convert to pdf. I assume this was done by adobe as this is installed on my machine

        var bytes = Convert.FromBase64String(imageAsByeArray);
        MemoryStream mystream = new MemoryStream(bytes);


        // Instantiate Document Object
        Document doc = new Document();
        // Add a page to pages collection of document
        Page page = doc.Pages.Add();

        

        page.PageInfo.Margin.Bottom = 0;
        page.PageInfo.Margin.Top = 0;
        page.PageInfo.Margin.Left = 0;
        page.PageInfo.Margin.Right = 0;

        Aspose.Pdf.Image imageObject = new Aspose.Pdf.Image();
        page.Paragraphs.Add(imageObject);
        imageObject.ImageStream = mystream;
     

        doc.Save(@"C:\Users\John Smith\Desktop\test.pdf");

test - Copy.png (225.9 KB)
test - Copy.pdf (294.5 KB)


#4

@Matt_b

We are checking your requirements and will get back to you shortly.


#5

@Matt_b

Thank you for contacting support.

You can convert an image to PDF with same page dimensions as of image’s. Please use following code snippet and then share your kind feedback with us.

String path = dataDir + "Test.JPG";
System.Drawing.Image srcImage = System.Drawing.Image.FromFile(path);
int h = srcImage.Height;
int w = srcImage.Width;
Document doc = new Document();
Page page = doc.Pages.Add();
Aspose.Pdf.Image image = new Aspose.Pdf.Image();
image.File = (path);
page.PageInfo.Height = (h);
page.PageInfo.Width = (w);
page.PageInfo.Margin.Bottom = (0);
page.PageInfo.Margin.Top = (0);
page.PageInfo.Margin.Right = (0);
page.PageInfo.Margin.Left = (0);
page.Paragraphs.Add(image);
doc.Save(dataDir + "ImagetoPDF_19.9.pdf");