0% found this document useful (0 votes)
37 views

ABCPDF: Split PDF Files Into Single Page PDF Files: Asked Modified Viewed

The document discusses splitting large PDF files containing many pages into individual single-page PDF files while preserving page rotation. The original method was fast but did not maintain rotation. A second method was slower but kept rotation by appending the full document and removing unwanted pages. The support team then provided an improved solution that copies each page individually and copies the rotation attribute from the source page, making it both fast and able to maintain rotation.

Uploaded by

swadhin_abap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

ABCPDF: Split PDF Files Into Single Page PDF Files: Asked Modified Viewed

The document discusses splitting large PDF files containing many pages into individual single-page PDF files while preserving page rotation. The original method was fast but did not maintain rotation. A second method was slower but kept rotation by appending the full document and removing unwanted pages. The support team then provided an improved solution that copies each page individually and copies the rotation attribute from the source page, making it both fast and able to maintain rotation.

Uploaded by

swadhin_abap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

ABCPDF: Split PDF files into single page PDF files

Asked 10 years, 5 months ago Modified 9 years, 11 months ago Viewed 6k times

I am using ABCpdf tool and I am trying to split 1TB of PDF files (so efficiency is a concern) into single page PDF files.
5 I have tried the following:
Doc theSrc = new Doc();
theSrc.Read("C://development//pdfSplitter//Bxdfbc91ca-fc05-4315-8c40-
798a77431ee0xP.pdf");

for (int i = 1; i <= theSrc.PageCount; i++)


{
Doc singlePagePdf = new Doc();
singlePagePdf.Rect.String = singlePagePdf.MediaBox.String =
theSrc.MediaBox.String;
singlePagePdf.AddPage();
singlePagePdf.AddImageDoc(theSrc, i, null);
singlePagePdf.FrameRect();

singlePagePdf.Save("C://development//pdfSplitter//singlePDF//singlePage"+i+".pdf")
singlePagePdf.Clear();
}
theSrc.Clear();

This one is very fast BUT it does not keep the rotated pages and they NEED to be. I tried to rotate them manually but this very quickly got a bit
messy and they did not come out the precise way as they were in the original document.
I have also tried:
Doc theSrc = new Doc();
theSrc.Read("C://development//pdfSplitter//Bxdfbc91ca-fc05-4315-8c40-
798a77431ee0xP.pdf");
for (int i = 1; i <= theSrc.PageCount; i++)
{
Doc singlePagePdf = new Doc();
singlePagePdf.Append(theSrc);
singlePagePdf.RemapPages(i.ToString());

singlePagePdf.Save("C://development//pdfSplitter//singlePDF//singlePage"+i+".pdf")
singlePagePdf.Clear();
}
theSrc.Clear();

This one is about 6 times slower(on large documents) than the first one BUT it keeps the formatting of the rotated pages and that is important.
The problem with this one is that I have to append the whole document and remove all the unwanted pages again. This is done for all pages in the
file which is very inefficient.
Can anybody help me on this matter?
c# abcpdf

Share Follow asked Aug 8, 2013 at 9:21


Kristian Barrett
3,634 2 26 42

1 Ideally the support staff of the component (ABC...) can help you with this - try their support first... – Yahia Aug 8, 2013 at 9:23
Ok I will try that as well. I will keep this thread posted. Thank you. – Kristian Barrett Aug 8, 2013 at 9:26

2 Answers Sorted by: Highest score (default)

So I talked to the support at WebSuperGoo (The creators of ABCpdf) and they gave me the following:
10 Doc theSrc = new Doc();
theSrc.Read("C://development//pdfSplitter//Bxdfbc91ca-fc05-4315-8c40-
798a77431ee0xP.pdf");

int srcPagesID = theSrc.GetInfoInt(theSrc.Root, "Pages");


int srcDocRot = theSrc.GetInfoInt(srcPagesID, "/Rotate");

for (int i = 1; i <= theSrc.PageCount; i++)


{
Doc singlePagePdf = new Doc();
singlePagePdf.Rect.String = singlePagePdf.MediaBox.String =
theSrc.MediaBox.String;
singlePagePdf.AddPage();
singlePagePdf.AddImageDoc(theSrc, i, null);
singlePagePdf.FrameRect();

int srcPageRot = theSrc.GetInfoInt(theSrc.Page, "/Rotate");


if (srcDocRot != 0)
{
singlePagePdf.SetInfo(singlePagePdf.Page, "/Rotate", srcDocRot);
}
if (srcPageRot != 0)
{
singlePagePdf.SetInfo(singlePagePdf.Page, "/Rotate", srcPageRot);
}

singlePagePdf.Save("C://development//pdfSplitter//singlePDF//singlePage"+i+".pdf")
singlePagePdf.Clear();
}
theSrc.Clear();

This solution is equal to my first solution but it incorporates the page rotation and is very fast.
I hope this can help others as well.
Share Follow answered Aug 9, 2013 at 8:46
Kristian Barrett
3,634 2 26 42

There is an updated solution for this, (latest version of > ABCpdf 9.0) this is an efficient and faster way of doing.
8 using (Doc copyDoc = new Doc())
{
copyDoc.Read(filePath);
copyDoc.RemapPages(sb.ToString());
copyDoc.Save(tagetFileName);
}

Pass arguments of type int[] pages or a string comma or space separated page numbers that you want to split to REMAPPAGES method (above
code sb is stringbuilder) and save.
Share Follow edited Jan 31, 2014 at 3:10 answered Jan 9, 2014 at 0:21
Jay
1,889 3 25 45

Join Stack Overflow to find the best answer to your technical question, Sign up with email Sign up with Google Sign up with GitHub Sign up with Facebook
help others answer theirs.

You might also like