Can I concatenate PDF without a rest call in golang?

I tried Aspose.PDF for Go via C++ | Aspose API References, which doesn’t have the merge functionality and Merge Multiple PDF Files|Documentation which uses the cloud SDK. I want to merge documents without sending any data to the cloud and preferably using a library and not send any DATA via rest call. Can you help?

@npatil

Can you please specify if you are looking for a specific library in Go for merging PDFs without using REST calls?

Yes that is correct

@npatil

We are checking it and will get back to you shortly.

Hi @npatil, thank you for your interest in Aspose.PDF for Go via C++! The PDF merge functionality is not yet available in the current version (25.3), but since the library is actively evolving, we do plan to implement it in the near future. We really appreciate your interest and for choosing to use our product!

Thank you for letting me know about ASPOSE.PDF for Go via C++. I want to merge two PDFs the only documentation I found was: Merge Multiple PDF Files|Documentation. Is the merged file in this created in the cloud? Do I have to upload the files to be merged to the cloud first? My company has confidentiality concerns so I want to avoid uploading anything to an external cloud. Can you help me confirm this? Also want to know if there’s any other aspose product I can use for merging PDFs. My application is in golang

Hi @npatil,

If confidentiality is your primary concern and uploading data to the cloud is not desirable, cloud-based solutions may not be suitable, as they require uploading files. However, we’re working on adding a solution for merging PDFs in Aspose.PDF for Go via C++ that will allow you to handle files entirely locally. We truly value you as a future customer and will do our best to deliver this functionality as soon as possible.

Thank you again for your interest!

Thanks for letting me know all this. I truly appreciate your time.

Hi @npatil,

We’d like to inform you that we’ve mobilized all available resources to address your request as a priority. As a result, we’ve added the Append() function ahead of schedule in the upcoming 25.4 release, which will be available within the next few days.

With the new Append() method, you’ll be able to merge multiple PDF documents easily. Here’s a simple example demonstrating how to do that:

// MergeMultiplePDFs merges multiple PDF files into a single PDF.
func MergeMultiplePDFs(outputPath string, inputPaths []string) error {
	mergedDoc, err := New()
	if err != nil {
		return err
	}
	defer mergedDoc.Close()

	for _, path := range inputPaths {
		inputDoc, err := Open(path)
		if err != nil {
			return fmt.Errorf("failed to open %s: %w", path, err)
		}

		err = mergedDoc.Append(inputDoc)
		inputDoc.Close()
		if err != nil {
			return fmt.Errorf("failed to append %s: %w", path, err)
		}
	}

	err = mergedDoc.SaveAs(outputPath)
	if err != nil {
		return fmt.Errorf("failed to save merged PDF: %w", err)
	}

	return nil
}

We hope this helps, and we appreciate your input in making the product better.
Please feel free to share any feedback once you try it out!

Best regards,
The Aspose.PDF Team

Hi,

Thanks a lot for letting me know. This is super helpful.Just to confirm, so with this new function I will no longer need to send my PDF file data to Aspose cloud and can do the merge locally without a REST call? Also, when will this be out so I can try it out?

Best,
Niharika

Hi Niharika,

Thank you very much for your interest in our product!

Yes, you are absolutely right — with the new functionality in Aspose.PDF for Go via C++, your PDF file data is processed locally on your machine. There is no need for a REST call, and your files are not sent to the Aspose Cloud. This makes it ideal for secure or offline environments.

The new version, 25.4, is scheduled for release today, April 30th.

Please also note that there are limitations when using the library without a license. You can find more details here:
:point_right: License information

Thanks again for your interest, and we look forward to your feedback once you try it out!

Best regards,
Aspose.PDF Team

Hi,

I was able to use this new functionality for merge thank you for the speedy turnaround :slight_smile: I let my team know that this helps us achieve our goals. I appreciate it. However the last thing I wanted to know, to complete my evaluation is, if I can convert the merged PDF or any other pdf to a byte array form? I don’t see a byte array converstion in the documentation for pdf for go via c++. Let me know if this already exists.

Hi Niharika,

Thank you once again for your interest in Aspose.PDF for Go via C++ — we’re happy to hear that the merge functionality is working well for your team!

Just to clarify: there are two ways you can merge PDF documents using the API:

  1. Append() - ppends pages from one document into another.
  2. MergeDocuments() - Creates a new PDF-document from multiple existing ones.

Both approaches will result in a new document that you can save to disk using SaveAs().

Regarding your question about converting the merged PDF (or any other PDF) to a byte array — while the library does not expose a direct ToByteArray() method, this can easily be achieved by reading the saved PDF file using Go’s standard library:

import (
    "os"
    "log"
)

func main() {
    // Save the merged PDF to disk
    // pdf.SaveAs("output.pdf") or pdf_merged.SaveAs("output.pdf")

    // Read the PDF as []byte
    data, err := os.ReadFile("output.pdf")
    if err != nil {
        log.Fatal(err)
    }

    // 'data' is your byte array representation of the PDF
    log.Printf("PDF size: %d bytes\n", len(data))
}

This will give you a []byte containing the full contents of the PDF, which you can then use as needed (e.g., sending over the network, storing in a database, etc.).

Let us know if you need any assistance implementing this — we're happy to help!

Best regards,
The Aspose.PDF Team

Hi,

Thanks a lot for your speedy response! I appreciate it :slight_smile:

We wanted to avoid saving and re-pulling the saved file, and directly convert it into bytes to send to another service. We’re hoping to fully replace our existing open source library with yours and the method to convert the pdf object to byte array would be super helpful even in other use cases of our system. Would it be possible to consider exposing such a method as a part of the pdf object? Let me know!

Best,
Niharika

Hi Niharika,

Thank you for your kind words — we’re really glad to hear you’re considering Aspose.PDF for Go via C++ for a broader integration into your system!

You’re absolutely right — being able to convert a PDF document directly into a byte array without saving it to disk is a highly practical use case, especially when interacting with APIs or microservices. Technically, we see no blockers to implementing this functionality.

While our development resources are limited and we have to prioritize carefully, we definitely recognize the value of this feature and will consider adding support for it as part of the public API. We’ll do our best to include it in one of the upcoming releases.

Thanks again for your thoughtful feedback — it’s much appreciated. Please feel free to reach out if you have any other suggestions or needs!

Best regards,
The Aspose.PDF Team

Thank you for trying! Appreciate it!

We truly appreciate our customers and always do our best to help — thank you again!