Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Sat Dec 02, 2023 11:17 am

I am trying to split a big PDF file (211 MB) of 353 pages into multiple PDFs. I tried a simple splitting into single pages but I got an error
Code: Select all
Unhandled Exception: System.FormatException: Format_InvalidString
   at System.Text.ValueStringBuilder.ThrowFormatInvalidString() + 0x36
   at System.Text.ValueStringBuilder.AppendFormatHelper(IFormatProvider, String, ReadOnlySpan`1) + 0x7d3
   at System.String.FormatHelper(IFormatProvider, String, ReadOnlySpan`1) + 0x8a
   at Spire.Pdf.PdfDocumentBase.Split(String, Int32) + 0x259
   at Spire.Pdf.AOT.NLPdfDocument.PdfDocument_SplitDS(IntPtr, IntPtr, Int32) + 0x66


Then I tried a simple read and write code

Code: Select all
def test_simple_pdf_save(filename):
    input_pdf_path = Path(PDF_FILES_PATH, filename + '.pdf')

    pdf = PdfDocument()
    pdf.LoadFromFile(str(input_pdf_path))
    pdf.SaveToFile("output.pdf")


and it doesn't crash but the output.pdf file is the same size as the original one (211 MB) but only 10 pages long instead of 353.

Any idea what could be the issue?

otanerat
 
Posts: 1
Joined: Sat Dec 02, 2023 11:09 am

Mon Dec 04, 2023 2:51 am

Hello,

Thank you for your inquiry.
Based on your description, I simulated a 300-page PDF file and conducted preliminary testing, but I was unable to reproduce your first issue. As for the second issue you mentioned, it occurs because you are not using our license, which results in the output file displaying only 10 pages. However, when splitting one page into a separate PDF document, there is no page limit without the license. Please note that each page in the resulting file will have a red warning message.
Furthermore, regarding document splitting, I am using the latest version (Spire.PDF for Python Version: 9.9.0) and the following test code. Please perform the test again using this version and code. If the issue still persists after testing, please provide your test PDF file. You can send it to us via email at [email protected] or share a download link with us. Thank you in advance.
Code: Select all
from spire.pdf import *

pdf = PdfDocument()
pdf.LoadFromFile("input.pdf")

pattern = "output\\SplitDocument-{0}.pdf"
pdf.Split(pattern)
pdf.Close()

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF

cron