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

Free Support Forum - aspose.com

Move pages within PDF document & convert PDF pages to thumbnail images

Hi,

Is it possible to move pages within a pdf document? What method would I use?

Also, is it possible to convert all PDF pages within a document to thumbnails, so they could be displayed on a ASP.NET webpage?

Thanks,

Michael

Hello Michael,

Thanks for considering Aspose.

Regarding your query for moving pages within Pdf, there is no such explicit function available but it can be achieved using to of the features of Aspsoe.Pdf.Kit. First Extract pages from Pdf document and create individual Pdf files and than call Concatenate function of PdfFileEditor calss. The following code example is for Pdf with 4 pages.

String prefix = @"C:\pdftest\Thumbnail\Extract";
String suffix = ".pdf";
int imageCount = 1;
FileStream inStream = new FileStream(@"C:\pdftest\Thumbnail\business.pdf", FileMode.Open);
PdfFileEditor editor = new PdfFileEditor();

for (int a = 1; a <= 4; a++)
{
int[] pages = new int[] {a};
FileStream outputStream = new FileStream(prefix + a + suffix, FileMode.Create);
editor.Extract(inStream, pages, outputStream);
outputStream.Close();
}

FileStream inStream1 = new FileStream(@"C:\pdftest\Thumbnail\Extract1.pdf", FileMode.Open);
FileStream inStream2 = new FileStream(@"C:\pdftest\Thumbnail\Extract2.pdf", FileMode.Open);
FileStream inStream3 = new FileStream(@"C:\pdftest\Thumbnail\Extract3.pdf", FileMode.Open);
FileStream inStream4 = new FileStream(@"C:\pdftest\Thumbnail\Extract4.pdf", FileMode.Open);

FileStream outStream = new FileStream(@"C:\pdftest\Thumbnail\Rearranged.pdf", FileMode.Create);
Stream[] inStreams = new Stream[] { inStream1, inStream3,inStream4, inStream2, inStream3 };
PdfFileEditor pdfEditor = new PdfFileEditor();
pdfEditor.Concatenate(inStreams, outStream);
outStream.Close();

For more information kindly visit Extract Pages from a PDF Document and Concatenate PDF Documents

Concerning your query to create Thumbnail of pages in a Pdf file, it can be achieved through PdfConverter class of Aspose.Pdf.Kit that converts each page of Pdf file to Specific image type and they can be displayed over the Asp.Net webpage.

PdfConverter pd = new PdfConverter();
pd.BindPdf(@"C:\pdftest\Thumbnail\business.pdf");
pd.Resolution = 100;

int imgCount = 1;
while (pd.HasNextImage())
{
pd.GetNextImage(@"C:\pdftest\Thumbnail\" + imgCount + ".gif", System.Drawing.Imaging.ImageFormat.Gif, 5, 5,10);
imgCount++;
}

For more information kindly visit Convert the PDF Document to Specified Images

Hi, thanks for the response.

When you say I can use the concatenate function, regarding your example, will those pages be concatenated at the end of the pdf document, or can I control where they are concatenated at? For example, I have a 10 page PDF document and I want to move page 2 after page 8... can that be accomplished using the concatenate function?

I wouldn't want page 2 concatenated after page 10.

Thanks...

Hello Michael,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

The sequence in which pages are concatenated is controlled through the array

Stream[] inStreams = new Stream[] { inStream1, inStream3,inStream4, inStream2, inStream3 };

The sequence you specify here will be used to generate the resultant Pdf. If you want page 2 after 8, write them accordingly in array.