Rotate PDF to NUP

page_nup.pdf (1.9 MB)
page_original.pdf (1.8 MB)
NUP does not rotate the rotated original file

@hbhur102

Would you kindly share the sample code snippet that you have tried at your side. We will test the scenario in our environment and address it accordingly.

                    MemoryStream[] outBuffer = pdfEditor.SplitToPages(dataDir + "\\" + name + ext);

                    // Save individual files

                    Document pdfDocument2 = new Document(".\\nup.pdf");
                    int fileNumber = 1;

                    foreach (MemoryStream aStream in outBuffer)

                    {

                        FileStream outStream = new FileStream(dataDir3 +"\\"+ "File_" + fileNumber.ToString() + "_out.pdf", FileMode.Create);

                        aStream.WriteTo(outStream);

                        outStream.Close();

                        if(fileNumber % 2 == 0)
                        {
                            Document pdfDocument3 = new Document(dataDir3 + "\\" + "File_" + fileNumber.ToString() + "_out.pdf");

                            //pdfDocument3.Pages[1].Rotate = Aspose.Pdf.Rotation.On180;
                            pdfDocument3.Pages[1].Rotate = Aspose.Pdf.Rotation.on180;
                            Console.WriteLine(pdfDocument3.Pages[1].Rotate);
                            pdfDocument3.Save(dataDir3 + "\\" + "File_" + fileNumber.ToString() + "_out.pdf");
                        }
                        fileNumber++;
                    }

                    for (int j = 0; j < 24; j++)
                    {
                        Document pdfDocument = new Document(dataDir3 + "\\" + "File_" + AA[j].ToString() + "_out.pdf");

                        pdfDocument2.Pages.Add(pdfDocument.Pages);
                    }

                    pdfDocument2.Pages.Delete(1);

                    pdfDocument2.Save(dataDir3 + "\\" + name + ext);


                    PdfFileEditor pdfEditor2 = new PdfFileEditor();

                    PageSize pageSize = new PageSize((float)(16.535433 * 72), (float)(11.692913 * 72));
                    pageSize.IsLandscape = true;

                    pdfEditor2.MakeNUp(dataDir3 + "\\" + name + ext, dataDir2 + "\\" + name + "(수정)" + ext, 2, 1, pageSize);

@hbhur102

Thanks for sharing sample code snippet.

We have checked your code snippet and noticed that it involves more than one PDF file. Furthermore, would you please elaborate a bit more about the issue that you are facing. We have also checked the output PDF document that you shared and could not notice any issue in it. Would you kindly share a code snippet that can be used to replicate the same issue which you are facing. We will again test the scenario in our environment and address it accordingly.

The original file and the NUP file and the result file I want
are only partially shared because the file is large.

pages-original.pdf (1.8 MB)

pages-nup.pdf (1.8 MB)
pages-wanted.pdf (1.8 MB)

@hbhur102

We were able to notice the issue in our environment while using following code snippet with Aspose.PDF for NET 20.5.

Document pdfDocument2 = new Document(dataDir + "pages-original.pdf");
pdfDocument2.Pages[3].Rotate = pdfDocument2.Pages[4].Rotate = Rotation.on180;
pdfDocument2.Save(dataDir + "output20.5.pdf");
var pdfEditor = new Facades.PdfFileEditor();
PageSize pageSize = new PageSize((float)(16.535433 * 72), (float)(11.692913 * 72));
pageSize.IsLandscape = true;
pdfEditor.MakeNUp(dataDir + "output20.5.pdf", dataDir + "merge_pdf_out.pdf", 2, 1, pageSize);

Therefore, we have logged an issue as PDFNET-48167 in our issue tracking system. We will further look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.

I am currently working with your library and need to manually rotate it 180 degrees. We urge you to fix it in a short time.

@hbhur102

We have recorded your concerns and will surely take care of them during issue investigation. However, please note that the issue is logged under normal support and it will be investigated and resolved on a first come first serve basis. We will surely inform you as soon as the issue is resolved. Please spare us some time.

We are sorry for the inconvenience.

When will the issue as PDFNET-48167 be completed???

@hbhur102

We are afraid that we cannot share any ETA at the moment as issue needs more time for investigation. We will surely investigate it and provide you an update as per the schedule. Please spare us some time.

We are sorry for the inconvenience.

has this bug fixed?
i have the same trouble in aspose.pdf for java
when i rotate one page then use makeNup always restore to original state
even i use other jar like pdfbox but useless

@MrMao

We are afraid that the earlier logged ticket has not been yet resolved. Can you please share your sample files and the code snippet that you are using so that we can log a dedicated ticket for your case as well.

I think I solved it another way

special_pdf.pdf (2.3 KB)

if use rotate first then makeNUp always get error result like this

        Document document = new Document("special.pdf");
        int size = document.getPages().size();
        for (int i = 1; i <= size; i++) {
            Page item = document.getPages().get_Item(i);
            double width = item.getPageRect(true).getWidth();
            double height = item.getPageRect(true).getHeight();
            if (width > height) {
                item.setRotate(Rotation.on270);
            }
        }
        document.save("special_out.pdf");

        PdfFileEditor pdfFileEditor = new PdfFileEditor();
        pdfFileEditor.makeNUp("special_out.pdf", "special_out_1.pdf", 2, 2);

Result
Snipaste_2024-09-09_10-33-53.png (393 字节)

But use PdfPageEditor is success rotate like this

        String filePath = "special_pdf.pdf";
        @Cleanup com.aspose.pdf.Document doc = new com.aspose.pdf.Document(filePath);

        ArrayList<Integer> list = new ArrayList<>();

        for (int i = 1; i <= doc.getPages().size(); i++) {
            Page item = doc.getPages().get_Item(i);
            double width = item.getPageRect(true).getWidth();
            double height = item.getPageRect(true).getHeight();
            if (width > height) {
                list.add(i);
            }
        }

        @Cleanup PdfPageEditor editor = new PdfPageEditor(doc);
        editor.setRotation(90);

        int size = list.size();
        int[] arrays = new int[size];
        for (int i = 0; i < arrays.length; i++) {
            arrays[i] = list.get(i);
        }

        editor.setProcessPages(arrays);

        editor.save("special_out.pdf");

        PdfFileEditor pdfFileEditor = new PdfFileEditor();
        pdfFileEditor.makeNUp("special_out.pdf", "special_out_1.pdf", 2, 2);

Result
Snipaste_2024-09-09_10-36-59.png (514 字节)

I can’t read the decompilation code , try to fix it

@MrMao

Are you saying that the issue has been sorted out for you at the moment? OR you still want us to investigate? What is about decompilation of the code?

yeah i solved by other way
but makeNUp also have bug about rotate,I provided sample code on top
i cant change the jar source code,so need your team to check this bug

@MrMao

Sure, we have logged the details that you have provided and will investigate from this perspective. We will inform you once we have some updates in this regard.